imas.util.calc_hash¶
- imas.util.calc_hash(node: IDSBase) bytes¶
Calculate the hash of the provided IDS object.
Hashes are calculated as follows:
Data nodes:
STR_0D: hash of value (encoded as UTF-8)STR_1D: hash of concatenation ofLength of the STR_1D (64-bit little-endian integer)
hash of value[0] (encoded as UTF-8)
hash of value[1] (encoded as UTF-8)
…
INT_0D: hash of value (32-bit little-endian signed integer)FLT_0D: hash of value (64-bit IEEE 754 floating point number)CPX_0D: hash of value (128-bit: real, imag)NDarrays: hash of concatenation ofDimension (8-bit integer)
Shape (dimension * 64-bits little-endian integer)
Concatenated data (little-endian, Fortran memory layout)
Array of structures nodes: hash of concatenation of
Length of the AoS (64-bit little-endian integer)
Hash of structure[0]
Hash of structure[1]
…
Structure nodes:
Sort all children alphabetically
Remove empty children. Children are empty when:
INT_0D: equal toEMPTY_INTFLT_0D: equal toEMPTY_FLOATCPX_0D: equal toEMPTY_COMPLEXNDarrays: array is emptySTR_0D: equal to""STR_1D: length is 0Array of structures: length is 0
Structure: all children are empty
Remove
ids_properties/version_putstructureCalculate hash of concatenation of
Name of child[0] (encoded as UTF-8)
Hash of child[0]
…
The hash function used is
xxhash.xxh3_64from thexxhashpackage.Example
cp = imas.IDSFactory().core_profiles() cp.ids_properties.homogeneous_time = 0 print(imas.util.calc_hash(cp).hex()) # 3b9b929756a242fd