You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Data access example

from psana import DataSource
ds = DataSource(exp='tmoc00318',run=10, dir='/cds/data/psdm/prj/public01/xtc')
orun = next(ds.runs())
det = orun.Detector('epix100')
for evt orun.events():
    o = det.raw

Direct methods of the detector interface 

Hidden for AMI mask methods

For implementation of AMI most of the area detector interface methods are hidden - name starts with underscore "_".

In scripts these methods can be used directly:

DTYPE_MASK = np.uint8
mask = o._mask_default(dtype=DTYPE_MASK)
mask = o._mask_calib()
mask = o._mask_calib_or_default(dtype=DTYPE_MASK)
mask = o._mask_from_status(status_bits=0xffff, gain_range_inds=(0,1,2,3,4), dtype=DTYPE_MASK, **kwa) # gain_range_inds for appropriate detectors
mask = o._mask_neighbors(mask, rad=9, ptrn='r')
mask = o._mask_edges(width=0, edge_rows=1, edge_cols=1, dtype=DTYPE_MASK, **kwa)
mask = o._mask_center(wcenter=0, center_rows=1, center_cols=1, dtype=DTYPE_MASK, **kwa)
mask = o._mask(status=True, status_bits=0xffff, gain_range_inds=(0,1,2,3,4),\
               neighbors=False, rad=3, ptrn='r',\
               edges=True, width=0, edge_rows=10, edge_cols=5,\
               center=True, wcenter=0, center_rows=5, center_cols=3,\
               calib=False,\
               umask=None)

Use mask in methods calib and image

kwa = {'status':True, 'status_bits':0xffff, 'gain_range_inds':(0,1,2,3,4),\
       'neighbors=False, 'rad':3, 'ptrn':'r',\
       'edges':True, 'width':0, 'edge_rows':10, 'edge_cols':5,\
       'center':True, 'wcenter':0, 'center_rows':5, 'center_cols':3,\
       'calib':False,\
       'umask':None,\
       'force_update':False}

a = o.calib(evt, cmpars=(7,2,100,10), **kwa)
a = o.image(evt, nda=None, **kwa)

Cumulative mask example

epix10ka_raw_calib_image mask -e ueddaq02 -d epixquad -r211 -o fig-ueddaq02-r211-epixquad-mask.png -P

umask = np.ones((4, 352, 384), dtype=np.uint8)
umask[3,100:120,160:200] = 0

mask = det.raw._mask(status=True, status_bits=0xffff, gain_range_inds=(0,1,2,3,4),\
                     neighbors=True, rad=5, ptrn='r',\
                     edges=True, edge_rows=10, edge_cols=5,\
                     center=True, center_rows=5, center_cols=3,\
                     calib=False,\
                     umask=umask,\
                     force_update=False)
mask += 1 # for visibility of the mask 0 and 1 relative to image background

Class Mask

Alternative usage of mask methods is implemented in class Mask. Class Mask is a wrapper of hidden for AMI mask methods, which can be used to set dedicated mask parameters separately from all other detector interface optional parameters.

Instantiation of the Mask object and access methods

At instantiation of class Mask object, passed parameters used to evaluate requested mask and cache it in det._mask_ property.

from psana.detector.mask import Mask, DTYPE_MASK

m = Mask(det,\
         status=True, status_bits=0xffff, gain_range_inds=(0,1,2,3,4),\
         neighbors=True, rad=5, ptrn='r',\
         edges=True, width=0, edge_rows=10, edge_cols=5,\
         center=True, wcenter=0, center_rows=5, center_cols=3,\
         calib=True,\
         umask=test_umask(det),\
         force_update=False)

m = Mask(det) # minimal version of the Mask object instantiation.

# All other methods are shotcuts to det._mask* methods w/o "_"
m = Mask(det)
m.set_mask(**kwa) # forced update of cached mask, **kwa - the same list of keyword arguments as in class Mask w/o det.
mask = m.mask(**kwa) # returns cached mask, **kwa - the same list of keyword arguments as in class Mask w/o det.
mask = m.mask_default()
mask = m.mask_calib_or_default() # if available returns mask from "pixel_mask" calibration type, otherwise array of ones. 
mask = m.mask_from_status(status_bits=0xffff, gain_range_inds=(0,1,2,3,4), dtype=DTYPE_MASK)
mask = m.mask_edges(width=0, edge_rows=1, edge_cols=1, dtype=DTYPE_MASK)
mask = m.mask_center(wcenter=0, center_rows=1, center_cols=1, dtype=DTYPE_MASK)
mask = m.mask_neighbors(mask, rad=9, ptrn='r')

References

  • No labels