fmflow.models package#

Module contents#

class AstroLines(function='cutoff', despiking=True, snr_threshold=10, deconvolution_width=3, subtraction_gain=0.5, *, convergence=0.001, n_maxiters=10000, logger=None)[source]#

Bases: BaseModel

fit(freq, spec, noise, freqlim=None)[source]#
class AtmosLines(snr_threshold=10, ch_tolerance=5, *, logger=None)[source]#

Bases: BaseModel

amconfig = 'f {fmin} GHz {fmax} GHz {fstep} GHz\noutput f GHz tau Tb K\n\nza 0 deg\ntol 0\nNscale h2o 0\nT0 2.7 K\n\nlayer\nPbase {Pbase} mbar\nTbase {Tbase} K\ncolumn o3 vmr {O3col}\n'#
amfreqs = []#
amlayers = [{'Pbase': '0.1', 'Tbase': '221.1', 'O3col': '1.74e-06'}, {'Pbase': '0.3', 'Tbase': '243.3', 'O3col': '1.64e-06'}, {'Pbase': '0.4', 'Tbase': '249.4', 'O3col': '1.62e-06'}, {'Pbase': '0.5', 'Tbase': '254.9', 'O3col': '1.81e-06'}, {'Pbase': '0.7', 'Tbase': '262.8', 'O3col': '2.12e-06'}, {'Pbase': '1', 'Tbase': '265.8', 'O3col': '2.66e-06'}, {'Pbase': '2', 'Tbase': '256.4', 'O3col': '3.99e-06'}, {'Pbase': '3', 'Tbase': '248.9', 'O3col': '5.83e-06'}, {'Pbase': '4', 'Tbase': '244.3', 'O3col': '7.19e-06'}, {'Pbase': '5', 'Tbase': '240.5', 'O3col': '8.00e-06'}, {'Pbase': '7', 'Tbase': '234.8', 'O3col': '8.51e-06'}, {'Pbase': '10', 'Tbase': '230.0', 'O3col': '8.71e-06'}, {'Pbase': '20', 'Tbase': '221.7', 'O3col': '7.69e-06'}, {'Pbase': '30', 'Tbase': '216.5', 'O3col': '5.52e-06'}, {'Pbase': '40', 'Tbase': '212.4', 'O3col': '3.53e-06'}, {'Pbase': '50', 'Tbase': '208.9', 'O3col': '2.20e-06'}, {'Pbase': '70', 'Tbase': '200.4', 'O3col': '1.16e-06'}, {'Pbase': '100', 'Tbase': '197.8', 'O3col': '3.92e-07'}, {'Pbase': '150', 'Tbase': '207.4', 'O3col': '1.14e-07'}, {'Pbase': '200', 'Tbase': '219.4', 'O3col': '6.18e-08'}, {'Pbase': '250', 'Tbase': '230.4', 'O3col': '5.02e-08'}, {'Pbase': '300', 'Tbase': '239.9', 'O3col': '4.70e-08'}, {'Pbase': '350', 'Tbase': '247.9', 'O3col': '4.58e-08'}, {'Pbase': '400', 'Tbase': '254.9', 'O3col': '4.52e-08'}, {'Pbase': '450', 'Tbase': '261.2', 'O3col': '4.47e-08'}, {'Pbase': '500', 'Tbase': '266.8', 'O3col': '4.39e-08'}, {'Pbase': '550', 'Tbase': '271.8', 'O3col': '4.30e-08'}, {'Pbase': '554', 'Tbase': '272.2', 'O3col': '4.24e-08'}]#
amtaus = []#
amtbs = []#
fit(freq, spec, noise, vrad=0.0, freqlim=None)[source]#
generate(freq, vrad=0.0)[source]#
class BaseModel(params, logger=None)[source]#

Bases: object

class EMPCA(n_components=50, ch_smooth=None, optimize_n=True, initialize='random', random_seed=None, *, convergence=0.001, n_maxiters=300, logger=None)[source]#

Bases: BaseModel

fit_transform(X, W=None)[source]#
FMGain#

alias of ONGain

class ONGain(window_length=51, polyorder=3, *, logger=None)[source]#

Bases: BaseModel

