BARNACLE’s library

Library of the glint_fitting_gpu6.py.

glint_fitting_functions6.binning(arr, binning, axis=0, avg=False)

Bin elements together

Parameters:
arr: nd-array

Array containing data to bin

binning: int

Number of frames to bin

axis: int

axis along which the frames are binned

avg: bool

If True, the method returns the average of the binned frame. Otherwise, return its sum.

Attributes:

Change the attributes

data: ndarray

datacube

glint_fitting_functions6.computeCdf(absc, data, mode, normed)

Compute the empirical cumulative density function (CDF) on GPU with CUDA.

Parameters:
absc: array

Abscissa of the CDF.

data: array

Data used to create the CDF.

mode: string

If ccdf, the survival function (complementary of the CDF) is calculated instead.

normed: bool

If True, the CDF is normed so that the maximum is equal to 1.

Returns:

cdf: CDF of data.

glint_fitting_functions6.computeCdfCpu(rv, x_axis, normed=True)

Compute the empirical cumulative density function (CDF) on CPU.

Parameters:
rv: array

data used to compute the CDF.

x_axis: array

Abscissa of the CDF.

normed: bool

If True, the CDF is normed so that the maximum is equal to 1.

Returns:
cdf: array

CDF of the data.

mask: array

Indexes of cumulated values.

glint_fitting_functions6.computeCdfCupy(rv, x_axis)

Compute the empirical cumulative density function (CDF) on GPU with cupy.

Parameters:
rv: array

Data used to compute the CDF.

x_axis: array

Abscissa of the CDF.

Returns:
cdf: array

CDF of data.

