Skip to content

Sky and Fourier grids

build_image_geometry selects the HEALPix pixels of each model field and tracks their directions through the observation. build_fourier_geometry defines the EoR coefficient grid, whose modes are converted to wavenumbers and grouped into power-spectrum bins.

Sky pixels

bayeseor_jax.model.observation.image_geometry.build_image_geometry

build_image_geometry(*, fov_eor: float, fov_fg: float | None = None, nside: int = 128, footprint_nside: int | None = None, telescope_latlonalt: tuple[float, float, float] = HERA_LOCATION, jd_center: float = 2461040.5, n_t: int = 1, d_t: float = 60.0) -> ImageGeometry

Construct the spherical sky coordinates used by both forward models.

Parameters:

Name Type Description Default
fov_eor float

Full cosmological and foreground field diameters in degrees. fov_fg=None uses the cosmological field. The cosmological field must be contained in the foreground field for the shared response.

required
fov_fg float

Full cosmological and foreground field diameters in degrees. fov_fg=None uses the cosmological field. The cosmological field must be contained in the foreground field for the shared response.

required
nside int

HEALPix resolution; all selected pixels have area 4*pi/(12*nside**2).

128
footprint_nside int or None

Resolution used only to select each field's time-union boundary. Include every child of the selected pixels at the shared model nside. Both resolutions must be powers of two, with footprint_nside <= nside. None uses the model grid directly. This keeps sky coverage fixed when refining a simulation or model, without introducing separate component resolutions.

None
telescope_latlonalt tuple of float

Geodetic latitude and longitude in degrees, followed by altitude in metres.

HERA_LOCATION
jd_center float

Reference UTC Julian date.

2461040.5
n_t int

Number of integrations.

1
d_t float

Separation of integration centres in seconds.

60.0

Returns:

Type Description
ImageGeometry

Fixed pixel selections represented by their time-dependent directions, shared cosmological-pixel mask, solid angle, and reference-time extents.

Notes

Select the union of HEALPix pixels entering each zenith drift-scan field across all integrations, follow their topocentric directions, and measure their angular extents at the reference time. Return an ImageGeometry for beam evaluation and the mapping from image brightness to visibilities.

bayeseor_jax.model.observation.image_geometry.ImageGeometry dataclass

Coordinates of the HEALPix pixels used to represent sky brightness.

Parameters:

Name Type Description Default
time_ind_center int

Index of the reference integration within the observing-time axis.

required
eor_fg_shared_axis Array

Boolean mask of shape (n_pix_fg,) selecting cosmological pixels from the foreground pixel axis.

required
n_pix_fg int

Number of selected foreground HEALPix pixels.

required
pixel_area_sr float

Solid angle of one HEALPix pixel in steradians.

required
lmn_fg Array

East, north, and zenith direction cosines, shape (n_time, 3, n_pix_fg).

required
az_za_fg Array

Azimuth and zenith angle in radians, shape (n_time, 2, n_pix_fg).

required
fov_l_angle_eor float

Pixel-padded cosmological angular extent along the local l chart in radians.

required
fov_m_angle_eor float

Pixel-padded cosmological angular extent along the local m chart in radians.

required
fov_l_angle_fg float

Pixel-padded foreground angular extent along the local l chart in radians.

required
fov_m_angle_fg float

Pixel-padded foreground angular extent along the local m chart in radians.

required
Notes

lmn_fg has shape (n_time, 3, n_pix_fg) with east, north, and zenith direction cosines. az_za_fg has shape (n_time, 2, n_pix_fg) and contains azimuth and zenith angle in radians. Both arrays retain the same pixel ordering throughout the observation.

eor_fg_shared_axis selects cosmological pixels from the foreground pixel axis. time_ind_center selects the reference-time chart used by the transverse Fourier operator. The four fov_*_angle_* values are pixel-padded angular widths in radians in that chart; pixel_area_sr is the equal solid angle used when integrating brightness over the sky.

bayeseor_jax.model.observation.image_geometry.required_healpix_nside

required_healpix_nside(longest_baseline_m: float, highest_frequency_hz: float, *, samples_per_fringe: float = 2.0) -> int

