Radiometric Lookup Functions

Overview

This class provides lookup functionality between source temperature, source radiance and sensor signal. In this class the sensor signal is called digital level, but it represents any arbitrary sensor signal unit.

See the __main__ function for examples of use.

This package was partly developed to provide additional material in support of students and readers of the book Electro-Optical System Analysis and Design: A Radiometry Perspective, Cornelius J. Willers, ISBN 9780819495693, SPIE Monograph Volume PM236, SPIE Press, 2013. http://spie.org/x648.html?product_id=2021423&origin_id=x646

Module classes

class pyradi.rylookup.RadLookup(specName, nu, tmprLow, tmprHi, tmprInc, sensorResp=None, opticsTau=None, filterTau=None, atmoTau=None, sourceEmis=None, sigMin=None, sigMax=None, sigInc=None, dicCaldata=None, dicPower=None, dicFloor=None)
Performs radiometric lookup capability between temperature and radiance, given
camera spectral and calibration data.

Given spectral data and temperature this class calculates loopup tables and provide lookup functions operating on the tables.

The class provides two parallel functional capabilities:

  • given spectral data and no calibration data it calculates a simple radiance-based lookup between temperature and radiance, assuming Planck-law relationships.
  • given camera calibration data it relates between signal value, temperature and radiance. It accounts for the effect of hot optics that cause a lower asymptotic radiance level. The calibration mode supports linear interpolation between two calibration curves, to account for the instrument internal temperature. This mode requires the sigMin, sigMax, sigInc, and dicCaldat parameters.

By not passing the calibration parameters simply means that that part of the code is not executed and only the simple radiance-based lookup is available.

Five spectral vectors can be supplied: (1) emissivity, (2) atmospheric transmittance, (3) filter transmittance, (4) optics transmittance, and (5) sensor response. Two sets of calculations are performed, the first with all five spectral vectors, and the second without the filter, but all four remaining vectors. This option may be useful when compensating for neutral density filters, i.e., radiance before or after the filter (with/without). This option is relevant only in the functions LookupRadTemp, LookupTempRad, and PlotTempRadiance. In these three functions, the appropriate option can be selected by setting the withFilter=True function parameter.

Spectral data parameter may be either a filename (data read from file) or a numpy array np.array(:,1) with the data on (nuMin, nuMax,nuInc) scale. The data file must have two columns: first column is wavelength, and second column is the spectral value at this wavelength. Data read in from the file will be interpolated to (nuMin, nuMax,nuInc) scale. If the parameter is None, then unity spectral values will be used.

The camera calibration data set requires the following data:

  • sigMin, sigMax, sigInc: the parameters to define the signal magnitude vector.
  • dicCaldata: the dictionary containing the camera calibration data. The dictionary key is the instrument internal temperature [deg-C] (one or two values required). For each key, provide a numpy array where the first column is the calibration source temperature K, and the second column is the signal measured on the instrument and the third column is the radiance for this temperature (only after the tables have been calculated).
  • dicPower: the dictionary containing the camera calibration curve lower knee sharpness. The dictionary key is the instrument internal temperature (one or two values required).
  • dicFloor: the dictionary containing the camera calibration curve lower asymptotic signal value. The dictionary key is the instrument internal temperature (one or two values required).

Error handling is simply to test for certain conditions and then execute the task if conditions are met, otherwise do nothing.

