PSpecBeam: Primary beam models

PSpecBeam objects carry information about the primary beam, such as how the beam solid angle varies with frequency. This information is needed to rescale power spectra into cosmological units, through the computation of a ‘beam scalar’.

The main purpose of PSpecBeam objects is to provide the PSpecData class with a way of normalizing the power spectra that it produces, using the compute_pspec_scalar() method. To attach a PSpecBeam object to a PSpecData object, pass one in when you instantiate the class, e.g.

# Create PSpecBeamUV from a beamfits file
beam = hp.PSpecBeamUV('HERA_Beams.beamfits')

# Attach beam to PSpecData object
psd = hp.PSpecData(dsets=[], wgts=[], beam=beam)

Another purpose of PSpecBeam objects is to convert flux densities to temperature units using the Jy_to_mK() method, e.g.

# Apply unit conversion factor to UVData
uvd = UVData()
uvd.read_miriad(datafile) # Load data (assumed to be in Jy units)
uvd.data_array *= beam.Jy_to_mK(np.unique(uvd.freq_array))[None, None, :, None]
# (The brackets [] are needed to match the shape of uvd.data_array)

Note that PSpecBeam objects have a cosmology attached to them. If you don’t specify a cosmology (with the cosmo keyword argument), they will be instantiated with the default cosmology from hera_pspec.conversions.

There are several different types of PSpecBeam object:

PSpecBeamBase: Base class for PSpecBeam

This is the base class for all other PSpecBeam objects. It provides the generic compute_pspec_scalar() and Jy_to_mK() methods, but subclasses must provide their own power_beam_int and power_beam_sq_int methods.

class hera_pspec.pspecbeam.PSpecBeamBase(cosmo=None)[source]
Jy_to_mK(freqs, pol='pI')[source]

Return the multiplicative factor [mK / Jy], to convert a visibility from Jy -> mK,

factor = 1e3 * 1e-23 * c^2 / [2 * k_b * nu^2 * Omega_p(nu)]

where k_b is boltzmann constant, c is speed of light, nu is frequency and Omega_p is the integral of the unitless beam-response (steradians), and the 1e3 is the conversion from K -> mK and the 1e-23 is the conversion from Jy to cgs.

Parameters
  • freqs (float ndarray) – Contains frequencies to evaluate conversion factor [Hz].

  • pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

Returns

factor – Contains Jy -> mK factor at each frequency.

Return type

float ndarray

compute_pspec_scalar(lower_freq, upper_freq, num_freqs, num_steps=5000, pol='pI', taper='none', little_h=True, noise_scalar=False, exact_norm=False)[source]

Computes the scalar function to convert a power spectrum estimate in “telescope units” to cosmological units

See arxiv:1304.4991 and HERA memo #27 for details.

Currently, only the “pI”, “XX” and “YY” polarization beams are supported. See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154 or arxiv:1502.05072 for details.

Parameters
  • lower_freq (float) – Bottom edge of frequency band over which power spectrum is being estimated. Assumed to be in Hz.

  • upper_freq (float) – Top edge of frequency band over which power spectrum is being estimated. Assumed to be in Hz.

  • num_freqs (int, optional) – Number of frequencies used in estimating power spectrum.

  • num_steps (int, optional) – Number of steps to use when interpolating primary beams for numerical integral. Default: 5000.

  • pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

  • taper (str, optional) – Whether a tapering function (e.g. Blackman-Harris) is being used in the power spectrum estimation. Default: none.

  • little_h (boolean, optional) – Whether to have cosmological length units be h^-1 Mpc or Mpc. Value of h is obtained from cosmo object stored in pspecbeam. Default: h^-1 Mpc

  • noise_scalar (boolean, optional) – Whether to calculate power spectrum scalar, or noise power scalar. The noise power scalar only differs in that the Bpp_over_BpSq term just because 1_over_Bp. See Pober et al. 2014, ApJ 782, 66.

  • exact_norm (boolean, optional) – returns only X2Y for scalar if True, else uses the existing framework involving antenna beam and spectral tapering factors. Default: False.

