from pathlib import Path
import rich
import mertisreader as mr
print("Libraries imported successfully.")Libraries imported successfully.
mertisreaderThis page is a Quarto version of the old notebook walkthrough. It keeps the narrative and executable examples together, while the package API remains documented through docstrings.
Use a Python virtual environment or conda environment, then install the package in editable mode while the migration is in progress.
MERTISDataPackReadercandidate_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/")
log_level = "INFO"
if not input_path.exists():
print(f"Input path {input_path} does not exist.")
else:
print(f"Reading path {input_path}")
ms_reader = mr.MERTISDataPackReader(input_dir=input_path, output_dir=output_path, log_level=log_level)
print(f"MERTISDataPackReader initialized with input directory: {ms_reader.input_dir}")
print(f"Output directory: {ms_reader.output_dir}")
print(f"Log level: {ms_reader.log_level}")2026-06-11 11:46:06,627|2181969|INFO|input_dir=PosixPath('/home/kidpixo/work/esa/mertis_data_management/mertisreader/data/bcmer_tm_all_START-20200409T000000_END-20200410T000000_CRE-20240717T132010-ParamEventBootSciHK-short/cal')
Reading path /home/kidpixo/work/esa/mertis_data_management/mertisreader/data/bcmer_tm_all_START-20200409T000000_END-20200410T000000_CRE-20240717T132010-ParamEventBootSciHK-short/cal
MERTISDataPackReader initialized with input directory: /home/kidpixo/work/esa/mertis_data_management/mertisreader/data/bcmer_tm_all_START-20200409T000000_END-20200410T000000_CRE-20240717T132010-ParamEventBootSciHK-short/cal
Output directory: /tmp
Log level: INFO
All files in input_dir :
Counter({'.dat': 2, '.lblx': 3, '.fits': 1})
All files in input_dir matching old pattern <v0.2.6 (\d{8}_\d{8}):
Counter()
All files in input_dir matching new pattern >=v0.2.6 (mer_cal_sc_tis_YYYYMMDD_1-...):
Counter({'mer_cal_sc_tis': 1})
{ 'hk_default': ['mer_cal_hk_default_20200409_1-0651130766-12538__0_1.dat'], 'hk_extended': ['mer_cal_hk_extended_20200409_1-0651130766-12595__0_1.dat'], 'sc_tis': ['mer_cal_sc_tis_20200409_1-0651130819-21186__0_1.fits'], 'sc_tir': [], 'sc_tis_ql': [], 'sc_tir_ql': [] }
{'hk_default': 1, 'hk_extended': 1, 'sc_tis': 1, 'sc_tir': 0, 'sc_tis_ql': 0, 'sc_tir_ql': 0}
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
Collected data keys: dict_keys(['hk_default', 'hk_extended', 'tis'])
hk_default: 1 files collected
hk_extended: 1 files collected
tis: 1 files collected
Reading filetype: tis from /home/kidpixo/work/esa/mertis_data_management/mertisreader/data/bcmer_tm_all_START-20200409T000000_END-20200410T000 000_CRE-20240717T132010-ParamEventBootSciHK-short/cal/mer_cal_sc_tis_20200409_1-0651130819-21186__0_1.fits
n_wav=40 # generic wavelengths : not precise enough for scientific analysis!
| | tis_stem | finite(geo) | geo.size |
|---:|:------------------------------------------------|--------------:|-----------:|
| 0 | mer_cal_sc_tis_20200409_1-0651130819-21186__0_1 | 672 | 10500 |
Indices of measurements targets (HK_STAT_TIS_DATA_ACQ_TARGET):
space_index_merged.shape=(21,)
bb7_index_merged.shape=(0,)
bb3_index_merged.shape=(0,)
planet_index_merged.shape=(0,)
Collected data statistics:
Number of TIS files: 1
Number of HK files: 2
Number of TIR files: 0
Number of TIS QL files: 0
Number of TIR QL files: 0
if ms_reader.processing_level != "RAW":
print(f"Geometry data keys: {ms_reader.geom_ls.keys()}")
print(f"Frames data keys: {ms_reader.frames.keys()}")
print(f"Wavelengths data keys: {ms_reader.wavelengths.keys()}")
print(f"MERTIS TIS metadata keys: {ms_reader.mertis_tis_metadata.keys()}")
print(f"Space index merged shape: {ms_reader.space_index_merged.shape}")
print(f"BB7 index merged shape: {ms_reader.bb7_index_merged.shape}")
print(f"BB3 index merged shape: {ms_reader.bb3_index_merged.shape}")
print(f"Planet index merged shape: {ms_reader.planet_index_merged.shape}")Geometry data keys: dict_keys(['mer_cal_sc_tis_20200409_1-0651130819-21186__0_1'])
Frames data keys: dict_keys(['mer_cal_sc_tis_20200409_1-0651130819-21186__0_1'])
Wavelengths data keys: dict_keys(['mer_cal_sc_tis_20200409_1-0651130819-21186__0_1'])
MERTIS TIS metadata keys: dict_keys(['mer_cal_sc_tis_20200409_1-0651130819-21186__0_1'])
Space index merged shape: (21,)
BB7 index merged shape: (0,)
BB3 index merged shape: (0,)
Planet index merged shape: (0,)
Once you know which file key you want to explore, you can inspect frames, metadata, and plots exactly as in the notebook version. The API reference on this site comes from quartodoc-generated pages built from docstrings.