About

This page provides examples for selected modules from Psana Module Catalog.

Auxiliary scripts

A few python scripts in ImgPixSpectra/data/ show how to process/plot the spectral array stored in the file.

A few auxiliary scripts for example are located in the directory ImgAlgos/data:

Examples for package cspad_mod

Example for module cspad_mod::CsPad2x2Pedestals

Configuration file for pedestals calibration of two CSPAD2x2 simultaneously:

[psana]
files = /reg/d/psdm/xpp/xpptut13/xtc/e308-r0070-s02-c00.xtc \
        /reg/d/psdm/xpp/xpptut13/xtc/e308-r0070-s03-c00.xtc
          
modules = cspad_mod.CsPad2x2Pedestals:0 \
          cspad_mod.CsPad2x2Pedestals:1

#skip-events = 100
#events = 1111

[cspad_mod.CsPad2x2Pedestals:0]
source = DetInfo(XppGon.0:Cspad2x2.0)
output = pedestals-ave-xppi0513-r0070-Cspad2x2.0.dat
noise  = pedestals-rms-xppi0513-r0070-Cspad2x2.0.dat

[cspad_mod.CsPad2x2Pedestals:1]
source = DetInfo(XppGon.0:Cspad2x2.1)
output = pedestals-ave-xppi0513-r0070-Cspad2x2.1.dat
noise  = pedestals-rms-xppi0513-r0070-Cspad2x2.1.dat

Command to run this script:

psana -c psana-xppi0513-r0070-cspad2x2-pedestals.cfg

The xtc file name(s) may be passed as an argument:

psana -c psana-xppi0513-r0070-cspad2x2-pedestals.cfg /reg/d/psdm/xpp/xpptut13/xtc/e308-r0070-*.xtc

Output files contain results, which can be plotted for average values:

and rms values:

Example for package CSPadPixCoords

How to write the CSPad image in text file:

[psana]                                                               
files         = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc
events        = 5

modules       = cspad_mod.CsPadCalib CSPadPixCoords.CSPadImageProducer ImgAlgos.ImgSaveInFile

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no

#[CSPadPixCoords.CSPadInterpolImageProducer]
[CSPadPixCoords.CSPadImageProducer]
calibDir      = /reg/d/psdm/<instrument>/<experiment>/calib
typeGroupName = CsPad::CalibV1
source        = CxiDs1.0:Cspad.0
key           = calibrated
imgkey        = Image2D
tiltIsApplied = true

[ImgAlgos.ImgSaveInFile]
source        = CxiDs1.0:Cspad.0
#eventSave    = 1
saveAll       = true

See Package CSPadPixCoords

Example for module CSPadPixCoords::CSPad2x2ImageProducer

See Module CSPadPixCoords::CSPad2x2ImageProducer

Example of the configuration script for psana (cspad2x2-test.cfg):

[psana]
files         = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc
events        = 5
modules       = CSPadPixCoords.CSPad2x2ImageProducer ImgAlgos.ImgSaveInFile

[CSPadPixCoords.CSPad2x2ImageProducer]
source         = DetInfo(:Cspad2x2)
inkey          = 
outimgkey      = Image
tiltIsApplied  = true
print_bits     = 15

[ImgAlgos.ImgSaveInFile]
source        = DetInfo(:Cspad2x2)
key           = Image
fname         = cspad2x2
saveAll       = true
#eventSave     = 5

Command to run:
psana -c cspad2x2-test.cfg
One of the saved files cspad2x2-<run>-<timestamp>.txt is plotted as an image by the command
./PlotCameraImageFromFile.py cspad2x2-<run>-<timestamp>.txt 0 1200

Configuration file for cspad2x2 with pedestal subtraction

Access to the CSPad2x2 aligned geometry is added on 2013-02-13
and is available for offline release > ana-0.9.1.

Example of <psana-config-file.cfg>:

[psana]
files    = /reg/d/psdm/mec/mec73313/xtc/e268-r0180-s02-c00.xtc
#calib-dir = ./calib

modules  = cspad_mod.CsPadCalib CSPadPixCoords.CSPad2x2ImageProducer ImgAlgos.ImgSaveInFile
events   = 5

[cspad_mod.CsPadCalib]
source        = DetInfo(MecTargetChamber.0:Cspad2x2.3)
inputKey      = 
outputKey     = calibrated_arr
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no


[CSPadPixCoords.CSPad2x2ImageProducer]
calibDir       = /reg/d/psdm/mec/mec73313/calib
typeGroupName  = CsPad2x2::CalibV1
#source        = DetInfo(MecTargetChamber.0:Cspad2x2.3)
source         = :Cspad2x2.3
inkey          = calibrated_arr
outimgkey      = Image
tiltIsApplied  = true
print_bits     = 15


[ImgAlgos.ImgSaveInFile]
source         = DetInfo(MecTargetChamber.0:Cspad2x2.3)
key            = Image
fname          = cspad2x2.3
saveAll        = true
print_bits     = 3
#eventSave     = 5

Example of psana configuration file to get cspad2x2 images for two detectors and save them in files, one in txt, another in tiff formats:

[psana]
files    = /reg/d/psdm/xpp/xpptut13/xtc/e308-r0008-s02-c00.xtc \
           /reg/d/psdm/xpp/xpptut13/xtc/e308-r0008-s03-c00.xtc

#modules = cspad_mod.CsPad2x2Pedestals

