xspress3 package

Submodules

xspress3.hdf5 module

class xspress3.hdf5.HDF5(file, logger=None)[source]

Xspress 3 HDF5 Parser

A class for parsing Xspress 3 HDF5 files. Is context managed so files are automatically closed when done

Example:
>>> with HDF5(file) as h5:
>>>     h5.size()
>>>     h5.mca(0,0)
>>>
>>> {'channels': 1, 'frames': 4, 'bins': 4096}
>>> [0,0,0....0]

Create an Xspress 3 HDF5 parser instance

Args:
file (string): the hdf5 file to open
close()[source]

Manually close the hdf5 file

dtc(chan, frameno)[source]

Returns the specified deadtime correction parameters

Args:

chan (int): channel number to return scalar for, zero offset

frameno (int): the frame number to return scalar for, zero offset

Returns:
dtc_params (list): returns a list of two dead time correction params:
  1. dead time correction factor
  2. dead time percentage
mca(chan, frameno)[source]

Returns the specified MCA

Args:

chan (int): the channel to return an MCA for

frameno (int): the frame number to return an MCA for

Returns:
mca (list[int]): the MCA as a list (usually with 4096 elements)
sca(chan, frameno, sca)[source]

Returns the specified scalar

Aargs:

chan (int): channel number to return scalar for, zero offset

frameno (int): the frame number to return scalar for, zero offset

sca (int): scalar to return

Returns:
scalar (int): the specified scalar value
Available scalars:
  1. Time in ticks
  2. ResetTicks
  3. ResetCount
  4. AllEvent
  5. AllGood
  6. InWindow 0
  7. InWindow 1
  8. PileUp
size()[source]

Returns the dimensions of the HDF5 file

Returns:

size (dict): the hdf5 file dimensions

  • channels (int): number of channels in the file
  • frames (int): number of frames in the file
  • bins (int): number of bins per mca in the file

xspress3.monitorpv module

class xspress3.monitorpv.MonitorPV(pv, is_string=False, logger=None)[source]
value()[source]

Module contents

class xspress3.Xspress3(prefix, logger=None, subframes=False)[source]

Xspress 3 Device

A class encapsulating an Xspress 3 Device

Example:
>>> x3 = Xspres3(pv_prefix)  # create an x3 object with pv_prefix
>>> x3.set(
>>>     exposure_time=1,
>>>     num_images=10
>>> )
>>> x3.acquire()

Create an Xspress 3 device instance

Args:
prefix (string): the PV prefix of the device, eg. XSPRESS3-EXAMPLE
Kwargs:
subframes (bool): enable subframe parmeters (special IOC required)
acquire()[source]

Starts an acquisition

acquiring()[source]

Returns the acquisition status

Returns:
acquiring (bool): the acquisition status of the device
add_frame_callback(callback)[source]

Add a frame change callback

Adds a callback to the list of callbacks called when a frame change occurs during an acquisition. The callback recieves the frame number as an argument

>>> def callback(frame_number):
>>>     print 'New frame {f}'.format(frame_number)
>>> x3.add_frame_callback(callback)
Args:
callback (callable): the callback to add to the list of frame callbacks
channels()[source]

Get the number of channels on the Xspress 3 system

Returns:
no_channels (int): The number of channels on the system
dropped_frames()[source]

Return the number of dropped frames in the last acquisition

At high frames rates EPICS cannot keep up with PVs changing quickly, in these situations use file saving and read the hdf5 with the hdf5 module. Tests shows this occurs above around 100Hz

This value will tell you how many frames were dropped

Returns:
dropped_frames (int): the number of dropped frames in the last acquisition
file_saving(enable)[source]

Enable file saving

File saving is disabled after each acquisition, renable or disable it

Args:
enable (bool): enable or disable file saving
filename()[source]

Returns the current/last hdf5 filename

Returns:
filename (string): the current hdf5 filename
get(param=None)[source]

Get the value of an attribute

Args:
param (string): parameter to return the value of
Returns:
value (mixed): the value of the parameter
mca(chan)[source]

Returns the MCA for the specified channel

This value will be automatically updated whenever the PV changes

Args:
chan (int): channel number to return MCA for, zero offset
Returns:
mca (list[int]): return a list of mca values (usually 4096 values)
num_acquired()[source]

Returns the number of frames acquired

Returns:
num_acquired (int): the number of frames acquired
sca(chan, sca)[source]

Returns the specified scalar for the specified channel

Args:

chan (int): channel number to return scalar for, zero offset

sca (int): scalar to return

Returns:
scalar (int): the specified scalar value
Available scalars:
  1. Time in ticks
  2. ResetTicks
  3. ResetCount
  4. AllEvent
  5. AllGood
  6. InWindow 0
  7. InWindow 1
  8. PileUp
set(**kwargs)[source]

Set an attribute on the device

Kwargs:

exposure_time (float): per image exposure time in seconds

num_images (int): number of images to acquire

trigger_mode (string): trigger mode (Internal, External)

file_path (string): path to save hdf5 files to

file_name (string): file template for hdf5

file_number (int): file number ({file_path}/{file_name}{file_number}.hdf5)

file_capture (bool): enable hdf5 saving

setup_file_saving(dirn, template)[source]

Setup hdf5 file saving

>>> x3.setup_file_saving('/home/test/data', 'test')
>>> '/home/test/data/test{number}.hdf5'
Args:

dirn (string): directory to save hdf5 files to

template (string): file template of hdf5 files

Returns:
filename (string): the filename of the last hdf5 captured
stop()[source]

Stops an acquisiton