Skip to content

Commit

Permalink
Merge pull request #459 from HERA-Team/fix_future_pyuvdata
Browse files Browse the repository at this point in the history
Fixes for compatibility with future pyuvdata
  • Loading branch information
steven-murray authored May 15, 2024
2 parents 0229ba1 + 8a92b92 commit f3b4a97
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 86 deletions.
7 changes: 6 additions & 1 deletion hera_qm/firstcal_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ def __init__(self, calfits_files, use_gp=True):
self.UVC = UVCal()
self.UVC.read_calfits(calfits_files, use_future_array_shapes=True)

self.pols = np.array([uvutils.polnum2str(jones, x_orientation=self.UVC.x_orientation)
if hasattr(self.UVC, "telescope"):
x_orientation = self.UVC.telescope.x_orientation
else:
x_orientation = self.UVC.x_orientation

self.pols = np.array([uvutils.polnum2str(jones, x_orientation=x_orientation)
for jones in self.UVC.jones_array])
self.Npols = self.pols.size

Expand Down
2 changes: 2 additions & 0 deletions hera_qm/tests/test_firstcal_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import pytest

pytestmark = pytest.mark.filterwarnings(
# this top one can be removed when we require pyuvdata >= 3.0
"ignore:.*Using known values for HERA",
"ignore:.*using values from known telescopes for HERA",
"ignore:.*Increasing the bound and calling fit again may find a better value",
"ignore:.*Decreasing the bound and calling fit again may find a better value",

Expand Down
2 changes: 2 additions & 0 deletions hera_qm/tests/test_omnical_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import numpy as np

pytestmark = pytest.mark.filterwarnings(
# this top one can be removed when we require pyuvdata >= 3.0
"ignore:.*Using known values for HERA",
"ignore:.*using values from known telescopes for HERA",
)

@pytest.fixture(scope='function')
Expand Down
21 changes: 17 additions & 4 deletions hera_qm/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
from pathlib import Path

pytestmark = pytest.mark.filterwarnings(
# this top one can be removed when we require pyuvdata >= 3.0
"ignore:.*Using known values for HERA",
"ignore:.*using values from known telescopes for HERA",
"ignore:The uvw_array does not match the expected values given the antenna positions.",
"ignore:telescope_location is not set. Using known values for HERA.",
"ignore:antenna_positions is not set. Using known values for HERA.",
)


def test_get_metrics_ArgumentParser_ant_metrics():
a = utils.get_metrics_ArgumentParser('ant_metrics')
# First try defaults - test a few of them
Expand Down Expand Up @@ -315,7 +317,11 @@ def test_apply_yaml_flags_uvdata(tmpdir, filein, flag_freqs, flag_times, flag_an
pol_selection = np.ones(uvd.Npols, dtype=bool)
elif isinstance(ant, (list, tuple)):
antnum = ant[0]
pol_num = uvutils.jstr2num(ant[1], x_orientation=uvd.x_orientation)
if hasattr(uvd, "telescope"):
x_orientation = uvd.telescope.x_orientation
else:
x_orientation = uvd.x_orientation
pol_num = uvutils.jstr2num(ant[1], x_orientation=x_orientation)
pol_selection = np.where(uvd.polarization_array == pol_num)[0]
blt_selection = np.logical_or(uvd.ant_1_array == antnum, uvd.ant_2_array == antnum)
if flag_ants:
Expand All @@ -342,6 +348,9 @@ def test_apply_yaml_flags_uvdata(tmpdir, filein, flag_freqs, flag_times, flag_an



# this top one can be removed when we require pyuvdata >= 3.0
@pytest.mark.filterwarnings("ignore:Cannot preserve total_quality_array when")
@pytest.mark.filterwarnings("ignore:Changing number of antennas, but preserving")
@pytest.mark.parametrize(
"filein",
["a_priori_flags_integrations.yaml",
Expand Down Expand Up @@ -386,7 +395,11 @@ def test_apply_yaml_flags_uvcal(filein):
pol_selection = np.ones(uvc.Njones, dtype=bool)
elif isinstance(ant, (list, tuple)):
antnum = ant[0]
pol_num = uvutils.jstr2num(ant[1], x_orientation=uvc.x_orientation)
if hasattr(uvc, "telescope"):
x_orientation = uvc.telescope.x_orientation
else:
x_orientation = uvc.x_orientation
pol_num = uvutils.jstr2num(ant[1], x_orientation=x_orientation)
pol_selection = np.where(uvc.jones_array == pol_num)[0]
ant_selection = uvc.ant_array == antnum
assert np.all(uvc.flag_array[ant_selection, :, :, pol_selection])
Expand Down
Loading

0 comments on commit f3b4a97

Please sign in to comment.