This note describes area detector interface methods to access raw and calibrated data, reconstruct image for mutli-panel detector, retrieve calibration constants, geometry parameters, define the mask for pixel array, etc.
Set environment
Code discussed in this note works on psana nodes which have access to data in lcls2 environment described in LCLS-II psana Environment.
To run examples one has to ssh to psana node and set environment
Code Block |
---|
title | Login to psana node and set lcls2 environment on pcds |
---|
collapse | true |
---|
|
ssh -Y pslogin.slac.stanford.edu
ssh -Y psana
source /cds/sw/ds/ana/conda1/manage/bin/psconda.sh |
Code Block |
---|
title | Login to psana node and set lcls2 environment on s3df |
---|
|
ssh -Y s3dflogin.slac.stanford.edu
ssh -Y psana
source /sdf/group/lcls/ds/ana/sw/conda1/manage/bin/psconda.sh |
Code examples
Most truthful updated description of this interface is on git : in the head of the file detector/areadetector.py
Create DataSource, Run, and Detector objects
...
Code Block |
---|
kwa = <dict-of-mask-parameters>
a = o.calib(evt, cmpars=(7,2,100,10), **kwa)
a = o.image(evt, nda=None, **kwa) |
...
# reduced shape for available segment only
a = o.image(evt, nda=None, value_for_missing_segments=800, **kwa) # full image including missing segments |
Calibration constants
All detector calibration constants (np.array) and associated metadata (dict) are available through the dictionary det.calibconst with calibration type as a key. For example:
...
Possible calibration types: pedestals, pixel_status, pixel_rms, pixel_gain, pixel_mask,
etc.
Other useful area detector methods
Mask
See for details Area detector mask examples.
Code Block |
---|
title | Instantiation of the Mask object |
---|
|
from psana.detector.mask import Mask, DTYPE_MASK
kwa = {'status':True, 'status_bits':0xffff, 'stextra_bits':(1<<64)-1, 'gain_range_inds':(0,1,2,3,4),\
'neighbors':False, 'rad':3, 'ptrn':'r',\
'edges':False, 'width':0, 'edge_rows':10, 'edge_cols':5,\
'center':False, 'wcenter':0, 'center_rows':5, 'center_cols':3,\
'calib':False,\
'umask':None,\
'force_update':False, 'dtype':DTYPE_MASK}
m = Mask(det, **kwa)
m = Mask(det) # minimal version. |
Code Block |
---|
title | Combined and separate mask methods |
---|
|
m.set_mask(**kwa) # forced update of cached mask.
mask = m.mask(**kwa) # returns cached mask.
mask = m.mask_default |
Code Block |
---|
# access calibration constants and derived arrays
peds = o._pedestals()
gain = o._gain() # ADU/keV
gfac = o._gain_factor() # keV/ADU
rms = o._rms()
status = o._status()
mask = o._mask_default(dtype=DTYPE_MASK)
mask = o._mask_calib()
mask = om._mask_calib_or_default(dtype=DTYPE_MASK)) # if available returns mask from "pixel_mask" calibration type, otherwise array of ones.
mask = om._mask_from_status(status_bits=0xffff, stextra_bits:(1<<64)-1, gain_range_inds=(0,1,2,3,4), dtype=DTYPE_MASK, **kwa)
mask = om._mask_neighbors(mask, rad=9, ptrn='r')
mask = o._mask_edges(width=0, edge_rows=1, edge_cols=1, dtype=DTYPE_MASK, **kwa)
mask = om._mask_center(wcenter=0, center_rows=1, center_cols=1, dtype=DTYPE_MASK, **kwa)
mask = om._mask(status=True, status_bits=0xffff, gain_range_inds=(0,1,2,3,4)\
neighbors=False, rad=3_neighbors(mask, rad=9, ptrn='r',\
edges) |
- default combined mask parameters (status=True,
...
- neighbors=False, edges=False, center=False, calib=False, umask=None) are set to define mask for pixel_status only.
- mask is used in det.raw.calib/image mask at evaluation of common mode correction, but by default it is not applied to data.
- to apply mask to data use multiplication calib *= mask.
Other useful area detector methods
Code Block |
---|
# direct access to calibration constants and derived arrays
peds = o._pedestals()
gain = o._gain() # ADU/keV
gfac = o._gain_factor() # keV/ADU
rms = o._rms()
status = o._status(0, edge_rows=10, edge_cols=5,\
center=True, wcenter=0, center_rows=5, center_cols=3,\
calib=False,\
umask=None,\
force_update=False)
arrx, arry, arrz = o._pixel_coords(do_tilt=True, cframe=0)
indx, indy, indz = o._pixel_coord_indexes(pix_scale_size_um=None, xy0_off_pix=None, do_tilt=True, cframe=0)
# array of the common mode increment
incr = o._common_mode_increment(evt, cmpars=(0,7,100,10)) |
References