Skip to content

Commit

Permalink
Fix: support for flag files written by GBTIDL
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofle committed Nov 25, 2024
1 parent 9fffadd commit 4c5d882
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/dysh/util/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,14 +1230,18 @@ def read(self, fileobj, **kwargs):
else:
values = l.split("|")
for i, v in enumerate(values):
if v == "*":
if v.strip() == "*":
continue
else:
if header[i] == "IDSTRING":
vdict[header[i]] = v
else:
if "," in v:
vdict[header[i]] = [int(float(x)) for x in v.split(",")]
elif ":" in v:
vdict[header[i]] = [int(float(x)) for x in range(*map(int, v.split(":")))] + [
int(v.split(":")[-1])
]
else:
vdict[header[i]] = int(float(v))

Expand All @@ -1254,6 +1258,21 @@ def read(self, fileobj, **kwargs):
echan = [int(float(x)) for x in echan]
# pair up echan and bchan
vdict["channel"] = list(zip(bchan, echan))
elif bchan is not None and echan is None:
if not isinstance(bchan, list):
bchan = [bchan]
bchan = [int(float(x)) for x in bchan]
echan = [2**25] * len(
bchan
) # Set to a large number so it effectively spans the whole range from `bchan`.
vdict["channel"] = tuple(zip(bchan, echan))
elif bchan is None and echan is not None:
if not isinstance(echan, list):
echan = [echan]
echan = [int(float(x)) for x in echan]
bchan = [0] * len(echan)
vdict["channel"] = tuple(zip(bchan, echan))

if kwargs is not None:
vdict.update(kwargs)
logger.debug(f"flag({tag=},{vdict})")
Expand Down

0 comments on commit 4c5d882

Please sign in to comment.