#calib-dir = ./calib
calib-dir = /reg/d/psdm/xpp/xpptut13/xtc/calib

modules  = cspad_mod.CsPadCalib:0 \ 
           cspad_mod.CsPadCalib:1 \ 
           CSPadPixCoords.CSPad2x2ImageProducer:0 \
           CSPadPixCoords.CSPad2x2ImageProducer:1 \ 
           ImgAlgos.ImgSaveInFile:0  \
           ImgAlgos.ImgSaveInFile:1

events   = 5

[cspad_mod.CsPadCalib:0]
source        = DetInfo(XppGon.0:Cspad2x2.0)
inputKey      = 
outputKey     = calibrated_arr0
doPedestals   = yes
doPixelStatus = no
doCommonMode  = yes

[cspad_mod.CsPadCalib:1]
source        = DetInfo(XppGon.0:Cspad2x2.1)
inputKey      = 
outputKey     = calibrated_arr1
doPedestals   = yes
doPixelStatus = no
doCommonMode  = yes


[CSPadPixCoords.CSPad2x2ImageProducer:0]
calibDir         = /reg/d/psdm/xpp/xpptut13/xtc/calib
typeGroupName    = CsPad2x2::CalibV1
source           = DetInfo(XppGon.0:Cspad2x2.0)
inkey            = calibrated_arr0
outimgkey        = Image
tiltIsApplied    = false
useWidePixCenter = false
print_bits       = 15

[CSPadPixCoords.CSPad2x2ImageProducer:1]
calibDir         = /reg/d/psdm/xpp/xpptut13/xtc/calib
typeGroupName    = CsPad2x2::CalibV1
source           = DetInfo(XppGon.0:Cspad2x2.1)
inkey            = calibrated_arr1
outimgkey        = Image
tiltIsApplied    = false
useWidePixCenter = false
print_bits       = 15



[ImgAlgos.ImgSaveInFile:0]
source         = DetInfo(:Cspad2x2.0)
key            = Image
fname          = cspad2x2.0
ftype          = txt
#ftype          = tiff
saveAll        = true
print_bits     = 3
#eventSave     = 5

[ImgAlgos.ImgSaveInFile:1]
source         = DetInfo(:Cspad2x2.1)
key            = Image
fname          = cspad2x2.1
#ftype          = txt
ftype          = tiff
saveAll        = true
print_bits     = 3
#eventSave     = 5

Example for package ImgPixSpectra

See Package ImgPixSpectra

Modules:

Example for module ImgPixSpectra::CSPadPixSpectra

See module description in Module ImgPixSpectra::CSPadPixSpectra
Configuration file psana-cxib2313-r0114-cspad-pix-spectra.cfg:

# Command to run this script: 
# psana -c psana-cxib2313-r0114-cspad-pix-spectra.cfg
#
# Other useful commands: 
# psana -n 5 -m  PrintSeparator,PrintEventId,psana_examples.DumpCsPad /reg/d/psdm/cxi/cxib2313/xtc/e336-r0114*
# psana -n 5 -m EventKeys exp=cxib2313:run=114:xtc

[psana]
files      = exp=cxib2313:run=114:xtc
#calib-dir = ./calib
skip-events = 0
events      = 100
modules     = cspad_mod.CsPadCalib ImgPixSpectra.CSPadPixSpectra

[cspad_mod.CsPadCalib]
source        = DetInfo(CxiDs1.0:Cspad.0)
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = yes

[ImgPixSpectra.CSPadPixSpectra]
source        = CxiDs1.0:Cspad.0
inputKey      = calibrated
amin          =   -20.
amax          =    20.
nbins         =    10
arr_fname     = cspad_spectral_array.txt

where module cspad_mod.CsPadCalib subtracts pedestals, apply common mode correction, and save CSPAD array in the event store with key "calibrated", which is used in the next module ImgPixSpectra.CSPadPixSpectra.

To run this script use command

psana -c psana-cxib2313-r0114-cspad-pix-spectra.cfg

which produces two files:

Plot for content of the file cspad_spectral_array.txt:

Example for module ImgPixSpectra::CSPad2x2PixSpectra

See module description in Module ImgPixSpectra::CSPad2x2PixSpectra
Configuration file example for CSPad2x2PixSpectra:

[psana]
files         = /reg/d/psdm/<instrument>/<experiment>/<file-name>.xtc
modules       = ImgPixSpectra.CSPad2x2PixSpectra

[ImgPixSpectra.CSPad2x2PixSpectra]
source        = CxiSc1.0:Cspad2x2.0
amin          =   500.
amax          =  1000.
nbins         =   100
arr_fname     = cspad2x2-pix-spectra.txt

To get images from saved file one may execute the auxiliary script:

ImgPixSpectra/data/PlotSpectralArrayFromFile.py cspad2x2-pix-spectra.txt

generates image for limited range of pixels for CSPad, CSPad2x2, or Camera, respectively:

Examples for package ImgAlgos

See Package ImgAlgos

Example for module ImgAlgos::Tahometer

See Module ImgAlgos::Tahometer

Example of the psana configuration file:

[psana]           
files         = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc\
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-2>.xtc

modules       = ImgAlgos.Tahometer

[ImgAlgos.Tahometer]
dn         = 10
print_bits = 7

Example for module ImgAlgos::PnccdImageProducer

See Module ImgAlgos::PnccdImageProducer

