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.

Info()

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.

The contents of the header is changed (new information added: frame time and detector temperature). The header is returned from the function to make it explicit that the contents have changed from the header passed into the function.

Args:
header (class object)
frameindex (integer): The frame to be extracted
Returns:
header.data (np.ndarray): requested frame DL values, dimensions (rows,cols)
header (class): updated header now with frame time and FPA temperature
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. The function returns the image data as well as the file and image header data (time and FPA temperature) valid for the particular frame. The frame header data is written in the same class as is the file header, in order to keep all the information together for the frame.

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)
fheaders (object): requested image frame header values
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