Absolute Calibration

pydiana.tools.absolute_calibration.absolute_calibration_fit(means, std_devs, err_means, err_std_devs, unit='mV', photon_wavelength=248, points2skip=None, hasnoise=True, fixs0=False, photon_wavelength_error=8, showplot=True, sort=True, get_detail_matrices=False, summary=False, legendpos_x=0.3, legendpos_y=0.65, fit_options='QS', useKeV=False, respORCalConst='both', enableSquarePar=False)[source]

Function for performing the absolute calibration fit

UPDATE: now there is the possibility to perform a quadratic fit (instead of a linear one); this (in principle) will correct eventual gain fluctuation (i.e. responsivity parameter instability)

Parameters:
  • means (array-like with the means for the absolute calibration) --

  • std_devs (array-like with the standard deviations for the absolute calibration) --

  • err_means (array-like with the errors on the means) --

  • err_std_devs (array-like with the errors on the standard deviations) --

  • unit (unit of means/std_devs) --

  • points2skip (list with the indixes of the points to be skipped in the fit in increasing order of mean amplitude (start from 0). If None everything is used. If sort is True then the order is given from the x axis.) --

  • hasnoise (boolean for indicating if the list of points provided contains a noise point) --

  • photon_wavelength (wavelength used for calibration in nm) --

  • photon_wavelength_error (error on the photon wavelength in nm) --

  • showplot (bool switch for enabling plotting) --

  • sort (bool for enable point sorting based on x axis) --

  • get_detail_matrices (bool for enabling the returning of the covariance and correlation matrices) --

  • summary (bool for enabling plot summary legend) --

  • legendpos_x (position of the summary legend on the y axis) --

  • legendpos_x --

  • enableSquarePar (bool which enable or not a parameter for the square dependence) --

Returns:

fit_results : pandas dataframe with relevant information on the calibration fig : figure instance of the calibration

pydiana.tools.absolute_calibration.apply_linearity(df, params, varcol, sep_field=None)[source]

Function for applying the linearization procedure to the data

Parameters:
  • df (pandas dataframe with the data) --

  • params (pandas dataframe with the results of one linearization fit or dictionary of dataframes with various results from linearization fits (must specify sep_field)) --

  • varcol (String with the name of the dataframe column where to calculate the linearization) --

  • sep_field (Used only if params is a dict, string containing the name of the column of df that contains the value of param's keys for each row of df.) --

Returns:

1D array with the linearized version of the specified variable

pydiana.tools.absolute_calibration.linearity_fit(x, y, err_y=None, err_x=None, unit_x='cycle', unit_y='mV', a_lims=None, b_lims=None, xlabel='Cycles', ylabel='Mean', points2skip=None, add_results=True, showplot=True, fit_options='QS', sort=True)[source]

Function for fitting a second degree polynomial to x and y and plot residuals plot.

Parameters:
  • x (array-like containing the number of cycles used for the LED) --

  • y (array-like containing the means) --

  • err_y (array-like containing the errors on the y) --

  • err_x (array-like containing the errors on the x (if left to None 0 errors will be applied)) --

  • unit_x (string for indicating the x units) --

  • unit_y (string for indicating the y units) --

  • a_lims (array-like containing min and max range for the "a" parameter) --

  • b_lims (array-like containing min and max range for the "b" parameter) --

  • xlabel (string containing the xlabel of the plot) --

  • ylabel (string containing the ylabel of the plot) --

  • points2skip (list with the indixes of the points to be skipped in the fit in increasing order of "x" (start from 0). If None everything is used) --

  • add_results (bool for enabling/disabling the writing of the results on the plot) --

  • showplot (switch for enabling the showing of the plot) --

Returns:

  • fit_results (pandas dataframe containing fit results)

  • fig (figure instance)

pydiana.tools.absolute_calibration.plot_linearity_uncertainty(params, xrange, varname='Variable', npoints=1000, showplot=False, title=None)[source]

Function for applying the linearization procedure to the data

Parameters:
  • df (pandas dataframe with the data) --

  • params (pandas dataframe with the results of one linearization fit or dictionary of dataframes with various results from linearization fits (must specify sep_field)) --

  • varcol (String with the name of the dataframe column where to calculate the linearization) --

  • sep_field (Used only if params is a dict, string containing the name of the column of df that contains the value of param's keys for each row of df.) --

Returns:

1D array with the linearized version of the specified variable