Skip to content

Commit

Permalink
maint: cleanup cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-murray committed Nov 26, 2024
1 parent cc5c58a commit e631234
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 96 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/visibility_simulator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"\n",
"The beam models given to the `beams` parameter can be: i) a `pyuvsim.BeamList` object, ii) a `pyuvdata.UVBeam`, or iii) a list of `pyuvsim.AnalyticBeam`, including its subclasses.\n",
"\n",
"The `hera_sim.beams` module provides analytic models of the HERA antenna through the `PolyBeam`, `PerturbedPolayBeam`, and `ZernikeBeam` objects (see HERA Memo [#081](http://reionization.org/wp-content/uploads/2013/03/HERA081_HERA_Primary_Beam_Chebyshev_Apr2020.pdf) and [#101](http://reionization.org/manual_uploads/HERA101_Analytic_polarized_beam.pdf), and [Choudhuri et al 2021](https://arxiv.org/abs/2101.02684)). These beam models are subclasses of `pyuvdata.analytic_beam.AnalyticBeam`, and so are recognizable by the pyuvsim configuration file parser."
"The `hera_sim.beams` module provides analytic models of the HERA antenna through the `PolyBeam`, `PerturbedPolyBeam`, and `ZernikeBeam` objects (see HERA Memo [#081](http://reionization.org/wp-content/uploads/2013/03/HERA081_HERA_Primary_Beam_Chebyshev_Apr2020.pdf) and [#101](http://reionization.org/manual_uploads/HERA101_Analytic_polarized_beam.pdf), and [Choudhuri et al 2021](https://arxiv.org/abs/2101.02684)). These beam models are subclasses of `pyuvdata.analytic_beam.AnalyticBeam`, and so are recognizable by the pyuvsim configuration file parser."
]
},
{
Expand Down
26 changes: 13 additions & 13 deletions hera_sim/sigchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def __call__(
"""
self._check_kwargs(**kwargs)
(
uvbeam,
beam,
reflection,
omega_p,
ant_1_array,
Expand All @@ -959,12 +959,12 @@ def __call__(

# Now, check that the input beam is OK in case we need to use it.
if coupling_matrix is None:
uvbeam = MutualCoupling._handle_beam(uvbeam, **beam_kwargs)
beam = MutualCoupling._handle_beam(beam, **beam_kwargs)

# This already happens in build_coupling_matrix, but the reshape
# step is not a trivial amount of time, so it's better to do it
# again here.
self._check_beam_is_ok(uvbeam)
self._check_beam_is_ok(beam)

# Let's make sure that we're only using antennas that are in the data.
antpos_ants = antpos_ants.intersection(data_ants)
Expand Down Expand Up @@ -997,7 +997,7 @@ def __call__(
ant_1_array=ant_1_array,
ant_2_array=ant_2_array,
array_layout=array_layout,
uvbeam=uvbeam,
uvbeam=beam,
reflection=reflection,
omega_p=omega_p,
pixel_interp=pixel_interp,
Expand Down Expand Up @@ -1196,20 +1196,20 @@ def build_coupling_matrix(
return coupling_matrix

@staticmethod
def _check_beam_is_ok(uvbeam):
if isinstance(uvbeam, AnalyticBeam):
def _check_beam_is_ok(beam):
if isinstance(beam, AnalyticBeam):
return
if getattr(uvbeam, "pixel_coordinate_system", "") != "az_za":
if getattr(beam, "pixel_coordinate_system", "") != "az_za":
raise ValueError("Beam must be given in az/za coordinates.")
if uvbeam.beam_type != "efield":
if beam.beam_type != "efield":
raise NotImplementedError("Only E-field beams are supported.")

@staticmethod
def _handle_beam(uvbeam, **beam_kwargs):
if isinstance(uvbeam, (AnalyticBeam, UVBeam)):
return uvbeam
if Path(uvbeam).exists():
return UVBeam.from_file(uvbeam, **beam_kwargs)
def _handle_beam(beam, **beam_kwargs):
if isinstance(beam, (AnalyticBeam, UVBeam)):
return beam
if Path(beam).exists():
return UVBeam.from_file(beam, **beam_kwargs)
raise ValueError("uvbeam has incorrect format")


Expand Down
68 changes: 0 additions & 68 deletions hera_sim/tests/test_beams.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,74 +23,6 @@ def check_beam_is_finite(polybeam: PolyBeam, efield: bool = True):
uvbeam = evaluate_polybeam(polybeam, efield)
assert np.all(np.isfinite(uvbeam.data_array))

# def convert_to_pStokes(eval_beam, az, za, Nfreq):
# """
# Convert an E-field to its pseudo-Stokes power beam.
# """
# nside_test = 64
# pixel_indices_test = hp.ang2pix(nside_test, za, az)
# npix_test = hp.nside2npix(nside_test)

# pol_efield_beam_plot = np.zeros((2, 2, Nfreq, npix_test), dtype=np.complex128)
# pol_efield_beam_plot[:, :, :, pixel_indices_test] = eval_beam[:, :, :, :]
# return efield_to_pstokes(pol_efield_beam_plot, npix_test, Nfreq)


# def run_sim(ants, sources, beams, use_pol=False, pol="xx"):
# """
# Run a simple sim using a rotated elliptic polybeam.
# """
# defaults.set("h1c")
# pol_array = np.array(["yx", "xy", "yy", "xx"]) if use_pol else ["xx"]

# # Observing parameters in a UVData object.
# uvdata = io.empty_uvdata(
# Nfreqs=1,
# start_freq=100000000.0,
# channel_width=97000.0,
# start_time=2458902.4,
# integration_time=40,
# Ntimes=1,
# array_layout=ants,
# polarization_array=pol_array,
# x_orientation="east",
# )
# freqs = uvdata.freq_array
# ra_dec, flux, spectral_index = sources

# # calculate source fluxes for hera_sim
# flux = (freqs[:, np.newaxis] / freqs[0]) ** spectral_index * flux
# if SIMULATOR.__name__ == "MatVis":
# simulator = SIMULATOR(precision=2)
# else:
# simulator = SIMULATOR()

# data_model = ModelData(
# uvdata=uvdata,
# beams=beams,
# sky_model=SkyModel(
# freq_array=freqs * units.Hz,
# ra=Longitude(ra_dec[:, 0] * units.rad),
# dec=Latitude(ra_dec[:, 1] * units.rad),
# spectral_type="full",
# stokes=np.array(
# [
# flux,
# np.zeros_like(flux),
# np.zeros_like(flux),
# np.zeros_like(flux),
# ]
# )
# * units.Jy,
# name=["derp"] * flux.shape[1],
# frame="icrs",
# ),
# )
# simulation = VisibilitySimulation(data_model=data_model, simulator=simulator)
# simulation.simulate()

# return np.abs(simulation.uvdata.get_data(0, 0, pol)[0][0])


class TestPerturbedPolyBeam:
def get_perturbed_beam(self, rotation: float) -> PerturbedPolyBeam:
Expand Down
12 changes: 1 addition & 11 deletions hera_sim/visibilities/matvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,7 @@ def simulate(self, data_model):
# The following are antenna positions in the order that they are
# in the uvdata.data_array
active_antpos, ant_list = data_model.uvdata.get_ENU_antpos(pick_data_ants=True)
# logger.info("Preparing Beams...")
# if not polarized:
# beam_list = [
# prepare_beam_unpolarized(beam, use_pol=feed * 2)
# for beam in data_model.beams
# ]
# else:
# beam_list = data_model.beams


beam_ids = np.array(
[
Expand Down Expand Up @@ -331,9 +324,6 @@ def _reorder_vis(self, req_pols, uvdata: UVData, visfull, vis, ant_list, polariz
)

for i, (ant1, ant2) in enumerate(uvdata.get_antpairs()):
# get official "antenna numbers" corresponding to these indices
#antnum1, antnum2 = ant_list[ant1], ant_list[ant2]

# get all blt indices corresponding to this antpair
indx = uvdata.antpair2ind(ant1, ant2)
vis_here = vis[:, i]
Expand Down
4 changes: 2 additions & 2 deletions hera_sim/visibilities/simulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pyuvdata import UVBeam, UVData
from pyuvsim import BeamList
from pyuvsim import __version__ as uvsimv
from pyuvdata import analytic_beam as ab
from pyuvdata import UniformBeam
from pyuvsim.simsetup import (
_complete_uvdata,
initialize_catalog_from_params,
Expand Down Expand Up @@ -114,7 +114,7 @@ def _process_uvdata(self, uvdata: UVData | str | Path):
@classmethod
def _process_beams(cls, beams: BeamListType | None, normalize_beams: bool):
if beams is None:
beams = [ab.UniformBeam()]
beams = [UniformBeam()]

if not isinstance(beams, BeamList):
beams = BeamList(beams)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install_requires =
deprecation
hera-cli-utils>=0.1.0
numpy>=1.18
pyuvdata>=3.1
pyuvdata>=3.1.2
pyuvsim>=1.4
pyyaml>=5.1
rich
Expand Down

0 comments on commit e631234

Please sign in to comment.