Spherical data cubes (ps_eor.sphcube)#
Frequency-dependent sky data in HEALPix and spherical harmonics.
This module is the spherical counterpart of ps_eor.datacube.
SphImageCube stores HEALPix maps shaped
(n_freqs, 12 * nside**2), while SphDataCube stores their complex
spherical-harmonic coefficients as (n_freqs, n_modes) with matching
(ell, m) coordinates. In a harmonic cube, the transverse spatial
coordinate used by the power-spectrum code is u = ell / (2 pi).
A Cartesian visibility cube can be reprojected to HEALPix and transformed to spherical harmonics when a large field of view makes a flat-sky treatment inappropriate:
from ps_eor import sphcube
alm_cube = sphcube.SphDataCube.from_cartcube(
cart_cube,
nside=128,
lmax=600,
)
alm_cube.filter_lm(lmin=20, lmax=500)
alm_cube.save('spherical-visibilities.h5')
The transformation can be reversed for inspection. mask_corrected=True
divides by the recorded sky window where its response is sufficiently large:
sky_cube = alm_cube.image(
mask_corrected=True,
mask_correction_threshold=.1,
)
sky_cube.plot(fmhz='med')
For multiple observations on the same harmonic grid,
SphDataCubeCombiner forms a weighted mean over their common frequency
channels. Most filter_* methods modify a spherical cube in place; copy it
first when the unfiltered cube must be retained.
- class ps_eor.sphcube.SphMetaData(metadata)[source]#
Bases:
objectObservation metadata associated with a spherical data cube.
Metadata may describe several accumulated observations. Per-observation pointing, duration, window, and weight fields are stored as lists, while the HEALPix geometry, integration time, coordinate system, and frequency width are shared.
- property nside#
HEALPix
nside.
- property int_time#
Integration time in seconds.
- property total_time#
Stored total time, or the sum of observation durations, in seconds.
- property freq_width#
Frequency-channel width in Hz.
- property win_fct#
Combined
SphWindowFunctionreconstructed from the metadata.
- static new_obs(mjd_obs, radec_obs, time_obs, int_time, nside, win_fct, fwhm, freq_width, coord_sys='ICRS', weight=1)[source]#
Create metadata for one observation.
- Parameters:
mjd_obs – Observation reference time in MJD.
radec_obs – Pointing
(RA, Dec)in degrees.time_obs – Observation duration in seconds.
int_time – Integration time in seconds.
nside – HEALPix resolution.
win_fct – Window name, or
Nonefor a unit mask.fwhm – Window full-width at half-maximum in radians.
freq_width – Frequency-channel width in Hz.
coord_sys – Astropy coordinate-system identifier.
weight – Relative observation weight.
- Returns:
Metadata containing the new observation.
- Return type:
- add_obs(mjd_obs, radec_obs, time_obs, win_fct, fwhm, weight=1)[source]#
Append one observation.
- Parameters:
mjd_obs – Observation reference time in MJD.
radec_obs – Pointing
(RA, Dec)in degrees.time_obs – Observation duration in seconds.
win_fct – Window name, or
None.fwhm – Window FWHM in radians.
weight – Relative observation weight.
- class ps_eor.sphcube.NoPrimaryBeam[source]#
Bases:
BasePrimaryBeam,NoMaskSpherical primary-beam model with unit response.
- class ps_eor.sphcube.SphWindowFunction(name, ra_dec, fwhm, weight=1, primary_beam=None)[source]#
Bases:
MaskAzimuthally symmetric sky window centred on a pointing.
- static from_meta(meta, primary_beam=None)[source]#
Reconstruct the combined window recorded in spherical metadata.
- Parameters:
meta –
SphMetaDatacontaining observation windows.primary_beam – Optional beam to include in every window.
- Returns:
Sum of the per-observation windows.
- Return type:
- class ps_eor.sphcube.SphDataCube(alm_cube, ll, mm, freqs, meta, weights=None)[source]#
Bases:
DataCubeFrequency cube of spherical-harmonic coefficients.
The data shape is
(n_freqs, n_modes). Each column is identified by the corresponding entries ofllandmm.- static from_cartcube(cube, nside, lmax, reproject_order='bilinear')[source]#
Reproject a Cartesian cube and transform it to spherical harmonics.
The Cartesian cube is imaged, reprojected onto an ICRS HEALPix grid, and transformed independently at every frequency. Pixels outside the Cartesian footprint are set to zero.
- Parameters:
cube –
CartDataCubeto transform.nside – Output HEALPix resolution.
lmax – Maximum spherical-harmonic degree.
reproject_order – Interpolation order accepted by
reproject.reproject_to_healpix().
- Returns:
Harmonic cube with observation metadata derived from the Cartesian input.
- Return type:
- new_with_data(data, weights=None, freqs=None)[source]#
Create a cube on the same harmonic grid with new data.
- Parameters:
data – Replacement array shaped
(n_freqs, n_modes).weights – Optional replacement weights.
freqs – Optional replacement frequencies in Hz.
- Returns:
The new cube.
- Return type:
- filter_m_theta_max(theta_max)[source]#
Keep azimuthal modes supported within
theta_maxin place.- Parameters:
theta_max – Maximum angular distance in radians.
- static load(filename)[source]#
Load a spherical-harmonic cube from HDF5.
- Parameters:
filename – Input HDF5 filename.
- Returns:
The restored coefficients and metadata.
- Return type:
- save(filename)[source]#
Save the spherical-harmonic cube to HDF5.
- Parameters:
filename – Destination HDF5 filename.
- plot_lm(fmhz='med', action_fct=None, ax=None, title=None, **kargs)[source]#
Plot real coefficients on the
(ell, m)plane.- Parameters:
fmhz – Frequency in MHz, or
'med'or'first'. Ignored whenaction_fctis supplied.action_fct – Optional reduction called as
action_fct(data, axis=0).ax – Matplotlib axes; a new one is created by default.
title – Optional axes title.
**kargs – Arguments passed to
matplotlib.axes.Axes.imshow().
- image(mask_corrected=False, mask_correction_threshold=0.1)[source]#
Transform the coefficients to a HEALPix image cube.
- Parameters:
mask_corrected – Divide by the recorded window where it is reliable.
mask_correction_threshold – Correct pixels above this fraction of the peak window response and set the others to zero.
- Returns:
Frequency-dependent HEALPix maps.
- Return type:
- class ps_eor.sphcube.SphImageCube(hmaps, freqs, meta)[source]#
Bases:
ImageCubeFrequency cube of HEALPix sky maps.
The data shape is
(n_freqs, 12 * nside**2).- apply_window_function(win_fct, add_to_meta=True)[source]#
Apply a sky window in place.
- Parameters:
win_fct –
SphWindowFunctionto multiply into every map.add_to_meta – Record the window as another observation in the metadata.
- ft(umin, umax)[source]#
Transform the maps to spherical harmonics over a UV range.
The transform uses
lmax = int(2 pi umax)and then retains modes whoseell / (2 pi)lies within the requested interval.- Parameters:
umin – Spatial-frequency limits in wavelengths.
umax – Spatial-frequency limits in wavelengths.
- Returns:
The selected harmonic coefficients.
- Return type:
- plot(fmhz='med', action_fct=None, dpar=None, dmer=None, title='', vmax=None, vmin=None, ax=None, auto_scale_quantiles=None, coord='CG', **kargs)[source]#
Plot one frequency map or a reduction over frequency.
- Parameters:
fmhz – Frequency in MHz, or
'med'or'first'. Ignored whenaction_fctis supplied.action_fct – Optional reduction called as
action_fct(data, axis=0).dpar – HEALPix graticule spacing.
dmer – HEALPix graticule spacing.
title – Plot title.
vmax – Explicit color limits.
vmin – Explicit color limits.
ax – Matplotlib axes; a new one is created by default.
auto_scale_quantiles – Optional
(low, high)quantiles used as color limits.coord – HEALPix coordinate conversion passed to
healpy.mollview().**kargs – Additional arguments passed to
healpy.mollview().
- class ps_eor.sphcube.SphDataCubeCombiner[source]#
Bases:
objectAccumulate weighted spherical cubes on their common frequencies.
- add(cube, weight)[source]#
Add a weighted cube to the accumulator.
Only channels common to all cubes accumulated so far are retained. Cubes are expected to share the same
(ell, m)grid.- Parameters:
cube –
SphDataCubeto accumulate.weight – Scalar weight applied to the complete observation.