Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
./print_event_id.py
     1: XtcEventId(run=366, time=2013-04-21 04:37:39.343773772-07, fiducials=38877, ticks=329342, vector=19553)
     2: XtcEventId(run=366, time=2013-04-21 04:37:39.360457259-07, fiducials=38883, ticks=331442, vector=19554)
     3: XtcEventId(run=366, time=2013-04-21 04:37:39.377123777-07, fiducials=38889, ticks=330560, vector=19555)
     4: XtcEventId(run=366, time=2013-04-21 04:37:39.393797466-07, fiducials=38895, ticks=329762, vector=19556)
     5: XtcEventId(run=366, time=2013-04-21 04:37:39.410477971-07, fiducials=38901, ticks=331204, vector=19557)
     6: XtcEventId(run=366, time=2013-04-21 04:37:39.427145705-07, fiducials=38907, ticks=331036, vector=19558)
     7: XtcEventId(run=366, time=2013-04-21 04:37:39.443816588-07, fiducials=38913, ticks=329370, vector=19559)
     8: XtcEventId(run=366, time=2013-04-21 04:37:39.460499778-07, fiducials=38919, ticks=331414, vector=19560)
     9: XtcEventId(run=366, time=2013-04-21 04:37:39.477167658-07, fiducials=38925, ticks=330616, vector=19561)
    10: XtcEventId(run=366, time=2013-04-21 04:37:39.493840079-07, fiducials=38931, ticks=329720, vector=19562)
    ...

Printing a catalog of event components

...

The sample can be run like this:

Code Block

./print_event_keys.py

Components of the first event found in the dataset:
  EventKey(type=psana.EvrData.DataV3, src='DetInfo(NoDetector.0:Evr.0)')
  EventKey(type=psana.Acqiris.DataDescV1,         src='DetInfo(SxrEndstation.0:Acqiris.0)')
  EventKey(type=psana.Acqiris.DataDescV1,         src='DetInfo(SxrEndstation.0:Acqiris.1)')
  EventKey(type=psana.Bld.BldDataEBeamV3,         src='BldInfo(EBeam)')
  EventKey(type=psana.Bld.BldDataPhaseCavity,     src='BldInfo(PhaseCavity)')
  EventKey(type=psana.Bld.BldDataFEEGasDetEnergy, src='BldInfo(FEEGasDetEnergy)')
  EventKey(type=psana.Bld.BldDataGMDV1,           src='BldInfo(GMD)')
  EventKey(type=psana.EventId)
  EventKey(type=None)

Why it's so important to know this information? Because these parameters will tell you:

...

The above shown output will translate into the following getters (similar to the one which is used in the very first example extracting event identifiers):

Code Block


obj = evt.get( psana.EvrData.DataV3,             psana.Source('DetInfo(NoDetector.0:Evr.0)'))
obj = evt.get( psana.Acqiris.DataDescV1,         psana.Source('DetInfo(SxrEndstation.0:Acqiris.0)'))
obj = evt.get( psana.Acqiris.DataDescV1,         psana.Source('DetInfo(SxrEndstation.0:Acqiris.1)'))
obj = evt.get( psana.Bld.BldDataEBeamV3,         psana.Source('BldInfo(EBeam)'))
obj = evt.get( psana.Bld.BldDataPhaseCavity,     psana.Source('BldInfo(PhaseCavity)'))
obj = evt.get( psana.Bld.BldDataFEEGasDetEnergy, psana.Source('BldInfo(FEEGasDetEnergy)'))
obj = evt.get( psana.Bld.BldDataGMDV1,           psana.Source('BldInfo(GMD)'))
obj = evt.get( psana.EventId)

Note that event components obtained through this API will be objects of various classes. A full catalog of those objects can be found in the Reference Manual DOXYGEN documentation which is auto-generated from the code of the OFFLINE releases.

4. Instrument-specific examples

...

Iterating over scans and events

Some of our experiments (in particular XPP) are heavily relying on so called scans (also known as "Calibration Transitions*) while taking their data. Each DAQ run has one or many scans. Events are recorded in a scope of a scan. The new framework has a special provision for scans through the iterator of scans. The idea begin the following example is:

  • open a data set which has multiple scans in each run
  • iterate over scans
  • iterate over events in each scan

This simple application knows about scan boundaries. More over, this example illustrates how to open a data set composed of many runs (processing a series of runs at once). There are two examples in this set:

Code Block


./scans_in_runs_xtc.py
./scans_in_runs_hdf.py

They both do the same. The only subtle difference is which data format they're suing. The first example will read XTC files, while the second one will read HDF5 files. When running these examples you should notice differences in their performance. They're explained by different organization of data in XTC vs HDF5 formats. We'll be happy to provide you with an explanation if you'll be interested in it.

4. Instrument-specific examples

This section includes a number of examples which are relevant for different instruments. Their primary meaning is to illustrate how to access data objects which are

XCS: movie

The code of examples is found at:

Code Block

/reg/g/psdm/tutorials/xcs/princeton_movie/

SXR: correlation plots for signals from GDM and Diode

The code of examples is found at:

Code Block

/reg/g/psdm/tutorials/sxr/gmd_vs_diode/

CXI: diffraction patterns on the CSPad detector

The code of examples is found at:

Code Block

/reg/g/psdm/tutorials/cxi/cspad_imaging/

5 Doing something less trivial

Custom HDF5 translator written by a user

A problem:

  • Let's suppose we need to write a data extraction tool to extract images (CSPad, Princeton, etc) from XTC files and make then available for further analysis in Matlab. At this point we should already know how to get images from the raw files using ipsana. Now the only remaining problem is to store them in some form which may be readable from Matlab (assuming we're looking at some reasonable performance).

Perhaps the best way to solve the problem would be to store those images in an HDF5 file using some library. And this is what this example offers. It uses the PyTables package to dump numpy arrays into an out put files. This package is known for its simple API which doesn't require a user to learn the low-level library h5py.

The code of example is found at:

Code Block

/reg/g/psdm/tutorials/common/hdf5_translator/