calc_uncertainty_scale

msaexp.spectrum.calc_uncertainty_scale(file=None, data=None, order=0, initial_mask=(0.2, 5), sys_err=0.02, fit_sys_err=False, method='bfgs', student_df=10, update=True, verbose=True, **kwargs)[source]

Compute a polynomial scaling of the spectrum uncertainties. The procedure is to fit for coefficients of a polynomial multiplied to the err array of the spectrum such that (flux - model)/(err*scl) residuals are N(0,1)

Parameters
filestr

Spectrum filename

datatuple

Precomputed outputs from plot_spectrum

orderint

Degree of the correction polynomial

initial_mask(float, float)

Masking for the fit initialization. First parameter is zeroth-order uncertainty scaling and the second parameter is the mask threshold of the residuals

sys_errfloat

Systematic component of the uncertainties

fit_sys_errbool

Fit for adjusted sys_err parameter

methodstr

Optimization method for scipy.optimize.minimize

student_dfint, None

If specified, calculate log likelihood of a scipy.stats.t Student-t distribution with ``df=student_df`. Otherwise, calculate log-likelihood of the scipy.stats.normal distribution.

updatebool

Update the global msaexp.spectrum.SCALE_UNCERTAINTY array with the fit result

verbosebool

Print status messages. If verbose > 1 will also print status at each step of the optimization.

kwargsdict

Keyword arguments for plot_spectrum if data not specified

Returns
specTable

The spectrum as fit

escalearray

The wavelength-dependent scaling of the uncertainties

sys_errfloat

The systematic uncertainty used, fixed or adjusted depending on fit_sys_err

resobject

Output from scipy.optimize.minimize