diff --git a/src/tavi/data/nexus_reader.py b/src/tavi/data/nexus_reader.py deleted file mode 100644 index c9335531..00000000 --- a/src/tavi/data/nexus_reader.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: utf-8 -*- -from typing import NamedTuple, Optional - -import numpy as np - - -class ScanInfo(NamedTuple): - """Metadata containing scan information""" - - scan_num: Optional[int] = None - time: Optional[str] = None - scan_title: str = "" - preset_type: str = "normal" - preset_channel: str = "time" - preset_value: float = 1.0 - def_y: str = "detector" - def_x: str = "s1" - - -class SampleUBInfo(NamedTuple): - """Metadata about sample and UB matrix""" - - sample_name: Optional[str] = None - lattice_constants: tuple[ - float, - float, - float, - float, - float, - float, - ] = (1.0, 1.0, 1.0, 90.0, 90.0, 90.0) - ub_matrix: Optional[np.ndarray] = None - # mode: int = 0 # mode for UB determination in SPICE - plane_normal: Optional[np.ndarray] = None - in_plane_ref: Optional[np.ndarray] = None - ubconf: Optional[str] = None # path to UB configration file - - -class InstrumentInfo(NamedTuple): - """Metadata about instrument configuration""" - - instrument_name: str = "" - # monochromator: - # analyzer: - # TODO - sense: int = 1 - collimation: tuple[float, float, float, float] = (60, 60, 60, 60) - # TODO vertical collimation?? - - -class ScanData(NamedTuple): - """Data points in a measured scan""" - - # Pt. - detector: Optional[tuple[int, ...]] = None - # monitor - time: Optional[tuple[float, ...]] = None - monitor: Optional[tuple[int, ...]] = None - mcu: Optional[tuple[float, ...]] = None - # monochromator - m1: Optional[tuple[float, ...]] = None - m2: Optional[tuple[float, ...]] = None - ei: Optional[tuple[float, ...]] = None - focal_length: Optional[tuple[float, ...]] = None - mfocus: Optional[tuple[float, ...]] = None - marc: Optional[tuple[float, ...]] = None - mtrans: Optional[tuple[float, ...]] = None - # analyzer - ef: Optional[tuple[float, ...]] = None - a1: Optional[tuple[float, ...]] = None - a2: Optional[tuple[float, ...]] = None - afocus: Optional[tuple[float, ...]] = None - # ctax double-focused analyzer - qm: Optional[ - tuple[ - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - ] - ] = None - xm: Optional[ - tuple[ - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - tuple[float, ...], - ] - ] = None - # goiometer motor angles - s1: Optional[tuple[float, ...]] = None - s2: Optional[tuple[float, ...]] = None - sgl: Optional[tuple[float, ...]] = None - sgu: Optional[tuple[float, ...]] = None - stl: Optional[tuple[float, ...]] = None - stu: Optional[tuple[float, ...]] = None - chi: Optional[tuple[float, ...]] = None - phi: Optional[tuple[float, ...]] = None - # slits - slit_pre_bt: Optional[tuple[float, ...]] = None - slit_pre_tp: Optional[tuple[float, ...]] = None - slit_pre_lf: Optional[tuple[float, ...]] = None - slit_pre_rt: Optional[tuple[float, ...]] = None - slit_aft_bt: Optional[tuple[float, ...]] = None - slit_aft_tp: Optional[tuple[float, ...]] = None - slit_aft_lf: Optional[tuple[float, ...]] = None - slit_aft_rt: Optional[tuple[float, ...]] = None - # Q-E space - q: Optional[tuple[float, ...]] = None - qh: Optional[tuple[float, ...]] = None - qk: Optional[tuple[float, ...]] = None - ql: Optional[tuple[float, ...]] = None - en: Optional[tuple[float, ...]] = None - # temperature - temp: Optional[tuple[float, ...]] = None - temp_a: Optional[tuple[float, ...]] = None - temp_2: Optional[tuple[float, ...]] = None - coldtip: Optional[tuple[float, ...]] = None - tsample: Optional[tuple[float, ...]] = None - sample: Optional[tuple[float, ...]] = None - vti: Optional[tuple[float, ...]] = None - dr_tsample: Optional[tuple[float, ...]] = None - dr_temp: Optional[tuple[float, ...]] = None - lt: Optional[tuple[float, ...]] = None - ht: Optional[tuple[float, ...]] = None - sorb_temp: Optional[tuple[float, ...]] = None - sorb: Optional[tuple[float, ...]] = None - sample_ht: Optional[tuple[float, ...]] = None - # field - persistent_field: Optional[tuple[float, ...]] = None - - -def dataset_to_string(ds): - return str(ds.asstr()[...]) - - -def unpack_nexus(nexus_entry): - scan_name = nexus_entry.filename.split("/")[-1] # e.g. "scan0001" - scan_info = ScanInfo( - scan_num=int(scan_name[4:-3]), - time=dataset_to_string(nexus_entry["start_time"]), - scan_title=dataset_to_string(nexus_entry["title"]), - preset_type="normal", - preset_channel=dataset_to_string(nexus_entry["monitor/mode"]), - preset_value=float(nexus_entry["monitor/preset"][...]), - def_y=nexus_entry["data"].attrs["signal"], - def_x=nexus_entry["data"].attrs["axes"], - ) - sample_ub_info = SampleUBInfo() - instrument_info = InstrumentInfo() - scan_data = ScanData() - - return (scan_info, sample_ub_info, instrument_info, scan_data) diff --git a/src/tavi/data/scan.py b/src/tavi/data/scan.py index 24436e74..7e1d8087 100644 --- a/src/tavi/data/scan.py +++ b/src/tavi/data/scan.py @@ -5,7 +5,14 @@ import matplotlib.pyplot as plt import numpy as np -from tavi.data.nexus_reader import InstrumentInfo, SampleUBInfo, ScanData, ScanInfo, unpack_nexus +from tavi.data.scan_reader import ( + InstrumentInfo, + SampleUBInfo, + ScanData, + ScanInfo, + nexus_entry_to_scan, + spice_entry_to_scan, +) class Scan(object): @@ -31,27 +38,18 @@ def __init__(self, scan_info, sample_ub_info, instrument_info, data) -> None: self.instrument_info: Optional[InstrumentInfo] = instrument_info self.data: Optional[ScanData] = data - # TODO ------------------------------------------------------ @classmethod def from_nexus(cls, nexus_path): with h5py.File(nexus_path, "r") as nexus_entry: - scan_info, sample_ub_info, instrument_info, data = unpack_nexus(nexus_entry) + scan_info, sample_ub_info, instrument_info, data = nexus_entry_to_scan(nexus_entry) return cls(scan_info, sample_ub_info, instrument_info, data) - def load_scan(self, nexus_entry): - """Unpack metadata and data from nexus_entry""" - - # scan_info, sample_ub_info, instrument_info, data = nexus_to_dict(nexus_entry) - ( - scan_info, - sample_ub_info, - instrument_info, - scan_data, - ) = Scan.unpack_nexus(nexus_entry) - self.scan_info = scan_info - self.sample_ub_info = sample_ub_info - self.instrument_info = instrument_info - self.data = scan_data + # TODO + @classmethod + def from_spice(cls, spice_path): + spice_entry = spice_path + scan_info, sample_ub_info, instrument_info, data = spice_entry_to_scan(spice_entry) + return cls(scan_info, sample_ub_info, instrument_info, data) def get_scan_info(self): """Return scan_info in metadata. diff --git a/src/tavi/data/scan_reader.py b/src/tavi/data/scan_reader.py new file mode 100644 index 00000000..afad9dac --- /dev/null +++ b/src/tavi/data/scan_reader.py @@ -0,0 +1,252 @@ +# -*- coding: utf-8 -*- +from typing import NamedTuple, Optional + +import numpy as np + + +class ScanInfo(NamedTuple): + """Metadata containing scan information""" + + scan_num: Optional[int] = None + start_time: Optional[str] = None + end_time: Optional[str] = None + scan_title: str = "" + # preset_type: str = "normal" + preset_channel: str = "time" + preset_value: float = 1.0 + def_y: str = "detector" + def_x: str = "s1" + + +class SampleUBInfo(NamedTuple): + """Metadata about sample and UB matrix""" + + sample_name: Optional[str] = None + lattice_constants: tuple = (1.0, 1.0, 1.0, 90.0, 90.0, 90.0) + ub_matrix: Optional[np.ndarray] = None + # ub_mode: int = 0 # mode for UB determination in SPICE + # angle_mode: int = 0 # mode for goni angle calculation in SPICE + plane_normal: Optional[np.ndarray] = None + # in_plane_ref: Optional[np.ndarray] = None + ubconf: Optional[str] = None # path to UB configration file + + +# TODO +class InstrumentInfo(NamedTuple): + """Metadata about instrument configuration""" + + instrument_name: str = "" + # monochromator: + # analyzer: + + sense: int = 1 + collimation: tuple[float, float, float, float] = (60, 60, 60, 60) + # TODO vertical collimation?? + + +class ScanData(NamedTuple): + """Data points in a measured scan""" + + # Pt. + detector: Optional[tuple[int, ...]] = None + # monitor + time: Optional[tuple[float, ...]] = None + monitor: Optional[tuple[int, ...]] = None + mcu: Optional[tuple[float, ...]] = None + # monochromator + m1: Optional[tuple[float, ...]] = None + m2: Optional[tuple[float, ...]] = None + ei: Optional[tuple[float, ...]] = None + focal_length: Optional[tuple[float, ...]] = None + mfocus: Optional[tuple[float, ...]] = None + marc: Optional[tuple[float, ...]] = None + mtrans: Optional[tuple[float, ...]] = None + # analyzer + ef: Optional[tuple[float, ...]] = None + a1: Optional[tuple[float, ...]] = None + a2: Optional[tuple[float, ...]] = None + afocus: Optional[tuple[float, ...]] = None + # ctax double-focused analyzer + qm: Optional[tuple] = None # 8 blades + xm: Optional[tuple] = None # 8 blades + # goiometer motor angles + s1: Optional[tuple[float, ...]] = None + s2: Optional[tuple[float, ...]] = None + sgl: Optional[tuple[float, ...]] = None + sgu: Optional[tuple[float, ...]] = None + stl: Optional[tuple[float, ...]] = None + stu: Optional[tuple[float, ...]] = None + chi: Optional[tuple[float, ...]] = None + phi: Optional[tuple[float, ...]] = None + # slits + bat: Optional[tuple[float, ...]] = None + bab: Optional[tuple[float, ...]] = None + bal: Optional[tuple[float, ...]] = None + bar: Optional[tuple[float, ...]] = None + bbt: Optional[tuple[float, ...]] = None + bbb: Optional[tuple[float, ...]] = None + bbl: Optional[tuple[float, ...]] = None + bbr: Optional[tuple[float, ...]] = None + slita_bt: Optional[tuple[float, ...]] = None + slita_tp: Optional[tuple[float, ...]] = None + slita_lf: Optional[tuple[float, ...]] = None + slita_rt: Optional[tuple[float, ...]] = None + slitb_bt: Optional[tuple[float, ...]] = None + slitb_tp: Optional[tuple[float, ...]] = None + slitb_lf: Optional[tuple[float, ...]] = None + slitb_rt: Optional[tuple[float, ...]] = None + slit_pre_bt: Optional[tuple[float, ...]] = None + slit_pre_tp: Optional[tuple[float, ...]] = None + slit_pre_lf: Optional[tuple[float, ...]] = None + slit_pre_rt: Optional[tuple[float, ...]] = None + # Q-E space + q: Optional[tuple[float, ...]] = None + qh: Optional[tuple[float, ...]] = None + qk: Optional[tuple[float, ...]] = None + ql: Optional[tuple[float, ...]] = None + en: Optional[tuple[float, ...]] = None + # temperature + temp: Optional[tuple[float, ...]] = None + temp_a: Optional[tuple[float, ...]] = None + temp_2: Optional[tuple[float, ...]] = None + coldtip: Optional[tuple[float, ...]] = None + tsample: Optional[tuple[float, ...]] = None + sample: Optional[tuple[float, ...]] = None + vti: Optional[tuple[float, ...]] = None + dr_tsample: Optional[tuple[float, ...]] = None + dr_temp: Optional[tuple[float, ...]] = None + lt: Optional[tuple[float, ...]] = None + ht: Optional[tuple[float, ...]] = None + sorb_temp: Optional[tuple[float, ...]] = None + sorb: Optional[tuple[float, ...]] = None + sample_ht: Optional[tuple[float, ...]] = None + # field + persistent_field: Optional[tuple[float, ...]] = None + + +def get_string(nexus_entry, entry_string): + try: + return str(nexus_entry[entry_string].asstr()[...]) + except KeyError: + return None + + +def get_data(nexus_entry, entry_string): + try: + return nexus_entry[entry_string][...] + except KeyError: + return None + + +def nexus_entry_to_scan(nexus_entry): + scan_name = nexus_entry.filename.split("/")[-1] # e.g. "scan0001" + scan_info = ScanInfo( + scan_num=int(scan_name[4:-3]), + start_time=get_string(nexus_entry, "start_time"), + end_time=get_string(nexus_entry, "end_time"), + scan_title=get_string(nexus_entry, "title"), + # preset_type="normal", + preset_channel=get_string(nexus_entry, "monitor/mode"), + preset_value=float(nexus_entry["monitor/preset"][...]), + def_y=nexus_entry["data"].attrs["signal"], + def_x=nexus_entry["data"].attrs["axes"], + ) + sample_ub_info = SampleUBInfo( + sample_name=get_string(nexus_entry, "sample/name"), + lattice_constants=np.array(get_data(nexus_entry, "sample/unit_cell")), + ub_matrix=np.array(get_data(nexus_entry, "sample/orientation_matrix")).reshape(3, 3), + # ub_mode=0, + # angle_mode=0, + plane_normal=get_data(nexus_entry, "sample/plane_normal"), + # in_plane_ref=None, + ubconf=get_string(nexus_entry, "sample/ub_conf"), + ) + instrument_info = InstrumentInfo() + + scan_data = ScanData( + detector=get_data(nexus_entry, "instrument/detector/data"), + # monitor + time=get_data(nexus_entry, "monitor/time"), + monitor=get_data(nexus_entry, "monitor/monitor"), + mcu=get_data(nexus_entry, "monitor/mcu"), + # monochromator + m1=get_data(nexus_entry, "instrument/monochromator/m1"), + m2=get_data(nexus_entry, "instrument/monochromator/m2"), + ei=get_data(nexus_entry, "instrument/monochromator/ei"), + focal_length=get_data(nexus_entry, "instrument/monochromator/focal_length"), + mfocus=get_data(nexus_entry, "instrument/monochromator/mfocus"), + marc=get_data(nexus_entry, "instrument/monochromator/marc"), + mtrans=get_data(nexus_entry, "instrument/monochromator/mtrans"), + # analyzer + ef=get_data(nexus_entry, "instrument/analyser/ef"), + a1=get_data(nexus_entry, "instrument/analyser/a1"), + a2=get_data(nexus_entry, "instrument/analyser/a2"), + afocus=get_data(nexus_entry, "instrument/analyser/afocus"), + # ctax double-focused analyzer + qm=np.array([get_data(nexus_entry, f"instrument/analyser/qm{i}") for i in range(1, 9, 1)]), + xm=np.array([get_data(nexus_entry, f"instrument/analyser/xm{i}") for i in range(1, 9, 1)]), + # goiometer motor angles + s1=get_data(nexus_entry, "sample/s1"), + s2=get_data(nexus_entry, "sample/s2"), + sgl=get_data(nexus_entry, "sample/sgl"), + sgu=get_data(nexus_entry, "sample/sgu"), + stl=get_data(nexus_entry, "sample/stl"), + stu=get_data(nexus_entry, "sample/stu"), + chi=get_data(nexus_entry, "sample/chi"), + phi=get_data(nexus_entry, "sample/phi"), + # slits + bat=get_data(nexus_entry, "instrument/slit/bat"), + bab=get_data(nexus_entry, "instrument/slit/bab"), + bal=get_data(nexus_entry, "instrument/slit/bal"), + bar=get_data(nexus_entry, "instrument/slit/bar"), + bbt=get_data(nexus_entry, "instrument/slit/bbt"), + bbb=get_data(nexus_entry, "instrument/slit/bbb"), + bbl=get_data(nexus_entry, "instrument/slit/bbl"), + bbr=get_data(nexus_entry, "instrument/slit/bbr"), + slita_bt=get_data(nexus_entry, "instrument/slit/slita_bt"), + slita_tp=get_data(nexus_entry, "instrument/slit/slita_tp"), + slita_lf=get_data(nexus_entry, "instrument/slit/slita_lf"), + slita_rt=get_data(nexus_entry, "instrument/slit/slita_rt"), + slitb_bt=get_data(nexus_entry, "instrument/slit/slitb_bt"), + slitb_tp=get_data(nexus_entry, "instrument/slit/slitb_tp"), + slitb_lf=get_data(nexus_entry, "instrument/slit/slitb_lf"), + slitb_rt=get_data(nexus_entry, "instrument/slit/slitb_rt"), + slit_pre_bt=get_data(nexus_entry, "instrument/slit/slit_pre_bt"), + slit_pre_tp=get_data(nexus_entry, "instrument/slit/slit_pre_tp"), + slit_pre_lf=get_data(nexus_entry, "instrument/slit/slit_pre_lf"), + slit_pre_rt=get_data(nexus_entry, "instrument/slit/slit_pre_rt"), + # Q-E space + q=get_data(nexus_entry, "sample/q"), + qh=get_data(nexus_entry, "sample/qh"), + qk=get_data(nexus_entry, "sample/qk"), + ql=get_data(nexus_entry, "sample/ql"), + en=get_data(nexus_entry, "sample/en"), + # temperature + temp=get_data(nexus_entry, "sample/temp"), + temp_a=get_data(nexus_entry, "sample/temp_a"), + temp_2=get_data(nexus_entry, "sample/temp_2"), + coldtip=get_data(nexus_entry, "sample/coldtip"), + tsample=get_data(nexus_entry, "sample/tsample"), + sample=get_data(nexus_entry, "sample/sample"), + vti=get_data(nexus_entry, "sample/vti"), + dr_tsample=get_data(nexus_entry, "sample/dr_tsample"), + dr_temp=get_data(nexus_entry, "sample/dr_temp"), + lt=get_data(nexus_entry, "sample/lt"), + ht=get_data(nexus_entry, "sample/ht"), + sorb_temp=get_data(nexus_entry, "sample/sorb_temp"), + sorb=get_data(nexus_entry, "sample/sorb"), + sample_ht=get_data(nexus_entry, "sample/sample_ht"), + # field + persistent_field=get_data(nexus_entry, "sample/persistent_field"), + ) + + return (scan_info, sample_ub_info, instrument_info, scan_data) + + +# TODO +def spice_entry_to_scan(spice_entry): + scan_info = ScanInfo() + sample_ub_info = SampleUBInfo() + instrument_info = InstrumentInfo() + scan_data = ScanData() + return (scan_info, sample_ub_info, instrument_info, scan_data) diff --git a/src/tavi/data/tavi.py b/src/tavi/data/tavi.py index 8d7297d6..77e2b901 100644 --- a/src/tavi/data/tavi.py +++ b/src/tavi/data/tavi.py @@ -26,10 +26,10 @@ class TAVI(object): def __init__(self) -> None: """Initialization""" self.file_path: Optional[str] = None - self.data: Optional[dict] = None - self.processed_data: Optional[dict] = None - self.fits: Optional[dict] = None - self.plots: Optional[dict] = None + self.data: dict = {} + self.processed_data: dict = {} + self.fits: dict = {} + self.plots: dict = {} def new_tavi_file(self, file_path: Optional[str] = None) -> None: """Create a new tavi file @@ -61,27 +61,22 @@ def load_nexus_data_from_disk(self, path_to_hdf5_folder): hdf5 folder must have the strucutre IPTSXXXX_INSTRUMENT_expXXXX """ # validate path - folder_name_parts = path_to_hdf5_folder.split("/")[-1].split("_") + if path_to_hdf5_folder[-1] != "/": + path_to_hdf5_folder += "/" + dataset_name = path_to_hdf5_folder.split("/")[-2] # e.g. IPTS32124_CG4C_exp0424 + folder_name_parts = dataset_name.split("_") if folder_name_parts[0][0:4] != "IPTS" or folder_name_parts[2][0:3] != "exp": print("Unrecogonized nexus folder name. Must be IPTSXXXX_INSTRUMENT_expXXXX.") raise ValueError - if path_to_hdf5_folder[-1] != "/": - path_to_hdf5_folder += "/" - - dataset_name = path_to_hdf5_folder.split("/")[-2] # e.g. IPTS32124_CG4C_exp0424 scan_list = os.listdir(path_to_hdf5_folder) scan_list = [scan for scan in scan_list if scan.startswith("scan")] scan_list.sort() scans = {} - - # TODO ----------------------------------------------------------- - for scan in scan_list: scan_name = scan.split(".")[0] # e.g. "scan0001" scan_path = path_to_hdf5_folder + scan - scan_entry = Scan.from_nexus(scan_path) scans.update({scan_name: scan_entry}) @@ -99,6 +94,7 @@ def load_spice_data_from_disk(self, path_to_spice_folder): pass + # TODO def load_data_from_oncat(self, user_credentials, ipts_info, OVERWRITE=True): """Load data from ONCat based on user_credentials and ipts_info. diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0001.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0001.h5 index 451a40b7..d9c99426 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0001.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0001.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0002.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0002.h5 index 6181e5dc..0ddf5707 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0002.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0002.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0003.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0003.h5 index 6c576bff..7d15657b 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0003.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0003.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0004.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0004.h5 index ce83620e..f7ac0c8e 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0004.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0004.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0005.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0005.h5 index fb2cd2ec..c6af6334 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0005.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0005.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0006.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0006.h5 index c4b03c15..90e6a891 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0006.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0006.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0007.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0007.h5 index 5fe41df9..1292470e 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0007.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0007.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0008.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0008.h5 index 65723537..3dab69da 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0008.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0008.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0009.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0009.h5 index a0e17b63..17c59659 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0009.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0009.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0010.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0010.h5 index a21df663..c9b3958e 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0010.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0010.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0011.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0011.h5 index fef26f61..962d7c1c 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0011.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0011.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0012.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0012.h5 index 1036ce06..2188f1e2 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0012.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0012.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0013.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0013.h5 index be9096cf..415aecfe 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0013.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0013.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0014.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0014.h5 index b1f061f8..e18df43d 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0014.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0014.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0015.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0015.h5 index 7d29fd6f..83c2c695 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0015.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0015.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0016.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0016.h5 index 0e8e2c05..2941503a 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0016.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0016.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0017.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0017.h5 index 7b92bdd4..135cd76a 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0017.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0017.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0018.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0018.h5 index 25f4d484..95bf92e0 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0018.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0018.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0019.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0019.h5 index 4328583c..a0c33b42 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0019.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0019.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0020.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0020.h5 index c816f025..8b6f04b4 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0020.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0020.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0021.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0021.h5 index e559dfe5..9e7d24eb 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0021.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0021.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0022.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0022.h5 index 19ec8a6d..887370ed 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0022.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0022.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0023.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0023.h5 index 7d81b25e..bfd2fa69 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0023.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0023.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0024.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0024.h5 index 88b2399d..dfc609f5 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0024.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0024.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0025.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0025.h5 index d0d8571b..e7faebff 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0025.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0025.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0026.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0026.h5 index 7d17b388..46683625 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0026.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0026.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0027.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0027.h5 index a4c8fca7..18e7d60f 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0027.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0027.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0028.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0028.h5 index c3e3e5c7..321095ae 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0028.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0028.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0029.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0029.h5 index d60b0aae..da4501db 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0029.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0029.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0030.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0030.h5 index d48feeab..a2ffe1c9 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0030.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0030.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0031.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0031.h5 index 93f5ad30..9a4e7e58 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0031.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0031.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0032.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0032.h5 index 3a31e957..88898457 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0032.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0032.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0033.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0033.h5 index 19c0d624..62dab0f1 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0033.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0033.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0034.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0034.h5 index 2d497a3f..172bcd12 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0034.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0034.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0035.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0035.h5 index d2484d10..331f0c77 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0035.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0035.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0036.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0036.h5 index 671049aa..dafdb093 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0036.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0036.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0037.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0037.h5 index 4cb8b9e3..9425042b 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0037.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0037.h5 differ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0038.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0038.h5 index e10c0534..a00ac94d 100644 Binary files a/test_data/IPTS32124_CG4C_exp0424/scan0038.h5 and b/test_data/IPTS32124_CG4C_exp0424/scan0038.h5 differ diff --git a/test_data/tavi_exp424_test.h5 b/test_data/tavi_exp424_test.h5 index 291578a4..ac5aa8d4 100644 Binary files a/test_data/tavi_exp424_test.h5 and b/test_data/tavi_exp424_test.h5 differ diff --git a/tests/test_scan.py b/tests/test_scan.py index 7446f6e4..29eb4846 100644 --- a/tests/test_scan.py +++ b/tests/test_scan.py @@ -3,7 +3,8 @@ from tavi.data.scan import Scan -def test_load_scan(): - +def test_load_nexus_scan(): nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" scan = Scan.from_nexus(nexus_file_name) + assert scan.scan_info.scan_num == 42 + assert len(scan.data.s1) == 40 diff --git a/tests/test_tavi_data.py b/tests/test_tavi_data.py index fdd7f4c8..8368d10d 100644 --- a/tests/test_tavi_data.py +++ b/tests/test_tavi_data.py @@ -2,6 +2,7 @@ import os import h5py +import numpy as np from tavi.data.tavi import TAVI @@ -47,6 +48,9 @@ def test_load_nexus_data_from_disk(): nexus_data_folder = "./test_data/IPTS32124_CG4C_exp0424" tavi.load_nexus_data_from_disk(nexus_data_folder) + assert len(tavi.data["IPTS32124_CG4C_exp0424"]) == 92 + scan0001 = tavi.data["IPTS32124_CG4C_exp0424"]["scan0001"] + assert np.allclose(scan0001.data.s1, [11.305, 11.1075]) # def test_open_tavi_file():