Estimate the HEALPix resolution needed to sample the shortest fringe.

Parameters:

Name Type Description Default
longest_baseline_m float

Largest physical baseline length in metres, finite and non-negative. Use the full three-dimensional length, not just its uv projection.

required
highest_frequency_hz float

Highest observing frequency in Hz, finite and positive. This sets the shortest wavelength and hence the finest instrumental fringe scale.

required
samples_per_fringe float

Number of nominal pixels per fringe, at least two. Defaults to the two-sample Nyquist estimate; larger values provide finer sampling.

2.0

Returns:

Type Description
int

Smallest power-of-two nside satisfying the nominal pixel-size criterion, with a minimum of one. Values outside the supported HEALPix range (nside < 2**30) raise ValueError.

Notes

The largest angular phase gradient is \(2\pi b_{\max}/\lambda\). Using the nominal HEALPix pixel width \(\sqrt{\Omega_{\rm pix}}\) therefore gives

\[ \frac{\sqrt{\pi/3}}{N_{\rm side}} \leq \frac{c}{s\,b_{\max}\nu_{\max}}, \]

where \(s\) is samples_per_fringe. For a zero baseline there is no fringe-resolution requirement and the function returns one.

This is a baseline-based sampling estimate, not a strict spherical sampling theorem: HEALPix pixels have different shapes, and beam, sky structure and sharp horizon masks can require finer quadrature. Check visibility convergence at higher resolution when accuracy matters. The helper does not change a run's configured resolution or foreground prior. See https://healpy.readthedocs.io/en/latest/generated/healpy.pixelfunc.nside2resol.html for the nominal pixel-width convention.

Fourier grid

bayeseor_jax.model.cosmology.fourier_geometry.build_fourier_geometry

build_fourier_geometry(*, n_u: int, n_v: int, n_eta: int, du: float, dv: float, d_eta: float) -> FourierGeometry

Define the rectilinear Fourier grid of the cosmological 21-cm brightness field.

Parameters:

Name Type Description Default
n_u int

Number of transverse u modes before removing the angular monopole.

required
n_v int

Number of transverse v modes before removing the angular monopole.

required
n_eta int

Number of line-of-sight Fourier modes before excluding eta=0.

required
du float

Transverse u spacing in inverse radians; must be positive.

required
dv float

Transverse v spacing in inverse radians; must be positive.

required
d_eta float

Positive eta spacing and integration weight in inverse Hz (seconds).

required

Returns:

Name Type Description
geometry FourierGeometry

Retained coordinates and spacings for (n_un_v - 1)(n_eta - 1) coefficients.

Notes

The intrinsic cosmological brightness field is parameterised by complex amplitudes on a three-dimensional rectilinear (u, v, eta) grid, rather than by independent image-pixel amplitudes. The transverse coordinates u and v are Fourier duals of the reference-time image direction cosines (l, m), while eta is the Fourier dual of observing frequency. These are model coordinates, not the baselines sampled by the instrument. The transverse representation uses a local tangent-plane description of the cosmological field.

This basis provides a natural parameterisation for power-spectrum inference. At a reference redshift, the modes map to comoving wavenumbers as

\[ k_x = 2\pi u / D_M, \qquad k_y = 2\pi v / D_M, \qquad k_z = 2\pi\eta / |d\chi/d\nu|. \]

Here D_M is the transverse comoving distance and |dchi/dnu| is the line-of-sight distance per unit frequency. Under the statistically homogeneous and isotropic Gaussian signal model, distinct Fourier modes are uncorrelated and their prior variances are determined by the power spectrum at |k|. Grouping modes into spherical k bins therefore links the coefficient prior directly to the power-spectrum amplitudes inferred downstream, while the individual amplitudes can be analytically marginalised. Coordinate conversion, binning, and prior construction are separate from this geometry builder.

Every retained transverse pair is combined with every retained eta mode. The (u, v)=(0, 0) pair and eta=0 plane are excluded, leaving (n_u*n_v - 1) * (n_eta - 1) coefficients. Flattening orders v first, then u, with eta varying fastest. The spacings du, dv, and d_eta also supply the Fourier integration weights; they are normally chosen from the reciprocal transverse model extents and observing bandwidth.

