Data¶
get_vis_data loads a visibility file or preprocessed vector and returns the data
vector, noise information and observation axes in the
analysis convention. The instrument enters
through its baselines, InstrumentModel, and its primary beam, Beam_Model.
See the Data guide for the supported inputs and settings.
Visibilities¶
bayeseor_jax.data.vis.get_vis_data
¶
get_vis_data(*, data_path: Path | str, inst_model: Path | str | None = None, noise_data_path: Path | str | None = None, sigma: float | None = None, noise_seed: int = 742123, calc_noise: bool = False, antenna_selection: str = 'cross', bl_cutoff: float | None = None, freq_idx_min: int | None = None, freq_min: float | None = None, freq_center: float | None = None, n_freqs_select: int | None = None, jd_idx_min: int | None = None, jd_min: float | None = None, jd_center: float | None = None, n_times_select: int | None = None, form_pi: bool = True, pi_norm: float = 1.0, pol: str = 'xx', redundant_avg: bool = False, uniform_redundancy: bool = False, n_freq: int | None = None, f0_mhz: float | None = None, df_mhz: float | None = None, n_t: int | None = None, d_t: float | None = None, save_vis: bool = False, save_model: bool = False, save_dir: Path | str = './', clobber: bool = False) -> dict[str, Any]
Load a visibility vector, its noise realisation and aligned observation metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_path
|
Path or str
|
A calibrated |
required |
inst_model
|
Path or str
|
Required for NumPy inputs. Directory containing |
None
|
noise_data_path
|
Path or str
|
Trusted NumPy noise vector in the same units and order as the data. Takes precedence over estimated noise. It is returned, not added: the input visibilities are assumed to contain noise already. |
None
|
sigma
|
float
|
Complex noise RMS in mK sr before redundancy scaling. Required when neither supplied nor estimated noise is available; the input is then treated as noiseless and a synthetic realisation is added. |
None
|
noise_seed
|
int
|
Seed passed to |
742123
|
calc_noise
|
bool
|
Request the legacy even/odd time-difference noise estimate for raw inputs. Does not estimate noise from preprocessed NumPy inputs. |
False
|
antenna_selection
|
str
|
pyuvdata antenna-selection string for raw inputs; default |
'cross'
|
bl_cutoff
|
float or Quantity
|
Raw-input cutoff on sqrt(u2 + v2), in metres if unitless. |
None
|
freq_idx_min
|
int
|
First raw frequency-channel index, starting from zero. |
None
|
freq_min
|
float or Quantity
|
Raw-input frequency lower bound or window centre, in Hz if unitless. |
None
|
freq_center
|
float or Quantity
|
Raw-input frequency lower bound or window centre, in Hz if unitless. |
None
|
n_freqs_select
|
int
|
Raw channel-window width. Supply a starting index, lower bound or centre to activate selection; a centre requires this width. |
None
|
jd_idx_min
|
int
|
First raw integration index, starting from zero. |
None
|
jd_min
|
float
|
Time-window lower bound or centre as Julian date. For NumPy inputs,
one is required to construct the time axis; |
None
|
jd_center
|
float
|
Time-window lower bound or centre as Julian date. For NumPy inputs,
one is required to construct the time axis; |
None
|
n_times_select
|
int
|
Raw time-window width, paired with an index, lower bound or centre. |
None
|
form_pi
|
bool
|
Form pseudo-Stokes I from raw XX and YY, or retain existing pI.
Defaults to True; otherwise select |
True
|
pi_norm
|
float
|
Scale in |
1.0
|
pol
|
str
|
Raw polarisation selected when |
'xx'
|
redundant_avg
|
bool
|
Average redundant raw baselines; defaults to False. |
False
|
uniform_redundancy
|
bool
|
Use unit redundancy weights even after averaging; defaults to False. |
False
|
n_freq
|
(int, float, float)
|
Required NumPy frequency-axis length, first frequency and spacing in
MHz. For a single raw channel, |
None
|
f0_mhz
|
(int, float, float)
|
Required NumPy frequency-axis length, first frequency and spacing in
MHz. For a single raw channel, |
None
|
df_mhz
|
(int, float, float)
|
Required NumPy frequency-axis length, first frequency and spacing in
MHz. For a single raw channel, |
None
|
n_t
|
(int, float)
|
Required NumPy time-axis length and cadence in seconds. |
None
|
d_t
|
(int, float)
|
Required NumPy time-axis length and cadence in seconds. |
None
|
save_vis
|
bool
|
Save raw preprocessing products: visibility/noise vectors and/or baseline, redundancy and antenna-pair arrays. Defaults to False. These hooks do not save subsequently generated synthetic noise. |
False
|
save_model
|
bool
|
Save raw preprocessing products: visibility/noise vectors and/or baseline, redundancy and antenna-pair arrays. Defaults to False. These hooks do not save subsequently generated synthetic noise. |
False
|
save_dir
|
Path or str
|
Directory for requested raw preprocessing products; defaults to './'. |
'./'
|
clobber
|
bool
|
Allow replacement of those saved products; defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Notes
Raw selection and conversion are delegated to preprocess_uvdata.
NumPy inputs bypass these steps and must already match the model's row
ordering and Hermitian augmentation; stored metadata are not used to infer
the axes. NumPy dictionary inputs are unpickled: load trusted files only.
This loader does not turn partial flags into per-visibility noise weights.
bayeseor_jax.data.vis.preprocess_uvdata
¶
preprocess_uvdata(filepath, antenna_selection='cross', bl_cutoff=None, freq_idx_min=None, freq_min=None, freq_center=None, n_freqs_select=None, jd_idx_min=None, jd_min=None, jd_center=None, n_times_select=None, form_pi=True, pi_norm=1.0, pol='xx', redundant_avg=False, uniform_redundancy=False, calc_noise=False, return_uvd=False, save_vis=False, save_model=False, save_dir='./', clobber=False)
Read visibility data from disk and form a one-dimensional data vector.
This function loads a pyuvdata-compatible file containing visibilities
for a set of baselines (Nbls), times (Ntimes), and frequencies (Nfreqs)
and forms a one-dimensional data vector with shape
(2*Nbls * Ntimes * Nfreqs,) and an accompanying instrument model of
baseline coordinates in metres and a redundancy model (when averaging
redundant baselines). The factor of two comes from appending conjugate
visibilities at reversed baselines (u, v, w) -> (-u, -v, -w). These are
redundant copies of the measurements, not independent observations.
Time is the slowest axis, frequency next, and baseline fastest.
Optionally, if calc_noise is True, a noise vector is also produced.
The noise is estimated by differencing visibilities at even and odd time
steps per baseline and frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path or str
|
Path read by pyuvdata (normally UVH5, UVFITS or a Measurement Set).
Unlike |
required |
antenna_selection
|
str
|
Antenna downselect string. This determines what baselines to keep in
the data vector. Please see |
'cross'
|
bl_cutoff
|
Quantity or float
|
Cutoff on sqrt(u2 + v2), in metres if not a Quantity. Defaults to None (keep all baselines). |
None
|
freq_idx_min
|
int
|
Minimum frequency channel index to keep in the data vector. Defaults to None (keep all frequencies). |
None
|
freq_min
|
Quantity or float
|
Minimum frequency to keep in the data vector in Hertz if not a
Quantity. All frequencies greater than or equal to |
None
|
freq_center
|
Quantity or float
|
Central frequency, in Hertz if not a Quantity, around which
|
None
|
n_freqs_select
|
int
|
Number of frequencies to keep starting from |
None
|
jd_idx_min
|
int
|
Minimum time index to keep in the data vector. Defaults to None (keep all times). |
None
|
jd_min
|
Time or float
|
Minimum time to keep in the data vector as a Julian date if not a Time. Defaults to None (keep all times). |
None
|
jd_center
|
Time or float
|
Central time, as a Julian date if not a Time, around which
|
None
|
n_times_select
|
int
|
Number of times to keep starting from |
None
|
form_pi
|
bool
|
Form pseudo-Stokes I visibilities. Otherwise, use the polarization
specified by |
True
|
pi_norm
|
float
|
Normalization, |
1.0
|
pol
|
str
|
Case-insensitive polarization string. Used only if |
'xx'
|
redundant_avg
|
bool
|
Redundantly average the data. Defaults to False. |
False
|
uniform_redundancy
|
bool
|
Force the redundancy model to be uniform. Defaults to False. |
False
|
calc_noise
|
bool
|
Calculate a noise estimate from the visibilities via differencing adjacent times per baseline and frequency. Defaults to False. |
False
|
return_uvd
|
bool
|
Return the preprocessed UVData object. Defaults to False. |
False
|
save_vis
|
bool
|
Write visibility vector to disk in |
False
|
save_model
|
bool
|
Write instrument model (antenna pairs, (u, v, w) sampling, and
redundancy model) to disk in |
False
|
save_dir
|
Path or str
|
Output directory if |
'./'
|
clobber
|
bool
|
Clobber files on disk if they exist. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
vis |
ndarray
|
Complex visibility vector in mK sr, shape (2NblsNfreqs*Ntimes,). |
antpairs |
list of tuple
|
List of antenna pair tuples corresponding to the (u, v, w) coordinates
in |
uvws |
ndarray
|
Baseline coordinates in metres, shape (Ntimes, 2*Nbls, 3). The
ordering of the Nbls axis matches the ordering of the baselines in
|
redundancy |
ndarray
|
Redundancy model containing the number of baselines averaged within a redundant baseline group, shape (Ntimes, 2*Nbls, 1). |
noise |
ndarray or None
|
Estimated noise vector with shape (2NblsNfreqs*Ntimes,). Returned
as None when |
uvd |
UVData or None
|
Preprocessed UVData object. Returned only if |
Notes
This path assumes a common set of baselines at every selected time and
unprojected drift-scan geometry. Fully flagged baselines are removed, but
individual flagged samples are not masked or assigned zero weight here.
The returned UVData data array has been converted to mK sr; its original
vis_units label is not updated. Use the returned vector for inference.
Instrument¶
bayeseor_jax.model.instrument.baselines.InstrumentModel
¶
Load a BayesEoR instrument model.
The instrument model consists of:
- (u, v, w) array with shape (nt, nbls, 3) where nt is the number of
times and nbls is the number of baselines
- Number of redundantly-averaged baselines per (u, v, w) with shape
(nt, nbls) or (nt, nbls, 1)
- (optional) a list of antenna pair tuples with length nbls matching the
order of baselines in the (u, v, w) array
This class first looks for an instrument_model.npy pickled dictionary
in inst_model_dir. If not found, it then loads the individual numpy
arrays specified by uvw_file, red_file, and antpairs_file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inst_model_dir
|
Path or str
|
Path to the instrument model directory. |
required |
uvw_file
|
str
|
File containing instrumentally sampled (u, v, w) coords. Defaults to
|
'uvw_model.npy'
|
red_file
|
str
|
File containing baseline redundancy info. Defaults to
|
'redundancy_model.npy'
|
antpairs_file
|
str
|
File containing baseline antenna pairs for each sampled (u, v, w).
Defaults to |
'antpairs.npy'
|
Attributes:
| Name | Type | Description |
|---|---|---|
uvw_array_m |
Array
|
Sampled (u, v, w) coordinates in meters with shape |
bl_red_array |
Array
|
Number of redundantly-averaged baselines per (u, v, w) with shape
|
antpairs |
array - like or None
|
Baseline antenna pair tuples if |
n_t
property
¶
n_t: int
Return the number of time integrations in the loaded baseline array.
Returns:
| Type | Description |
|---|---|
int
|
Length of the time axis of |
n_bls
property
¶
n_bls: int
Return the number of sampled baselines per integration.
Returns:
| Type | Description |
|---|---|
int
|
Length of the baseline axis of |
__init__
¶
__init__(inst_model_dir: Path | str, uvw_file: str = 'uvw_model.npy', red_file: str = 'redundancy_model.npy', antpairs_file: str = 'antpairs.npy') -> None
Load sampled baselines and redundancy weights from saved NumPy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inst_model_dir
|
Path or str
|
Directory containing an |
required |
uvw_file
|
str
|
Coordinate file relative to the directory; defaults to
|
'uvw_model.npy'
|
red_file
|
str
|
Redundancy file; defaults to |
'redundancy_model.npy'
|
antpairs_file
|
str
|
Optional antenna-pair file; defaults to |
'antpairs.npy'
|
Returns:
| Type | Description |
|---|---|
None
|
Populates the instance with validated baseline arrays. |
Notes
A combined dictionary takes precedence over separate files. The time and baseline axes are preserved so visibility rows, noise weights, and forward-operator rows refer to the same measurements.
bayeseor_jax.model.instrument.beam.Beam_Model
¶
Supply the beam weights multiplying image-domain sky brightness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
beam_type
|
str
|
Supported beam types are:
|
None
|
peak_amp
|
float
|
Peak power-response amplitude for Gaussian-based profiles. Defaults to 1.0; the uniform and untapered Airy profiles have unit peak. |
1.0
|
fwhm_deg
|
float
|
Full width at half maximum in degrees. Gaussian-based profiles use
this width when supplied, otherwise deriving a width from |
None
|
diam
|
float
|
Antenna (aperture) diameter in meters. Used if |
None
|
cosfreq
|
float
|
Cosine frequency in inverse radians. Used if |
None
|
tanh_freq
|
float
|
Exponential frequency (rate parameter) in inverse radians. Used if
|
None
|
tanh_sl_red
|
float
|
Fractional suppression of the Airy power response far from zenith. Used if
|
None
|
pol
|
str
|
Polarization string. Used only if |
'xx'
|
freq_interp_kind
|
str
|
Frequency interpolation kind from scipy.interpolate.interp1d. Defaults to 'cubic'. |
'cubic'
|
Notes
Analytic profiles or an interpolated UVBeam power model are evaluated at
each pixel's topocentric direction and observing frequency. get_beam_vals
returns the diagonal entries of the primary-beam operator; it does not
allocate a dense diagonal matrix.
__init__
¶
__init__(beam_type: str | None = None, peak_amp: float = 1.0, fwhm_deg: float | None = None, diam: float | None = None, cosfreq: float | None = None, tanh_freq: float | None = None, tanh_sl_red: float | None = None, pol: str = 'xx', freq_interp_kind: str = 'cubic') -> None
Configure an analytic profile or load the selected UVBeam polarisation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
beam_type
|
str or None
|
Analytic beam name or beamfits file path. None selects a uniform beam. |
None
|
peak_amp
|
float
|
Peak power gain for Gaussian-based beam profiles; defaults to 1. |
1.0
|
fwhm_deg
|
float or None
|
Configured beam full width at half maximum in degrees, when used instead of an aperture-derived width. |
None
|
diam
|
float or None
|
Physical or effective aperture diameter in metres for Airy or Gaussian beam profiles. |
None
|
cosfreq
|
float or None
|
Angular modulation frequency in inverse radians for the gausscosine profile. |
None
|
tanh_freq
|
float or None
|
Angular taper rate in inverse radians for the tanhairy profile. |
None
|
tanh_sl_red
|
float or None
|
Fractional far-off-axis power suppression for the tanhairy profile. |
None
|
pol
|
str
|
Polarisation selected from a file-backed beam, for example xx or pI. |
'xx'
|
freq_interp_kind
|
str
|
Frequency interpolation method used by UVBeam; defaults to cubic. |
'cubic'
|
Returns:
| Type | Description |
|---|---|
None
|
Initialises the instance without returning a value. |
Notes
Pixel gains are evaluated later by get_beam_vals. File-backed
electric-field beams are converted to the requested power or
pseudo-Stokes response before interpolation.
get_beam_vals
¶
get_beam_vals(coords: ndarray, freqs: ndarray) -> jnp.ndarray
Weight each HEALPix sky direction by the beam at every frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
Shape (n_t, 2, n_pix) containing [az, za] in radians. |
required |
freqs
|
ndarray
|
Shape (n_freq,) in Hz. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
beam_vals |
ndarray
|
Dimensionless power response, shape |
Notes
For each integration, use the pixel's azimuth and zenith angle to
evaluate P(nu, t, p). Set the response to zero where the zenith
angle is at least pi/2, including pixels that cross the horizon
during the observation.
aperture_width_uv
¶
aperture_width_uv(freqs_hz: ndarray, gaussian_nsigma: float = 5.0) -> float
Estimate the transverse Fourier extent added by primary-beam weighting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freqs_hz
|
array - like
|
One-dimensional observing-frequency array in Hz. |
required |
gaussian_nsigma
|
float
|
Number of Gaussian standard deviations used to define the beam support in uv space. Defaults to 5. |
5.0
|
Returns:
| Type | Description |
|---|---|
float
|
Approximate beam-support width in uv units. Returns |
Notes
This quantity supplies the buffer around measured baselines when
choosing the cosmological uv grid. Airy-like beams contribute an
aperture width equal to the effective dish diameter in wavelengths,
while Gaussian-like beams contribute Nsigma / (2πσ) using the
broadest angular width at the lowest observing frequency.
Simulated noise¶
bayeseor_jax.data.noise.generate_gaussian_noise
¶
generate_gaussian_noise(sigma: float, s: ndarray, n_freq: int, n_t: int, uvw_array_m: ndarray, bl_red_array: ndarray, random_seed: int | None = None) -> tuple[jnp.ndarray, jnp.ndarray, dict[int, int]]
Generate and add Hermitian complex Gaussian noise to a noiseless vector.
The random draw intentionally follows the old BayesEoR NumPy
implementation so the realized noise matches the original pipeline for the
same sigma and random_seed:
- real part seeded with
random_seed - imaginary part seeded with
random_seed * 123(123 for a seed of 0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sigma
|
float
|
RMS amplitude for the complex noise. Real and imaginary components are
drawn with standard deviation |
required |
s
|
Array
|
Noiseless visibility vector with shape |
required |
n_freq
|
int
|
Number of frequency channels. |
required |
n_t
|
int
|
Number of time integrations. |
required |
uvw_array_m
|
Array
|
UVW coordinates in meters, shape |
required |
bl_red_array
|
Array
|
Baseline redundancy array with shape |
required |
random_seed
|
int or None
|
Seed for deterministic noise generation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
d |
Array
|
Noisy visibility vector |
complex_noise_hermitian |
Array
|
Generated Hermitian noise vector with the same shape as |
bl_conjugate_pairs_map |
dict[int, int]
|
Map from baseline index to its conjugate baseline index. |