Content
Quick Start
These commands setup the psana environment, get the code, analyze 5 events with 2 separate hit finders in the equator/arc regions, display the found hits, and save the resulting hit information to a "small-data" text file (similar to cheetah):
ssh -X pslogin.slac.stanford.edu ssh -X psana source /reg/g/psdm/etc/ana_env.sh cp -r /reg/g/psdm/tutorials/cxi/cxif5315 . cd cxif5315 python psana-cxif5315-r0169-cspad-ds2-NDArrDropletFinder.py
This command reads the resulting small-data text file and can select specific events for reanalysis. The name of the txt file changes for different runs, so insert the name of your .txt file in the work/ subdirectory:
python readSmallData.py exp=cxif5315:run=169 work/PutNameOfYourTxtFileHere.txt
This same script can also read cheetah-produced text files, and only analyze specific events
Data
- exp=cxif5315:run=147, 198 - dark
- exp=cxif5315:run=162 - water sample
- exp=cxif5315:run=169 - data sample
- Detector: CxiDs2.0:Cspad.0
Calibration files
Use my local calibration store
[psana] calib-dir = /reg/neh/home1/dubrovin/LCLS/rel-mengning/calib
Dark files were obtained and deployed using Calibration Management Tool
exp=cxif5315:run=147 dark average, rms, and average difference between runs 147-198:
Difference of average dark images between runs 147-198 is small, 0.3 ADU, difference rms=0.6 ADU, this proves that CxiDs2.0:Cspad.0 is stable during 50 runs.
Image array averaging
Image array averaging is useful procedure for many purpose;
- for dark,
- for background,
- for statistics of good/bad pixels and associated mask, etc.
1) Download configuration file psana-cxif5315-cspad-ds2-NDArrAverage.cfg
2) To get average/rms/max over 10000 events data of run 169 use command:
psana -c psana-cxif5315-cspad-ds2-NDArrAverage.cfg -n 1000 exp=cxif5315:run=169
This command produces files with arrays of size (32x185x388)
- cspad-ndarr-ave-cxif5315-r0169.dat
- cspad-ndarr-rms-cxif5315-r0169.dat
- cspad-ndarr-max-cxif5315-r0169.dat
3) To get average/rms/max over 1000 events (skipping 5000) data for water sample of run 162 use command:
psana -c psana-cxif5315-cspad-ds2-NDArrAverage.cfg -s 5000 -n 1000 exp=cxif5315:run=162
This command produces files with arrays of size (32x185x388)
- cspad-ndarr-ave-cxif5315-r0162.dat - file for averaged background
- cspad-ndarr-rms-cxif5315-r0162.dat
- cspad-ndarr-max-cxif5315-r0162.dat
Geometry alignment
In accordance with CSPAD Alignment, use geometry file:
/reg/g/psdm/detector/alignment/cspad/calib-cxi-ds2-2015-01-20/calib/CsPad::CalibV1/CxiDs2.0:Cspad.0/geometry/1-end.data
and array with image from file: cspad-ndarr-ave-cxif5315-r0169.dat
Apparently, this geometry file had wrong indexes associated with quads (cable swap) that gives misaligned 2x1s in quads. This problem should be fixed in the file
/reg/g/psdm/detector/alignment/cspad/calib-cxi-ds2-2015-01-20/calib/CsPad::CalibV1/CxiDs2.0:Cspad.0/geometry/geo-cxif5315-r0169-swap-tuned.data
Tuning of geometry can be done with Detector alignment tool running command:
geo -i cspad-ndarr-ave-cxif5315-r0169.dat -g geo-cxif5315-r0169-swap-tuned.data
Thus obtained geo-cxif5315-r0169-swap-tuned.data gives image, radial, and spectral histograms for averaged array:
or see image array with maximal intensities by the command
geo -i cspad-ndarr-max-cxif5315-r0169.dat -g geo-cxif5315-r0169-swap-tuned.data
looks like: ,
and similar for water background from run 162:
ROI Masks
Using image array in cspad-ndarr-max-cxif5315-r0169.dat and geometry file geo-cxif5315-r0169-swap-tuned.data, one can generate masks using the Mask Editor embedded in Calibration Manager.
Run command calibman
, select tab ROI
and performing all steps of the mask creation procedure, one can draw ROI on image, create the mask for this image, convert this mask to ndarray, and use this ndarray for data processing. This ndarray can be used later for image reconstruction with the same geometry file.
For data processing of exp=cxif5315:run=169 two masks were produced for arc and equatorial regions:
Files with mask ndarray for arc and equator regions:
Peak finder
Who is doing what
Peak finding algorithm is based on psana module ImgAlgos::NDArrDropletFinder with preceded CSPAD ndarray producer CSPadPixCoords::CSPadNDArrProducer and its calibration ImgAlgos::NDArrCalib. Detector geometry information is provided by the module ImgAlgos::PixCoordsProducer. Configuration file psana-cxif5315-r0169-cspad-ds2-NDArrDropletFinder.cfg (download) defines parameters for these modules. Two instances of modules are used in order to process two region of interests for Arc and Equator.
For each event psana modules are executed first and save the list of found peaks in the event store. Then, python script psana-cxif5315-r0169-cspad-ds2-NDArrDropletFinder.py (download) works with lists of peaks, performs additional selection, plots image with peaks, and saves selected peaks in the file.
Latest version of packages
On 2015-04-16:
Release ana-0.14.2
is up to date.
Until ana-current
is ana-0.14.1
, one has to use sit_setup
script with release tag parameter:
sit_setup ana-0.14.2
External files
In order to run examples create directory with some arbitrary name my_analysis
and work
directory in it:
mkdir my_analysis mkdir my_analysis/work cd my_analysis sit_setup ana-0.14.2
Download files in my_analysis
directory:
- configuration file for ndarray averaging psana-cxif5315-cspad-ds2-NDArrAverage.cfg (download )
- configuration file for droplet(peak) finder psana-cxif5315-r0169-cspad-ds2-NDArrDropletFinder.cfg (download)
- python script for droplet(peak) finder for droplet(peak) finderpsana-cxif5315-r0169-cspad-ds2-NDArrDropletFinder.py (download)
Configuration script expects a few files in the local directory work/
; two files with masks and file with a shape of background needs to be downloaded in the my_analysis/work directory:
In the local or standard calib/
directory the files for calibration should be available for geometry, pedestals, pixel_status, common_mode
etc., whatever is going to be used in the modules.
How to run
Use command:
python psana-cxif5315-r0169-cspad-ds2-NDArrDropletFinder.py
Example: get table of peaks for different regions
Image with peaks for separate and both regions can be plotted:
File with table of parameters for found peaks has an unique name like work/peaks-2015-04-14-15:57:44-cxif5315-r0169.txt
and contains records with peak parameters:
# Exp Run Event Date Time time(sec) time(nsec) fiduc Reg Seg Row Col Amax Atot Npix X(um) Y(um) cxif5315 169 3 2015-02-22 02:20:47 1424600447 503058551 104427 equ 1 145 27 165.8 2970.8 70 -224 9450 cxif5315 169 3 2015-02-22 02:20:47 1424600447 503058551 104427 equ 17 155 47 164.0 3130.3 58 506 -9674 cxif5315 169 7 2015-02-22 02:20:47 1424600447 536405573 104439 arc 8 10 20 500.9 10085.8 74 -48264 1186 cxif5315 169 7 2015-02-22 02:20:47 1424600447 536405573 104439 equ 1 161 13 483.6 3238.8 56 1318 7695 cxif5315 169 7 2015-02-22 02:20:47 1424600447 536405573 104439 equ 16 152 8 191.7 3393.9 74 -3801 -32359 cxif5315 169 7 2015-02-22 02:20:47 1424600447 536405573 104439 equ 17 30 69 295.3 2644.8 50 2903 -23418 cxif5315 169 7 2015-02-22 02:20:47 1424600447 536405573 104439 equ 17 167 48 153.0 2723.5 59 618 -8355 cxif5315 169 7 2015-02-22 02:20:47 1424600447 536405573 104439 equ 17 171 32 283.2 3447.1 59 -1139 -7913 cxif5315 169 8 2015-02-22 02:20:47 1424600447 544737897 104442 equ 17 168 47 201.7 2797.8 54 508 -8245 cxif5315 169 12 2015-02-22 02:20:47 1424600447 578091436 104454 equ 1 152 27 159.8 2374.2 58 -222 8681 cxif5315 169 14 2015-02-22 02:20:47 1424600447 594757102 104460 equ 1 153 29 160.8 3308.4 62 -442 8571 ...
The 1st line in this file is a (commented) header with colon-titles.
Remarks
- Peak finder parameters - all parameters in the peak finder are set without optimization. They need to be tuned in two places;
- in the configuration file for two modules
ImgAlgos.NDArrDropletFinder(:Arc/:Equ)
, and - in the python script in calls of
peaks_filter(...)
method.
- in the configuration file for two modules
- ROI for peakfinder is defined by combination of two mechanisms;
- mask - ndarray with values 1/0. Pixels masked by "0", are ignored.
- a set of rectangular windows on sensors, defined by the parameter windows in module ImgAlgos::NDArrDropletFinder.
- Peak finder parameters need to be optimized!
Example: optimization of peak parameters
Selection parameters
Selection of peaks and events is defined in few stages, as listed below.
1. Peak selection parameters in module ImgAlgos.NDArrDropletFinder:
[ImgAlgos.NDArrDropletFinder:Arc] ... threshold_low = 10 threshold_high = 150 peak_radius = 3 ...
2. Peak list selection parameters:
nda_peaks_arc = peaks_filter(nda_droplets_arc, atot_thr=2000, npix_thr=20, npeaks_min=1, npeaks_max=10)
3. Peak/event selection parameters at peak-list file readout
def peakIsSelected() : """Apply peak selection criteria to each peak from file """ amax, atot, npix, x, y, r, phi = sp.amax, sp.atot, sp.npix, sp.x, sp.y, sp.r, sp.phi if amax<150 : return False if atot<2500 : return False if npix<30 : return False if r<434 : return False if r>444 : return False if phi<150 and phi>-150 : return False return True
Parameter | Sel.1 (rpeak5) | Sel.2 (rpeak7) | Sel.3 (rpeak3) |
---|---|---|---|
in module NDArrDropletFinder:Arc | |||
threshold_low | 10 | 10 | 10 |
threshold_high | 100 | 100 | 150 |
peak_radius | 5 | 7 | 3 |
in method peaks_filter(...) | |||
atot_thr | 2000 | 2000 | 2000 |
npix_thr | 20 | 30 | 20 |
npeaks_min | 1 | 1 | 1 |
npeaks_max | 10 | 20 | 10 |
Save selected peaks in file | |||
Process peaks from file | |||
amax | 150 | 150 | 150 |
atot | 2500 | 2500 | 2500 |
npix | 30 | 40 | 20 |
rmin | 434 | 434 | 434 |
rmax | 444 | 444 | 444 |
phi | <-150 & >150 | <-150 & >150 | <-150 & >150 |
Sel.1 (rpeak=5):
Sel.2 (rpeak=7):
Sel.3 (rpeak=3):
References