Skip to content

Commit 2ee2e9b

Browse files
kartographerbhazelton
authored andcommitted
Cleaning up pol_convention handling when already applied to UVData
1 parent cbd3eb8 commit 2ee2e9b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/pyuvdata/utils/uvcalibrate.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ def _get_pol_conventions(
6161
f"different values: {uvd_pol_convention} and {uvdata.pol_convention}."
6262
)
6363
else:
64-
if uvdata.pol_convention is not None:
65-
raise ValueError("You are trying to calibrate already-calibrated data.")
64+
if uvdata.pol_convention is not None and (
65+
uvc_pol_convention != uvdata.pol_convention
66+
):
67+
raise ValueError(
68+
"UVData already has a pol_convention applied that does not match UVCal "
69+
f"convention: {uvdata.pol_convention} and {uvc_pol_convention}."
70+
)
6671
if uvd_pol_convention is None:
6772
uvd_pol_convention = uvc_pol_convention
6873

src/pyuvdata/uvdata/mir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def _init_from_mir_parser(
714714
self.uvw_array = (-1.0) * uvw_array
715715

716716
self.vis_units = "Jy"
717-
# self.pol_convention = "avg"
717+
self.pol_convention = "avg"
718718

719719
isource = np.unique(mir_data.in_data["isource"])
720720
for sou_id in isource:

tests/utils/test_uvcalibrate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ def test_uvd_uvdata_different(self):
9797

9898
def test_calibrate_already_calibrated(self):
9999
with pytest.raises(
100-
ValueError, match="You are trying to calibrate already-calibrated data"
100+
ValueError, match="UVData already has a pol_convention applied"
101101
):
102102
_get_pol_conventions(
103-
uvdata=SimpleNamespace(pol_convention="avg"),
103+
uvdata=SimpleNamespace(pol_convention="sum"),
104104
uvcal=SimpleNamespace(pol_convention="avg"),
105105
undo=False,
106106
uvc_pol_convention="avg",
107-
uvd_pol_convention="avg",
107+
uvd_pol_convention="sum",
108108
)
109109

110110
@pytest.mark.parametrize("which", ["uvc", "uvd"])

0 commit comments

Comments
 (0)