podi_nonlinearity Module

This module contains all functionality related to creating and applying non-linearity coefficients from and to data.

Standalone options

Measure the intensity of each cell in each OTA in a number of input files

podi_nonlinearity.py file1.fits file2.fits

Fit all data and compute non-linearity coefficients

podi_nonlinearity.py -fit (-mint=0.0) (-maxt=100.0) (-minf=10.0) (-maxf=59000.0) (-order=3) input.datafile output.fits

-mint=X and -maxt=X specify the minimum and maximum exposure times to be
included in the fit
-minf=X and -maxf limit the intensity-range allowed during the fit. This
is useful to limit problematic andor saturated intensity ranges.

-order=X determines th epolynomial degree to be used in the fit.

Load the coefficient file and print the coefficients for a given OTA

podi_nonlinearity.py -load coefficients.fits OTA-number

Apply the correction to a overscan-subtracted raw-frame

podi_nonlinearity.py -correctraw input.fits coeffs.fits output.fits

Apply the non-linearity correction to a collectcells-reduced frame

podi_nonlinearity.py -correct input.fits coeffs.fits output.fits

Create a diagnostic plot, showing data, fit, and fit-residuals, for a given cell

podi_nonlinearity.py -plotdatafit data.file ota cellx celly coeffs.fits output.png

Create a map, showing the relative amplitude of the non-linearity correction relative to the input intensity, at a given intensity-level.

podi_nonlinearity.py -nonlinmap coeffs.fits output.png fluxlevel

Methods:

podi_nonlinearity.apply_gain_correction(data, cellx, celly, nonlin_data)[source]

Apply the gain correction

podi_nonlinearity.compute_cell_nonlinearity_correction(data, cellx, celly, nonlin_data)[source]

Select the non-linearity coefficients for the specified cell and compute the correction.

podi_nonlinearity.compute_nonlinearity_correction(data, coeffs)[source]

Evaluate the polynomial describing the non-linearity correction

podi_nonlinearity.create_data_fit_plot(data, fitfile, ota, cellx, celly, outputfile)[source]

Create a plot, for a given individual cell, showing the non-linearity measurements, polynomial fits for various degrees and the difference between data and fit,

podi_nonlinearity.create_nonlinearity_data(inputfiles)[source]

Prepare the non-linearity data by measuring the mean/median intensity level in each and all cells in each of the given files.

All this data is then returned. During execution, the generated data is also written to disk into a file named “alldata.tmp”

podi_nonlinearity.create_nonlinearity_fits(data, outputfits, polyorder=3, exptime_range=[0.1, 2.5], intensity_range=[100, 59000], verbose=False)[source]

Fit all non-linearity data for all cells, based on data created earlier.

podi_nonlinearity.create_nonlinearity_map(fitfile, outputfile, fluxlevel, minmax, labels=True)[source]

Create a non-linearity map, showing (color-coded) the ratio of non-linearity correction to input data, for each cell across the entire focalplane.

podi_nonlinearity.find_nonlinearity_coefficient_file(target_mjd, options)[source]

Select the appropriate non-linearity coefficient file based on a history file and a given MJD timestamp.

podi_nonlinearity.fit_nonlinearity_sequence(pinit, args)[source]

Perform a polynomial fit to all data of a given cell. Mostly a wrapper around scipy.optimize.leastsq.

podi_nonlinearity.load_nonlinearity_correction_table(filename, search_ota)[source]

Load the fits table with all non-linearity coefficients and down-select coefficients for the specified OTA.

podi_nonlinearity.plot_cellbycell_map(fitfile, outputfile, minmax, labels=True, fontsize=2)[source]

Table Of Contents