Ptw File Functions

Overview

This module provides functionality to read the contents of files in the PTW file format and convert the raw data to source radiance or souorce temperature (provided that the instrument calibration data is available).

Functions are provided to read the binary Agema/Cedip/FLIR Inc PTW format into data structures for further processing.

The following functions are available to read PTW files:

readPTWHeader(ptwfilename)
showHeader(header)
getPTWFrame (header, frameindex)

readPTWHeader(ptwfilename) : Returns a class object defining all the header information in ptw file.

showHeader(header) : Returns nothing. Prints the PTW header content to the screen.

getPTWFrame (header, frameindex) : Return the raw DL levels of the frame defined by frameindex.

The authors wish to thank FLIR Advanced Thermal Solutions for the permission to publicly release our Python version of the ptw file reader. Please note that the copyright to the proprietary ptw file format remains the property of FLIR Inc.

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.ryptw.JadeCalibrationData(filename, datafileroot)

Container to describe the calibration data of a Jade camera.

CalculateCalibrationTables()

Calculate the mapping functions between digital level, 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.

LoadPrepareData()

Load the camera calibration data from files and preprocess spectrals data

LookupDLRad(DL, Tint)

Calculate the radiance associated with a DL and Tint pair. Interpolate linearly on Tint radiance not temperature.

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.

LookupDLTemp(DL, Tint)

Calculate the temperature associated with a DL and Tint pair. Here we interpolate linearly on Tint temperature - actually we must interpolate linearly on radiance - to be done later. Note that dicLookupRadTemp is available for both Tint values, but it has the same value in both cases.

PlotDLRadiance()

Plot DL level versus radiance for both camera temperatures

PlotDLTemp()

Plot digital level versus temperature for both camera temperatures

PlotRadiance()

Plot all spectral radiance data for the calibration temperatures.

PlotSpectrals()

Plot all spectral curve data to a single graph.

PlotTempRadiance()

Plot temperature versus radiance for both camera temperatures

PlotTintRad()

Plot optics radiance versus instrument temperature

Print()

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

class pyradi.ryptw.PTWFrameInfo

Class to store the ptw file header information.

Module functions

pyradi.ryptw.readPTWHeader(ptwfilename)

Given a ptw filename, read the header and return the header to caller

Args:
filename (string) with full path to the ptw file.
Returns:
Header (class) containing all PTW header information.
Raises:
No exception is raised.
Reference:
h_variables of the header and byte positions are obtained from DL002U-D Altair Reference Guide
pyradi.ryptw.showHeader(Header)

Utility function to print the PTW header information to stdout

Args:
header (class object) ptw file header structure
Returns:
None
Raises:
No exception is raised.
pyradi.ryptw.getPTWFrame(header, frameindex)

Retrieve a single PTW frame, given the header and frame index

This routine also stores the data array as part of the header. This may change - not really needed to have both a return value and header stored value for the DL valueheader. This for a historical reason due to the way GetPTWFrameFromFile was written

Args:
header (class object)
frameindex (integer): The frame to be extracted
Returns:
header.data (np.ndarray): requested frame DL values, dimensions (rows,cols)
Raises:
No exception is raised.
pyradi.ryptw.GetPTWFrameFromFile(header)
From the ptw file, load the frame specified in the header variable
header.h_framepointer
Args:
header (class object) header of the ptw file, with framepointer set
Returns:
header.data plus newly added information: requested frame DL values, dimensions (rows,cols)
Raises:
No exception is raised.
pyradi.ryptw.getPTWFrames(header, loadFrames=[])

Retrieve a number of PTW frames, given in a list of frameheader.

Args:
header (class object)
loadFrames ([int]): List of indices for frames to be extracted
Returns:
data (np.ndarray): requested image frame DL values, dimensions (frames,rows,cols)
Raises:
No exception is raised.
pyradi.ryptw.myint(x)
pyradi.ryptw.mylong(x)
pyradi.ryptw.myfloat(x)
pyradi.ryptw.mybyte(x)
pyradi.ryptw.mydouble(x)
pyradi.ryptw.terminateStrOnZero(str)

Iterate through string and terminate on first zero

Table Of Contents

Previous topic

Utility Functions

Next topic

Modtran utility

This Page