Skip to content

Commit

Permalink
Merge pull request #208 from HERA-Team/beam_norm
Browse files Browse the repository at this point in the history
feat: option to peak-normalize beams in ModelData
  • Loading branch information
r-pascua authored Jan 19, 2022
2 parents 4e6ca7b + 0aa2c33 commit eddbf1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog
=========

v2.3.0 [2022.01.19]
===================

Added
-----
- ``normalize_beams`` option in ``ModelData`` class. Setting this parameter to
``True`` enforces peak-normalization on all of the beams used in the simulation.
The default behavior is to not peak-normalize the beams.

v2.2.1 [2022.01.14]
===================

Expand Down
13 changes: 11 additions & 2 deletions hera_sim/visibilities/simulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class ModelData:
list. By default, if one beam is given all antennas use the same beam, whereas
if a beam is given per antenna, they are used in their given order.
Shape=(N_ANTS,).
normalize_beams
Whether to peak-normalize the beams. This removes the bandpass from the beams'
data arrays and moves it into their ``bandpass_array`` attributes.
Notes
-----
Expand All @@ -64,14 +67,15 @@ def __init__(
sky_model: SkyModel,
beam_ids: Dict[str, int] | Sequence[int] | None = None,
beams: BeamListType | None = None,
normalize_beams: bool = False,
):

self.uvdata = self._process_uvdata(uvdata)

# NOT Nants because we only want ants with data
self.n_ant = self.uvdata.Nants_data

self.beams = self._process_beams(beams)
self.beams = self._process_beams(beams, normalize_beams)
self.beam_ids = self._process_beam_ids(beam_ids, self.beams)
self._validate_beam_ids(self.beam_ids, self.beams)

Expand All @@ -96,7 +100,7 @@ def _process_uvdata(self, uvdata: UVData | str | Path):
)

@classmethod
def _process_beams(cls, beams: BeamListType | None):
def _process_beams(cls, beams: BeamListType | None, normalize_beams: bool):
if beams is None:
beams = [ab.AnalyticBeam("uniform")]

Expand All @@ -111,6 +115,11 @@ def _process_beams(cls, beams: BeamListType | None):
# pyuvsim.
raise ValueError("All beams must be of the same beam_type!")

if normalize_beams:
for beam in beams:
if beam.data_normalization != "peak":
beam.peak_normalize()

return beams

def _process_beam_ids(
Expand Down

0 comments on commit eddbf1a

Please sign in to comment.