diff --git a/mapcat/toolkit/act.py b/mapcat/toolkit/act.py index a671c9d..d4cdf92 100644 --- a/mapcat/toolkit/act.py +++ b/mapcat/toolkit/act.py @@ -18,9 +18,22 @@ def extract_string(input: bytes) -> str: def parse_info_file(path: Path) -> dict: with h5py.File(path, "r") as f: - return { - "frequency": extract_string(f["band"][...])[1:], - "tube_slot": extract_string(f["detset"][...]), + if 'band' in f and 'detset' in f: + ## backward compatibility with old SO format + return { + "frequency": extract_string(f["band"][...])[1:], + "tube_slot": extract_string(f["detset"][...]), + "observations": [extract_string(x) for x in f["ids"][...]], + "start_time": f["period"][0], + "stop_time": f["period"][1], + "ctime": float(f["t"][...]), + "box": f["box"][...], + } + else: + ## ACT depth1 format. + return { + "frequency": extract_string(f["array"][...]).split('_')[1], + "tube_slot": extract_string(f["array"][...]).split('_')[0], "observations": [extract_string(x) for x in f["ids"][...]], "start_time": f["period"][0], "stop_time": f["period"][1], @@ -28,7 +41,6 @@ def parse_info_file(path: Path) -> dict: "box": f["box"][...], } - def parse_filenames(base: str, relative_to: Path) -> dict[str, str]: """ Parse a base filename (e.g. /path/base/18234/depth1_182341234_i1_f090)