Returns

scalar – [int dnu (Omega_PP / Omega_P^2) ( B_PP / B_P^2 ) / (X^2 Y)]^-1 Units: h^-3 Mpc^3 or Mpc^3.

Return type

float

get_Omegas(polpairs)[source]

Get OmegaP and OmegaPP across beam_freqs for requested polarization pairs.

Parameters

polpairs (list) – List of polarization-pair tuples or integers.

Returns

  • OmegaP (array_like) – Array containing power_beam_int, shape: (Nbeam_freqs, Npols).

  • OmegaPP (array_like) – Array containing power_sq_beam_int, shape: (Nbeam_freqs, Npols).

PSpecBeamUV: Beams from a UVBeam object

This class allows you to use any beam that is supported by the UVBeam class in the pyuvdata package. These usually contain Healpix-pixelated beams as a function of frequency and polarization.

To create a beam that uses this format, simply create a new PSpecBeamUV instance with the name of a beamfits file that is supported by UVBeam, e.g.

beam = hp.PSpecBeamUV('HERA_Beams.beamfits')
class hera_pspec.pspecbeam.PSpecBeamUV(uvbeam, cosmo=None)[source]
beam_normalized_response(pol='pI', freq=None, x_orientation=None)[source]

Outputs beam response for given polarization as a function of pixels on the sky and input frequencies. The response needs to be peak normalized, and is read in from Healpix coordinates. Uses interp_freq function from uvbeam for interpolation of beam response over given frequency values.

Parameters
  • pol (str, optional) – Which polarization to compute the beam response for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ The output shape is (Nfreq, Npixels) Default: ‘pI’

  • freq (array, optional) – Frequencies [Hz] to interpolate onto.

  • x_orientation (str, optional) – Orientation in cardinal direction east or north of X dipole. Default keeps polarization in X and Y basis.

Returns

  • beam_res (float, array-like) – Beam response as a function healpix indices and frequency.

  • omega (float, array-like) – Beam solid angle as a function of frequency

  • nside (int, scalar) – used to compute resolution

power_beam_int(pol='pI')[source]

Computes the integral of the beam over solid angle to give a beam area (in str) as a function of frequency. Uses function in pyuvdata.

See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154 or arxiv:1502.05072 for details.

Parameters

pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

Returns

primary_beam_area – Scalar integral over beam solid angle.

Return type

float, array-like

power_beam_sq_int(pol='pI')[source]

Computes the integral of the beam**2 over solid angle to give a beam**2 area (in str) as a function of frequency. Uses function in pyuvdata.

See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154 or arxiv:1502.05072 for details.

Parameters

pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

Returns

primary_beam_area

Return type

float, array-like

Jy_to_mK(freqs, pol='pI')

Return the multiplicative factor [mK / Jy], to convert a visibility from Jy -> mK,

factor = 1e3 * 1e-23 * c^2 / [2 * k_b * nu^2 * Omega_p(nu)]

where k_b is boltzmann constant, c is speed of light, nu is frequency and Omega_p is the integral of the unitless beam-response (steradians), and the 1e3 is the conversion from K -> mK and the 1e-23 is the conversion from Jy to cgs.

Parameters
  • freqs (float ndarray) – Contains frequencies to evaluate conversion factor [Hz].

  • pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

Returns

factor – Contains Jy -> mK factor at each frequency.

Return type

float ndarray

compute_pspec_scalar(lower_freq, upper_freq, num_freqs, num_steps=5000, pol='pI', taper='none', little_h=True, noise_scalar=False, exact_norm=False)

Computes the scalar function to convert a power spectrum estimate in “telescope units” to cosmological units

See arxiv:1304.4991 and HERA memo #27 for details.

Currently, only the “pI”, “XX” and “YY” polarization beams are supported. See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154 or arxiv:1502.05072 for details.

