Skip to content

Commit

Permalink
fix(beamform): do not crash beamformer, when no data is available
Browse files Browse the repository at this point in the history
data_available is set in `_process_config`, instead of in `_process_data`,
bc of this bug:
radiocosmology/caput#181 (comment)

For `BeamFormCat`, `_process_data` is in `setup()`, and `setup()` is not
called if there is no data available.

Closes #133
  • Loading branch information
anjakefala committed Oct 20, 2021
1 parent 58ae7c0 commit c83f705
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions draco/analysis/beamform.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class BeamFormBase(task.SingleTask):
timetrack = config.Property(proptype=float, default=900.0)
variable_timetrack = config.Property(proptype=bool, default=False)
freqside = config.Property(proptype=int, default=None)
data_available = True

def setup(self, manager):
"""Generic setup method.
Expand Down Expand Up @@ -629,6 +630,10 @@ def _process_catalog(self, catalog):
if "position" not in catalog:
raise ValueError("Input is missing a position table.")

if not hasattr(self, "epoch"):
self.log.warning("Epoch not set. Was the requested data not available?")
self.data_available = False

coord = catalog.attrs.get("coordinates", None)
if coord == "CIRS":
self.log.info("Catalog already in CIRS coordinates.")
Expand Down Expand Up @@ -687,6 +692,9 @@ def process(self, data):
self._process_data(data)
self._process_catalog(self.catalog)

if not self.data_available:
return None

# Call generic process method.
return super(BeamForm, self).process()

Expand Down Expand Up @@ -726,6 +734,9 @@ def process(self, source_cat):
"""
self._process_catalog(source_cat)

if not self.data_available:
return None

# Call generic process method.
return super(BeamFormCat, self).process()

Expand Down

0 comments on commit c83f705

Please # to comment.