fit(Pon)[source]#
static to_ilogG(logG)[source]#
static to_logG(ilogG)[source]#
class PCA(n_components=50, optimize_n=True, *, logger=None)[source]#

Bases: BaseModel

fit_transform(X)[source]#
astrolines(array, weights=None, reverse=False, mode='spectrum', freqlim=None, function='cutoff', despiking=True, snr_threshold=10, deconvolution_width=3, subtraction_gain=0.5, convergence=0.001, n_maxiters=10000, **kwargs)[source]#

Model astrolines by cutoff-and-fitting method.

Parameters:
  • array (xarray.DataArray) –

  • weights (xarray.DataArray, optional) –

  • reverse (bool, optional) –

  • mode (str, optional) –

  • freqlim (list of float, optional) –

  • function (str, optional) –

  • despiking (bool, optional) –

  • snr_threshold (float, optional) –

  • deconvolution_width (float, optional) –

  • subtraction_gain (float, optional) –

  • convergence (float, optional) –

  • n_maxiters (int, optional) –

Return type:

model (xarray.DataArray)

atmoslines(array, weights=None, reverse=False, mode='spectrum', freqlim=None, snr_threshold=10, ch_tolerance=5, **kwargs)[source]#
computeam(array, reverse=False)[source]#
decomposition(array, n_components=None, decomposer='TruncatedSVD', centering=True, **kwargs)[source]#

Reconstruct an array from decomposed one with a scikit-learn decomposer.

Parameters:
  • array (xarray.DataArray) – An input array to be decomposed.

  • n_components (int) – A number of components to keep.

  • decomposer (str) – A name of algorithm provided by sklearn.decomposition.

  • centering (bool) – If True, mean vector along time axis is subtracted from array before decomposition and then added to the reconstructed one.

  • kwargs (dict) – Parameters for the spacified algorithm such as n_components and for the timechunk calculation such as timechunk, n_processes. See fmflow.timechunk for more detail.

Returns:

An output reconstructed array.

Return type:

array (xarray.DataArray)

Example

To reconstruct an array from top two principal components:

>>> result = fm.model.reducedim(array, 'PCA', n_components=2)
empca(array, weights=None, n_components=50, ch_smooth=None, optimize_n=True, initialize='random', random_seed=None, centering=True, convergence=0.001, n_maxiters=300, **kwargs)[source]#

Reconstruct an array from decomposed one with EMPCA.

Parameters:
  • array (xarray.DataArray) – An input array to be decomposed.

  • weights (xarray.DataArray) – A weight array. The shape must be same as array.

  • n_components (int) – A number of components to keep.

  • ch_smooth (int) – A length of the filter window for smoothing eigenvectors. It must be a positive odd integer.

  • optimize_n (bool) – If True, n_components used for reconstruction is optimized by an exponential fitting of eigen values of EMPCA.

  • initialize (string) – A method of initializing eigenvectors. Options are random (random orthogonal matrix) and svd (orthogonal matrix from singular value decomposition).

  • random_seed (int) – random seed values used for the initial state.

  • centering (bool) – If True, mean vector along time axis is subtracted from array before computing EMPCA and then added to the reconstructed one.

  • convergence (float) – A convergence threshold. See fmflow.utils.Convergence for more detail.

  • n_maxiters (int) – A number of maximum iterations of the EM step.

  • kwargs (dict) – Parameters for the timechunk calculation such as timechunk, n_processes. See fmflow.timechunk for more detail.

Returns:

An output reconstructed array.

Return type:

array (xarray.DataArray)

fmgain(Pon, window_length=51, polyorder=3)#
ongain(Pon, window_length=51, polyorder=3)[source]#
pca(array, n_components=50, optimize_n=True, centering=True)[source]#

Reconstruct an array from decomposed one with PCA.

Parameters:
  • array (xarray.DataArray) – An input array to be decomposed.

  • n_components (int) – A number of components to keep.

  • optimize_n (bool) – If True, n_components used for reconstruction is optimized by an exponential fitting of eigen values of PCA.

  • centering (bool) – If True, mean vector along time axis is subtracted from array before computing PCA and then added to the reconstructed one.

  • kwargs (dict) – Parameters for the timechunk calculation such as timechunk, n_processes. See fmflow.timechunk for more detail.

Returns:

An output reconstructed array.

Return type:

array (xarray.DataArray)