Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 19

...

Code Block
bgColor#F7F7ED
# 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, drawn by different colors:

Image Added

Image Removed  Image RemovedImage Added

 

Example for module ImgAlgos::AcqirisAverage

...

Code Block
bgColors#AAFFFF
# 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

#======EOF======

With this script psana runs over 1000 events

...

Example for module ImgAlgos::AcqirisCalib

See description of parameters in Module ImgAlgos::AcqirisCalib

Configuration file psana

...

-amo01509-r0125-

...

acqiris-

...

calib.cfg:

...

 
Code Block
bgColors

 

 

  • Example for module ImgAlgos::AcqirisCalib

  • See description of parameters in Module ImgAlgos::AcqirisCalib
  • Configuration file psana-amo01509-r0125-acqiris-calib.cfg:
Code Block
bgColors#AAFFFF
# 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

This script produces files for raw and calibrated (subrtacted baseline) waveforms:

  • acq-AmoETOF-wform-raw-r0125-e00000005-20091018-182512.194787218.txt
  • acq-AmoETOF-wform-calibrated-r0125-e00000005-20091018-182512.194787218.txt

which can be plotted as:

Image RemovedImage Removed

Noise is slightly reduced in case of calibrated waveforms...


#======EOF======

 

 

 

 

 

 

 

 

 

Example for module ImgAlgos::ImgAverage

See Module ImgAlgos::ImgAverage

The ImgAverage module can be used for evaluation of averaged pedestals or background using dedicated runs. Typical configuration file may looks like this:

Code Block
bgColor

...

