Page History
...
See also Examples for package pyimgalgos.
Package Translator
The translator package include the H5Output module which translates xtc to hdf5. For more information see the page The XTC-to-HDF5 Translator
Package psana_test
The psana_test package includes the psana module dump. This will take a standard psana datasource and dump all the event, config, and epics data found. The entire contents of large arrays are not printed. However a checksum over all the array data is, as well as the min, 25th percentile, median, 75th percentile, and max over the data. The dump module does not serve as a good example of how to retrieve and work with objects from the event store – see the psana_examples package for this. The psana_test package is primarily for psana developers to do software testing.
module dump
Running psana_test dump
An example of running the module is
psana -n 2 -m psana_test.dump exp=xpptut13:run=179
This dumps the first two events of run 179 of the xpp tutorial data.
Understanding psana_test dump output
Below we annotate the output that psana_test.dump can produce. All annotations are preceded by a #
Code Block | ||||
---|---|---|---|---|
| ||||
==================
=== begin job ====
# first the epics aliases are printed during begin job.
Epics Aliases: total = 250
Be_xpos
Be_ypos
Be_zpos
...
# next the epics pv, as they appear during beginJob.
# This corresponds to the xtc configure transition.
# At this point, these are ctrl pvs. T
Epics PV
pvName=HFX:DG2:MMS:08.RBV pvid=117 dbrtype=34 isCtrl=1 numElements=1 status=0 severity=0 units=mm upper_disp_limit=1.9500e+02 lower_disp_limit=-2.0500e+02 upper_alarm_limit=0.0000e+00 upper_warning_limit=0.0000e+00 lower_warning_limit=0.0000e+00 lower_alarm_limit=0.0000e+00 upper_ctrl_limit=1.9500e+02 lower_ctrl_limit=-2.0500e+02 data=4.2898e+01
...
# After epics, we get the content of the psana env configStore.
# The dump module is getting all keys from the configStore(),
# then retrieving each object. Objects that have a xtc type id, or are
# an numpy array will be printed.
# For each object, we first get a string describing the even key:
type=psana.ControlData.ConfigV2, src=ProcInfo(0.0.0.0, pid=7670)
# then we get the data of the object. Each method is called.
# methods that return unsigned ints print in hex.
# methods that return signed ints print in decimal.
# methods that return floats print in scientific format with 4 decimals of precision.
npvControls: 0x1
npvMonitors: 0x0
npvLabels: 0x0
events: 0x1E0
uses_duration: 0x0
uses_events: 0x1
# methods that return a complex type, like time, will get methods of the complex type indented:
duration:
nanoseconds: 0x0
seconds: 0x0
# some methods that return a python list. Each element in the list is printed separately:
pvControls[0]:
name: las_lensh
index: 0xFFFFFFFF
value: 0.0000e+00
array: 0x0
...
# epics config is not dumped, as it is redundant with what is in the epics store
type=psana.Epics.ConfigV1, src=DetInfo(EpicsArch.0:NoDevice.0)
epicsConfig not dumped
# cspad config is an example which has methods that return ndarrays
type=psana.CsPad.ConfigV4, src=DetInfo(XppGon.0:Cspad.0)
...
numSect: 0x20
# some methods return a list of simple types, these are printed in one line
roiMask [0]=0xFF [1]=0xFF [2]=0xFF [3]=0xFF
numAsicsStored [0]=0x10 [1]=0x10 [2]=0x10 [3]=0x10
...
quads[0]:
...
dp:
# for an ndarray, we print the type, dimensions, adler32 checksum, and quartile
# statistics (min, 25th percentile, median, 75th percentile, and max):
pots: ndarray_uint8_1: dim=[ 80 ] adler32=0x231B31F5 min=0x0 25th=0x3F median=0xB0 75th=0xFF max=0xFF
gm:
gainMap: ndarray_uint16_2: dim=[ 185 x 194 ] adler32=0x18730001 min=0x0 25th=0x0 median=0x0 75th=0x0 max=0x0
...
===============================================================
=== beginrun 0 === # typically, there is nothing new in beginrun
===============================================================
=== begincalibcycle run=0 step=0 ===
# having dumped the entire initial contents of epics and the config store,
# the dump module will now only print changes to epics or the config.
# That is it remembers how each epics pv and config object printed the last
# time it saw it. With each new transition, it looks at all the epics pv and
# config objects. If any change, they are dumped.
# The control data changed in the calib cycle:
type=psana.ControlData.ConfigV2, src=ProcInfo(0.0.0.0, pid=7670)
npvControls: 0x1
npvMonitors: 0x0
npvLabels: 0x0
events: 0x1E0
uses_duration: 0x0
uses_events: 0x1
duration:
nanoseconds: 0x0
seconds: 0x0
pvControls[0]:
name: las_lensh
index: 0xFFFFFFFF
value: -4.9997e-01
array: 0x0
# next we see event data, printing the following:
===============================================================
=== event: run=0 step=0 event=0 seconds= 1362889345 nanoseconds= 770371931 fiducials= 19593
# at this point, all epics pv's are replaced with TIME pv's, not the stamp.sec, stamp.nsec below:
Epics PV
pvName=OTRS:DMP1:695:FLT2_PNEU pvid=87 dbrtype=17 isTime=1 numElements=1 status=17 severity=3 stamp.sec=0 stamp.nsec=0 data=0x0
pvName=OTRS:DMP1:695:Image:ArrayData pvid=81 dbrtype=19 isTime=1 numElements=1424 status=0 severity=0 stamp.sec=765084864 stamp.nsec=401243855 data=ndarray_int32_1: dim=[ 1424 ] adler32=0xA4FBE55A min=71 25th=117 median=132 75th=149 max=223
...
# while most epics pv's have one value, there are some with more than one, such as ArrayData above. If it has less than 20 values, they are all printed, otherwise an array summary of the data is printed, as above.
# now we get into regular event data
type=psana.EvrData.DataV3, src=DetInfo(NoDetector.0:Evr.0)
numFifoEvents: 0x2
fifoEvents[0]:
timestampHigh: 0x4C89
timestampLow: 0x32A6
eventCode: 0x29
fifoEvents[1]:
timestampHigh: 0x4C89
timestampLow: 0x2E4C
eventCode: 0x8C
type=psana.CsPad.DataV2, src=DetInfo(XppGon.0:Cspad.0)
quads[0]:
seq_count: 0x1
ticks: 0x329D
fiducials: 0x4C89
sb_temp: ndarray_uint16_1: dim=[ 4 ] adler32=0x4FC00AC min=0x7 25th=0x8 median=0x9 75th=0x291 max=0x291
frame_type: 0x4
data: ndarray_int16_3: dim=[ 8 x 185 x 388 ] adler32=0xAD5ACF7F min=0 25th=1281 median=1346 75th=1475 max=16383
virtual_channel: 0x0
lane: 0x0
tid: 0x0
acq_count: 0x85
op_code: 0x85
quad: 0x0
sectionMask: 0xFF
quads[1]:
seq_count: 0x1
ticks: 0x329D
fiducials: 0x4C89
sb_temp: ndarray_uint16_1: dim=[ 4 ] adler32=0x2DB006A min=0x7 25th=0xA median=0xA 75th=0x34B max=0x34B
frame_type: 0x4
data: ndarray_int16_3: dim=[ 8 x 185 x 388 ] adler32=0xD28441BE min=0 25th=1316 median=1374 75th=1504 max=16383
virtual_channel: 0x0
lane: 0x0
tid: 0x0
acq_count: 0x85
op_code: 0x85
quad: 0x1
sectionMask: 0xFF |
src aliases
If a source alias has been defined, it will show up when the event key is printed:
type=psana.Pimax.FrameV1, src=DetInfo(AmoEndstation.0:Pimax.0) alias=pimax
Options
Several options allow you to control the output of psana_test.dump
The most useful are
include = term1 term2
exclude = term1 term2
These are used to filter the key strings. For example, running
psana -m psana_test.dump -o psana_test.dump.include=10k exp=mob30114:run=145
Would only dump event keys that had 10k in them, effectively giving you only Epix::Config10KV1 and psana.Epix.ElementV1 since these are the only types coming from the source DetInfo(NoDetector.0:Epix10k.0).
Other options one could set are:
epics = False
aliases = False
config = False
counter = False
indent = 4
Library Usage
Two functions are provided in the Python psana_test package that allow Python scripts to turn Psana objects into strings. A Python script could include the following function to build dictionaries describing the state of the event, configStore, and epicsStore:
Code Block | ||
---|---|---|
| ||
from psana_test import obj2str, epicsPvToStr
def getPsanaState(event, configStore, epicsStore):
evtDict = {}
cfgDict = {}
epicsDict = {}
for key in event.keys():
if key.type() is None: continue
obj = event.get(key.type(), key.src(), key.key())
if (obj is None): continue
if not hasattr(obj,'TypeId'): continue
evtDict[str(key)]=obj2str(obj)
for key in configStore.keys():
if key.type() is None: continue
obj = configStore.get(key.type(), key.src())
if (obj is None): continue
if not hasattr(obj,'TypeId'): continue
cfgDict[str(key)]=obj2str(obj)
for pvName in epicsStore.pvNames():
pv = epicsStore.getPV(pvName)
if not pv: continue
epicsDict[pvName] = epicsPvToStr(pv)
return evtDict, cfgDict, epicsDict |
References
- Psana User Manual - Old
- Psana Reference Manual - Old
- psana - Module Examples
- Migration from pyana to psana
- psana - Migration from pyana
...