Args:
specName (string): Name for this lookup data set, used in graphs.
nu (np.array(N,1)): wavenumber vector to be used in spectral calcs.
tmprLow (float): Lower temperature bound [K] for lookup tables.
tmprHi (float): Upper temperature bound [K] for lookup tables.
tmprInc (float): Increment temperature [K] for lookup tables.
sensorResp (string/np.array(N,1)): sensor/detector spectral filename or array data (optional).
opticsTau (string/np.array(N,1)): opticsTransmittance spectral filename or array data (optional).
filterTau ((string/np.array(N,1)): filter spectral filename or array data (optional).
atmoTau (string/np.array(N,1)): atmoTau spectral filename or array data (optional).
sourceEmis (string/np.array(N,1)): sourceEmis spectral filename or array data (optional).
sigMin (float): minimum signal value, typically 2**0 (optional).
sigMax (float): maximum signal value, typically 2**14 (optional).
sigInc(float): signal increment, typically 2**8 (optional).
dicCaldata (dict): calibration data for sensor.
dicPower (dict): cal curve lower asymptote knee sharpness parameter (optional).
dicFloor (dict): cal curve lower asymptote parameter (optional).
Returns:
Nothing, but init() loads data and calculates the tables on instantiation.
Raises:
No exception is raised.
CalculateDataTables()

Calculate the mapping functions between sensor signal, radiance and temperature.

Using the spectral curves and DL vs. temperature calibration inputs calculate the various mapping functions between digital level, radiance and temperature. Set up the various tables for later conversion.

The TableTempRad table has three columns: (1) temperature, (2) radiance with filter present and (3) radiance without filter.

Args:
None.
Returns:
None. Side effect of all tables calculated.
Raises:
No exception is raised.
Info()

Write the calibration data file data to a string and return string.

Args:
None.
Returns:
(string) containing the key information for this class.
Raises:
No exception is raised.
LoadSpectrals()

Load the five required spectral parameters, interpolate on the fly to local spectrals.

If the spectral parameters are strings, the strings are used as filenames and the data loaded from file. If None, unity values are assumed. If not a string or None, the parameters are used as is, and must be numpy arrays with shape (N,1) where the N vector exactly matches to spectral samples

Args:
None.
Returns:
None. Side-effect of loaded spectrals.
Raises:
No exception is raised.
LookupDLRad(DL, Tint)
Calculate the radiance associated with a DL and Tint pair.
Interpolate linearly on Tint radiance not temperature.
Args:
DL (float, np.array[N,]): scalar, list or array of sensor signal values.
Tint (float): scalar, internal temperature of the sensor, deg C
Returns:
(np.array[N,]) radiance W/(sr.m2) values associated with sensor signals.
Raises:
No exception is raised.
LookupDLRadHelper(DL, paraK)
Calculate the radiance associated with a DL and parametric pair. The
parametric variable was calculated once and used for all DL values.
Args:
DL (float, np.array[N,]): scalar, list or array of sensor signal values.
paraK (float): scalar, internal temperature parametric values.
Returns:
(np.array[N,]) radiance W/(sr.m2) values associated with sensor signals.
Raises:
No exception is raised.
LookupDLTemp(DL, Tint)
Calculate the temperature associated with a DL and Tint pair.
Interpolate linearly on Tint temperature - actually we must interpolate linearly on radiance - to be done later.
Args:
DL (float, np.array[N,]): scalar, list or array of sensor signal values.
Tint (float): scalar, internal temperature of the sensor, deg C
Returns:
(np.array[N,]) temperature K values associated with sensor signals.
Raises:
No exception is raised.
LookupRadTemp(radiance, withFilter=True)

Calculate the temperature associated with a radiance value for the given spectral shapes (no calibration involved).

Args:
radiance (float, np.array[N,]): scalar, list or array of radiance W/(sr.m2) values.
withFilter (boolean): use table with filter to do lookup, no filter if false (optional).
Returns:
(np.array[N,]) temperature K values associated with radiance values.
Raises:
No exception is raised.
LookupTempRad(temperature, withFilter=True)

Calculate the radiance associated with a temperature for the given spectral shapes (no calibration involved).

Args:
temperature(np.array[N,]) scalar, list or array of temperature K values.
withFilter (boolean): use table with filter to do lookup, no filter if false (optional).
Returns:
radiance (float, np.array[N,]): radiance W/(sr.m2) associated with temperature values..
Raises:
No exception is raised.
PlotCalDLRadiance(savePath=None, saveExt='png', saveFig=False, plotPoints=None, colPoints=['k'], markPoints=['.'])

Plot DL level versus radiance for both camera temperatures

The filename is constructed from the given object name, save path, and the word ‘CaldlRadiance’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
plotPoints (np.array) : array of points to be plotted, default None (optional).
colPoints (list[string]) : Colour of points, default None (optional).
markPoints (list[string]) : Marker for points, default None (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotCalDLTemp(savePath=None, saveExt='png', saveFig=False, plotPoints=None, colPoints=['k'], markPoints=['.'])

Plot digital level versus temperature for both camera temperatures

The filename is constructed from the given object name, save path, and the word ‘CalDLTemp’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
plotPoints (np.array) : array of points to be plotted, default None (optional).
colPoints (list[string]) : Colour of points, default None (optional).
markPoints (list[string]) : Marker for points, default None (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotCalSpecRadiance(savePath=None, saveExt='png', saveFig=False)

Plot spectral radiance data for the calibration temperatures.

The filename is constructed from the given object name, save path, and the word ‘CalRadiance’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotCalTempDL(savePath=None, saveExt='png', saveFig=False, plotPoints=None, colPoints=['k'], markPoints=['.'])

Plot digital level versus temperature for both camera temperatures

The filename is constructed from the given object name, save path, and the word ‘CalDLTemp’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
plotPoints (np.array) : array of points to be plotted, default None (optional).
colPoints (list[string]) : Colour of points, default None (optional).
markPoints (list[string]) : Marker for points, default None (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotCalTempRadiance(savePath=None, saveExt='png', saveFig=False, plotPoints=None, colPoints=['k'], markPoints=['.'])

Plot temperature versus radiance for both camera temperatures

The filename is constructed from the given object name, save path, and the word ‘CalTempRadiance’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
plotPoints (np.array) : array of points to be plotted, default None (optional).
colPoints (list[string]) : Colour of points, default None (optional).
markPoints (list[string]) : Marker for points, default None (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotCalTintRad(savePath=None, saveExt='png', saveFig=False, plotPoints=None, colPoints=['k'], markPoints=['.'])

Plot optics radiance versus instrument temperature

The filename is constructed from the given object name, save path, and the word ‘CalInternal’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
plotPoints (np.array) : array of points to be plotted, default None (optional).
colPoints (list[string]) : Colour of points, default None (optional).
markPoints (list[string]) : Marker for points, default None (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotSpectrals(savePath=None, saveExt='png', saveFig=False)

Plot all spectral curve data to a single graph.

The filename is constructed from the given object name, save path, and the word ‘spectrals’.

if saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
savePath (string): Path to where the plots must be saved. If not given use data filename (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.
PlotTempRadiance(withFilter=True, savePath=None, saveExt='png', saveFig=False, plotPoints=None, colPoints=['k'], markPoints=['.'])

Plot temperature versus radiance for both camera temperatures

The filename is constructed from the given object name, save path, and the word ‘TempRadiance’.

If saveFig==True, images are saved to a specified location in savePath, or in the location from which the script is running.

Args:
withFilter (boolean): use table with filter to do lookup, no filter if false (optional).
savePath (string): Path to where the plots must be saved (optional).
saveExt (string) : Extension to save the plot as, default of ‘png’ (optional).
saveFig (bool) : Flag to control writing plot to file, default False (optional).
plotPoints (np.array) : array of points to be plotted, default None (optional).
colPoints (list[string]) : Colour of points, default None (optional).
markPoints (list[string]) : Marker for points, default None (optional).
Returns:
None, the images are saved to a specified location or in the location
from which the script is running.
Raises:
No exception is raised.