Versions Compared

Key

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

...

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

Auxiliary scripts

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

...

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

See Module CSPadPixCoords::CSPadNDArrProducer

Example of the module CSPadNDArrProducer working in sequence with ImgAlgos::NDArrAverage is shown in Example for module ImgAlgos::NDArrAverage 

...

This script makes ndarrays for two cspad2x2 detectors and use them evaluate average, rms, mask and hot pixel arrays.

See Module CSPadPixCoords::CSPad2x2NDArrProducer

Example for module CSPadPixCoords::CSPad2x2ImageProducer

See Module CSPadPixCoords::CSPad2x2ImageProducer

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

...

Example for package ImgPixSpectra

See Package ImgPixSpectra

Modules:

  • ImgPixSpectra::CSPadPixSpectra
  • ImgPixSpectra::CSPad2x2PixSpectra
  • ImgPixSpectra::CameraPixSpectra

...

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

...

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

...

Examples for package ImgAlgos

See Package ImgAlgos

Example for module ImgAlgos::Tahometer

See Module ImgAlgos::Tahometer

Example of the psana configuration file:

...

Example for module ImgAlgos::PnccdImageProducer

See Module ImgAlgos::PnccdImageProducer

Example of the psana configuration file:

...

Example for module ImgAlgos::CameraImageProducer

See Module ImgAlgos::CameraImageProducer

Example of the psana configuration file:

...

Example for module ImgAlgos::PrincetonImageProducer

See Module ImgAlgos::PrincetonImageProducer

Example of the psana configuration file:

...

See description of parameters in Module ImgAlgos::AcqirisArrProducer

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

...

See description of parameters in Module ImgAlgos::AcqirisAverage

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

...

See description of parameters in Module ImgAlgos::AcqirisCalib

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

...

See description of parameters in Module ImgAlgos::AcqirisCFD

Configuration file psana_cfd.cfg:

...

See description of parameters in Modules ImgAlgos::AcqirisArrProducer, AcqirisAverage, and AcqirisCalib

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

...

Example for module ImgAlgos::NDArrAverage

  • See Module ImgAlgos::NDArrAverage andModule CSPadPixCoords::CSPadNDArrProducer
  • The NDArrAverage module in combination with CSPadNDArrProducer (or any other device NDArrProducer) can be used for evaluation of averaged pedestals or background using dedicated runs.
    Typical configuration file may looks like this:

    No Format
    # Run this script:
    # psana -c psana-meca1113-r0045-cspad-cspad-dark-hotpix.cfg
    
    [psana]
    files = exp=meca1113:run=45
    events = 400
    #skip-events = 0
    
    modules = CSPadPixCoords.CSPadNDArrProducer \
              ImgAlgos.NDArrAverage \
              ImgAlgos.Tahometer
    
    
    [CSPadPixCoords.CSPadNDArrProducer]
    source       = MecTargetChamber.0:Cspad.0
    inkey        = 
    outkey       = cspad_ndarr
    outtype      = int16
    is_fullsize  = yes
    print_bits   = 3
    
    
    [ImgAlgos.NDArrAverage]
    source       = MecTargetChamber.0:Cspad.0
    key          = cspad_ndarr
    avefile      = cspad.0-ave
    rmsfile      = cspad.0-rms
    maskfile     = cspad.0-msk
    hotpixfile   = cspad.0-hot
    thr_rms_ADU  = 10
    thr_min_ADU  = 4
    thr_max_ADU  = 10000
    print_bits   = 29
    #evts_stage1  = 100
    #gate_width1  = 500.
    #evts_stage2  = 200
    #gate_width2  = 100.
    
    
    [ImgAlgos.Tahometer]
    dn         = 100
    print_bits = 7
  • Module ImgAlgos.Tahometer is not required in this configuration file and is added for convenience to print timing statistics for this job.
  • Evaluation of average intensity in 2 or 3 stages using gate-based algorithms excludes out-layers in intensity spectra and makes average more stable and reliable. However, the gate width is not an universal parameter. In order to set this parameter one has to look at spectrum of averaged intensities for particular device.  The same is valid for evaluation of hot/bad pixel masks. One has to plot spectra of averaged intensity and rms values. Averaged intensity and rms spectra for exp=meca1113:run=45 are shown on plots, respectively:

...

Example for module ImgAlgos::NDArrCalib

  • See  Module ImgAlgos::NDArrCalibModule ImgAlgos::NDArrAverage
  • The NDArrCalib module in combination with PnccdNDArrProducer (or any other device NDArrProducer) can be used for evaluation of averaged pedestals or background using dedicated runs.
    Typical configuration file may looks like this:

Code Block
[psana]                                                               
files = exp=amoa1214:run=7
#skip-events = 100
events      = 5

modules = ImgAlgos.Tahometer \
          ImgAlgos.PnccdNDArrProducer \
          ImgAlgos.NDArrCalib \
          ImgAlgos.PnccdImageProducer \
          ImgAlgos.ImgSaveInFile
#         ImgAlgos.NDArrAverage \


[ImgAlgos.PnccdNDArrProducer]
source        = DetInfo(Camp.0:pnCCD.0)
key_in  =
key_out = pnccd-ndarr
outtype = asdata
print_bits = 13


[ImgAlgos.NDArrCalib] 
source = DetInfo(Camp.0:pnCCD.0) 
key_in = pnccd-ndarr 
key_out = calibrated 
do_peds = yes
do_cmod = yes
do_stat = no
do_mask = no
do_bkgd = no
do_gain = no 
do_nrms = no
do_thre = no
fname_mask = 
fname_bkgd = 
fname_rms  =  
masked_value     =    0
threshold_nrms   =    03 
threshold        =  100
below_thre_value =   50 0
bkgd_ind_min     =    0
bkgd_ind_max     = 1000
bkgd_ind_inc     =   10
print_bits       =  255 


[ImgAlgos.PnccdImageProducer]
source        = DetInfo(Camp.0:pnCCD.0)
#inkey         = pnccd-ndarr
inkey         = calibrated
outimgkey     = pnccd-img
gap_size      = 20
gap_value     = 0
print_bits    = 1


[ImgAlgos.ImgSaveInFile]
source        = DetInfo(Camp.0:pnCCD.0)
key           = pnccd-img
fname         = pnccd-img-from-arr
ftype         = txt
saveAll       = true
print_bits    = 31


 
[ImgAlgos.Tahometer]
dn         = 100
print_bits = 7

...

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:

...

Example for module ImgAlgos::ImgMaskEvaluation

...

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 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

...

Example for module ImgAlgos::ImgPeakFinder

See Module ImgAlgos::ImgPeakFinder

Configuration file example:

...

Example for module ImgAlgos::ImgPeakFinderAB

See Module ImgAlgos::ImgPeakFinderAB

Configuration file example:

...

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.

...

Example for module ImgAlgos::ImgSpectra

See Module ImgAlgos::ImgSpectra

Configuration file for psana:

...

Example for module ImgAlgos::ImgSpectraProc

See Module ImgAlgos::ImgSpectraProc

Configuration file for psana:

...

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

...

Example for module ImgAlgos::CSPadArrAverage

See Module ImgAlgos::CSPadArrAverage

Configuration file example for evaluation of pedestals:

...

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.

...

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.

...

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

...

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

...

Example for module ImgAlgos::CSPadArrPeakAnalysis

See Module ImgAlgos::CSPadArrPeakAnalysis

Example of the psana configuration file:

...

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 pyimgalgos

...

See description of modules in Package pyimgalgos.

Example of configuration file for CSPAD

...

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

References

Psana psana - Module Catalog