glint_fitting_functions6.computeHanot(na, IA, IB, wavelength, opd, phase_bias, dphase_bias, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch, switch_invert_null)

Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the one used in Hanot et al. (2011)(https://ui.adsabs.harvard.edu/abs/2011ApJ…729..110H/abstract).

Parameters:
na: float

Astrophysical null depth.

IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

phase_bias: float

Achromatic phase offset in radian.

dphase_bias: float

Achromatic phase offset complement in radian (originally supposed to be fitted but now set to 0).

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

Returns:
null: array

Synthetic sequence of null dephts.

Iminus: array

Synthetic sequence of flux in the null output.

Iplus: array

Synthetic sequence of flux in the antinull output.

glint_fitting_functions6.computeNullDepth(na, IA, IB, wavelength, opd, phase_bias, dphase_bias, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch, switch_invert_null)

Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the ratio of the null over the antinull fluxes.

Parameters:
na: float

Astrophysical null depth.

IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

phase_bias: float

Achromatic phase offset in radian.

dphase_bias: float

Achromatic phase offset complement in radian (originally supposed to be fitted but now set to 0).

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

Returns:
null: array

Synthetic sequence of null dephts.

Iminus: array

Synthetic sequence of flux in the null output.

Iplus: array

Synthetic sequence of flux in the antinull output.

glint_fitting_functions6.computeNullDepth2(na, IA, IB, wavelength, opd, phase_bias, dphase_bias, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch, switch_invert_null, sig_opd)

DISCARDED

Compute the null depth from generated random values of photometries, detector noise and OPD. The interferometric term is weighted by the loss of coherence expressed as the exponential form \(e^{-(2\pi/\lambda \sigma_{OPD})^2 / 2}\).

Parameters:
na: float

Astrophysical null depth.

IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

sig_opd: float

Standard deviation of the fluctuations of OPD.

Returns:
null: array

Synthetic sequence of null dephts.

Iminus: array

Synthetic sequence of flux in the null output.

Iplus: array

Synthetic sequence of flux in the antinull output.

glint_fitting_functions6.computeNullDepthCos(IA, IB, wavelength, offset_opd, dopd, phase_bias, dphase_bias, na, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch)

Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the ratio of the null over the antinull fluxes. The interferometric term uses a cosine and not a sine function.

Parameters:
na: float

Astrophysical null depth.

IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

phase_bias: float

Achromatic phase offset in radian.

dphase_bias: float

Achromatic phase offset complement in radian (originally supposed to be fitted but now set to 0).

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

Returns:
null: array

Synthetic sequence of null dephts.

glint_fitting_functions6.computeNullDepthLinear(na, IA, IB, wavelength, opd, phase_bias, dphase_bias, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch, switch_invert_null)

Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the linear expression \(N = N_a + N_{instr}\).

Parameters:
na: float

Astrophysical null depth.

IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

phase_bias: float

Achromatic phase offset in radian.

dphase_bias: float

Achromatic phase offset complement in radian (originally supposed to be fitted but now set to 0).

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

Returns:
null: array

Synthetic sequence of null dephts.

Iminus: array

Synthetic sequence of flux in the null output.

Iplus: array

Synthetic sequence of flux in the antinull output.

glint_fitting_functions6.computeNullDepthLinearCos(na, IA, IB, wavelength, opd, phase_bias, dphase_bias, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch)

Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the linear expression \(N = N_a + N_{instr}\). The interferometric term uses a cosine and not a sine function.

Parameters:
na: float

Astrophysical null depth.

IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

phase_bias: float

Achromatic phase offset in radian.

dphase_bias: float

Achromatic phase offset complement in radian (originally supposed to be fitted but now set to 0).

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

Returns:
null: array

Synthetic sequence of null dephts.

Iminus: array

Synthetic sequence of flux in the null output.

Iplus: array

Synthetic sequence of flux in the antinull output.

glint_fitting_functions6.computeNullDepthNoAntinull(IA, IB, wavelength, opd, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch, switch_invert_null)

Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the ratio of the null over the antinull fluxes. The antinull flux is considered as a pure constructive fringe.

Parameters:
IA: array

Values of intensity of beam A in the fringe pattern.

IB: array

Values of intensity of beam B in the fringe pattern.

wavelength : float

Wavelength of the fringe pattern.

opd: array

Value of OPD in nm.

dark_null: array

Synthetic values of detector noise in the null output.

dark_antinull: array

Synthetic values of detector noise in the antinull output.

zeta_minus_A: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_minus_B: float

Value of the zeta coefficient between null and photometric outputs for beam B.

zeta_plus_A: float

Value of the zeta coefficient between antinull and photometric outputs for beam A.

zeta_plus_B: float

Value of the zeta coefficient between antinull and photometric outputs for beam B.

spec_chan_width: float

Width of a spectral channel in nm.

oversampling_switch: bool

If True, the spectral channel is oversampled and averaged to take into account the loss of temporal coherence.

switch_invert_null: bool

If True, the null and antinull sequences are swapped because they are swapped on real data.

Returns:
Iminus: array

Synthetic sequence of flux in the null output.

Iplus: array

Synthetic sequence of flux in the antinull output.

glint_fitting_functions6.curvefit(func, xdata, ydata, p0=None, sigma=None, bounds=(None, None), diff_step=None, x_scale=1)

Adaptation from the Scipy wrapper curve_fit. The Scipy wrapper curve_fit does not give all the outputs of the least_squares function but gives the covariance matrix (not given by the latter function). So I create a new wrapper giving both. I just copy/paste the code source of the official wrapper (https://github.com/scipy/scipy/blob/v1.5.4/scipy/optimize/minpack.py#L532-L834) and create new outputs for getting the information I need. The algorithm is Trust-Reflective-Region.

For exact documentation of the arguments diff_step and x_scale, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html#scipy.optimize.least_squares.

Parameters:

func: function to fit on data.

xdata : array.

The independent variable where the data is measured. Should usually be an M-length sequence or an (k,M)-shaped array for functions with k predictors, but can actually be any object.

ydata: array

The dependent data, a length M array - nominally f(xdata, ...).

p0: list, optional

Initial guess for the parameters (length N). If None, then the initial values will all be 1 (if the number of parameters for the function can be determined using introspection, otherwise a The default is None.

sigma: None or M-length sequence, optional.

Determines the uncertainty in ydata. If we define residuals as r = ydata - f(xdata, *popt). The default is None.

bounds: 2-tuple of array_like, optional

Lower and upper bounds on parameters. Defaults to no bounds. Each element of the tuple must be either an array with the length equal to the number of parameters, or a scalar (in which case the bound is taken to be the same for all parameters). Use np.inf with an appropriate sign to disable bounds on all or some parameters. The default is (None, None).

diff_step: None or scalar or array_like, optional

Determines the relative step size for the finite difference approximation of the Jacobian. The actual step is computed as x * diff_step. If None (default), then diff_step is taken to be a conventional “optimal” power of machine epsilon for the finite difference scheme used William H. Press et. al., “Numerical Recipes. The Art of Scientific Computing. 3rd edition”, Sec. 5.7.. The default is None.

x_scale: array_like or scalar, optional

Characteristic scale of each variable. Setting x_scale is equivalent to reformulating the problem in scaled variables xs = x / x_scale. An alternative view is that the size of a trust region along jth dimension is proportional to x_scale[j]. Improved convergence may be achieved by setting x_scale such that a step of a given size along any of the scaled variables has a similar effect on the cost function. If set to ‘jac’, the scale is iteratively updated using the inverse norms of the columns of the Jacobian matrix (as described in J. J. More, “The Levenberg-Marquardt Algorithm: Implementation and Theory,” Numerical Analysis, ed. G. A. Watson, Lecture Notes in Mathematics 630, Springer Verlag, pp. 105-116, 1977.). The default is 1.

Raises:
ValueError: “Unable to determine number of fit parameters”.

If either ydata or xdata contain NaNs, or if incompatible options are used.

Returns:

popt: array Optimal values for the parameters so that the sum of the squared residuals of f(xdata, *popt) - ydata is minimized.

pcov: 2-D array

The estimated covariance of popt. The diagonals provide the variance of the parameter estimate. To compute one standard deviation errors on the parameters use perr = np.sqrt(np.diag(pcov)).

res : OptimizeResult with the following fields defined:

  • x : ndarray, shape (n,)

    Solution found.

  • cost : float

    Value of the cost function at the solution.

  • fun : ndarray, shape (m,)

    Vector of residuals at the solution.

  • jac : ndarray, sparse matrix or LinearOperator, shape (m, n)

    Modified Jacobian matrix at the solution, in the sense that J^T J is a Gauss-Newton approximation of the Hessian of the cost function. The type is the same as the one used by the algorithm.

  • grad : ndarray, shape (m,)

    Gradient of the cost function at the solution.

  • optimality : float

    First-order optimality measure. In unconstrained problems, it is always the uniform norm of the gradient. In constrained problems, it is the quantity which was compared with gtol during iterations.

  • active_mask : ndarray of int, shape (n,)

    Each component shows whether a corresponding constraint is active (that is, whether a variable is at the bound):

    • 0 : a constraint is not active.
    • -1 : a lower bound is active.
    • 1 : an upper bound is active.

    Might be somewhat arbitrary for ‘trf’ method as it generates a sequence of strictly feasible iterates and active_mask is determined within a tolerance threshold.

  • nfev : int

    Number of function evaluations done. Methods ‘trf’ and ‘dogbox’ do not count function calls for numerical Jacobian approximation, as opposed to ‘lm’ method.

  • njev : int or None

    Number of Jacobian evaluations done. If numerical Jacobian approximation is used in ‘lm’ method, it is set to None.

  • status : int

    The reason for algorithm termination:

    • -1 : improper input parameters status returned from MINPACK.
    • 0 : the maximum number of function evaluations is exceeded.
    • 1 : gtol termination condition is satisfied.
    • 2 : ftol termination condition is satisfied.
    • 3 : xtol termination condition is satisfied.
    • 4 : Both ftol and xtol termination conditions are satisfied.
  • message : str

    Verbal description of the termination reason.

  • success : bool

    True if one of the convergence criteria is satisfied (status > 0).

glint_fitting_functions6.curvefit2(func, xdata, ydata, p0=None, sigma=None)

New wrapper where one of the algorithm of the Scipy minimize library is used instead of the TRF. Documentation based on https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html.

Parameters:

func: function to fit on data.

xdata : array

The independent variable where the data is measured. Should usually be an M-length sequence or an (k,M)-shaped array for functions with k predictors, but can actually be any object.

ydata: array

The dependent data, a length M array - nominally f(xdata, ...).

p0: list, optional

Initial guess for the parameters (length N). If None, then the initial values will all be 1 (if the number of parameters for the function can be determined using introspection, otherwise a The default is None.

sigma: None or M-length sequence, optional

Determines the uncertainty in ydata. If we define residuals as r = ydata - f(xdata, *popt). The default is None.

Raises:
ValueError: “Unable to determine number of fit parameters”

If either ydata or xdata contain NaNs, or if incompatible options are used.

Returns:
popt: array

Optimal values for the parameters so that the sum of the squared residuals of f(xdata, *popt) - ydata is minimized.

pcov: 2-D array

The estimated covariance of popt. The diagonals provide the variance of the parameter estimate. To compute one standard deviation errors on the parameters use perr = np.sqrt(np.diag(pcov)).

res: OptimizeResult

The optimization result represented as a OptimizeResult object. Important attributes are: x the solution array, success a Boolean flag indicating if the optimizer exited successfully and message which describes the cause of the termination. See OptimizeResult for a description of other attributes.

glint_fitting_functions6.divide_chunks(l, n)

Yield successive n-sized chunks from l.

Parameters:
l: integer

Size of the list to chunk.

n: integer

Size of a chunk of the list.

Yields:

Generator of the chunks.

glint_fitting_functions6.doubleGaussCdf(x, mu1, mu2, sig1, sig2, A)

Calculate the CDF of the sum of two normal distributions.

Parameters:
x : array

Abscissa of the CDF.

mu1: float

Location parameter of the first normal distribution.

mu2: float

Location parameter of the second normal distribution.

sig1: float

Scale parameter of the first normal distribution.

sig2: float

Scale parameter of the second normal distribution.

A: float

Relative amplitude of the second distribution with respect to the first one.

Returns:
Array

CDF of the double normal distribution.

glint_fitting_functions6.getErrorBinomNorm(pdf, data_size)

Calculate the error of the PDF knowing the number of elements in a bin is a random value following a binomial distribution.

Parameters:
pdf : array

Normalized PDF which the error is calculated.

data_size: integer

Number of elements used to calculate the PDF.

Returns:
pdf_err : array

Error of the PDF.

glint_fitting_functions6.getErrorCDF(data_null, data_null_err, null_axis)

Calculate the error of the CDF. It uses the cupy library.

Parameters:
data_null: array

Null depth measurements used to create the CDF.

data_null_err: array

Error on the null depth measurements.

null_axis: array

Abscissa of the CDF.

Returns:
std: cupy array

Error of the CDF.

glint_fitting_functions6.getErrorNull(data_dic, dark_dic)

Compute the error of the null depth.

Parameters:
data_dic: dictionary

Dictionary of the data from load_data.

dark_dic: dictionary

Dictionary of the dark from load_data.

Returns:
std_null : array

Array of the error on the null depths.

glint_fitting_functions6.getErrorPDF(data_null, data_null_err, null_axis)

Calculate the error of the PDF. It uses the cupy library.

Parameters:
data_null: array

Null depth measurements used to create the PDF.

data_null_err: array

Error on the null depth measurements.

null_axis: array

Abscissa of the CDF.

Returns:
std: array

Error of the PDF.

glint_fitting_functions6.getErrorWilson(cdf, data_size, confidence)

DISCARDED. Calculate the error of the CDF following the Wilson estimator (https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Wilson_score_interval).

Parameters:
cdf : array

CDF for which we want the error.

data_size: integer

Number of elements used to calculate the CDF.

confidence: float between 0 and 1

Requested confident interval.

Returns:
cdf_err: array

Error on the CDF.

glint_fitting_functions6.getHistogram(data, bins, density, target='cpu')

DISCARDED

Compute the histogram of the data.

Parameters:
data: array

Data from which we want the histogram.

bins: array

Left-edge of the bins of the histogram but the last value which is the right-edge of the last bin.

density: bool

If True, the histogram is normalized as described in documentation of np.histogram.

target: string, optional

Indicates what creates the histograms: the cpu or the gpu. The default is ‘cpu’.

Returns:
pdf: array

PDF of the data.

bins_cent: array

Centered bins of the histogram.

glint_fitting_functions6.getHistogramOfIntensities(data, bins, split, target='cpu')

DISCARDED

Compute the histograms of the photometric outputs.

Parameters:
data: array

Data from which we want the histogram.

bins: array

Left-edge of the bins of the histogram but the last value which is the right-edge of the last bin.

split: ????

target: string, optional

Indicates what creates the histograms: the cpu or the gpu. The default is ‘cpu’.

Returns:
pdf_I_interf: array

PDF of the intensities.

bins_cent: array

Centered bins of the histogram.

glint_fitting_functions6.getInjectionAndSpectrum(photoA, photoB, wl_scale, wl_bounds=(1400, 1700))

Get the distributions of the broadband injections and the spectra of beams A and B.

Parameters:
photoA: array-like

Values of the photometric output of beam A.

photoB: array-like

Values of the photometric output of beam B.

wl_scale: array-like

Wavelength of the spectra in nm.

wl_bounds : 2-tuple, optional

Boundaries between which the spectra are extracted. The wavelengths are expressed in nm. The default is (1400,1700).

Returns:
2-tuple of 2-tuple

The first tuple contains the histograms of the broadband injection of beams A and B, respectively. The second tuple contains the spectra of beams A and B, respectively.

glint_fitting_functions6.get_zeta_coeff(path, wl_scale, plot=False, **kwargs)

Interpolate the zeta coefficients for the requested wavelengths.

Parameters:
path: string

Path to the zeta coefficients’ file.

wl_scale: array

List of wavelength for which we want the zeta coefficients

plot: bool, optional

If True, the plot of the interpolated zeta coefficients curve is displayed. The default is False.

kwargs: extra keyword arguments

Bins the zeta coefficient between the specified wavelength in this keyword.

Returns:
coeff_new : dictionary

Dictionary of the interpolated zeta coefficients.

glint_fitting_functions6.load_data(data, wl_edges, null_key, nulls_to_invert, *args, **kwargs)

Load data from data file to create the histograms of the null depths and do Monte-Carlo.

Parameters:
data: array

List of data files.

wl_edges: 2-tuple

Lower and upper bounds of the spectrum to load.

null_key: string

Baseline to load.

nulls_to_invert: list

List of nulls to invert because their null and antinull outputs are swapped.

args: extra arguments

Use dark data to get the error on the null depth.

kwargs: extra keyword arguments

Performs temporal binning of frames.

Returns:
out: dictionary

Includes data to use for the fit: flux in (anti-)null and phtometric outputs, errors, wavelengths.

glint_fitting_functions6.rv_gen_doubleGauss(nsamp, mu1, mu2, sig, A, target)

Random values generator according to a double normal distribution with the same scale factor. This function uses cupy to generate the values.

This function can be used to model the phase distribution as a double normal distribution if the fluctuations present two modes.

Parameters:
nsamp : integer

Number of random values to generate.

mu1: float

Location parameter of the first normal distribution.

mu2: float

Location parameter of the second normal distribution.

sig: float

Scale parameter of the both normal distributions.

A: float

Relative amplitude of the second normal distribution with respect to the first one.

target: string

If target = cpu, the random values are transferred from the graphic card memory to the RAM.

Returns:
rv : array or cupy array

Random values generated according to the double normal distribution.

glint_fitting_functions6.rv_generator(absc, cdf, nsamp)

Random values generator based on the CDF.

Parameters:
absc: array

Abscissa of the CDF;

cdf: array

Normalized arbitrary CDF to use to generate rv.

nsamp: integer

Number of values to generate.

Returns:
output_samples: array

Array of random values generated from the CDF.

glint_fitting_functions6.rv_generator_wPDF(bins_cent, pdf, nsamp)

Random values generator based on the PDF.

Parameters:
bins_cent: array

Centered bins of the PDF.

pdf: array

Normalized arbitrary PDF to use to generate rv.

nsamp: integer

Number of values to generate.

Returns:
output_samples: array

Array of random values generated from the PDF.

glint_fitting_functions6.sortFrames(dic_data, binned_frames, quantile, factor_minus, factor_plus, which_null, plot=False, save_path='')

Sigma-clipping to filter the frames which phase is not Gaussian (e.g. because of LWE). Fluxes of the null and antinull outputs are analysed in two steps. In the first step, for a given output, values between two thresholds are kept. The base is the upper bound for the antinull output or the lower bound for the null output. The base is defined as the median of the measurements which lower than the quantile (typically 10%) of the total sample in the null output, and upper for the antinull output. The second threshold is defined as the base plus or minus the standard deviation of the global sample wieghted by a coefficient. In the second step, frames for which both fluxes are kept are saved, the others are discarded.

Parameters:
dic_data: dictionary

Contains the extracted data from files by the function load_data.

binned_frames: integer

Number of frames to bin before applying the filter. It is used to increase the SNR and exhibit the phase noise over the detector noise.

quantile: float between 0 and 1

first quantile taken to determine the base threshold.

factor_minus: float

Factor applied to the std of the null flux to determine the second threshold.

factor_plus: float

Factor applied to the std of the antinull flux to determine the second threshold.

which_null: string

Indicates on which baseline the filter is applied.

plot : bool, optional

If True, it displays the time serie of the binned frames, the thresholds and highlights the filtered frames. The default is False.

save_path: string, optional

Path where the plots is saved in png format (dpi = 300). The default is ‘’.

Returns:
new_dic: dictionary

New dictionary with only the saved data points.

idx_good_frames: array

Index of the kept frames in the input dictionary.