tomoscan.tomoscan_stream_pso
¶
Software for tomography scanning with EPICS
Classes¶
- TomoScanStreamPSO
Derived class for tomography scanning with EPICS using Aerotech controllers and PSO trigger outputs in the streaming mode
Functions:
Software for tomography scanning with EPICS |
- class tomoscan.tomoscan_stream_pso.TomoScanStreamPSO(pv_files, macros)[source]¶
Bases:
TomoScan
Derived class used for tomography scanning with EPICS using Aerotech controllers and PSO trigger outputs
- Parameters
pv_files (list of str) – List of files containing EPICS pvNames to be used.
macros (dict) – Dictionary of macro definitions to be substituted when reading the pv_files
- begin_scan()[source]¶
Performs the operations needed at the very start of a scan.
Calls the base class method.
Sets the speed of the rotation motor
Computes the delta theta, start and stop motor positions for the scan
Programs the Aerotech driver to provide pulses at the right positions
Begin streaming
- begin_stream()[source]¶
Streaming settings adjustments at the beginning of the scan
set dark/flat fields modes as None (do not take static dark/flat fields)
set binning in ROI1 plugin
set capturing status to Done for all capturing pvs
set circular buffer
add callbacks for capturing changing sizes pvs
- broadcast_dark()[source]¶
Broadcast dark fields
read dark fields from the file
take average and bin dark fields according to StreamBinning parameter
broadcast dark field with the pv variable
- broadcast_flat()[source]¶
Broadcast flat fields
read flat fields from the file
take average and bin flat fields according to StreamBinning parameter
broadcast flat field with the pv variable
- capture_projections()[source]¶
Monitor the capturing projections process: capture projections, save pre-buffer, dump angles, copy dark and flat fields. The result of this capturing process is 4 files, e.g. scan_045.h5 (captured projections), circular_buffer_scan_045.h5 (pre-buffer with projections), dark_fields_scan_045.h5 (dark fields), and flat_fields_scan_045.h5 (flat fields)
set StreamMessage to ‘Capturing projections’
disable cb plugin
set number of captured frames in the hdf5 plugin as StreamNumCapture parameter
set file name
start capturing to the hdf5 file
wait when capturing is started
wait when capturing is finished
dump angles
take basename and dirname from full file name
NOTE: Temporarily: dont copy dark and flats // copy dark_flat fields file to the one having the same index as data (eg. copy dark_fields.h5 dark_fields_scan_045.h5) // copy dark_flat fields file to the one having the same index as data (eg. copy flat_fields.h5 flat_fields_scan_045.h5)
- if circular buffer size > 0:
set StreamMessage to ‘Capturing circular buffer’
save file name, hdf5 plugin port name, autoincrement values
change hdf5 file name to circular_buffer_*file_name*, set autoincrent to No
switch input port of hdf5 plugin to the circular buffer port
set the number of captured frames in the hdf5 as the currentQty value in cb
start capturing to the hdf5 file
set the number of post-count in cb plugin equal to currentQty
press trigger button in cb plugin
enable cb callbacks
wait when trigger is finished
start cb capturing again
dump angles to hdf5 with data from cb
switch input port for hdf plugin back to the initial
change hdf5 file name and autoincrement values back to the initial
compute total number of captured frames and show it the medm screen
enable circular buffer (because if number of elements in CB == 0 then the plugin will automatically turn off)
set StreamMessage to ‘Done’
set capturing status to ‘Done’
- change_binning()[source]¶
Change binning for broadcasted projections and dark/flat fields
change binning in the ROI1 plugin
broadcast binned dark and flat fields
cancel change_binning if StreamMessage!=’Done’
- change_cbsize()[source]¶
Change the circular buffer size
stop cb capturing
set precount in circular buffer to the new size
start cb capturing
if StreamMessage!=’Done’, cancel the entered value for the cb size
- cleanup_PSO()[source]¶
Cleanup activities after a PSO scan. Turns off PSO and sets the speed back to default. Same as in TomoScanPSO
- collect_projections()[source]¶
Collects projections in fly scan mode.
Call the superclass collect_projections() function
Taxi to the start position
Set the External trigger mode on the camera
Starts the camera acquiring in external trigger mode.
Assign fly angular positions to theta depending on the stream type (‘backforth’ or ‘continuous’)
Broadcast angles in a pva variable
- compute_frame_time()[source]¶
Redefine the one from Tomoscan, set no readout
- Returns
float – The frame time, which is the minimum time allowed between triggers for the value of the
ExposureTime
PV.
- compute_positions_PSO()[source]¶
Computes several parameters describing the fly scan motion. Computes the spacing between points, ensuring it is an integer number of encoder counts. Uses this spacing to recalculate the end of the scan, if necessary. Computes the taxi distance at the beginning and end of scan to allow the stage to accelerate to speed. Same as in TomoScanPSO except angles are not initiated here
- copy_flat_dark_to_hdf()[source]¶
Copies the flat and dark field data to the HDF5 file with the projection data. This allows the file to be a fully valid DXchange file. Once the file is created it will be copied to the remote data analysis computer (if CopyToAnalysisDir is set to yes)
- dump_theta()[source]¶
Add theta to the hdf5 file by using unique ids stored in the same hdf5 file
read unique projection ids from the hdf5 file
take angles by ids from the PSO
dump angles into hdf5 file
- end_scan()[source]¶
Performs the operations needed at the very end of a scan.
End streaming
Calls
save_configuration()
.Put the camera back in “FreeRun” mode and acquiring so the user sees live images.
Sets the speed of the rotation stage back to the maximum value.
Stop rotation with Jog
Calls the base class method.
- end_stream()[source]¶
Stream settings adjustments at the end of the scan
set capturing status to Done for all capturing pvs
remove callbacks
- program_PSO()[source]¶
Performs programming of PSO output on the Aerotech driver. Same as in TomoScanPSO, but with adding RotationSpeedJog
- pv_callback_stream(pvname=None, value=None, char_value=None, **kw)[source]¶
Callback functions for capturing in the streaming mode
- retake_dark()[source]¶
Recollect dark fields while in the streaming mode
set StreamMessage to ‘Captruing dark fields’
save file_name, template, autoincrement values
change file name to dark_fields.h5, autoincrement to No, template to %s%s
set frame type to DarkField
disable circular buffer plugin
close shutter
collect dark fields
enable circular buffer plugin
return file name to the initial one
set the frame type to ‘Projection’
set the retake dark button to Done
broadcast dark fields
set StreamMessage to ‘Done’
set capturing status to ‘Done’
- retake_flat()[source]¶
Recollect flat fields while in the streaming mode
set StreamMessage to ‘Captruing flat fields’
save file_name, template, autoincrement values
change file name to flat_fields.h5, autoincrement to No, template to %s%s
set frame type to DarkField
disable circular buffer plugin
close shutter
collect flat fields
enable circular buffer plugin
return file name to the initial one
set the frame type to ‘Projection’
set the retake dark button to Done
broadcast flat fields
set StreamMessage to ‘Done’
set capturing status to ‘Done’
- stream_sync()[source]¶
Synchronize new angular step and exposure with rotation speed. Broadcast new array of angles for streaming reconstruction
cleanup PSO
save last unique ID of projection
program pso (base part)
change the JOG speed wrt exposure and angular step
initiate DATAACQ in aerotech for saving encoder values
ARM PSO
wait exposure time to acquire 1 projection
read encoder value for the projection unique_id + 1
convert encoder value to the angle, form array of angles
broadcast array of angles for streaming
NOTE: currently doesn’t work for backforth scans