CHAP.giwaxs.processor
¶
File : processor.py Author : Rolf Verberg Description: Module for Processors used only by GIWAXS experiments
Module Contents¶
Classes¶
API¶
- class CHAP.giwaxs.processor.GiwaxsConversionProcessor¶
Bases:
CHAP.processor.Processor
- process(data, config, save_figures=False, inputdir='.', outputdir='.', interactive=False)¶
- convert_q_rect(nxentry, config, save_figures=False, interactive=False, outputdir='.')¶
Return NXroot containing the converted GIWAXS images.
- Parameters:
nxentry – The GIWAXS map with the raw detector data.
config (CHAP.giwaxs.models.GiwaxsConversionConfig) – The GIWAXS conversion configuration.
save_figures (bool, optional) – Save .pngs of plots for checking inputs & outputs of this Processor, defaults to
False
.interactive (bool, optional) – Allows for user interactions, defaults to
False
.outputdir (str, optional) – Directory to which any output figures will be saved, defaults to
'.'
.
- Returns:
NXroot containing the converted GIWAXS images.
- Return type:
nexusformat.nexus.NXroot
- static curved_to_rect(data_curved, q_par, q_perp, q_par_rect, q_perp_rect, return_maps=False, normalize=True)¶
data_rect = curved_to_rect(…): distributes counts from a curvilinear grid (data_curved), e.g. x-ray data collected in angular space, into a rectilinear grid (reciprocal space).
data_rect, norm, xmap, ymap, xwid, ywid = curved_to_rect(…, return_maps=True): distributes counts from a curvilinear grid (data_curved), e.g. x-ray data collected in angular space, into a rectilinear grid (reciprocal space).
q_par, q_perp, and data_curved are M x N following the normal convention where the the first & second index corrspond to the vertical (y) and horizontal (x) locations of the scattering pattern. q_par, q_perp represent the q coordinates of the center of pixels whose intensities are stored in data_curved. Reiterating the convention above, q_par and q_perp vary primarilly along the 2nd and 1st index, respectively. rect_qpar and rect_qperp are evenly-spaced, monotonically increasing, arrays determining the new grid.
data_rect : the new matrix with intensity from data_curved disctributed into a regular grid defined by rect_qpar, rect_qpar. norm : a matrix with the same shape of data_rect representing the area of the pixel in the original angular units. It should be used to normalize the resulting array as norm_z = data_rect / norm.
Algorithm: Step 1 : Compute xmap, ymap, which containt the values of q_par and q_perp, but represented in pixel units of the target coordinates rect_qpar, rect_qperp. In other words, xmap(i,j) = 3.4 means that q_par(i,j) lands 2/5 of the q_distance between rect_qpar(3) and rect_qpar(4). Intensity in qpar(i,j) should thus be distributed in a 2:3 ratio among neighboring mini-columns of pixels 3 and 4. Step 2 : Use the procedure described by Barna et al (RSI v.70, p. 2927, 1999) to distribute intensity from each source pixel i,j into each of 9 destination pixels around the xmap(i,j) and ymap(i,j). Keep track of how many source “pixels” are placed into each bin in the variable, “norm”. Note also that if xmap(i,j)-floor(xmap(i,j)) > 0.5, the “center” pixel of the 9 destination pixels is floor(xmap+0.5). (Outside this function): The normalized intensity in each new pixel can be obtained asI = data_rect./norm, but with the caveat that zero values of “norm” should be changed to ones first, norm(data_rect == 0) = 1.0.
Example Usage: 1. Compute the values of q_par and q_perp for each pixel in the image z (according to scattering geometry). 2. Set or determing a good target grid, e.g.:
min_qpar, max_qpar = q_par.mix(), q_par.max() min_qperp, max_qperp = q_perp.mix(), q_perp.max() q_par_rect, q_par_step = np.linspace(min_qpar , max_qpar, image_dim[1], retstep=True) q_perp_rect, q_perp_step = np.linspace(min_qperp, max_qperp, image_dim[0], retstep=True) 3. data_rect = curved_to_rect(data_curved, q_par, q_perp, q_par_rect, q_perp_rect) 4. plt.imshow(data_rect, extent = [ q_par_rect[0], q_par_rect[-1], q_perp_rect[-1], q_perp_rect[0]]) xlabel([‘Q_{||} [’ char(197) ‘^{-1}]’]) ylabel([‘Q_{\perp} [’ char(197) ‘^{-1}]’])
- _calc_q_coords(images, thetas, poni_file)¶
Return a 3D arrays representing the perpendicular and parallel components of q relative to the detector surface for each pixel in an image for each theta.