File Processing Routines

Introduction

The FileProcessor class converts a list of filenames (or a scan object containing from which a list of filenames can be found) into a 3D array, or stack of images. These images are corrected by dark images and are normalized by the beam monitor. The intention of the file processor is to form a consistent interface to the CCD processing routines.

Using the FileProcessor

The FileProcessor is a class and can be called as:

>>>fp = FileProcessor()

which creates a blank image processor object. In order to process images the user must provide a list of filenames for both the images and dark images. If this list is 1D then each image corresponds to one image in the stack. If the list is 2D (or in python-speak a list of lists) then the inner list is taken as a number of sub images which should be binned together. This is true for dark images also. To set the image processor to process a spec scan one can call:

>>>sf = SpecDataFile('myfile.01')
>>>scan = sf[101]
>>>fp = FileProcessor(spec = scan)

In order to process the data set, the function process() is called:

>>>fp.process()

The resulting stack can be accessed through the function getImage():

>>>stack = fp.getImage()

For more information see the class documentation.

FileProcessor Documentation

class pyspec.ccd.transformations.FileProcessor(filenames=None, darkfilenames=None, norm=None, format='SPE', spec=None, process=False)

FileProcessor Class

This class processes CCD files and returns a numpy array of float values for all the images. Images can be saved to disk for faster processing in the future.

The basic building block of this concept is a list of all filenames to process. This should be provided through the helper functions or can be set through a specfile object.

getImage(n=None)

Return the image data

n : int or None
Image number to return. If None, return all images.
getMeanImage()

Return the mean image after processing.

Calculates the mean of all images processed. Returns a tuple of the mean image and the standard error

load(filename)

Load images from previous save operation

filename : string
Filename of images previously stored by save()
process(dark=True, norm=True, dtype=<type 'float'>, quiet=False, crop=False, BG=False)

Read in images and process into 3D array.

dark : bool
If True, subtract the dark images from the data
norm : bool
If True, normalize by monitor.
dtype : datatype
numpy datatype of processed array.
quiet : bool
If True, dont write to screen when reading images.
save(filename, compressed=False)

Save an image sequance to a numpy binary file

filename : string
Filename to save to.
compressed : bool
If True save as compressed file
saveImage(filename, inum=None, dtype=<type 'numpy.float32'>)

Save image to binary file of specified datatype

filename : string
Filename to save image stack to.
inum : Integer
Image number to save
dtype : numpy data type
Datatype for images
setFilenames(filenames=None, darkfilenames=None)

Set the list of filenames and darkfilenames

filenames : list of strings
Set the list of filenames to process for the light images
darkfilenames : list of strings
Set the list of filenames to process the dark images
setFromSpec(scan, mon='Monitor')

Set the filenames from a SpecScan instance

This function sets the following from a SpecScan instance:

CCD Filenames CCD Dark Filenames Monitor normalization values.
scan : SpecScan instance
SpecScan to use for data
mon : String
Name of monitor in SpecScan instance
setMeanMonitor(b)

Set if the images are normalized by the mean of the monitor

b : bool
If True, normalize to mean of monitor counts.

Table Of Contents

Previous topic

Introduction to CCD Package

Next topic

Image Processing Routines

This Page