Downstream, F_z maps eta modes to frequency and F' maps transverse modes to brightness at the selected HEALPix pixel centres. The primary beam and full three-dimensional fringe response then propagate this field into the measured visibilities, where instrumental coupling mixes the mode signatures. This function defines only coordinates and spacings; it does not construct a brightness realisation, prior covariance, or any of those operators.

bayeseor_jax.model.cosmology.fourier_geometry.FourierGeometry dataclass

Retained Fourier coordinates and their integration spacings.

Parameters:

Name Type Description Default
uv Array

Retained angular Fourier coordinates, shape (2, n_uv_mode), excluding the transverse monopole.

required
eta Array

Retained line-of-sight Fourier coordinates in inverse Hz, shape (n_eta_mode,), excluding eta=0.

required
du float

Transverse u spacing in inverse radians; must be positive.

required
dv float

Transverse v spacing in inverse radians; must be positive.

required
d_eta float

Positive eta spacing and integration weight in inverse Hz (seconds).

required
Notes

uv has shape (2, n_uv_mode) and contains angular spatial frequencies; eta has shape (n_eta_mode,) in inverse Hz. du, dv, and d_eta supply the corresponding integration weights. A coefficient belongs to each (uv, eta) pair, with eta varying fastest when coefficients are flattened into a vector.

Wavenumbers and bins

bayeseor_jax.model.cosmology.transforms.Cosmology dataclass

FRW cosmology helper for 21-cm coordinate and volume conversion transforms.

Parameters:

Name Type Description Default
H0_km_s_Mpc float

Hubble constant H0 in (km / s) / Mpc.

float(value)
Om0 float

Present-day matter density parameter.

float(Om0)
Ode0 float

Present-day dark-energy density parameter.

float(Ode0)
Ok0 float

Present-day curvature density parameter.

float(Ok0)
Or0 float

Present-day radiation density parameter, including the Planck18 photon and neutrino contributions.

float(Ogamma0 + Onu0)
f_21_hz float

Rest frequency of the 21-cm line in Hz.

1420405751.77
c_ms float

Speed of light in m/s.

float(value)
Notes

Defaults are loaded from astropy.cosmology.Planck18. Expansion rates and transverse distances are evaluated with that fixed Astropy cosmology on the host and returned as JAX arrays; those methods are not JIT-compatible. Changing the stored density parameters does not change these Astropy evaluations. Frequency/redshift and line-of-sight conversions use the stored rest frequency, speed of light, and Hubble constant where applicable.

f2z

f2z(f_hz: ndarray) -> jnp.ndarray

Convert observing frequency to redshift via the 21-cm rest frequency.

Parameters:

Name Type Description Default
f_hz ndarray

Observing frequency in Hz.

required

Returns:

Name Type Description
z ndarray

Redshift with broadcasted shape of f_hz.

z2f

z2f(z: ndarray) -> jnp.ndarray

Convert redshift to observing frequency.

Parameters:

Name Type Description Default
z ndarray

Redshift.

required

Returns:

Name Type Description
f_hz ndarray

Observed frequency in Hz, same broadcasted shape as z.

e_z

e_z(z: ndarray) -> jnp.ndarray

Evaluate dimensionless expansion rate E(z) = H(z)/H0.

Parameters:

Name Type Description Default
z ndarray

Redshift.

required

Returns:

Name Type Description
e_z ndarray

Dimensionless expansion-rate factor, same shape as input.

Notes

Uses Planck18.efunc on the host, independently of the density parameters stored on this instance.

dL_df

dL_df(z: ndarray) -> jnp.ndarray

Compute LOS comoving conversion factor magnitude per observing frequency.

Parameters:

Name Type Description Default
z ndarray

Redshift.

required

Returns:

Name Type Description
dL_df ndarray

Positive conversion factor in Mpc / Hz, same shape as z.

Notes

