utils
static_interpolation.utils
Functions:
| Name | Description |
|---|---|
balanced_slices |
Split a range of length n into the minimal number of contiguous chunks, |
polar_scattering_coordinates_to_pixel_coordinates |
Converts Elwald's sphere coodinates to detector pixel coordinates |
get_max_q |
Computes the maximum momentum transfer in 2pi/meter for the given inputs. |
balanced_slices(n, max_chunk_size, start=0)
[source]
Split a range of length n into the minimal number of contiguous chunks, each of size <= max_chunk_size, with chunk sizes differing by at most 1.
Returns Python slice objects [slice(start0, stop0), slice(start1, stop1), …].
Parameters
n : int Number of items. max_chunk_size : int Upper bound S for each chunk size. start : int, default 0 Start index for the slices. Use start=0 for normal Python indexing. Use start=1 if you literally want slices over labels 1..N.
polar_scattering_coordinates_to_pixel_coordinates(polar_scatter_grid, p_origin, p_xdir, p_ydir, energy)
[source]
Converts Elwald's sphere coodinates to detector pixel coordinates
Points on the Ewald's sphere \((q,\theta(q),\phi)\) given by \((q,\phi)\) are mapped to pixel coordinates on a detector plane in real space whose origin is given by p_origin, whose x-direction is given by p_xdir and whose y-direction is given by p_ydir. Forthermore the length of p_ydir and p_xdir specify the pixel dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polar_scatter_grid
|
NDArray
|
(n_panels,…,2) Array containing (q,phi) points in its last axis. q unit is [2*pi/m] |
required |
p_origin
|
NDArray
|
(n_panels,3) Array containing Panel origin vectors in cartesian coodinates, unit is [m] |
required |
p_xdir
|
NDArray
|
(n_panels,3) Array containing pixel x-direction vectors in cartesian coodinates, unit is [m] |
required |
p_ydir
|
NDArray
|
(n_panels,3) Array containing pixel y-direction vectors in cartesian coodinates, unit is [m] |
required |
energy
|
float
|
X-ray energy in electron Volts [eV] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
(n_panels,…,2) pixel coordinates. |
get_max_q(geom, detector_origin, xray_energy, pad=False)
[source]
Computes the maximum momentum transfer in 2pi/meter for the given inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom
|
DetectorGeometryBase
|
Geometry describing the detector pixel positions. |
required |
detector_origin
|
NDArray
|
Detector origin (x,y,z) relative to the sample in meters [m] |
required |
xray_energy
|
float
|
Energy of the used X-rays in electron Volts[eV] |
required |
pad
|
bool
|
Whether or not to pad the pixel center coordinates so that max_q coverse the entire pixel area not only the centers. |
False
|
Returns: float: maximal momentum transfer covered by the geometry.