Versions Compared

Key

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

Include Page
PSDM:Psana Module Examples
PSDM:Psana Module Examples

Table of Contents

This page provides examples for selected modules from Psana Module Catalog. Only the modules that are included in the standard analysis releases appear on this page.

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. The class SpectralArray defined in this script is used in the PlotSpectralArrayFromFile.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 the get_list_of_input_file_names() method. The output file name, out_fname, is also hardwired in the call to spectra_merging(out_fname).

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

  • psana.cfg - set non-default parameters to run psana for ImgAlgos::ImgPeakFinder and ImgAlgos::ImgPeakFilter
    The psana 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

The command for 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:
Image RemovedImage Removed Image Removed

Examples for Package ImgAlgos

Example for Module ImgAlgos::ImgPeakFinder

  • 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:
Image RemovedImage RemovedImage RemovedImage RemovedImage Removed

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

Example of the configuration file 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

Example of the configuration file for evaluation of background:

Code Block

[psana]
modules = cspad_mod.CsPadCalib ImgAlgos.CSPadArrAverage
files   = <path-to-the-background-run-file>.xtc
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:
Image RemovedImage Removed

Example for Module ImgAlgos::CSPadBkgdSubtract

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:
Image RemovedImage Removed
Image RemovedImage Removed

Other event with better subtracted background:
Image RemovedImage Removed

Example for Module ImgAlgos::ImgRadialCorrection

Calibrated image and spectrum:
Image RemovedImage Removed

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

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