From 8a5d00b2cde778463f11ce8d1018c0197834520f Mon Sep 17 00:00:00 2001 From: Aaron Ewall-Wice Date: Sun, 16 Jan 2022 23:44:29 -0800 Subject: [PATCH 1/3] compare earth oriented pols. --- hera_sim/visibilities/vis_cpu.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/hera_sim/visibilities/vis_cpu.py b/hera_sim/visibilities/vis_cpu.py index 60d3c963..080bee90 100644 --- a/hera_sim/visibilities/vis_cpu.py +++ b/hera_sim/visibilities/vis_cpu.py @@ -418,8 +418,19 @@ def _get_req_pols(self, uvdata, uvbeam, polarized: bool) -> List[Tuple[int, int] # TODO: this can be updated to just access uvbeam.feed_array once the # AnalyticBeam API has been improved. feeds = list(getattr(uvbeam, "feed_array", ["x", "y"])) - # In order to get all 4 visibility polarizations for a dual feed system + # We should compare pols in the earth-oriented frame so here we convert + # to earth orientations (if possible) + if uvbeam.x_orientation is not None: + for fn, feed in enumerate(feeds): + if feed == 'x': + feeds[fn] = uvbeam.x_orientation[0] + elif feed == 'y': + if uvbeam.x_orientation.lower() == 'north': + feeds[fn] = 'e' + else: + feeds[fn] = 'n' + vispols = set() for p1, p2 in itertools.combinations_with_replacement(feeds, 2): vispols.add(p1 + p2) @@ -428,9 +439,13 @@ def _get_req_pols(self, uvdata, uvbeam, polarized: bool) -> List[Tuple[int, int] vispol: (feeds.index(vispol[0]), feeds.index(vispol[1])) for vispol in vispols } - # Get the mapping from uvdata pols to uvbeam pols + + # We want to compare pols in the earth-oriented labels (nn, ee) + # So I've changed this to compute the uvdata earth-oriented pols + # and compare directly to avail_pols which are alos earth-oriented + # from the UVBeam object. uvdata_pols = [ - uvutils.polnum2str(polnum, getattr(uvbeam, "x_orientation", None)) + uvutils.polnum2str(polnum, getattr(uvdata, "x_orientation", None)) for polnum in uvdata.polarization_array ] if any(pol not in avail_pols for pol in uvdata_pols): From 9dd930205480d3896c0ee4dad846b273f73dd40a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jan 2022 08:23:36 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- hera_sim/visibilities/vis_cpu.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hera_sim/visibilities/vis_cpu.py b/hera_sim/visibilities/vis_cpu.py index 080bee90..4d51391d 100644 --- a/hera_sim/visibilities/vis_cpu.py +++ b/hera_sim/visibilities/vis_cpu.py @@ -423,13 +423,13 @@ def _get_req_pols(self, uvdata, uvbeam, polarized: bool) -> List[Tuple[int, int] # to earth orientations (if possible) if uvbeam.x_orientation is not None: for fn, feed in enumerate(feeds): - if feed == 'x': + if feed == "x": feeds[fn] = uvbeam.x_orientation[0] - elif feed == 'y': - if uvbeam.x_orientation.lower() == 'north': - feeds[fn] = 'e' + elif feed == "y": + if uvbeam.x_orientation.lower() == "north": + feeds[fn] = "e" else: - feeds[fn] = 'n' + feeds[fn] = "n" vispols = set() for p1, p2 in itertools.combinations_with_replacement(feeds, 2): From 7ab6c65090d3759db649cae891418207177d5a99 Mon Sep 17 00:00:00 2001 From: Aaron Ewall-Wice Date: Mon, 17 Jan 2022 01:33:22 -0800 Subject: [PATCH 3/3] make sure that uvbeam has x_orientation attr before checking it to be not none. --- hera_sim/visibilities/vis_cpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hera_sim/visibilities/vis_cpu.py b/hera_sim/visibilities/vis_cpu.py index 4d51391d..a7ad0df7 100644 --- a/hera_sim/visibilities/vis_cpu.py +++ b/hera_sim/visibilities/vis_cpu.py @@ -421,7 +421,7 @@ def _get_req_pols(self, uvdata, uvbeam, polarized: bool) -> List[Tuple[int, int] # In order to get all 4 visibility polarizations for a dual feed system # We should compare pols in the earth-oriented frame so here we convert # to earth orientations (if possible) - if uvbeam.x_orientation is not None: + if getattr(uvbeam, "x_orientation", None) is not None: for fn, feed in enumerate(feeds): if feed == "x": feeds[fn] = uvbeam.x_orientation[0]