Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions mapcat/toolkit/act.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,29 @@ 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],
"ctime": float(f["t"][...]),
"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)
Expand Down
Loading