cupy-rsoxs Reduced-Result q Grids#
The cupy-rsoxs backend can reduce simulated detector panels on the GPU
before results are streamed to host memory or retained on device. Reduced
layouts are selected through Morphology(..., backend_options=...):
morph = Morphology(
...,
backend="cupy-rsoxs",
backend_options={
"result_layout": "integrated",
"result_q_grid_mode": "union",
},
)
result = morph.run(return_xarray=True)
The supported reduced layouts are "integrated", "i_only",
"i_para_i_perp", and "i_a". Raw "detector" output has qx and
qy coordinates rather than a shared radial coordinate, so it rejects
result_q_grid_mode="union".
Grid modes#
For multi-energy 3D results, detector-corrected |q| varies with energy.
result_q_grid_mode determines how those per-energy radial coordinates are
placed on one shared xarray q dimension:
"intersection"The default. The shared q range is restricted to the overlap supported by every energy. This preserves the maintained
NRSSIntegratorbehavior and existing parity workflows."union"The shared q range extends from the smallest finite per-energy bound to the largest. Values outside an individual energy’s physical q support are represented by
NaN. This permits a high-energy frame, such as Cu K-alpha at 8047.8 eV, to retain q values that are unavailable to soft-X-ray frames in the same result stack.
For a single energy, there is no shared-grid interpolation. In 2D
reciprocal-plane mode, the radial coordinate is energy-independent q_perp.
Consequently, union and intersection differ only for multi-energy 3D reduced
results.
Optional q window#
Set backend_options={"q_max": 0.8} to request samples at or below
0.8 nm⁻¹. The option accepts finite, nonnegative real values. Omitting it
or setting it to None uses the default accessible q range for the
selected result layout, with the original coordinates and support mask.
Detector output uses the continuous forward-Ewald magnitude at each energy,
or the transverse radius for a singleton-Z reciprocal plane. NRSS returns
the smallest common rectangle on the original qy and qx axes and
sets cells outside each energy’s requested region to NaN. A zero
cutoff retains the original DC pixel. The attributes q_max,
q_window_offset_yx and q_window_logical_shape_zyx record the
cutoff and the crop’s location on the full logical detector.
Reduced layouts select samples from their existing radial grids. Shared
grids select by q and slice the auxiliary q_abs coordinate at the
same positions. For per_slice_q_abs, NRSS retains the union of
requested positions and masks unsupported samples separately for each energy.
On the compact-tensor path, the q window also bounds the detector pixels needed for projection, rotation, and Fourier gathering. The planner includes the original interpolation neighbors. The transform grid stays at its configured logical size. A single off-axis E direction uses the full projection internally and applies the cutoff to its result.
Coordinates and metadata#
The returned xarray object uses q as the uniform shared coordinate. For a
multi-energy 3D reduction, q_abs stores the exact detector-corrected
per-energy radial axes before common-grid interpolation. Union output also
contains:
result_q_grid_mode = "union"radial_coordinate_mode = "shared_q_grid_union_interpolated"a
q_axis_notedescribing the union and NaN support mask
The data’s finite mask is the authoritative indication that an energy supports a shared q sample:
supported = result.notnull()
hard_energy = result.sel(energy=8047.8)
For Dataset layouts, apply notnull() to the desired data variable.
q resolution#
The native Cartesian detector-axis increment is
The polar remesh has a fixed radial bin count determined by the detector’s pixel-space center-to-corner radius. Both common-grid modes retain that bin count and construct a uniform shared coordinate over their selected q range:
Union and intersection therefore generally do not have the same q increment. When a soft-X-ray energy supports only a small fraction of the numerical detector range, intersection mode can oversample the available native radial information because it places the full polar bin count inside the shorter overlap. Union mode spans the wider range with the same number of bins and can have a larger common-grid increment. This changes interpolation density, not the underlying simulated detector resolution.
Compatibility and validation#
"intersection" remains the default, so existing workflows and
NRSSIntegrator parity are unchanged unless union mode is requested
explicitly. NRSS validates the option during Morphology construction and
raises BackendOptionError for unknown grid modes or for union mode combined
with result_layout="detector".