Example of the psana configuration file:

[psana]                                                               
files         = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc\
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-2>.xtc
#skip-events = 100
events      =  5
modules = ImgAlgos.PnccdImageProducer ImgAlgos.ImgSaveInFile

[ImgAlgos.PnccdImageProducer]
source        = DetInfo(:pnCCD)
inkey         =
outimgkey     = imgpnccd
print_bits    = 1

[ImgAlgos.ImgSaveInFile]
source        = DetInfo(:pnCCD)
key           = imgpnccd
fname         = pnccd-img-ev
saveAll       = true
#eventSave     = 82
print_bits    = 1

This script saves text files with images like pnccd-img-ev-<run-date-time.nsec>.txt, which can be presented as:

Example for module ImgAlgos::CameraImageProducer

See Module ImgAlgos::CameraImageProducer

Example of the psana configuration file:

[psana]                                                               
files           = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc
modules         = ImgAlgos.CameraImageProducer ImgAlgos.ImgSaveInFile
events          = 5

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 15

[ImgAlgos.ImgSaveInFile]
source        = DetInfo(:Opal1000)
key           = img
fname         = img-from-my-experiment
saveAll       = true
#eventSave     = 1

This script saves text files with images like img-from-my-experiment-<run-date-time.nsec>.txt, which can be drawn by the python script

./ImgAlgos/data/PlotCameraImageFromFile.py <filename>.txt <Amin> <Amax>

Example for module ImgAlgos::PrincetonImageProducer

See Module ImgAlgos::PrincetonImageProducer

Example of the psana configuration file:

[psana]                                                               
files         = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc\
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-2>.xtc
modules       = ImgAlgos.PrincetonImageProducer \
                ImgAlgos.ImgSaveInFile
events          = 3

[ImgAlgos.PrincetonImageProducer] 
source          = DetInfo(:Princeton)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 31

[ImgAlgos.ImgSaveInFile]
source        = DetInfo(:Princeton)
key           = img
fname         = img-xcs
saveAll       = true
print_bits    = 31

Example for module ImgAlgos::AcqirisArrProducer

See description of parameters in Module ImgAlgos::AcqirisArrProducer

Example of the psana configuration file psana-amo01509-r0125-acqiris.cfg :

# Command to run this script:
# psana -c psana-amo01509-r0125-acqiris.cfg;
#
# Useful commands:
# psana -n 5 -m EventKeys exp=amo01509:run=125:xtc > test-acqiris-file.txt;
# psana -n 5 -m psana_examples.DumpAcqiris exp=amo01509:run=125:xtc > test-acqiris-file.txt;    (C++ version)
# psana -n 1 -m psana_examples.dump_acqiris exp=amo01509:run=125:xtc > test-acqiris-file.txt;   (python version)

[psana]
#files = /reg/d/psdm/AMO/amo01509/xtc/e8-r0125-s00-c00.xtc /reg/d/psdm/AMO/amo01509/xtc/e8-r0125-s01-c00.xtc
files = exp=amo01509:run=125:xtc

modules = ImgAlgos.AcqirisArrProducer ImgAlgos.ImgSaveInFile:wf ImgAlgos.ImgSaveInFile:wt

skip-events = 0
events      = 100


[ImgAlgos.AcqirisArrProducer]
source        = AmoETOF.0:Acqiris.0
key_in        =
key_wform     = acqiris_wform
key_wtime     = acqiris_wtime
fname_prefix  = acq
print_bits    = 11


[ImgAlgos.ImgSaveInFile:wf]
source         = AmoETOF.0:Acqiris.0
key            = acqiris_wform
fname          = acq-AmoETOF-wform
ftype          = txt
#ftype          = tiff
#saveAll        = true
print_bits     = 3
eventSave      = 5


[ImgAlgos.ImgSaveInFile:wt]
source         = AmoETOF.0:Acqiris.0
key            = acqiris_wtime
fname          = acq-AmoETOF-wtime
ftype          = txt
#ftype          = tiff
#saveAll        = true
print_bits     = 3
eventSave      = 5

This script saves text files

Arrays from these files can be plotted for all channels, shown by different colors:

 

 

Example for module ImgAlgos::AcqirisAverage

See description of parameters in Module ImgAlgos::AcqirisAverage

Configuration file psana-amo01509-r0125-acqiris-average.cfg:

# Command to run this script: 
# psana -c psana-amo01509-r0125-acqiris-average.cfg;
#
# Useful commands: 
# psana -n 5 -m EventKeys exp=amo01509:run=125:xtc > test-acqiris-file.txt;
# psana -n 5 -m psana_examples.DumpAcqiris exp=amo01509:run=125:xtc > test-acqiris-file.txt;    (C++ version)
# psana -n 1 -m psana_examples.dump_acqiris exp=amo01509:run=125:xtc > test-acqiris-file.txt;   (python version)

[psana]
#files = /reg/d/psdm/AMO/amo01509/xtc/e8-r0125-s00-c00.xtc /reg/d/psdm/AMO/amo01509/xtc/e8-r0125-s01-c00.xtc
files = exp=amo01509:run=125:xtc

modules = ImgAlgos.AcqirisArrProducer ImgAlgos.AcqirisAverage

skip-events = 0
events      = 1000


[ImgAlgos.AcqirisArrProducer]
source        = AmoETOF.0:Acqiris.0
key_in        = 
key_wform     = acqiris_wform
key_wtime     = acqiris_wtime
fname_prefix  = acq
print_bits    = 3


