Page History
...
At instantiation of class Mask object, passed parameters used to evaluate combined mask and cache it in det._mask_ property. If this property is None - mask is re-evaluated. Currently default combined mask is evaluated for status only: status=True, neighbors=False, edges=False, center=False, calib=False, umask=None.
Code Block |
---|
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, dtype=DTYPE_MASK) m = Mask(det) # minimal version. |
...
Code Block |
---|
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') |
Implementation notes
- 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 defined as m = Mask(det) and property det._mask_ is cached for combined/cumulative mask retrieved by the method mask=m.mask().
- Method m.set_mask(**kwa) or its equivalent mask = m.mask(force_update=True, ...) can be used to update cached mask, if necessary.
- Method m.mask(...) applies mask_neighbors after mask_from_status only. It this is not enough, mask needs to be constructed using separate m.mask_*(...) methods.
- Most of methods mask = m.mask_*(...) do not cache intermediate results and consume time for specific mask evaluation. To optimize computing time in analysis it would be wise to evaluate mask once per run only.
- Module psana.detector.UtilsMask contains useful methods for manual mask building, for example merge_masks(...).
References
Overview
Content Tools