Beam Interface

The BeamInterface object is designed to provide a unified interface for UVBeam and AnalyticBeam objects to compute beam response values. It can be constructed with either a pyuvdata.UVBeam or AnalyticBeam and it provides the pyuvdata.BeamInterface.compute_response() method, which can be used to either evaluate the response of an AnalyticBeam or interpolate a UVBeam to get the beam response. This interface provides a simplified way for simulators to get beam responses from either UVBeams or analytic beams with the same code.

class pyuvdata.BeamInterface(beam: AnalyticBeam | UVBeam, beam_type: Literal['efield', 'power'] | None = None, include_cross_pols: dataclasses.InitVar[bool] = True)[source]

Definition for a unified beam interface.

This object provides a unified interface for UVBeam and AnalyticBeam objects to compute beam response values in any direction.

beam

Beam object to use for computations. If a BeamInterface is passed, a new view of the same object is created.

Type:

pyuvdata.UVBeam or pyuvdata.AnalyticBeam or BeamInterface

beam_type

The beam type, either “efield” or “power”.

Type:

str

include_cross_pols

Option to include the cross polarized beams (e.g. xy and yx or en and ne). Used if beam is a UVBeam and and the input UVBeam is an Efield beam but beam_type is “power”. Ignored otherwise (the cross pol inclusion is set by the beam object.)

Type:

bool

property Npols

The number of polarizations in the beam.

property polarization_array

The polarizations defined on the beam.

property feed_array

The feeds for which the beam is defined.

property feed_angle

The feeds for which the beam is defined.

property Nfeeds

The number of feeds defined on the beam.

clone(**kw)[source]

Return a new instance with updated parameters.

as_power_beam(include_cross_pols: bool | None = None, allow_beam_mutation: bool = False)[source]

Return a new interface instance that is in the power-beam mode.

If already in the power-beam mode, this is a no-op. Note that this might be slighty unexpected, because the effect of include_cross_pols is not accounted for in this case.

Parameters:
  • include_cross_pols (bool, optional) – Whether to include cross-pols in the power beam. By default, this is True for E-field beams, and takes the same value as the existing beam if the existing beam is already a power beam.

  • allow_beam_mutation (bool, optional) – Whether to allow the underlying beam to be updated in-place.

with_feeds(feeds, *, maintain_ordering: bool = True)[source]

Return a new interface instance with updated feed_array.

Parameters:
  • feeds (array_like of str) – The feeds to keep in the beam. Each value should be a string, e.g. ‘n’, ‘x’.

  • maintain_ordering (bool, optional) – If True, maintain the same polarization ordering as in the beam currently. If False, change ordering to match the input feeds, which are turned into pols (if a power beam) by using product(feeds, feeds).

compute_response(*, az_array: ndarray[tuple[Any, ...], dtype[floating]], za_array: ndarray[tuple[Any, ...], dtype[floating]], freq_array: ndarray[tuple[Any, ...], dtype[floating]] | None, az_za_grid: bool = False, interpolation_function=None, freq_interp_kind=None, freq_interp_tol: float = 1.0, reuse_spline: bool = False, spline_opts: dict | None = None, check_azza_domain: bool = True)[source]

Calculate beam responses, by interpolating UVBeams or evaluating AnalyticBeams.

Parameters:
  • az_array (array_like of floats, optional) – Azimuth values to compute the response for in radians, either specifying the azimuth positions for every interpolation point or specifying the azimuth vector for a meshgrid if az_za_grid is True.

  • za_array (array_like of floats, optional) – Zenith values to compute the response for in radians, either specifying the zenith positions for every interpolation point or specifying the zenith vector for a meshgrid if az_za_grid is True.

  • freq_array (array_like of floats or None) – Frequency values to compute the response for in Hz. If beam is a UVBeam this can be set to None to get the responses at the UVBeam frequencies. It must be a numpy array if beam is an analytic beam.

  • az_za_grid (bool) – Option to treat the az_array and za_array as the input vectors for points on a mesh grid.

  • interpolation_function (str, optional) – Specify the interpolation function to use. Defaults to: “az_za_simple” for objects with the “az_za” pixel_coordinate_system and “healpix_simple” for objects with the “healpix” pixel_coordinate_system. Only applies if beam is a UVBeam.

  • freq_interp_kind (str) – Interpolation method to use frequency. See scipy.interpolate.interp1d for details. Defaults to “cubic”.

  • freq_interp_tol (float) – Frequency distance tolerance [Hz] of nearest neighbors. If all elements in freq_array have nearest neighbor distances within the specified tolerance then return the beam at each nearest neighbor, otherwise interpolate the beam. Only applies if beam is a UVBeam.

  • reuse_spline (bool) – Save the interpolation functions for reuse. Only applies if beam is a UVBeam and interpolation_function is “az_za_simple”.

  • spline_opts (dict) – Provide options to numpy.RectBivariateSpline. This includes spline order parameters kx and ky, and smoothing parameter s. Only applies if beam is a UVBeam and interpolation_function is “az_za_simple” or “az_za_map_coordinates”.

  • check_azza_domain (bool) – Whether to check the domain of az/za to ensure that they are covered by the intrinsic data array. Checking them can be quite computationally expensive. Conversely, if the passed az/za are outside of the domain, they will be silently extrapolated and the behavior is not well-defined. Only applies if beam is a UVBeam and interpolation_function is “az_za_simple” or “az_za_map_coordinates”.

Returns:

array_like of float or complex – An array of computed values, shape (Naxes_vec, Nfeeds or Npols, freq_array.size, az_array.size)