[ImgAlgos.AcqirisAverage]
source               = AmoETOF.0:Acqiris.0
key_in               = acqiris_wform
key_ave              = acqiris_average
fname_ave_prefix     = acq
thresholds           = 
is_positive_signal   = true
do_inverse_selection = false
#skip_events          = 0
#proc_events          = 100
print_bits           = 255

Psana with this script runs over 1000 events and produces file acq-amo01509-r0125-ave-wfs.txt with averaged array of waveforms:

Example for module ImgAlgos::AcqirisCalib

See description of parameters in Module ImgAlgos::AcqirisCalib

Configuration file psana-amo01509-r0125-acqiris-calib.cfg:

# Command to run this script: 
# psana -c psana-amo01509-r0125-acqiris-calib.cfg;
#
# Useful commands: 
# psana -n 5 -m EventKeys exp=amo01509:run=125:xtc > test-acqiris-file.txt;
# psana -n 5 -m psana_examples.DumpAcqiris exp=amo01509:run=125:xtc > test-acqiris-file.txt;    (C++ version)
# psana -n 1 -m psana_examples.dump_acqiris exp=amo01509:run=125:xtc > test-acqiris-file.txt;   (python version)

[psana]
#files = /reg/d/psdm/AMO/amo01509/xtc/e8-r0125-s00-c00.xtc /reg/d/psdm/AMO/amo01509/xtc/e8-r0125-s01-c00.xtc
files = exp=amo01509:run=125:xtc

modules = ImgAlgos.AcqirisArrProducer ImgAlgos.AcqirisCalib ImgAlgos.ImgSaveInFile:wf_raw ImgAlgos.ImgSaveInFile:wf_calib

skip-events = 0
events      = 10


[ImgAlgos.AcqirisArrProducer]
source        = AmoETOF.0:Acqiris.0
key_in        = 
key_wform     = acqiris_wform
key_wtime     = acqiris_wtime
fname_prefix  = acq
print_bits    = 1


[ImgAlgos.AcqirisCalib]
source               = AmoETOF.0:Acqiris.0
key_in               = acqiris_wform
key_out              = wf-calibrated
fname_base_line      = acq-amo01509-r0125-ave-wfs.txt
#skip_events          = 0
#proc_events          = 100
print_bits           = 255


[ImgAlgos.ImgSaveInFile:wf_raw]
source         = AmoETOF.0:Acqiris.0
key            = acqiris_wform
fname          = acq-AmoETOF-wform-raw
ftype          = txt
#ftype          = tiff
#saveAll        = true
print_bits     = 3
eventSave      = 5


[ImgAlgos.ImgSaveInFile:wf_calib]
source         = AmoETOF.0:Acqiris.0
key            = wf-calibrated
fname          = acq-AmoETOF-wform-calibrated
ftype          = txt
#ftype          = tiff
#saveAll        = true
print_bits     = 3
eventSave      = 5

In this script the base-line level for all waveforms is subtracted in module ImgAlgos.AcqirisCalib.

For example, the raw and calibrated waveforms for event 5 were saved in the files:

 

 

 

 

 

 

 

 

[psana]                                                               
files   = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name>.xtc
modules = ImgAlgos.CameraImageProducer \
          ImgAlgos.ImgAverage
events  = 1000

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 1

[ImgAlgos.ImgAverage] 
source          = DetInfo(:Opal1000)
key             = img
avefile         = img-ave.dat
rmsfile         = img-rms.dat
print_bits      = 31
evts_stage1     = 100
evts_stage2     = 100
gate_width1     = 200
gate_width2     = 20
[ImgAlgos.ImgMaskEvaluation] 
source          = DetInfo(:Opal1000)
key             = img
file_mask_satu	= img-mask-satu.dat
file_mask_nois	= img-mask-nois.dat
file_mask_comb	= img-mask-comb.dat
file_frac_satu	= img-frac-satu.dat
file_frac_nois	= img-frac-nois.dat
thre_satu   	= 400   
frac_satu       = 0
dr              = 1
thre_SoN        = 3
frac_nois       = 0.05
print_bits      = 63

In this example parameters were chosen in order to get a small number of "noisy" pixel just due to statistics.

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 1

[ImgAlgos.ImgCalib] 
source          = DetInfo(:Opal1000)
key_in          = img
key_out         = calibrated
fname_peds      = <pedestal-file-name>
fname_mask      = <mask-file-name>
fname_bkgd      = 
fname_gain      = 
print_bits      = 31
[psana]
files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \
        /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \
        ...
        /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc
skip-events = 500
events      = 10
modules = cspad_mod.CsPadCalib \
#         ImgAlgos.CSPadBkgdSubtract \
          CSPadPixCoords.CSPadImageProducer \
          ImgAlgos.ImgRadialCorrection \
          ImgAlgos.ImgSaveInFile:1
 

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no

[ImgAlgos.CSPadBkgdSubtract]
source        = DetInfo(CxiDs1.0:Cspad.0)
inputKey      = calibrated
outputKey     = bkgd_subtracted_arr
bkgd_fname    = <the-file-name-with-background-array>
norm_sector   = 0
print_bits    = 0

[CSPadPixCoords.CSPadImageProducer]
calibDir      = /reg/d/psdm/<instrument>/<experiment>/calib
typeGroupName = CsPad::CalibV1
source        = CxiDs1.0:Cspad.0
key           = calibrated
imgkey        = current_img
#tiltIsApplied = true

[ImgAlgos.ImgRadialCorrection]
source        = DetInfo(CxiDs1.0:Cspad.0)
inkey         = current_img
outkey        = r_cor_img
xcenter       = 866
ycenter       = 857
rmin          = 100
rmax          = 810
n_phi_bins    = 60
event         = 0
print_bits    = 3

[ImgAlgos.ImgSaveInFile:1]
source        = CxiDs1.0:Cspad.0
key           = r_cor_img
fname         = <file-name-for-image-array>
#saveAll       = true
eventSave     = 8
[psana]                                                               
files         = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \
                /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \
                ...
                /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc

modules       = ImgAlgos.ImgPeakFinder PrintSeparator

#skip-events  = 500
events        = 120

[ImgAlgos.ImgPeakFinder] 
source         = DetInfo(:Opal1000)
key            = 
peaksKey       =  peaks
threshold_low  =  20
threshold_high =  50
sigma          =  1.5
smear_radius   =  2
peak_radius    =  3
xmin           =  200
xmax           =  800
ymin           =  100
ymax           =  900
testEvent      =  115
print_bits     =  0
finderIsOn     =  true
[ImgAlgos.ImgPeakFilter] 
source         = DetInfo(:Opal1000)
key            = peaks
threshold_peak = 5
threshold_total= 0
n_peaks_min    = 10
print_bits     = 11
fname          = img
selection_mode = SELECTION_ON
[psana]                                                               
files   = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name>.xtc
modules = ImgAlgos.CameraImageProducer \
          ImgAlgos.ImgPeakFinderAB
events  = 10

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 1

[ImgAlgos.ImgPeakFinderAB]
source                 = DetInfo(:Opal1000)
key                    = img
key_peaks_out          = peaks
#key_signal_out        = signal-arr
#hot_pix_mask_inp_file = ana-misc-exp/mask.dat
#hot_pix_mask_out_file = noise-mask-out.dat
#frac_noisy_evts_file  = noise-frac-out.dat
evt_file_out           = tmp/img-

rmin                =    10
dr                  =     1
SoNThr_noise        =     3
SoNThr_signal       =     3
frac_noisy_imgs     =   0.9
peak_npix_min       =     3
peak_npix_max       =   100
peak_amp_tot_thr    =     0.
peak_SoN_thr        =     4.
event_npeak_min     =     5
event_npeak_max     =  1000
event_amp_tot_thr   =     0.
nevents_mask_update =     0
nevents_mask_accum  =    50
selection_mode      = SELECTION_ON
out_file_bits       =    15
print_bits          =   513
# File: psana-amo74213-r0093-opal-img-average.cfg

[psana]
#files = /reg/d/psdm/AMO/amo74213/xtc/e269-r0093-s05-c00.xtc
files = exp=amo74213:run=93:xtc

modules = ImgAlgos.CameraImageProducer \
          ImgAlgos.ImgAverage
skip-events = 0
events      = 1000

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 1

[ImgAlgos.ImgAverage] 
source          = DetInfo(:Opal1000)
key             = img
avefile         = img-ave-for-peds
rmsfile         = img-rms-for-thre
evts_stage1     = 100
evts_stage2     = 100
gate_width1     = 50
gate_width2     = 10
print_bits      = 31
psana -c psana-amo74213-r0093-opal-img-average.cfg
# File: psana-amo74213-r0093-opal-img-hit-finder.cfg

[psana]
#files = /reg/d/psdm/AMO/amo74213/xtc/e269-r0093-s05-c00.xtc
files = exp=amo74213:run=93:xtc

modules = ImgAlgos.CameraImageProducer \
          ImgAlgos.ImgHitFinder \
          ImgAlgos.ImgAverage
skip-events = 0
events      = 1000

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 1

[ImgAlgos.ImgHitFinder] 
source           = DetInfo(:Opal1000)
key_in           = img
key_out          = img_hits
fname_peds       = img-ave-for-peds-r0093.dat
fname_mask       = 
fname_gain       = 
fname_thre       = img-rms-for-thre-r0093.dat
masked_value     = 0
thre_mode        = 3
#thre_mode        = 2
thre_param       = 5
thre_below_value = 0
thre_above_value = 1
win_row_min      = 10
win_row_max      = 1000
win_col_min      = 10
win_col_max      = 1000
print_bits       = 39

[ImgAlgos.ImgAverage] 
source          = DetInfo(:Opal1000)
key             = img_hits
sumfile         = img-sum-result
print_bits      = 25
psana -c psana-amo74213-r0093-opal-img-hit-finder.cfg
[psana]                                                               
files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name>.xtc

modules       =  ImgAlgos.CameraImageProducer \
                 ImgAlgos.ImgSpectra \
                 ImgAlgos.ImgSaveInFile:2
#                ImgAlgos.ImgSaveInFile
#                psana_examples.DumpOpal1k \

events          = 100

[ImgAlgos.CameraImageProducer] 
source          = DetInfo(:Opal1000)
key_in          = 
key_out         = img
subtract_offset = true
print_bits      = 1

