MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / compute_selected_rois

Function compute_selected_rois

pyxrf/core/map_processing.py:984–1137  ·  view source on GitHub ↗

Compute XRF map based on ROIs for XRF dataset. Parameters ---------- data: da.core.Array, np.ndarray or RawHDF5Dataset (this is a custom type) Raw XRF map represented as Dask array, numpy array or reference to a dataset in HDF5 file. The XRF map must have dimensions

(
    data,
    data_sel_indices,
    roi_dict,
    snip_param=None,
    use_snip=True,
    chunk_pixels=5000,
    n_chunks_min=4,
    progress_bar=None,
    client=None,
)

Source from the content-addressed store, hash-verified

982
983
984def compute_selected_rois(
985 data,
986 data_sel_indices,
987 roi_dict,
988 snip_param=None,
989 use_snip=True,
990 chunk_pixels=5000,
991 n_chunks_min=4,
992 progress_bar=None,
993 client=None,
994):
995 """
996 Compute XRF map based on ROIs for XRF dataset.
997
998 Parameters
999 ----------
1000 data: da.core.Array, np.ndarray or RawHDF5Dataset (this is a custom type)
1001 Raw XRF map represented as Dask array, numpy array or reference to a dataset in
1002 HDF5 file. The XRF map must have dimensions `(ny, nx, ne)`, where `ny` and `nx`
1003 define image size and `ne` is the number of spectrum points
1004 data_sel_indices: tuple
1005 tuple `(n_start, n_end)` which defines the indices along axis 2 of `data` array
1006 that are used for fitting. Note that `ne` (in `data`). Indexes
1007 `n_start .. n_end - 1` will be selected from each pixel.
1008 roi_dict: dict
1009 Dictionary that specifies ROIs for the selected emission lines:
1010 key - emission line, value - tuple (left_val, right_val).
1011 Energy values are in keV.
1012 snip_param: dict
1013 Dictionary of parameters forwarded to 'snip' method for background removal.
1014 Keys: `e_offset`, `e_linear`, `e_quadratic` (parameters of the energy axis approximation),
1015 `b_width` (width of the window that defines resolution of the snip algorithm).
1016 The values of `e_offset` and `e_linear` are used to compute indices for ROIs, so they
1017 need to be always provided.
1018 use_snip: bool, optional
1019 enable/disable background removal using snip algorithm
1020 chunk_pixels: int
1021 The number of pixels in a single chunk. The XRF map will be rechunked so that
1022 each block contains approximately `chunk_pixels` pixels and contain all `ne`
1023 spectrum points for each pixel.
1024 n_chunks_min: int
1025 Minimum number of chunks. The algorithm will try to split the map into the number
1026 of chunks equal or greater than `n_chunks_min`.
1027 progress_bar: callable or None
1028 reference to the callable object that implements progress bar. The example of
1029 such a class for progress bar object is `TerminalProgressBar`.
1030 client: dask.distributed.Client or None
1031 Dask client. If None, then local client will be created
1032
1033 Returns
1034 -------
1035 roi_dict_computed: dict
1036 Dictionary with XRF maps computed for ROIs specified by `roi_dict`.
1037 Key: emission line. Value: numpy array with shape `(ny, nx)`.
1038 XRF map values represent area under of the experimental spectrum computed
1039 over ROI.
1040 """
1041

Callers 4

get_roi_sumMethod · 0.85

Calls 8

prepare_xrf_mapFunction · 0.85
dask_client_createFunction · 0.85
dask_close_all_filesFunction · 0.85
keysMethod · 0.80
itemsMethod · 0.80
runMethod · 0.45

Tested by 3