Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary fix for future array shape #216

Merged
merged 6 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]
===================

Expand Down
4 changes: 4 additions & 0 deletions hera_sim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 3 additions & 1 deletion hera_sim/tests/test_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions hera_sim/visibilities/pyuvsim_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ def simulate(self, data_model: ModelData):
catalog=pyuvsim.simsetup.SkyModelData(data_model.sky_model),
quiet=self.quiet,
)
out_uv.use_current_array_shapes()
data_model.uvdata.use_current_array_shapes()
return out_uv.data_array
16 changes: 11 additions & 5 deletions hera_sim/visibilities/simulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,24 @@ def __init__(
self._validate()

def _process_uvdata(self, uvdata: UVData | str | Path):
if isinstance(uvdata, UVData):
return uvdata
elif isinstance(uvdata, (str, Path)):

if isinstance(uvdata, (str, Path)):
out = UVData()
out.read(str(uvdata))
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:
Expand Down