[ImgAlgos.ImgSpectra] 
source          = DetInfo(:Opal1000)
key_in          = img
key_out         = spectra
sig_band_rowc   = 512.
ref_band_rowc   = 552.
sig_band_tilt   =   0.
ref_band_tilt   =   0.
sig_band_width  =  10 
ref_band_width  =  10 
print_bits      =  3

[ImgAlgos.ImgSpectraProc] 
source          = DetInfo(:Opal1000)
key_in          = spectra
print_bits      =  15

[ImgAlgos.ImgSaveInFile:2]
source        = DetInfo(:Opal1000)
key           = spectra
fname         = spec-xppi0412
saveAll       = true

[ImgAlgos.ImgSaveInFile]
source        = DetInfo(:Opal1000)
key           = img
fname         = img-xppi0412
saveAll       = true
[ImgAlgos.ImgSpectraProc] 
source          = DetInfo(:Opal1000)
key_in          = spectra
print_bits      =  15
[info:ImgAlgos.ImgSpectraProc] Spectral array shape =3, 1024
[info:ImgAlgos.ImgSpectraProc] Image spectra for run=0060 Evt=000100
Column:       0     100     200     300     400     500     600     700     800     900    1000
Signal:    1211    4062   11150   17070   16406   12949    7991    5168    3968    3542    3811
Refer.:     933    3485   10425   17128   17791   13522    8315    5000    3390    2967    3193
Diff. :   0.259   0.153   0.067  -0.003  -0.081  -0.043  -0.040   0.033   0.157   0.177   0.176
[info:ImgAlgos.ImgSpectraProc] Run=0060 Evt=000100 Time=20120507-125420.982421325 done...
modules = ... ImgAlgos.ImgSaveInFile:1 ...

[ImgAlgos.ImgSaveInFile:1]
source         = DetInfo(:Opal1000)   # or CxiDs1.0:Cspad.0
key            = img
fname          = my-img
#ftype          = txt
#ftype          = bin
#ftype          = png
ftype          = tiff
#eventSave     = 5
saveAll        = true
[psana]
files   = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \
          ...
          /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc

events      =  1000
experiment  = cxii0212
calib-dir   = ana-cxii0212/calib

modules = cspad_mod.CsPadCalib \
          ImgAlgos.CSPadMaskApply \
          CSPadPixCoords.CSPadImageProducer \
          ImgAlgos.ImgPeakFinder \
          ImgAlgos.ImgPeakFilter \
          ImgAlgos.ImgSaveInFile:1

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = yes

[ImgAlgos.CSPadMaskApply]
source            = DetInfo(CxiDs1.0:Cspad.0)
inkey             = calibrated
outkey            = masked_arr
mask_fname        = <your-local-directory>/<mask-file-name>.dat
masked_amp        =  0
print_bits        =  5
mask_control_bits = 15

[CSPadPixCoords.CSPadImageProducer]
calibDir       = /reg/d/psdm/<instrument>/<experiment>/calib
typeGroupName  = CsPad::CalibV1
source         = CxiDs1.0:Cspad.0
key            = masked_arr
imgkey         = img
print_bits     =  0
#tiltIsApplied  = true

[ImgAlgos.ImgPeakFinder] 
source         = DetInfo(CxiDs1.0:Cspad.0)
key            = img
peaksKey       = peaks
threshold_low  = 2
threshold_high = 5
sigma          = 1.5
smear_radius   = 5
peak_radius    = 7
xmin           = 20
xmax           = 1700
ymin           = 20
ymax           = 1700
#testEvent      = 5
print_bits     = 3
#finderIsOn     = true

[ImgAlgos.ImgPeakFilter] 
source         = DetInfo(CxiDs1.0:Cspad.0)
key            = peaks
threshold_peak = 5
threshold_total= 0
n_peaks_min    = 10
print_bits     = 11
fname          = cspad-img
selection_mode = SELECTION_ON

[ImgAlgos.ImgSaveInFile:1]
source         = CxiDs1.0:Cspad.0
key            = img
fname          = cspad-img
#eventSave     = 1
saveAll        = true
[psana]
modules = ImgAlgos.CSPadArrAverage
files   = <path-to-the-dark-run-file>.xtc

[ImgAlgos.CSPadArrAverage]
source  = DetInfo(CxiDs1.0:Cspad.0)
key     =
avefile = cspad-pedestals-ave.dat
rmsfile = cspad-pedestals-rms.dat
print_bits  = 15
evts_stage1 = 100
evts_stage2 = 100
gate_width1 = 100
gate_width2 =  10
[psana]
files       = <path-to-the-background-run-file>.xtc
modules     = cspad_mod.CsPadCalib ImgAlgos.CSPadArrAverage
skip-events = 500
events      = 1000000

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no

[ImgAlgos.CSPadArrAverage]
source  = DetInfo(CxiDs1.0:Cspad.0)
key     = calibrated
avefile = cspad-background-ave.dat
rmsfile = cspad-background-rms.dat
print_bits  = 15
[psana]
files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \
        /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \
        ...
        /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc
skip-events = 500
events      = 10
modules     = cspad_mod.CsPadCalib ImgAlgos.CSPadBkgdSubtract

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no


[ImgAlgos.CSPadBkgdSubtract]
source        = DetInfo(CxiDs1.0:Cspad.0)
inputKey      = calibrated
outputKey     = bkgd_subtracted
bkgd_fname    = <the-file-name-with-background-array>
norm_sector   = 0
print_bits    = 3
./MakePixelMask.py <input-background-cspad-arr-file-name> <threshold> <output-file-name> 
modules = cspad_mod.CsPadCalib \
          ImgAlgos.CSPadBkgdSubtract \
          ImgAlgos.CSPadMaskApply \
          ...
