nifits.extra
¶
Submodules¶
Package Contents¶
Classes¶
Class representation of the nifits object. |
|
This variant of the backend class offers a statistically whitened alternate |
Functions¶
|
|
|
|
|
|
|
Computes the residual of Pdet |
Attributes¶
- nifits.extra.NIFITS_EXTENSIONS¶
- nifits.extra.STATIC_EXTENSIONS = [True, True, True, True, False, False, False, False, False, True, True, False]¶
- nifits.extra.NIFITS_EXTENSIONS¶
- nifits.extra.STATIC_EXTENSIONS = [True, True, True, True, False, False, False, False, False, True, True, False]¶
- class nifits.extra.NIFITSClass¶
Bases:
object
Class representation of the nifits object.
- header: astropy.io.fits.Header¶
- oi_wavelength: OI_WAVELENGTH¶
- ni_oswavelength: NI_OSWAVELENGTH¶
- classmethod from_nifits(filename: str)¶
Create the nifits object from the HDU extension of an opened fits file.
- to_nifits(filename: str = '', static_only: bool = False, dynamic_only: bool = False, static_hash: str = '', writefile: bool = True, overwrite: bool = False)¶
Write the extension objects to a nifits file.
- Parameters:
static_only – (bool) only save the extensions corresponding to static parameters of the model (NI_CATM and NI_FOV). Default: False
dynamic_only – (bool) only save the dynamic extensions. If true, the hash of the static file should be passed as static_hash. Defaultult: False
static_hash – (str) The hash of the static file. Default: “”
- check_unit_coherence()¶
Check the coherence of the units of and prints the result
NI_IOUT, NI_KCOV, and NI_KIOUT if they exist.
Otherwise, does nothing.
- class nifits.extra.Post(nifits: nifits.io.oifits.nifits = None, module=np)[source]¶
Bases:
nifits.backend.NI_Backend
This variant of the backend class offers a statistically whitened alternate forward model with directly whitened observables by calling
w_
prefixed methods. (Ceau et al. 2019, Laugier et al. 2023)After normal construction, use
create_whitening_matrix()
to update the whitening matrix based on theNI_KCOV
data.Use
w_get_all_outs
andget_moving_outs
in the same way, but they return whitened observables. Compare it toself.nifits.ni_kiout.w_kiout
instead ofself.nifits.ni_kiout.kiout
.- create_whitening_matrix(replace: bool = False, md: types.ModuleType = np)[source]¶
Updates the whitening matrix:
- Parameters:
replace – If true, the forward model methods are replaced by the whitened ones. The old ones get a
old_
prefix.md – A numpy-like backend module.
The pile of whitening matrices is stored as
self.Ws
(one for each frame).
- whiten_signal(signal)[source]¶
Whitens a signal so that error covariance is identity in the new axis.
- Parameters:
signal – The direct signal to whiten (differential observable a.k.a kernel-null)
- Returns:
- the whitened signal ($mathbf{W}cdot mathbf{s}$)
in the new basis.
- Return type:
wout_full
- whitened_outputs(func)[source]¶
A decorator methods that gives applies statistical whitening to the output of the function. The whitening relies on self.W which is computed as by create_whitening_matrix. :param func: The function to decorate.
- Returns:
The decorated function
- Return type:
inner
- add_blackbody(temperature)[source]¶
Initializes the blackbody for a given temperature
- Parameters:
temperature – units.Quantity
- get_pfa_Te(signal=None, md=np)[source]¶
Compute the Pfa for the energy detector test.
- Parameters:
signal – The raw signal (non-whitened)
- Returns:
- pfa the false alarm probability (p-value) associated
to the given signal.
- get_pfa_Tnp(alphas, betas, signal=None, model_signal=None, md=np)[source]¶
Compute the Pfa for the Neyman-Pearson test.
- get_blackbody_native()[source]¶
- Returns:
- in units consistent with the native
units of the file $[a.sr^{-1}.m^{-2}]$ (where [a] is typically [ph/s]).
- Return type:
blackbody_spectrum
- get_blackbody_collected(alphas, betas, kernels=True, whiten=True, to_si=True)[source]¶
Obtain the output spectra of a blackbody at the given blackbody temperature
- Parameters:
alphas – ArrayLike: Relative position in rad
betas – ArrayLike: Relative position in rad
kernels – Bool (True) Whether to work in the kernel postprocessing space (False is not implemented yet)
whiten – Bool (True) whether to use whitening post-processing (False is not implemented yet)
to_si – Bool (True) convert to SI units
- get_Te()[source]¶
Computes the Te test statistic of the current file. This test statistic
is supposed to be distributed as a chi^2 under H_0. :returns: x.T.dot(x) where x is the whitened signal. :rtype: Te
- get_pdet_te(alphas, betas, solid_angle, kernels=True, pfa=0.046, whiten=True, temperature=None)[source]¶
pfa: * 1 sigma: 0.32 * 2 sigma: 0.046 * 3 sigma: 0.0027
- get_sensitivity_te(alphas, betas, kernels=True, temperature=None, pfa=0.046, pdet=0.9, distance=None, radius_unit=units.Rjup, md=np)[source]¶
from scipy.stats import ncx2 xs = np.linspace(-10, 10, 100) ys = np.linspace(1e-6, 0.999, 100) u = 1 - ncx2.cdf(xs, df=10, nc=0) v = ncx2.ppf(1 - ys, df=10, nc=0) plt.figure() plt.plot(xs, u) plt.show() plt.figure() plt.plot(ys, v) plt.plot(u, xs) plt.show()
- nifits.extra.massq2sr¶
- nifits.extra.sr2massq¶
- nifits.extra.residual_pdet_Te(lamb, xsi, rank, targ)[source]¶
Computes the residual of Pdet
Arguments:
lamb : The noncentrality parameter representing the feature
targ : The target Pdet to converge to
xsi : The location of threshold
rank : The rank of observable
Returns the Pdet difference. See Ceau et al. 2019 for more information