#F7F7ED
[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

Example for module ImgAlgos::ImgMaskEvaluation

See Module ImgAlgos::ImgMaskEvaluation

Configuration parameters for psana:

Code Block
bgColor#F7F7ED
[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
Note

...

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

Typical image:

Plots for fraction of noisy pixels:

Plots for fraction of saturated pixels:

Masks: noisy, saturated, and combined:

Example for module ImgAlgos::ImgCalib

See Module ImgAlgos::ImgCalib

Code Block
bgColor#F7F7ED
[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

Example of the mask file and resulting image:

Example for module ImgAlgos::ImgRadialCorrection

See Module ImgAlgos::ImgRadialCorrection

Code Block
bgColor#F7F7ED
[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

Note: the option of the background subtraction (ImgAlgos.CSPadBkgdSubtract) is commented out in this configuration file . In order to evoke this option, the comment sign (#) should be removed from the list of modules and the key=bkgd_subtracted_arr should be used in CSPadPixCoords.CSPadImageProducer.

Calibrated image and spectrum:

Calibrated and radial-corrected image, spectrum, and subtracted r-phi65 distribution for n_phi_bins=65:

Calibrated and radial-corrected image, spectrum, and subtracted r-phi12 distribution for n_phi_bins=12:

Example for module ImgAlgos::ImgPeakFinder

See Module ImgAlgos::ImgPeakFinder

Configuration file example:

Code Block
bgColor#F7F7ED
[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
  • This algorithm consumes ~15 ms/event on psana0101 for full Opal1000 (1024x1024) camera image.
  • Smearing algorithm use a "safety margin" which is currently set to 10 pixels (offset from each boarder of the full image size).

Image on different stages of this algorithm:

  1. raw image,
  2. image in the window with amplitudes above the threshold_low
    • few peaks at the edges were discarded by the window limits,
    • image still contains many 1-photon pixels, which need to be eliminated,
  3. smeared image,
  4. raw image with found peaks (marked by the red circles)
  5. zoom of the previous plot.

Example for module ImgAlgos::ImgPeakFilter

Code Block
bgColor#F7F7ED
[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

Example for module ImgAlgos::ImgPeakFinderAB

See Module ImgAlgos::ImgPeakFinderAB

Configuration file example:

Code Block
bgColor#F7F7ED
[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

Results:

Example for module ImgAlgos::ImgHitFinder

See Module ImgAlgos::ImgHitFinder

ImgHitFinder in regular mode needs in file with pedestals (offset) to correct the image and file with threshold.
In amo74213 run 93 these files can be obtained directly from data, discarding signal hits as outliers using
ImgAlgos.ImgAverage module as follows with configuration file:

Code Block
bgColor#F7F7ED
# 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

Run psana using command:

Code Block
bgColor#F7F7ED
psana -c psana-amo74213-r0093-opal-img-average.cfg

At the end of this procedure two files will be created:

  • img-ave-for-peds-r0093.dat - may be used for pedestal subtraction:
    Image Modified Image Modified
  • img-rms-for-thre-r0093.dat - may be used multiplied by number of rms as a threshold:
    Image Modified Image Modified

The file with accumulated pixel hits can be obtained using configuration file:

Code Block
bgColor#F7F7ED
# 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

and run it by the command:

Code Block
bgColor#F7F7ED
psana -c psana-amo74213-r0093-opal-img-hit-finder.cfg

Which creates the file: img-sum-result-r0093.dat for thre_mode = 2 and thre_mode = 3, respectively:

Example for module ImgAlgos::ImgSpectra

See Module ImgAlgos::ImgSpectra
Configuration file for psana:

Code Block
bgColor#F7F7ED
[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

This script can be used in order to produce text files with image and spectral array:

or graphics for several images:

Example for module ImgAlgos::ImgSpectraProc

See Module ImgAlgos::ImgSpectraProc
Configuration file for psana:

Code Block
bgColor#F7F7ED
[ImgAlgos.ImgSpectraProc] 
source          = DetInfo(:Opal1000)
key_in          = spectra
print_bits      =  15

For each event it prints something similar to:

Code Block
bgColor#F7F7ED
[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...

Example for module ImgAlgos::ImgSaveInFile

Code Block
bgColor#F7F7ED
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

See Module ImgAlgos::ImgSaveInFile

Example for module ImgPeakFinder and ImgPeakFilter for CSPad

Module ImgAlgos::ImgPeakFinder works on image. In order to apply this algorithm to CSPad the image should be produced. In next example the image is produced using consequtive modules cspad_mod.CsPadCalib, ImgAlgos.CSPadMaskApply, and CSPadPixCoords.CSPadImageProducer:

Code Block
bgColor#F7F7ED
[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

Example for module ImgAlgos::CSPadArrAverage

See Module ImgAlgos::CSPadArrAverage

Configuration file example for evaluation of pedestals:

Code Block
bgColor#F7F7ED
[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

Configuration file example for evaluation of background:

Code Block
bgColor#F7F7ED
[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

Images of the CSPad arrays for averaged and rms values, respectively, in one of the CXI runs:

Example for module ImgAlgos::CSPadBkgdSubtract

See Module ImgAlgos::CSPadBkgdSubtract

Code Block
bgColor#F7F7ED
[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

The file with the background array, bkgd_fname, was obtained by averaging 1000 events using module CSPadArrAverage. Subtraction is done with normalization for norm_sector=0.
Event image and pixel amplitude spectrum before and after the background subtraction are shown in plots:

Other event with better subtracted background:

Example for Module ImgAlgos::CSPadMaskApply

See Module ImgAlgos::CSPadMaskApply

The array for mask contains zeros and ones for masked and passed pixels, respectively, and has a shape of full-size CSPad array 4*8*185388.
For example, it can be generated by the command

Code Block
bgColor#F7F7ED
./MakePixelMask.py <input-background-cspad-arr-file-name> <threshold> <output-file-name> 

for the averaged background amplitude array <input-background-cspad-arr-file-name> abtained as a result of ImgAlgos::CSPadArrAverage module.

Plots show the averaged background, and the mask arrays generated from this background for three thresholds 10, 20, and 30 EDU:

The best results in filtering can be achieved in combination of modiles:

Code Block
bgColor#F7F7ED
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

where

  • cspad_mod.CsPadCalib - subtracts the pedestals from raw CSPad data,
  • ImgAlgos.CSPadBkgdSubtract - subtracts the background,
  • ImgAlgos.CSPadMaskApply - apply the mask.

In the test with images for background represented by the water and solvent rings this filter provides the background suppression factor about 100.
The background images that still pass this filter have significantly larger intensity with respect to averaged background:

Input parameter mask_control_bits allows to control masking regions of 2x1. For example, if all edges need to be masked, then use mask_control_bits = 15, which gives image array like:

where red regions/lines of pixels of amplitude=8 are masked.

Example for module ImgAlgos::CSPadArrNoise

See Module ImgAlgos::CSPadArrNoise

Code Block
bgColor#F7F7ED
[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

Index map in median algorithm for rmin=3, dr=1:

Code Block
bgColor#F7F7ED
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

Pixel status (fraction of events where S/N > SoNThr):

For cspad-cxi49012-r0020 with parameters from confguration file (frac_noisy_imgs=0.15) we get, depending on number of events:

Nnoisy, Ntotal, Nnoisy/Ntotal pixels =94585 2296960 0.041 for 10 events
Nnoisy, Ntotal, Nnoisy/Ntotal pixels =2112 2296960 0.00092 for 100 events

Pixel mask for noisy pixels with |S/N| > SoNThr:

Example for Module ImgAlgos::CSPadArrPeakFinder

See Module ImgAlgos::CSPadArrPeakFinder::CSPadArrPeakFinder

Code Block
bgColor#F7F7ED
[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

Results:

Code Block
bgColor#F7F7ED
[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

Selected events

ev-007713:

ev-008944:

Example for module ImgAlgos::CSPadArrPeakAnalysis

See Module ImgAlgos::CSPadArrPeakAnalysis

Example of the psana configuration file:

Code Block
bgColor#F7F7ED
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

After execution in psana the file.root containing histogram(s) and ntuple(s) will be produced. Then, auxiliary script in root, running by the commend
root -q -f proc.C
produces the plots with histograms:

Example for TimeStampFilter and XtcOutputModule

This example demonstrates how to run psana with the time stamp filter and event writer in xtc file.
Both modules are available in psana library and they need only to be described in the configuration file. For example, the configuration file tstamp-filter-and-event-writer.cfg may looks like:

Code Block
bgColor#F7F7ED
[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

Command to run psana is:
psana -c ./tstamp-filter-and-event-writer.cfg
For this configuration file psana will skip 10 events and loop over the next 100 events from the /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s0*-c00.xtc files and run consecutively modules = ImgAlgos.TimeStampFilter PSXtcOutput.XtcOutputModule. Parameters of these modules are described in the bottom part of the configuration file. Module TimeStampFilter passes events from the specified time interval and prints some useful information. Module XtcOutputModule will write passed events in the file with auto-generated name ./test_out/e158-r0021.xtcf.

See also: Module ImgAlgos::TimeStampFilter and PSXtcOutput::PSXtcOutput

Examples for Package py_img_algos

Package py_img_algos contains python modules which work with both frameworks pyana and psana.
Configuration file for pyana and/or psana should have relevant sections with parameters for [pyana] and/or [psana]. Alean section is ignored in each framework at run time. This is the only difference between two frameworks in the configuration file. All module descriptions are the same for two frameworks, as shown in examples below.

See description of modules in Package py_img_algos.

Example of configuration file for CSPAD

File py-xcs72913-r0049-cspad.cfg:

Code Block
bgColor#AAFFFF
# 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

To run this script use command

psana -c py-xcs72913-r0049-cspad.cfg

or

pyana -c py-xcs72913-r0049-cspad.cfg

Example of configuration file for CSPAD2x2

File py-meca6113-r0028-cspad2x2.cfg

Code Block
bgColor#AAFFFF
# 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

To run this script use command

psana -c py-meca6113-r0028-cspad2x2.cfg

or

pyana -c py-meca6113-r0028-cspad2x2.cfg

References

 

 

 

 

 

 

 

 

 

Example for module ImgAlgos::ImgAverage

See Module ImgAlgos::ImgAverage

The ImgAverage module can be used for evaluation of averaged pedestals or background using dedicated runs. Typical configuration file may looks like this:

...

background using dedicated runs. Typical configuration file may looks like this:

Code Block
bgColor#F7F7ED
[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

Example for module ImgAlgos::ImgMaskEvaluation

See Module ImgAlgos::ImgMaskEvaluation

Configuration parameters for psana:

Code Block
bgColor#F7F7ED
[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

...

Note

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

Typical image:

Plots for fraction of noisy pixels:

Plots for fraction of saturated pixels:

Masks: noisy, saturated, and combined:

Example for module ImgAlgos::ImgCalib

See Module ImgAlgos::ImgCalib

Code Block
bgColor#F7F7ED
[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

Example of the mask file and resulting image:

Example for module ImgAlgos::ImgRadialCorrection

See Module ImgAlgos::ImgRadialCorrection

Code Block
bgColor#F7F7ED
[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

Note: the option of the background subtraction (ImgAlgos.CSPadBkgdSubtract) is commented out in this configuration file . In order to evoke this option, the comment sign (#) should be removed from the list of modules and the key=bkgd_subtracted_arr should be used in CSPadPixCoords.CSPadImageProducer.

Calibrated image and spectrum:

Calibrated and radial-corrected image, spectrum, and subtracted r-phi65 distribution for n_phi_bins=65:

Calibrated and radial-corrected image, spectrum, and subtracted r-phi12 distribution for n_phi_bins=12:

Example for module ImgAlgos::ImgPeakFinder

See Module ImgAlgos::ImgPeakFinder

Configuration file example:

Code Block
bgColor#F7F7ED
[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
  • This algorithm consumes ~15 ms/event on psana0101 for full Opal1000 (1024x1024) camera image.
  • Smearing algorithm use a "safety margin" which is currently set to 10 pixels (offset from each boarder of the full image size).

Image on different stages of this algorithm:

  1. raw image,
  2. image in the window with amplitudes above the threshold_low
    • few peaks at the edges were discarded by the window limits,
    • image still contains many 1-photon pixels, which need to be eliminated,
  3. smeared image,
  4. raw image with found peaks (marked by the red circles)
  5. zoom of the previous plot.

Example for module ImgAlgos::ImgPeakFilter

Code Block
bgColor#F7F7ED
[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

Example for module ImgAlgos::ImgPeakFinderAB

See Module ImgAlgos::ImgPeakFinderAB

Configuration file example:

Code Block
bgColor#F7F7ED
[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

Results:

Example for module ImgAlgos::ImgHitFinder

See Module ImgAlgos::ImgHitFinder

ImgHitFinder in regular mode needs in file with pedestals (offset) to correct the image and file with threshold.
In amo74213 run 93 these files can be obtained directly from data, discarding signal hits as outliers using
ImgAlgos.ImgAverage module as follows with configuration file:

Code Block
bgColor#F7F7ED
# 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

Run psana using command:

Code Block
bgColor#F7F7ED
psana -c psana-amo74213-r0093-opal-img-average.cfg

At the end of this procedure two files will be created:

  • img-ave-for-peds-r0093.dat - may be used for pedestal subtraction:
    Image Modified Image Modified
  • img-rms-for-thre-r0093.dat - may be used multiplied by number of rms as a threshold:
    Image Modified Image Modified

The file with accumulated pixel hits can be obtained using configuration file:

Code Block
bgColor#F7F7ED
# 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

and run it by the command:

Code Block
bgColor#F7F7ED
psana -c psana-amo74213-r0093-opal-img-hit-finder.cfg

Which creates the file: img-sum-result-r0093.dat for thre_mode = 2 and thre_mode = 3, respectively:

Example for module ImgAlgos::ImgSpectra

See Module ImgAlgos::ImgSpectra
Configuration file for psana:

Code Block
bgColor#F7F7ED
[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

This script can be used in order to produce text files with image and spectral array:

or graphics for several images:

Example for module ImgAlgos::ImgSpectraProc

See Module ImgAlgos::ImgSpectraProc
Configuration file for psana:

Code Block
bgColor#F7F7ED
[ImgAlgos.ImgSpectraProc

...

] 
source          = DetInfo(:Opal1000)
key_in          = spectra
print_bits      =  15

For each event it prints something similar to:

Code Block
bgColor#F7F7ED
[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...

Example for module ImgAlgos::ImgSaveInFile

Code Block
bgColor#F7F7ED
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

See Module ImgAlgos::ImgSaveInFile

Example for module ImgPeakFinder and ImgPeakFilter for CSPad

Module ImgAlgos::ImgPeakFinder works on image. In order to apply this algorithm to CSPad the image should be produced. In next example the image is produced using consequtive modules cspad_mod.CsPadCalib, ImgAlgos.CSPadMaskApply, and CSPadPixCoords.CSPadImageProducer:

Code Block
bgColor#F7F7ED
[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

Example for module ImgAlgos::CSPadArrAverage

See Module ImgAlgos::CSPadArrAverage

Configuration file example for evaluation of pedestals:

Code Block
bgColor#F7F7ED
[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

Configuration file example for evaluation of background:

Code Block
bgColor#F7F7ED
[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

Images of the CSPad arrays for averaged and rms values, respectively, in one of the CXI runs:

Example for module ImgAlgos::CSPadBkgdSubtract

See Module ImgAlgos::CSPadBkgdSubtract

Code Block
bgColor#F7F7ED
[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

The file with the background array, bkgd_fname, was obtained by averaging 1000 events using module CSPadArrAverage. Subtraction is done with normalization for norm_sector=0.
Event image and pixel amplitude spectrum before and after the background subtraction are shown in plots:

Other event with better subtracted background:

Example for Module ImgAlgos::CSPadMaskApply

See Module ImgAlgos::CSPadMaskApply

The array for mask contains zeros and ones for masked and passed pixels, respectively, and has a shape of full-size CSPad array 4*8*185388.
For example, it can be generated by the command

Code Block
bgColor#F7F7ED
./MakePixelMask.py <input-background-cspad-arr-file-name> <threshold> <output-file-name> 

for the averaged background amplitude array <input-background-cspad-arr-file-name> abtained as a result of ImgAlgos::CSPadArrAverage module.

Plots show the averaged background, and the mask arrays generated from this background for three thresholds 10, 20, and 30 EDU:

The best results in filtering can be achieved in combination of modiles:

Code Block
bgColor#F7F7ED
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

where

  • cspad_mod.CsPadCalib - subtracts the pedestals from raw CSPad data,
  • ImgAlgos.CSPadBkgdSubtract - subtracts the background,
  • ImgAlgos.CSPadMaskApply - apply the mask.

In the test with images for background represented by the water and solvent rings this filter provides the background suppression factor about 100.
The background images that still pass this filter have significantly larger intensity with respect to averaged background:

Input parameter mask_control_bits allows to control masking regions of 2x1. For example, if all edges need to be masked, then use mask_control_bits = 15, which gives image array like:

where red regions/lines of pixels of amplitude=8 are masked.

Example for module ImgAlgos::CSPadArrNoise

See Module ImgAlgos::CSPadArrNoise

Code Block
bgColor#F7F7ED
[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

Index map in median algorithm for rmin=3, dr=1:

Code Block
bgColor#F7F7ED
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

Pixel status (fraction of events where S/N > SoNThr):

For cspad-cxi49012-r0020 with parameters from confguration file (frac_noisy_imgs=0.15) we get, depending on number of events:

Nnoisy, Ntotal, Nnoisy/Ntotal pixels =94585 2296960 0.041 for 10 events
Nnoisy, Ntotal, Nnoisy/Ntotal pixels =2112 2296960 0.00092 for 100 events

Pixel mask for noisy pixels with |S/N| > SoNThr:

Example for Module ImgAlgos::CSPadArrPeakFinder

See Module ImgAlgos::CSPadArrPeakFinder

Code Block
bgColor#F7F7ED
[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

Results:

Code Block
bgColor#F7F7ED
[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

Selected events

ev-007713:

ev-008944:

Example for module ImgAlgos::CSPadArrPeakAnalysis

See Module ImgAlgos::CSPadArrPeakAnalysis

Example of the psana configuration file:

Code Block
bgColor#F7F7ED
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

After execution in psana the file.root containing histogram(s) and ntuple(s) will be produced. Then, auxiliary script in root, running by the commend
root -q -f proc.C
produces the plots with histograms:

Example for TimeStampFilter and XtcOutputModule

This example demonstrates how to run psana with the time stamp filter and event writer in xtc file.
Both modules are available in psana library and they need only to be described in the configuration file. For example, the configuration file tstamp-filter-and-event-writer.cfg may looks like:

...

tstamp-filter-and-event-writer.cfg may looks like:

Code Block
bgColor#F7F7ED
[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

Command to run psana is:
psana -c ./tstamp-filter-and-event-writer.cfg
For this configuration file psana will skip 10 events and loop over the next 100 events from the /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s0*-c00.xtc files and run consecutively modules = ImgAlgos.TimeStampFilter PSXtcOutput.XtcOutputModule. Parameters of these modules are described in the bottom part of the configuration file. Module TimeStampFilter passes events from the specified time interval and prints some useful information. Module XtcOutputModule will write passed events in the file with auto-generated name ./test_out/e158-r0021.xtcf.

See also: Module ImgAlgos::TimeStampFilter and PSXtcOutput::PSXtcOutput

Examples for Package py_img_algos

Package py_img_algos contains python modules which work with both frameworks pyana and psana.
Configuration file for pyana and/or psana should have relevant sections with parameters for [pyana] and/or [psana]. Alean section is ignored in each framework at run time. This is the only difference between two frameworks in the configuration file. All module descriptions are the same for two frameworks, as shown in examples below.

See description of modules in Package py_img_algos.

Example of configuration file for CSPAD

File py-xcs72913-r0049-cspad.cfg:

Code Block
bgColor#AAFFFF
# 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

To run this script use command

psana -c py-xcs72913-r0049-cspad.cfg

or

pyana -c py-xcs72913-r0049-cspad.cfg

Example of configuration file for CSPAD2x2

File py-meca6113-r0028-cspad2x2.cfg

Code Block
bgColor#AAFFFF
# 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

To run this script use command

psana -c py-meca6113-r0028-cspad2x2.cfg

or

pyana -c py-meca6113-r0028-cspad2x2.cfg

References