feat(utils/opatio): updated hash generation to only look at logKappa
This commit is contained in:
@@ -167,13 +167,13 @@ class OpatIO:
|
||||
raise TypeError(f"{name} must be a non-empty 1D array or iterable")
|
||||
|
||||
@staticmethod
|
||||
def compute_checksum(data: bytes) -> bytes:
|
||||
def compute_checksum(data: np.ndarray) -> bytes:
|
||||
"""
|
||||
@brief Compute the SHA-256 checksum of the given data.
|
||||
@param data The data to compute the checksum for.
|
||||
@return The SHA-256 checksum.
|
||||
"""
|
||||
return hashlib.sha256(data).digest()
|
||||
return hashlib.sha256(data.tobytes()).digest()
|
||||
|
||||
def set_version(self, version: int) -> int:
|
||||
"""
|
||||
@@ -290,7 +290,7 @@ class OpatIO:
|
||||
*logT,
|
||||
*logKappa
|
||||
)
|
||||
checksum = self.compute_checksum(tableBytes)
|
||||
checksum = self.compute_checksum(logKappa)
|
||||
return (checksum, tableBytes)
|
||||
|
||||
def _tableIndex_bytes(self, tableIndex: TableIndex) -> bytes:
|
||||
|
||||
27
utils/opatio/utils/mkTestData.py
Normal file
27
utils/opatio/utils/mkTestData.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from opatio import OpatIO
|
||||
import numpy as np
|
||||
np.random.seed(42)
|
||||
|
||||
def generate_synthetic_opacity_table(n_r, n_t):
|
||||
logR = np.linspace(-8, 2, n_r, dtype=np.float64) # log Density grid
|
||||
logT = np.linspace(3, 9, n_t, dtype=np.float64) # log Temperature grid
|
||||
logK = np.random.uniform(-2, 2, size=(n_r, n_t)).astype(np.float64) # Synthetic Opacity
|
||||
return logR, logT, logK
|
||||
|
||||
if __name__ == "__main__":
|
||||
n_r = 50
|
||||
n_t = 50
|
||||
num_tables = 20
|
||||
XValues = np.linspace(0.1, 0.7, num_tables)
|
||||
ZValues = np.linspace(0.001, 0.03, num_tables)
|
||||
opat = OpatIO()
|
||||
opat.set_comment("Synthetic Opacity Tables")
|
||||
opat.set_source("utils/opatio/utils/mkTestData.py")
|
||||
|
||||
for i in range(num_tables):
|
||||
logR, logT, logK = generate_synthetic_opacity_table(n_r, n_t)
|
||||
opat.add_table((XValues[i], ZValues[i]), logR, logT, logK)
|
||||
|
||||
opat.save("testData/synthetic_tables.opat")
|
||||
opat.save_as_ascii("testData/synthetic_tables_OPAT.ascii")
|
||||
|
||||
BIN
utils/opatio/utils/testData/synthetic_tables.opat
Normal file
BIN
utils/opatio/utils/testData/synthetic_tables.opat
Normal file
Binary file not shown.
1163
utils/opatio/utils/testData/synthetic_tables_OPAT.ascii
Normal file
1163
utils/opatio/utils/testData/synthetic_tables_OPAT.ascii
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user