From 7c39a1446f14b0b7b4b9a9be9d222022b6b33828 Mon Sep 17 00:00:00 2001 From: piyanat Date: Tue, 22 Feb 2022 20:45:59 +0200 Subject: [PATCH 1/6] Add temporary fix for future array shape. pyuvdata switched to using `future_array_shapes` by default from `pyuvdata>=2.7.0`. Many functionality of `hera_sim=2.x.x` relies on the `current_array_shapes`. The full fixes are planned for `hera_sim=3.0.0`. --- hera_sim/io.py | 4 ++++ hera_sim/visibilities/simulators.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/hera_sim/io.py b/hera_sim/io.py index a021be80..7cc949f9 100644 --- a/hera_sim/io.py +++ b/hera_sim/io.py @@ -114,6 +114,10 @@ def empty_uvdata( if conjugation is not None: uvd.conjugate_bls(convention=conjugation) + # Temporary fix for future array shape - to be removed after v3. + if uvd.future_array_shapes: + uvd.use_current_array_shapes() + return uvd diff --git a/hera_sim/visibilities/simulators.py b/hera_sim/visibilities/simulators.py index f0e151ac..d69fee67 100644 --- a/hera_sim/visibilities/simulators.py +++ b/hera_sim/visibilities/simulators.py @@ -88,10 +88,16 @@ def __init__( def _process_uvdata(self, uvdata: UVData | str | Path): if isinstance(uvdata, UVData): + # Temporary fix for future array shape - to be removed after v3. + if uvdata.future_array_shapes: + uvdata.use_current_array_shapes() return uvdata elif isinstance(uvdata, (str, Path)): out = UVData() out.read(str(uvdata)) + # Temporary fix for future array shape - to be removed after v3. + if out.future_array_shapes: + out.use_current_array_shapes() return out else: raise TypeError( From 510f2c846557b9ed2bceae13c9c19700fb7da90b Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Tue, 22 Feb 2022 12:16:20 -0700 Subject: [PATCH 2/6] test: update uvsim beam consistency check --- hera_sim/tests/test_vis.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hera_sim/tests/test_vis.py b/hera_sim/tests/test_vis.py index 5f65f1d7..f25a61b9 100644 --- a/hera_sim/tests/test_vis.py +++ b/hera_sim/tests/test_vis.py @@ -5,6 +5,7 @@ from astropy.units import sday, rad from astropy import units from pyuvsim.analyticbeam import AnalyticBeam +from pyuvsim.telescope import BeamConsistencyError from vis_cpu import HAVE_GPU from hera_sim.defaults import defaults from hera_sim import io @@ -357,6 +358,7 @@ def test_autocorr_flat_beam(uvdata, simulator): v = sim.uvdata.get_data((0, 0, "xx")) + print(v) # The sky is uniform and integrates to one over the full sky. # Thus the stokes-I component of an autocorr will be 0.5 (going to horizon) # Since I = XX + YY and X/Y should be equal, the xx part should be 0.25 @@ -619,7 +621,7 @@ def test_beam_type_consistency(uvdata, sky_model): beams = [AnalyticBeam("gaussian"), AnalyticBeam("airy")] beams[0].efield_to_power() - with pytest.raises(ValueError): + with pytest.raises(BeamConsistencyError): ModelData(uvdata=uvdata, sky_model=sky_model, beams=beams) From 872ab89622b410cf6559f4e5eab43cdde108b506 Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Tue, 22 Feb 2022 12:20:48 -0700 Subject: [PATCH 3/6] force uvsim output to current_array_shapes --- hera_sim/visibilities/pyuvsim_wrapper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hera_sim/visibilities/pyuvsim_wrapper.py b/hera_sim/visibilities/pyuvsim_wrapper.py index a703b4f2..467abfe7 100644 --- a/hera_sim/visibilities/pyuvsim_wrapper.py +++ b/hera_sim/visibilities/pyuvsim_wrapper.py @@ -52,4 +52,5 @@ def simulate(self, data_model: ModelData): catalog=pyuvsim.simsetup.SkyModelData(data_model.sky_model), quiet=self.quiet, ) + out_uv.use_current_array_shapes() return out_uv.data_array From 1299a8147d6d406cdb1984b3a1ee8f6305a07c1a Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Tue, 22 Feb 2022 12:57:57 -0700 Subject: [PATCH 4/6] fix: also force the inherent uvdata to be current array shape --- hera_sim/visibilities/pyuvsim_wrapper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hera_sim/visibilities/pyuvsim_wrapper.py b/hera_sim/visibilities/pyuvsim_wrapper.py index 467abfe7..58cd2472 100644 --- a/hera_sim/visibilities/pyuvsim_wrapper.py +++ b/hera_sim/visibilities/pyuvsim_wrapper.py @@ -53,4 +53,5 @@ def simulate(self, data_model: ModelData): quiet=self.quiet, ) out_uv.use_current_array_shapes() + data_model.uvdata.use_current_array_shapes() return out_uv.data_array From 984d866c9f74d1222929e63848d56c69c7095651 Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Tue, 22 Feb 2022 13:19:37 -0700 Subject: [PATCH 5/6] refactor: check array shape once --- hera_sim/visibilities/simulators.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hera_sim/visibilities/simulators.py b/hera_sim/visibilities/simulators.py index d69fee67..59b22914 100644 --- a/hera_sim/visibilities/simulators.py +++ b/hera_sim/visibilities/simulators.py @@ -87,24 +87,24 @@ def __init__( self._validate() def _process_uvdata(self, uvdata: UVData | str | Path): - if isinstance(uvdata, UVData): - # Temporary fix for future array shape - to be removed after v3. - if uvdata.future_array_shapes: - uvdata.use_current_array_shapes() - return uvdata - elif isinstance(uvdata, (str, Path)): + + if isinstance(uvdata, (str, Path)): out = UVData() out.read(str(uvdata)) - # Temporary fix for future array shape - to be removed after v3. - if out.future_array_shapes: - out.use_current_array_shapes() - return out - else: + uvdata = out + + if not isinstance(uvdata, UVData): raise TypeError( "uvdata must be a UVData object or path to a compatible file. Got " f"{uvdata}, type {type(uvdata)}" ) + # Temporary fix for future array shape - to be removed after v3. + if uvdata.future_array_shapes: + uvdata.use_current_array_shapes() + + return uvdata + @classmethod def _process_beams(cls, beams: BeamListType | None, normalize_beams: bool): if beams is None: From 8542daaee8a284c3a8655388f8d82f02db23da8b Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Tue, 22 Feb 2022 13:45:59 -0700 Subject: [PATCH 6/6] docs: update changelog --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9ecd5a62..dd68542d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,13 @@ Changelog ========= +dev-version +=========== + +Changed +------- +- Temporarily forced all UVData objects in the code to use current array shapes. + v2.3.3 [2022.02.21] ===================