This page captures the utilities from nbs/01_lazy_loading.py.
Helper Methods
MERTISDataPackReader exposes convenience methods that hide the collect_data plumbing and return LazyArray instances ready to use.
from pathlib import Pathimport mertisreader as mr# Assume a CAL or PAR directory exists; the reader picks the processing level automatically.candidate_roots = [Path.cwd().resolve(), Path.cwd().resolve().parent, Path.cwd().resolve().parent.parent]repo_root =next(root for root in candidate_roots if (root /"data").exists())input_path = ( repo_root/"data"/"bcmer_tm_all_START-20200409T000000_END-20200410T000000""_CRE-20240717T132010-ParamEventBootSciHK-short"/"cal")output_path = Path("/tmp/")reader = mr.MERTISDataPackReader(input_dir=input_path, output_dir=output_path, lazy=True)reader.data_collector()product = reader.get_tis_product()print(f"Frames proxy: {product['frames']}")print(f"Shape (no I/O): {product['frames'].shape}")print(f"Path: {product['path'].name}")
Reading filetype: hk_default from mer_cal_hk_default_20200409_1-0651130766-12538__0_1
Processing label: /home/kidpixo/work/esa/mertis_data_management/mertisreader/data/bcmer_tm_all_START-20200409T000000_END-20200410T000000_CRE-20240717T132010-ParamEventBootSciHK-short/cal/mer_cal_hk_default_20200409_1-0651130766-12538__0_1.lblx
Now processing a Table_Delimited structure: MERTIS_CAL_DEFAULT_HOUSEKEEPING_DATA_TABLE
Reading filetype: hk_extended from mer_cal_hk_extended_20200409_1-0651130766-12595__0_1
Processing label: /home/kidpixo/work/esa/mertis_data_management/mertisreader/data/bcmer_tm_all_START-20200409T000000_END-20200410T000000_CRE-20240717T132010-ParamEventBootSciHK-short/cal/mer_cal_hk_extended_20200409_1-0651130766-12595__0_1.lblx
Now processing a Table_Delimited structure: MERTIS_CAL_EXTENDED_HOUSEKEEPING_DATA_TABLE
Reading filetype: tis from mer_cal_sc_tis_20200409_1-0651130819-21186__0_1
Frames proxy: LazyArray(shape=(40, 100, 21), dtype=>f8, status=lazy (memmap))
Shape (no I/O): (40, 100, 21)
Path: mer_cal_sc_tis_20200409_1-0651130819-21186__0_1.fits
LazyCSVLoader(path=/tmp/mertisreader_lazy_loading_sample.csv, status=lazy (query plan))
['column_1', 'column_2', 'column_3']
column_1 column_2 column_3
0 a b c
1 1 2 3
2 4 5 6
Notes
LazyArray keeps FITS-backed data accessible without forcing an immediate load, while LazyCSVLoader defers CSV reads until the data is explicitly collected.