[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated_arr
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no

[ImgAlgos.CSPadBkgdSubtract]
source        = DetInfo(CxiDs1.0:Cspad.0)
inputKey      = calibrated_arr
outputKey     = bkgd_subtracted_arr
bkgd_fname    = ana-cxi49012/cspad-cxi49012-r0025-background-ave.dat
norm_sector   = 0
print_bits    = 0

[ImgAlgos.CSPadMaskApply]
source            = DetInfo(CxiDs1.0:Cspad.0)
inkey             = bkgd_subtracted_arr
outkey            = masked_arr
mask_fname        = ana-cxi49012/cspad-cxi49012-r0025-mask-40.dat
masked_amp        =  0
print_bits        =  3
mask_control_bits =  1
[psana]
modules = cspad_mod.CsPadCalib ImgAlgos.CSPadArrNoise

files   = /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s00-c00.xtc \
          /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s01-c00.xtc \
          /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s02-c00.xtc \
          /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s03-c00.xtc \
          /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s04-c00.xtc \
          /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s05-c00.xtc

#skip-events = 1000
events      = 10

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no

[ImgAlgos.CSPadArrNoise]
source          = DetInfo(CxiDs1.0:Cspad.0)
key             = calibrated
statusfile      = ana-cxi49012/cspad-cxi49012-r0020-noise-status.dat
maskfile        = ana-cxi49012/cspad-cxi49012-r0200-noise-mask.dat
print_bits      = 255
rmin            = 3
dr              = 1
SoNThr          = 3
frac_noisy_imgs = 0.15
CSPadArrNoise::printMatrixOfIndexesForMedian():
 0 0 0 0 1 0 0 0 0
 0 0 1 1 1 1 1 0 0
 0 1 0 0 0 0 0 1 0
 0 1 0 0 0 0 0 1 0
 1 1 0 0 + 0 0 1 1
 0 1 0 0 0 0 0 1 0
 0 1 0 0 0 0 0 1 0
 0 0 1 1 1 1 1 0 0
 0 0 0 0 1 0 0 0 0
[psana]
files   = \
   /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s00-c00.xtc \
   /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s01-c00.xtc \
   /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s02-c00.xtc \
   /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s03-c00.xtc \
#   /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s04-c00.xtc \ suddenly it became unavailable...
   /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s05-c00.xtc

#skip-events = 1000
#events      = 200

modules = cspad_mod.CsPadCalib \
          ImgAlgos.CSPadMaskApply \
          ImgAlgos.CSPadArrPeakFinder

[cspad_mod.CsPadCalib]
inputKey      = 
outputKey     = calibrated
doPedestals   = yes
doPixelStatus = no
doCommonMode  = no

[ImgAlgos.CSPadMaskApply]
source            = DetInfo(CxiDs1.0:Cspad.0)
inkey             = calibrated
outkey            = masked_arr
mask_fname        = ana-cxi49012/cspad-cxi49012-r0150-mask-badregs.dat
#mask_fname        = ana-cxi49012/cspad-cxi49012-r0150-mask-bkgd.dat
#mask_fname        = ana-cxi49012/cspad-cxi49012-r0150-mask-rects.dat
masked_amp        =  8
print_bits        =  1
mask_control_bits = 15

[ImgAlgos.CSPadArrPeakFinder]
source            = DetInfo(CxiDs1.0:Cspad.0)
key               = masked_arr
key_peaks_out     = peaks

hot_pix_mask_inp_file = ana-cxi49012/cspad-cxi49012-r0150-noise-mask.dat
hot_pix_mask_out_file = ana-cxi49012/cspad-cxi49012-r0150-noise-mask-out.dat
frac_noisy_evts_file  = ana-cxi49012/cspad-cxi49012-r0150-noise-frac.dat

evt_file_out      = tmp/cspad-ev-

rmin              =     3
dr                =     1
SoNThr            =     3
frac_noisy_imgs   =   0.1

peak_npix_min     =     4
peak_npix_max     =    25
peak_amp_tot_thr  =   100.

event_npeak_min   =    10
event_amp_tot_thr =  1000.

nevents_mask_update = 100
nevents_mask_accum  =  50

selection_mode    = SELECTION_ON
out_file_bits     =    15
print_bits        =    512
[info:TimeInterval::startTime] Start time: 2012-06-12 15:32:02
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 1000  N selected = 55  Fraction of selected = 0.055
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 2000  N selected = 62  Fraction of selected = 0.031
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 3000  N selected = 81  Fraction of selected = 0.027
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 4000  N selected = 95  Fraction of selected = 0.02375
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 5000  N selected = 150  Fraction of selected = 0.03
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 6000  N selected = 265  Fraction of selected = 0.0441667
[info:ImgAlgos.CSPadArrPeakFinder]   N processed events = 7000  N selected = 404  Fraction of selected = 0.0577143
[info:ImgAlgos.CSPadArrPeakFinder] ===== JOB SUMMARY =====
[info:TimeInterval::stopTime] Time to process 7945 events is 3747.48 sec, or 0.471678 sec/event
modules = cspad_mod.CsPadCalib \
          ImgAlgos.CSPadMaskApply \
          ImgAlgos.CSPadArrPeakFinder \
          ImgAlgos.CSPadArrPeakAnalysis

# ...configuration parameters of other modules...

[ImgAlgos.CSPadArrPeakAnalysis]
source             = DetInfo(CxiDs1.0:Cspad.0)
key                = peaks
print_bits         = 7
fname_root         = file.root
[psana]                                                               
files         = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s00-c00.xtc \
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s01-c00.xtc \
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s02-c00.xtc \
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s03-c00.xtc \
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s04-c00.xtc \
                /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s05-c00.xtc

skip-events   = 10
events        = 100
modules       = ImgAlgos.TimeStampFilter  PSXtcOutput.XtcOutputModule 

[PSXtcOutput.XtcOutputModule]
dirName       = ./test_out

[ImgAlgos.TimeStampFilter]
tsinterval    = 2012-02-02 18:17:00.409143728 / 2012-02-02 18:17:00.525853474
filterIsOn    = true
print_bits    = 11
# Run this script:
# psana -c py-xcs72913-r0049-cspad.cfg
# pyana -c py-xcs72913-r0049-cspad.cfg
#
# Useful commands:
# psana -m EventKeys -n 5 /reg/d/psdm/xcs/xcs72913/xtc/e265-r0049-*
# psana -m psana_examples.dump_cspad -n 5 exp=xcs72913:run=49
# pyana -m pyana_examples.dump_cspad -n 5 /reg/d/psdm/xcs/xcs72913/xtc/e265-r0049-*

[pyana]
files  = /reg/d/psdm/xcs/xcs72913/xtc/e265-r0049-s00-c00.xtc /reg/d/psdm/xcs/xcs72913/xtc/e265-r0049-s04-c00.xtc /reg/d/psdm/xcs/xcs72913/xtc/e265-r0049-s05-c00.xtc
num-events = 5
#skip-events = 0
#num-cpu = 1
verbose = 1 ; logging output: 0-nothing?, 1+INFO, 2+DEBUG, ...
modules = py_img_algos.tahometer py_img_algos.cspad_arr_producer py_img_algos.cspad_image_producer py_img_algos.image_save_in_file


[psana]
files = exp=xcs72913:run=49
events = 5                 
#skip-events = 0
modules = py_img_algos.tahometer py_img_algos.cspad_arr_producer py_img_algos.cspad_image_producer py_img_algos.image_save_in_file
verbose = 1 


[py_img_algos.tahometer]
dn         = 10
print_bits = 255


[py_img_algos.cspad_arr_producer]
#source    = -|Cspad-*
source     = XcsEndstation-0|Cspad-0 
data_type  = double
#data_type  = float
#data_type  = unsigned
#data_type  = uint16
val_miss   = 0
key_out    = cspad_array
print_bits = 1


[py_img_algos.cspad_image_producer]
calib_dir  = /reg/d/psdm/xcs/xcs72913/calib/CsPad::CalibV1/XcsEndstation.0:Cspad.0/
key_in     = cspad_array
key_out    = cspad_image
print_bits = 1

# Supported output file formats tiff, gif, png, eps, jpg, jpeg, txt, npy(default), npz
[py_img_algos.image_save_in_file]
key_in     = cspad_image
ofname     = img-for-cspad.txt
print_bits = 255
# Run this script:
# psana -c py-meca6113-r0028-cspad2x2.cfg
# pyana -c py-meca6113-r0028-cspad2x2.cfg
#
# Useful commands:
# psana -m EventKeys -n 5 /reg/d/psdm/mec/meca6113/xtc/e332-r0028-s03-c00.xtc
# psana -m psana_examples.dump_cspad -n 5 exp=meca6113:run=28
# pyana -m pyana_examples.dump_cspad -n 5 /reg/d/psdm/mec/meca6113/xtc/e332-r0028-s03-c00.xtc

[pyana]
files  = /reg/d/psdm/mec/meca6113/xtc/e332-r0028-s03-c00.xtc
num-events = 5
#skip-events = 0
#num-cpu = 1
verbose = 0 ; logging output: 0-nothing?, 1+INFO, 2+DEBUG, ...
modules = py_img_algos.tahometer py_img_algos.cspad_arr_producer py_img_algos.cspad_image_producer py_img_algos.image_save_in_file


[psana]
files = exp=meca6113:run=28
events = 5 
#skip-events = 0
modules = py_img_algos.tahometer py_img_algos.cspad_arr_producer py_img_algos.cspad_image_producer py_img_algos.image_save_in_file


[py_img_algos.tahometer]
dn         = 10
print_bits = 255


[py_img_algos.cspad_arr_producer]
#source    = -|Cspad-*
source     = MecTargetChamber-0|Cspad2x2-3
#data_type  = double
data_type  = float
#data_type  = unsigned
#data_type  = uint16
#data_type  = uint32
val_miss   = 0
key_out    = cspad2x2_array
print_bits = 255


[py_img_algos.cspad_image_producer]
calib_dir  = /reg/d/psdm/mec/meca6113/calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3/
key_in     = cspad2x2_array
key_out    = cspad2x2_image
print_bits = 1

# Supported output file formats tiff, gif, png, eps, jpg, jpeg, txt, npy(default), npz
[py_img_algos.image_save_in_file]
key_in     = cspad2x2_image
ofname     = img-for-cspad2x2.tiff 
print_bits = 255