Foreground fitting (ps_eor.fgfit)#
Classical foreground fitting and subtraction methods.
All fitters implement the same small interface: call run(data_cube,
noise_cube) and receive a FitterResult containing the foreground
model in FitterResult.fit and the residual data in
FitterResult.sub. Both outputs retain the input cube geometry, so the
residual can be passed directly to flagging or power-spectrum estimation.
A common deterministic fit models each visibility with a smooth function of frequency. The noise cube supplies the per-frequency noise scale used by the fit:
from ps_eor import fgfit
fitter = fgfit.PolyForegroundFit(
deg=3,
fit_type='power_poly',
)
result = fitter.run(data_cube, noise_cube)
foreground = result.fit
residual = result.sub
Valid polynomial families are 'poly', 'bernstein', 'power_poly',
and 'power_bernstein'. The power variants are often useful for smooth
foreground spectra.
For a component-based separation, PcaForegroundFit fits the real and
imaginary data independently and also exposes its component representation:
result = fgfit.PcaForegroundFit(n_cmpt=3).run(data_cube, noise_cube)
first_component = result.inverse_transform(0)
These fitters provide inexpensive deterministic baselines. Probabilistic
foreground separation and posterior sampling are available through
ps_eor.ml_gpr.
- class ps_eor.fgfit.FitterResult(cube_fit, cube_sub)[source]#
Bases:
objectForeground model and residual cubes.
- fit#
Fitted foreground model.
- sub#
Input data minus the model.
- class ps_eor.fgfit.MixForegroundResult(cube_fit, cube_sub, cube_mix, inv_trans)[source]#
Bases:
FitterResultA fitted model with its component mixing representation.
- inverse_transform(mode)[source]#
Reconstruct the sky from the mixing model.
- Parameters:
mode – component index to reconstruct alone, or
Nonefor all.- Returns:
the reconstructed cube.
- Return type:
- class ps_eor.fgfit.AbstractForegroundFitter[source]#
Bases:
objectInterface implemented by foreground fitters.
- run(data_cube, data_cube_noise)[source]#
Fit the foregrounds in
data_cubeand separate them from the data.- Parameters:
data_cube – the data to fit (a
CartDataCube).data_cube_noise – a noise cube of the same geometry, used to weight the fit and set thresholds.
- Returns:
the foreground model (
.fit) and residual (.sub).- Return type:
- class ps_eor.fgfit.NoAction[source]#
Bases:
AbstractForegroundFitterA no-op fitter: a zero model, leaving the data untouched.
- class ps_eor.fgfit.GmcaForegroundFit(n_cmpt, mints=0, do_wave_transform=False, do_poly_fit=0)[source]#
Bases:
AbstractForegroundFitterForeground separation with Generalized Morphological Component Analysis.
- run(data_cube, data_cube_noise)[source]#
Separate foregrounds with GMCA (see
AbstractForegroundFitter.run()).- Returns:
the GMCA model (
.fit) and residual (.sub).- Return type:
- class ps_eor.fgfit.PcaForegroundFit(n_cmpt)[source]#
Bases:
AbstractForegroundFitterForeground separation using independent PCA fits to real and imaginary data.
- run(data_cube, data_cube_noise)[source]#
Separate foregrounds with PCA (see
AbstractForegroundFitter.run()).- Returns:
the model (
.fit), residual (.sub) and the component mixing cube (.mix/MixForegroundResult.get_component()).- Return type:
- class ps_eor.fgfit.PolyForegroundFit(deg, fit_type)[source]#
Bases:
AbstractForegroundFitterFit a smooth spectral model independently to each visibility.
- run(data_cube, data_cube_noise)[source]#
Fit a smooth spectral model per visibility (see
AbstractForegroundFitter.run()).- Returns:
the smooth model (
.fit) and residual (.sub).- Return type: