sgt package

Submodules

Module contents

Higher-level interface for manipulation of scattering geometry.

class sgt.geometry(width_px: int = 1, height_px: int = 1, px_width_mm: float = 1.0, px_height_mm: float = 1.0, u0_mm: float = 0.0, v0_mm: float = 0.0, alpha_deg: float = 0.0, beta_deg: float = 0.0, gamma_deg: float = 0.0, L0_mm: float = 1.0, lam_ang: float = 1.0, qmin: float = 0.0, qmax: float = 1.0, N_q: int = 100, N_azi: int = 1, mask: Optional[ndarray] = None)[source]

Bases: object

Interface class for scattering geometry manipulation.

Example

To create a geometry instance,

>>> import sgt
>>> g = sgt.geometry()

Although all necessary parameters may be supplied as the args of the initializer, the easiest way is to load the specs from a file.

>>> g.load_specs("Geometry_AgBh.txt")

Make sure to call refresh functions when you make changes to the geometry.

>>> g.refresh_q()

Mask can be supplied later. For example, suppose that we already have the mask array maskarray,

>>> g.mask = maskarray

Make sure to refresh polar maps whenever you made any changes to the geometry.

>>> g.refresh_polar_map()

Finally, it can perform circular averaging. Suppose that we have the 2D intensity array i and associated error array e_i,

>>> i_av, e_i_av = g.circular_average(i, e_i)

The output arrays are also 2D. For example, i_av[k] is the q-profile at k th azimuthal section. The arrays along the q and azimuthal angle axes are stored as g.ax_q and g.ax_azi, respectively.

minimal_spec_keys: Tuple = ('width_px', 'height_px', 'px_width_mm', 'px_height_mm', 'u0_mm', 'v0_mm', 'alpha_deg', 'beta_deg', 'gamma_deg', 'L0_mm', 'lam_ang', 'qmin_anginv', 'qmax_anginv', 'q_number', 'azi_number')
load_specs(fp: str | IO) None[source]

Loads and applies parameters from a file

It loads parameters from a geometry specification file, which is a JSON-formatted text file. The file must contain all keys listed in minimal_spec_keys.

Parameters:

fp – file-like or path to a JSON-formatted file.

save_specs(fp: str | IO) None[source]
refresh_q() None[source]

Note

self.mask is not used in this method.

refresh_polar_map() None[source]

Note

This method uses self.mask.

circular_average(intensity: ndarray, e_intensity: ndarray) Tuple[ndarray, ndarray][source]

Performs circular averaging.

Parameters:
  • intensity – intensity array.

  • e_intensity – intensity error array.

Returns:

Two 2D numpy arrays of the intensity and the error, both with the shape (azi_number, q_number).

property R: ndarray
property u: ndarray
property v: ndarray
property x: ndarray
property y: ndarray
property z: ndarray
property qx: ndarray
property qy: ndarray
property qz: ndarray
property solid_angle_factor: ndarray
property map_q: ndarray
property map_azi: ndarray
property density: ndarray
property ax_q: ndarray
property ax_azi: ndarray
property normal_incidence_dist: float