Page History
...
- 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(...).
- By default mask is used in common mode correction, but it is not applied to data in det.raw.calib(...)
Mask conversion from image to ndarray
API
Examples of conversion image-like 2-d mask to data-like 3-d ndarray
Code Block | ||
---|---|---|
| ||
from psana.detector.UtilsMask import *
m = convert_mask2d_to_ndarray_using_pixel_coord_indexes(mask2d, ix, iy)
m = convert_mask2d_to_ndarray_using_geo(mask2d, geo, **kwargs) # kwargs passed to geo.get_pixel_coord_indexes(**kwargs)
m = convert_mask2d_to_ndarray_using_geometry_file(mask2d, gfname, **kwargs) # kwargs passed to geo.get_pixel_coord_indexes(**kwargs) |
See for detail UtilsMask.py
CLI
roicon -h
Code Block | ||||
---|---|---|---|---|
| ||||
(ps-4.5.26) [dubrovin@psanagpu110:~/LCLS/con-lcls2]$ roicon -h
usage:
1) Construct 2-d image (or mask-of-segments) from ndarray with image shaped as data using appropriate geometry file
roicon 1 -g <geometry-file> [-a (input)<ndarray-shaped-as-data-fname>] [-i <image-(output)file>] [-c <control-bitword>]
ex1: roicon 1 -g <geometry-fname>
ex2: roicon 1 -g <geometry-fname> -a <ndarray-shaped-as-data-fname>
test: roicon 1 -g /cds/group/psdm/detector/data_test/geometry/geo-epix10ka2m-16-segment.data -i test-2d-mask.npy -t
2) (TBD) Create ROI mask using mask editor "med" (DO NOT FORGET to save mask in file!)
roicon 2 [-i <image-(input)file>] [-m <roi-mask-(output)file>]
ex1,2: roicon 2
ex3: roicon 2 -i image.npy -m roi-mask.npy
3) Convert ROI mask to ndarray with mask shaped as data
roicon 3 -g <geometry-file> [-m <roi-mask-(input)file>] [-n ndarray-with-mask-(output)-file] [-c <control-bitword>]
ex1,2: roicon 3 -g <geometry-fname>
test: roicon 3 -g /cds/group/psdm/detector/data_test/geometry/geo-epix10ka2m-16-segment.data -m test-2d-mask.npy -n test-3d-mask.npy
Conversion between 2-d and 3-d masks.
positional arguments:
args process number: 1-construct image, 2-run mask editor on image, 3-convert image mask to ndarray; default = 1
optional arguments:
-h, --help show this help message and exit
-g GFNAME, --gfname GFNAME
geometry file name, default = <geometry-fname>
-a AFNAME, --afname AFNAME
input ndarray file name, default = None
-i IFNAME, --ifname IFNAME
image file name, default = mask-img.txt
-m MFNAME, --mfname MFNAME
ROI mask file name, default = mask-roi.txt
-n NFNAME, --nfname NFNAME
ndarray mask file name, default = mask-nda.txt
-c CBITS, --cbits CBITS
mask control bits, =0-none, +1-edges, +2-middle, etc..., default = 65535
-v, --verb verbosity, default = False
-t, --dotest add a couple of rings to the 2-d mask for test purpose, default = False
-S, --save save plots, default = False
-o DIRREPO, --dirrepo DIRREPO
repository for logs and output files, default = ./work
-L LOGMODE, --logmode LOGMODE
logging mode, one of CRITICAL FATAL ERROR WARN WARNING INFO DEBUG NOTSET TRACE, default = INFO
-k KWARGS, --kwargs KWARGS
str python code evaluated to dict and passed to geo.get_pixel_coord_indexes(**kwargs), default = {}
(ps-4.5.26) [dubrovin@psanagpu110:~/LCLS/con-lcls2]$ |
Test commands and plots
Code Block | ||
---|---|---|
| ||
roicon 1 -g /cds/group/psdm/detector/data_test/geometry/geo-epix10ka2m-16-segment.data -i test-2d-mask.npy -t -S
roicon 2 ... runs Mask Editor - TBD
roicon 3 -g /cds/group/psdm/detector/data_test/geometry/geo-epix10ka2m-16-segment.data -m test-2d-mask.npy -n test-3d-mask.npy -S |
Content of the files
- test-2d-mask.npy shape:(1641, 1639), generated for geo-epix10ka2m-16-segment.data with a couple of artificially added rings
- test-3d-mask.npy (16, 352, 384) reshaped to 2d shape:(16*352, 384)
References
Overview
Content Tools