Page History
Include Page | ||||
---|---|---|---|---|
|
Table of Contents |
---|
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.
PlotSpectralArrayFromFile.py
- allows to plot content of the spectral array as a 2-d plot.SpectralArray.py
- provides access to the spectral array stored in the file. Theclass SpectralArray
defined in this script is used in thePlotSpectralArrayFromFile.py
.
MergeArrays.py
- sums the arrays from different files defined in the list and saves resulting array in a single file with the same shape. In this script the list of files is hardwired in theget_list_of_input_file_names()
method. The output file name,out_fname
, is also hardwired in the call tospectra_merging(out_fname)
.
A few auxiliary scripts for example are located in the directory ImgAlgos/data
:
psana.cfg
- set non-default parameters to runpsana
forImgAlgos::ImgPeakFinder
andImgAlgos::ImgPeakFilter
Thepsana
running this script saves images and peaks for event 115 in text files.PlotCameraImageFromFile.py
- Plots image and spectrum for image saved in file.PlotCameraImageAndPeaks.py
- Plots image with found peaks and spectrum.
Example for Package ImgPixSpectra
Modules:
- ImgPixSpectra::CSPadPixSpectra
- ImgPixSpectra::MiniCSPadPixSpectra
- ImgPixSpectra::CameraPixSpectra
Configuration file example for MiniCSPadPixSpectra
:
Code Block |
---|
[psana]
files = /reg/d/psdm/<instrument>/<experiment>/<file-name>.xtc
modules = ImgPixSpectra.MiniCSPadPixSpectra
[ImgPixSpectra.MiniCSPadPixSpectra]
source = CxiSc1.0:Cspad2x2.0
amin = 500.
amax = 1000.
nbins = 100
arr_fname = mini-cspad-pix-spectra.txt
|
To get images from saved file one may execute the auxiliary script:
Code Block |
---|
ImgPixSpectra/data/PlotSpectralArrayFromFile.py mini-cspad-pix-spectra.txt
|
generates image for limited range of pixels for CSPad, MiniCSPad, or Camera, respectively:
Examples for Package ImgAlgos
See Package ImgAlgos
Example for Module ImgAlgos::ImgPeakFinder
See Module ImgAlgos::ImgPeakFinder
Configuration file example:
Code Block |
---|
[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:
- raw image,
- 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,
- smeared image,
- raw image with found peaks (marked by the red circles)
- zoom of the previous plot.
Example for Module ImgAlgos::CSPadArrAverage
See Module ImgAlgos::CSPadArrAverage
Configuration file example for evaluation of pedestals:
Code Block |
---|
[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 |
---|
[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 |
---|
[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::ImgRadialCorrection
See Module ImgAlgos::ImgRadialCorrection
Code Block |
---|
[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 \
CSPadPixCoords.CSPadImageGetTest: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
#key = bkgd_subtracted_arr
imgkey = current_img
runNumber = 22
#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
[CSPadPixCoords.CSPadImageGetTest: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: