Versions Compared

Key

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

...

Code Block
languagepython
#!/usr/bin/env python

# these two lines for example purposes only, to allow user to write
# calibration information to local directory called "calib".
# should be deleted for real analysis.
import psana
psana.setOption('psana.calib-dir','calib')

from xtcav.GenerateDarkBackground import *
GDB=GenerateDarkBackground();
GDB.experiment='xpptut15'
GDB.runs='102'
GDB.maxshots=10  #small number for this example, people often use 1000 shots for this.
GDB.SetValidityRange(101,125) # delete second run number argument to have the validity range be open-ended 
("end")
GDB.Generate();

An example of a non-lasing run is in /reg/g/psdm/tutorials/examplePython/xtcav/xtcavLasingOff.py:

Code Block
languagepython
#!/usr/bin/env python

# these two lines for example purposes only, to allow user to write
# calibration information to local directory called "calib".
# should be deleted for real analysis.
import psana
psana.setOption('psana.calib-dir','calib')
 
from xtcav.GenerateLasingOffReference import *
GLOC=GenerateLasingOffReference();
GLOC.experiment='xpptut15'
GLOC.runs='101'
GLOC.maxshots=2  #small number for this example, people often use 1400 shots for this.
GLOC.nb=2
GLOC.islandsplitmethod = 'scipyLabel'       # see confluence documentation for how to set this parameter
GLOC.groupsize=5             # see confluence documentation for how to set this parameter
GLOC.SetValidityRange(101,125) # delete second run number argument to have the validity range be open-ended
 ("end")
GLOC.Generate();

This script can be quite slow.  It can be easily run in parallel by submitting a parallel MPI job to the batch system as described here, however you should change the above script to increase the "maxshots" parameter (so that each core has at least 1 shot to process).  People often use ~1400 shots for this.

...

Code Block
languagepython
import psana

# this line is for example purposes only, to allow user to read
# calibration information from local directory called "calib".
# should be deleted for real analysis.  It also sets a flag
# ("allow-corrupt-epics") that allows the old example data to be analyzed.
psana.setOptions({'psana.calib-dir':'calib',
                  'psana.allow-corrupt-epics':True})

from xtcav.ShotToShotCharacterization import *
experiment='xpptut15'  #Experiment label
runs='124'             #Runs
#Loading the dataset from the "dark" run, this way of working should be compatible with both xtc and hdf5 f
ilesfiles
dataSource=psana.DataSource("exp=%s:run=%s:idx" % (experiment,runs))
#XTCAV Retrieval (setting the data source is useful to get information such as experiment name)
XTCAVRetrieval=ShotToShotCharacterization();
XTCAVRetrieval.SetEnv(dataSource.env())
for r,run in enumerate(dataSource.runs()):
    times = run.times()
    for t in times:
        evt = run.event(t)
        if not XTCAVRetrieval.SetCurrentEvent(evt):
            continue
        time,power,ok=XTCAVRetrieval.XRayPower()  
        agreement,ok=XTCAVRetrieval.ReconstructionAgreement()

...