Parameters
  • lower_freq (float) – Bottom edge of frequency band over which power spectrum is being estimated. Assumed to be in Hz.

  • upper_freq (float) – Top edge of frequency band over which power spectrum is being estimated. Assumed to be in Hz.

  • num_freqs (int, optional) – Number of frequencies used in estimating power spectrum.

  • num_steps (int, optional) – Number of steps to use when interpolating primary beams for numerical integral. Default: 5000.

  • pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

  • taper (str, optional) – Whether a tapering function (e.g. Blackman-Harris) is being used in the power spectrum estimation. Default: none.

  • little_h (boolean, optional) – Whether to have cosmological length units be h^-1 Mpc or Mpc. Value of h is obtained from cosmo object stored in pspecbeam. Default: h^-1 Mpc

  • noise_scalar (boolean, optional) – Whether to calculate power spectrum scalar, or noise power scalar. The noise power scalar only differs in that the Bpp_over_BpSq term just because 1_over_Bp. See Pober et al. 2014, ApJ 782, 66.

  • exact_norm (boolean, optional) – returns only X2Y for scalar if True, else uses the existing framework involving antenna beam and spectral tapering factors. Default: False.

Returns

scalar – [int dnu (Omega_PP / Omega_P^2) ( B_PP / B_P^2 ) / (X^2 Y)]^-1 Units: h^-3 Mpc^3 or Mpc^3.

Return type

float

get_Omegas(polpairs)

Get OmegaP and OmegaPP across beam_freqs for requested polarization pairs.

Parameters

polpairs (list) – List of polarization-pair tuples or integers.

Returns

  • OmegaP (array_like) – Array containing power_beam_int, shape: (Nbeam_freqs, Npols).

  • OmegaPP (array_like) – Array containing power_sq_beam_int, shape: (Nbeam_freqs, Npols).

PSpecBeamGauss: Simple Gaussian beam model

A Gaussian beam type is provided for simple testing purposes. You can specify a beam FWHM that is constant in frequency, for the I (pseudo-Stokes I) polarization channel only.

For example, to specify a Gaussian beam with a constant FWHM of 0.1 radians, defined over a frequency interval of [100, 200] MHz:

# Each beam is defined over a frequency interval:
beam_freqs = np.linspace(100e6, 200e6, 200) # in Hz

# Create a new Gaussian beam object with full-width at half-max. of 0.1 radians
beam_gauss = hp.PSpecBeamGauss(fwhm=0.1, beam_freqs=beam_freqs)
class hera_pspec.pspecbeam.PSpecBeamGauss(fwhm, beam_freqs, cosmo=None)[source]
__init__(fwhm, beam_freqs, cosmo=None)[source]

Object to store a simple (frequency independent) Gaussian beam in a PspecBeamBase object.

Parameters
  • fwhm (float) – Full width half max of the beam, in radians.

  • beam_freqs (float, array-like) – Frequencies over which this Gaussian beam is to be created. Units assumed to be Hz.

  • cosmo (conversions.Cosmo_Conversions object, optional) – Cosmology object. Uses the default cosmology object if not specified. Default: None.

power_beam_int(pol='pI')[source]

Computes the integral of the beam over solid angle to give a beam area (in sr). Uses analytic formula that the answer is 2 * pi * fwhm**2 / 8 ln 2.

Trivially this returns an array (i.e., a function of frequency), but the results are frequency independent.

See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154 or arxiv:1502.05072 for details.

Parameters

pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

Returns

primary_beam_area – Primary beam area.

Return type

float, array-like

power_beam_sq_int(pol='pI')[source]

Computes the integral of the beam**2 over solid angle to give a beam area (in str). Uses analytic formula that the answer is pi * fwhm**2 / 8 ln 2.

Trivially this returns an array (i.e., a function of frequency), but the results are frequency independent.

See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154 or arxiv:1502.05072 for details.

Parameters

pol (str, optional) – Which polarization to compute the beam scalar for. ‘pI’, ‘pQ’, ‘pU’, ‘pV’, ‘XX’, ‘YY’, ‘XY’, ‘YX’ Default: ‘pI’

Returns

primary_beam_area – Primary beam area.

Return type

float, array-like