Skip to content

Operators

These functions evaluate the EoR and foreground operators as JAX arrays. They do not read files, choose hardware or apply priors, so they can be used inside compiled code. For full-size operators saved to disk, see construction.

\[ \mathbf T_{21}=\mathbf F^{-1}\mathbf P\mathbf F'\mathbf F_z, \qquad \mathbf T_{\rm FG}=\mathbf F^{-1}\mathbf P\mathbf Q_z \]

Main interface

T_21 and T_fg build a block of each operator from the sky geometry, baselines and beam. T_fg_weighted applies the prior and noise weighting used by the KL reduced basis.

Linear operators used in BayesEoR's interferometric forward model.

The component models share the beam-weighted measurement operator \(R = F^{-1}P\) and differ in how their coefficients define sky brightness:

\[ m_{21} = T_{21}a, \qquad T_{21} = R F' F_z, \qquad m_{\rm FG} = T_{\rm FG}q, \qquad T_{\rm FG} = R Q_z. \]

build_transverse_fourier_operator constructs F' (uv to image), build_spectral_fourier_operator constructs F_z (eta to frequency), and build_foreground_spectral_operator supplies the spectral part of Q_z. build_sky_to_visibility_operator constructs R, including the pixel solid angle and primary beam. T_21 and T_fg compose the response and component factors for supplied blocks of visibility rows.

These functions perform numerical construction only. Geometry modules define the coordinates; construction/operator_construction.py chooses CPU blocks, distributes their construction, and saves the assembled matrices. BuildMatrices supplies the configured input arrays. The compact factors below implement these products without forming full Kronecker matrices. T_fg_weighted additionally applies supplied prior and noise factors to prepare the foreground operator for decomposition. No unit conversion or KL compression is applied.

T_21

T_21(lmn: Array, uvw_lambda: Array, beam: Array, pixel_area_sr: float, transverse_operator: Array, spectral_operator: Array) -> jax.Array

Evaluate the cosmological coefficient-to-visibility operator on supplied samples.

Parameters:

Name Type Description Default
lmn Array

Cosmological pixel directions, shape (n_time, 3, n_pixel).

required
uvw_lambda Array

Selected baselines in wavelengths, shape (n_frequency, 3, n_baseline).

required
beam Array

Horizon-masked power gains, shape (n_time, n_frequency, n_pixel).

required
pixel_area_sr float

Equal-area pixel solid angle in steradians.

required
transverse_operator Array

Selected columns of F', shape (n_pixel, n_uv_mode), including transverse Fourier integration weights.

required
spectral_operator Array

Selected frequency rows and eta columns of F_z, shape (n_frequency, n_eta_mode), including the eta integration weight.

required

Returns:

Name Type Description
operator Array

T_21 = F^-1 P F' F_z, shape (n_time*n_frequency*n_baseline, n_uv_mode*n_eta_mode). Rows vary fastest in baseline; columns vary fastest in eta.

Notes

Pass matching subsets of observing times, frequencies, baselines and Fourier modes to evaluate a block. Retain all image pixels needed for the cosmological integral: dropping pixels changes the model rather than merely selecting coefficient columns. This function is JAX-native and can be composed inside jax.jit or automatic differentiation. It does not select a device, access files, distribute work, or apply KL reduction.

T_fg

T_fg(lmn: Array, uvw_lambda: Array, beam: Array, pixel_area_sr: float, spectral_operator: Array) -> jax.Array

Evaluate the foreground coefficient-to-visibility operator on supplied samples.

Parameters:

Name Type Description Default
lmn Array

Selected foreground pixel directions, shape (n_time, 3, n_pixel).

required
uvw_lambda Array

Selected baselines in wavelengths, shape (n_frequency, 3, n_baseline).

required
beam Array

Horizon-masked power gains, shape (n_time, n_frequency, n_pixel).

required
pixel_area_sr float

Equal-area pixel solid angle in steradians.

required
spectral_operator Array

Selected frequency rows and component columns of Q, shape (n_frequency, n_spectral_component). Any supplied linear spectral basis is accepted, not just the default constant and power laws.

required

Returns:

Name Type Description
operator Array

T_fg = F^-1 P Q_z, shape (n_time*n_frequency*n_baseline, n_spectral_component*n_pixel). Rows vary fastest in baseline; columns vary fastest in pixel.

Notes

Select matching input arrays before calling to evaluate only the required visibility rows and component/pixel columns. The function is JAX-native and can be used inside jax.jit or automatic differentiation without saving a matrix. It performs no device selection, distributed scheduling, prior weighting, or KL reduction.

T_fg_weighted

T_fg_weighted(lmn: Array, uvw_lambda: Array, beam: Array, pixel_area_sr: float, spectral_operator: Array, *, prior_sqrt: Array, noise_whitener: Array) -> jax.Array

Evaluate the prior- and noise-weighted physical foreground mapping.

Parameters:

Name Type Description Default
lmn Array

Foreground pixel directions, shape (n_time, 3, n_pixel).

required
uvw_lambda Array

Baselines in wavelengths, shape (n_frequency, 3, n_baseline).

required
beam Array

Horizon-masked gains, shape (n_time, n_frequency, n_pixel).

required
pixel_area_sr float

Equal-area pixel solid angle in steradians.

required
spectral_operator Array

Foreground spectral factors, shape (n_frequency, n_component).

required
prior_sqrt Array

Prior standard deviations in component/pixel order, or a square covariance factor, as defined in weight_foreground_operator.

required
noise_whitener Array

Inverse noise RMS in time/frequency/baseline order, or a square whitening matrix, as defined in weight_foreground_operator.

required

Returns:

Name Type Description
weighted_operator Array

A = W T_fg L, shape (n_time*n_frequency*n_baseline, n_component*n_pixel).

Notes

Composes the unchanged physical T_fg with prior weighting and noise whitening. It is JAX-native, including under jax.jit and automatic differentiation; distribution, saving and decomposition remain separate. To reuse an already constructed matrix, call weight_foreground_operator instead. Correlated factors require complete contracted axes, as described there; diagonal factors permit independently evaluated visibility blocks.

Building blocks

Each factor of the operators can also be built separately: the fringe response, \(\mathbf R = \mathbf F^{-1}\mathbf P\); the Fourier transforms, \(\mathbf F'\) and \(\mathbf F_z\); and the foreground spectral basis, \(\mathbf Q_z\).

Linear operators used in BayesEoR's interferometric forward model.

The component models share the beam-weighted measurement operator \(R = F^{-1}P\) and differ in how their coefficients define sky brightness:

\[ m_{21} = T_{21}a, \qquad T_{21} = R F' F_z, \qquad m_{\rm FG} = T_{\rm FG}q, \qquad T_{\rm FG} = R Q_z. \]

build_transverse_fourier_operator constructs F' (uv to image), build_spectral_fourier_operator constructs F_z (eta to frequency), and build_foreground_spectral_operator supplies the spectral part of Q_z. build_sky_to_visibility_operator constructs R, including the pixel solid angle and primary beam. T_21 and T_fg compose the response and component factors for supplied blocks of visibility rows.

These functions perform numerical construction only. Geometry modules define the coordinates; construction/operator_construction.py chooses CPU blocks, distributes their construction, and saves the assembled matrices. BuildMatrices supplies the configured input arrays. The compact factors below implement these products without forming full Kronecker matrices. T_fg_weighted additionally applies supplied prior and noise factors to prepare the foreground operator for decomposition. No unit conversion or KL compression is applied.

build_sky_to_visibility_operator

build_sky_to_visibility_operator(lmn: Array, uvw_lambda: Array, beam: Array, pixel_area_sr: float) -> jax.Array

Map individual HEALPix pixel brightnesses to measured visibilities.

Parameters:

Name Type Description Default
lmn Array

Topocentric sky coordinates with shape (n_time, 3, n_pixel). Pixel identities remain fixed on the celestial sky while their topocentric direction cosines change with observing time.

required
uvw_lambda Array

Baselines in observing wavelengths with shape (n_frequency, 3, n_baseline). BayesEoR follows the PyUVData ant2 - ant1 baseline convention, hence the positive phase used below is equivalent to a negative phase with the opposite ant1 - ant2 baseline convention. Baselines are fixed in the instrument frame; sky rotation is already represented by lmn.

required
beam Array

Horizon-limited primary-beam power response with shape (n_time, n_frequency, n_pixel). Pixels at or below the horizon must already have zero gain.

required
pixel_area_sr float

Solid angle of one equal-area sky pixel in steradians.

required

Returns:

Type Description
Array

Beam-weighted sky-to-visibility response with shape (n_time, n_frequency, n_baseline, n_pixel).

Notes

At each observing time, propagate the pixels' topocentric (l, m, n) directions through the full three-dimensional discrete Fourier response, including primary-beam weighting and pixel solid angle. The combined operator is \(R=F^{-1}P\).

\[ R_{tfbp} = \Delta\Omega\,P_{tfp}\, \exp[+2\pi i\,\boldsymbol u_b(\nu_f)\cdot\hat{\boldsymbol s}_p(t)]. \]

Summing R[t, f, b, p] * brightness[f, p] over pixels gives a model visibility. Both sky components use this response, restricted to their respective pixel selections. F^{-1} denotes the sky-to-visibility Fourier operator; it does not imply a numerical matrix inversion here.

build_transverse_fourier_operator

build_transverse_fourier_operator(uv: Array, lm: Array, uv_cell_area: float) -> jax.Array

Map cosmological (u, v) coefficients to brightness at HEALPix pixel centres.

Parameters:

Name Type Description Default
uv Array

Retained model coordinates, shape (2, n_uv_mode). These are the cosmological Fourier grid, not the instrument's sampled baselines.

required
lm Array

Image direction cosines, shape (2, n_pixel). The caller selects the cosmological pixels at the reference time, defining a fixed transverse chart for the intrinsic brightness field.

required
uv_cell_area float

Fourier-cell integration weight du * dv.

required

Returns:

Type Description
Array

Complex matrix of shape (n_pixel, n_uv_mode). Applied alongside F_z in build_T_21_core; drift-scan time dependence enters the separate sky-to-visibility operator.

Notes

This transverse Fourier operator is denoted \(F'\).

\[ F'_{pu} = \Delta u\,\Delta v\, \exp[-2\pi i(u_u l_p + v_u m_p)]. \]

build_spectral_fourier_operator

build_spectral_fourier_operator(eta: Array, frequency_offsets_hz: Array, d_eta: float) -> jax.Array

Map cosmological eta coefficients to brightness at observing frequencies.

Parameters:

Name Type Description Default
eta Array

Retained line-of-sight Fourier coordinates in inverse Hz (seconds), shape (n_eta_mode,). Geometry construction excludes eta=0.

required
frequency_offsets_hz Array

Frequencies relative to the chosen reference channel, in Hz, shape (n_frequency,). BuildMatrices uses channel n_freq // 2.

required
d_eta float

Fourier integration weight in inverse Hz, normally 1 / bandwidth.

required

Returns:

Type Description
Array

Complex matrix of shape (n_frequency, n_eta_mode). The same spectral mapping applies to every transverse cosmological mode.

Notes

This line-of-sight Fourier operator is denoted \(F_z\).

\[ (F_z)_{fe} = \Delta\eta\, \exp[-2\pi i(\nu_f-\nu_{\rm ref})\eta_e]. \]

build_foreground_spectral_operator

build_foreground_spectral_operator(frequencies_mhz: Array, reference_frequency_mhz: float, spectral_indices: Sequence[float] = (-2.63, -2.82)) -> jax.Array

Map a pixel's foreground amplitudes to its brightness spectrum.

Parameters:

Name Type Description Default
frequencies_mhz Array

Observing frequencies in MHz, shape (n_frequency,).

required
reference_frequency_mhz float

Positive reference frequency nu_0 in MHz. Power-law amplitudes are defined at this frequency.

required
spectral_indices sequence of float

Signed exponents for the power-law components, following the constant component. For example, -2.63 gives a spectrum decreasing with frequency. BuildMatrices converts its positive beta_fg configuration values to this signed convention.

(-2.63, -2.82)

Returns:

Type Description
Array

Dimensionless complex matrix of shape (n_frequency, 1 + len(spectral_indices)). It contains only the spectral factors; build_T_fg_core applies them independently to each image pixel to implement the full Q_z mapping.

Notes

These constant and power-law factors define the spectral part of \(Q_z\), shared by every foreground HEALPix pixel.

\[ Q_{f0}=1,\qquad Q_{fs}=(\nu_f/\nu_0)^{\beta_s}\ (s>0), \qquad s_p(\nu_f)=\sum_s Q_{fs}q_{s,p}. \]

build_T_21_core

build_T_21_core(sky_to_visibility: Array, transverse_operator: Array, spectral_operator: Array) -> jax.Array

Map cosmological (u, v, eta) amplitudes to a block of visibilities.

Parameters:

Name Type Description Default
sky_to_visibility Array

R restricted to cosmological image pixels, with shape (n_time, n_frequency, n_baseline, n_pixel).

required
transverse_operator Array

F' with shape (n_pixel, n_uv_mode). Its pixel order must match the last axis of sky_to_visibility.

required
spectral_operator Array

F_z with shape (n_frequency, n_eta_mode), selected for the same frequency rows as sky_to_visibility.

required

Returns:

Type Description
Array

Matrix of shape (n_time * n_frequency * n_baseline, n_uv_mode * n_eta_mode). Rows are ordered by time, frequency, then baseline; columns by transverse mode, then eta (fastest varying). Multiplication by the correspondingly ordered a gives m_21.

Notes

Reconstruct their brightness on the cosmological HEALPix selection and propagate it through the beam-weighted three-dimensional fringe response, implementing \(T_{21}=R F' F_z\).

\[ (T_{21})_{(tfb),(ue)} = \left[\sum_p R_{tfbp} F'_{pu}\right](F_z)_{fe}. \]

core denotes the equation-level calculation for supplied arrays. T_21_build_save handles distributed CPU construction and saving. All integration weights are already included in the input operators.

build_T_fg_core

build_T_fg_core(sky_to_visibility: Array, spectral_operator: Array) -> jax.Array

Map spectral foreground amplitudes at each HEALPix pixel to visibilities.

Parameters:

Name Type Description Default
sky_to_visibility Array

R for the foreground pixel selection, with shape (n_time, n_frequency, n_baseline, n_pixel).

required
spectral_operator Array

Spectral factors Q from build_foreground_spectral_operator, shape (n_frequency, n_spectral_component). Frequency rows must match those in sky_to_visibility.

required

Returns:

Type Description
Array

Matrix of shape (n_time * n_frequency * n_baseline, n_spectral_component * n_pixel). Rows are ordered by time, frequency, then baseline. Columns are ordered by spectral component, then pixel, matching q = (q_0.T, q_1.T, ...).T.

Notes

Evaluate each pixel's brightness at the observing frequencies and apply the beam-weighted three-dimensional fringe response, implementing \(T_{\rm FG}=R Q_z\).

\[ (T_{\rm FG})_{(tfb),(sp)} = R_{tfbp} Q_{fs}. \]

Each foreground coefficient belongs to one image pixel and one spectral component. Q supplies the spectral dependence at every pixel; R propagates the resulting brightness through the instrument.

T_fg_build_save distributes and saves blocks from this core. The pixel identity in Q_z is applied implicitly, so no dense Kronecker product or additional pixel-area factor is needed.

weight_foreground_operator

weight_foreground_operator(operator: Array, prior_sqrt: Array, noise_whitener: Array) -> jax.Array

Prior-weight and noise-whiten a foreground coefficient-to-visibility matrix.

Parameters:

Name Type Description Default
operator Array

Physical foreground operator, shape (n_visibility, n_coefficient). Columns use spectral-component/pixel order; rows use time/frequency/baseline order, as returned by T_fg.

required
prior_sqrt Array

Factor L satisfying Sigma_q = L @ L.conj().T. Supply either its diagonal as a vector of length n_coefficient (the prior standard deviations), or a square matrix for correlated coefficients. Entries have the units of the corresponding physical coefficients.

required
noise_whitener Array

Factor W satisfying W @ N @ W.conj().T = I. Supply either its diagonal as a vector of length n_visibility (inverse complex noise RMS, equivalently sqrt(Ninv)), or a square whitening matrix. Noise RMS must use the units of the visibilities predicted by operator acting on the physical coefficients.

required

Returns:

Name Type Description
weighted_operator Array

A = W @ operator @ L, with the same shape as operator. Maps standard-normal foreground deviations into noise-whitened visibilities.

Notes

With Hermitian covariance roots this is

\[ A = N^{-1/2} T_{\rm FG} \Sigma_q^{1/2}, \qquad A A^\dagger = W T_{\rm FG} \Sigma_q T_{\rm FG}^\dagger W^\dagger. \]

Thus an SVD of A or eigendecomposition of A @ A.conj().T can recover its noise-relevant visibility modes. This function only applies the factors: it does not construct a covariance, decompose, truncate, save, or choose a device. The caller supplies valid covariance factors; shape checks remain compatible with jax.jit and differentiation. Prior means affect the predicted mean, not this uncertainty operator.

For diagonal factors, matching row/column subsets can be weighted independently. Dense factors mix rows/columns and require the complete contracted axes; slicing their diagonal blocks generally changes the model.

build_nudft_matrix

build_nudft_matrix(coords_in: ndarray, coords_out: ndarray, sign: int = -1) -> jnp.ndarray

Map amplitudes between supplied coordinate sets with a Fourier kernel.

Parameters:

Name Type Description Default
coords_in ndarray

Source coordinates. Shape (N_axes, N_in). e.g., Sky positions (l, m, n) for a forward transform.

required
coords_out ndarray

Target coordinates. Shape (N_axes, N_out). e.g., Baselines (u, v, w) for a forward transform.

required
sign int

Fourier exponent sign: -1 gives exp(-2 pi i phase) and +1 gives its complex conjugate. This is independent of the baseline convention documented in build_sky_to_visibility_operator.

-1

Returns:

Name Type Description
nudft_matrix ndarray

A Complex128 matrix of shape (N_out, N_in).

Notes

For input coordinates x_i and output coordinates y_j, return

\[ K_{ji} = \exp\!\left(\mathrm{sign}\,2\pi i\,y_j\cdot x_i\right). \]

Multiplication by K maps input amplitudes to the output samples. The coordinate pairs determine the spaces being connected; sign selects the Fourier phase convention. Reversing the sign alone does not construct a matrix inverse for arbitrary non-uniform sampling. The physical operator builders supply their own integration weights.