Uses |dchi/df| = D_H * (1+z)^2 / (f_21 * E(z)) with D_H = c/H0. The signed derivative dchi/df is negative.

dL_dth

dL_dth(z: ndarray, n_z_samples: int = 2048) -> jnp.ndarray

Compute transverse comoving distance D_M(z) per radian.

Parameters:

Name Type Description Default
z ndarray

Scalar or array of redshifts; the output preserves its shape.

required
n_z_samples int

Unused compatibility argument, default 2048. Astropy controls the distance calculation rather than an explicit sampling grid.

2048

Returns:

Name Type Description
dL_dth ndarray

D_M in Mpc/rad (numerically Mpc since rad is dimensionless). Returns scalar for scalar z; otherwise shape (N,).

Notes

Uses Planck18.comoving_transverse_distance on the host. This distance converts transverse angular Fourier modes to cosmological wavenumbers through k_perp = 2*pi*sqrt(u**2 + v**2)/D_M.

inst_to_cosmo_vol

inst_to_cosmo_vol(z: ndarray, n_z_samples: int = 2048) -> jnp.ndarray

Convert (dOmega, df) elements to a comoving volume conversion factor.

Parameters:

Name Type Description Default
z ndarray

Redshift array; output shape follows input/broadcast.

required
n_z_samples int

Unused compatibility argument forwarded to dL_dth.

2048

Returns:

Name Type Description
inst_to_cosmo_vol ndarray

dV/(dOmega df) in Mpc^3 / (sr Hz).

bayeseor_jax.model.cosmology.power_spectrum.generate_k_modes_in_physical_coordinates

generate_k_modes_in_physical_coordinates(uv: Array, eta: Array, transverse_distance_mpc: float, line_of_sight_distance_mpc_per_hz: float) -> jax.Array

Convert retained instrumental Fourier modes to cosmological wavenumbers.

Parameters:

Name Type Description Default
uv Array

Transverse angular Fourier coordinates, shape (2, n_uv_mode), in inverse radians; these are model modes, not sampled baselines.

required
eta Array

Line-of-sight Fourier coordinates, shape (n_eta_mode,), in inverse Hz.

required
transverse_distance_mpc float

Transverse comoving distance D_M at the reference redshift, in Mpc.

required
line_of_sight_distance_mpc_per_hz float

Positive conversion factor |dchi/df| at that redshift, in Mpc/Hz.

required

Returns:

Name Type Description
mod_k Array

Wavenumber magnitudes in inverse Mpc, shape (n_uv_mode*n_eta_mode,), with eta varying fastest to match the cosmological operator columns.

Notes

The conversion is (k_x, k_y) = 2*pi*(u, v)/D_M and k_z = 2*pi*eta/|dchi/df|. Each Cartesian combination receives a spherical magnitude used to assign its power-spectrum prior bin.

bayeseor_jax.model.cosmology.power_spectrum.generate_k_cube_model_spherical_binning

generate_k_cube_model_spherical_binning(mod_k_vo: ndarray, ps_box_size_para_mpc: float, num_k_bins: int = 50, growth_factor: float = 1.35)

Assign each k-mode to a spherical |k| bin.

Parameters:

Name Type Description Default
mod_k_vo ndarray

Shape (n_k_modes,), flattened |k| values in Mpc^-1.

required
ps_box_size_para_mpc float

Line-of-sight box size in Mpc, used to define geometric bin edges.

required
num_k_bins int

Number of spherical bins.

50
growth_factor float

Geometric ratio between successive upper edges.

1.35

Returns:

Name Type Description
bin_id_per_k_mode ndarray

Shape (n_k_modes,), integer bin index in [0, num_k_bins) or -1 if invalid.

valid_mask ndarray

Shape (n_k_modes,), True where k-mode is inside configured bins.

bin_low, bin_high : jnp.ndarray

Shape (num_k_bins,), spherical bin edges in Mpc^-1.

counts ndarray

Shape (num_k_bins,), number of valid k-modes per bin.

Notes

With searchsorted(..., side="left") and k > bin_low, intervals are (bin_low, bin_high]. Values above the last bin_high are marked invalid.