revertex package

Subpackages

Submodules

revertex.cli module

revertex.cli.cli(args=None)
Return type:

None

revertex.core module

revertex.core._get_chunks(n, m)
Parameters:
Return type:

ndarray

revertex.core.convert_output_kin(arr, *, eunit='keV', tunit='ns', lunit='mm', include_positions=False)

Converts the vertices to the correct output format for kin information.

This follows the convention defined by remage and optionally can also include positions into a combined table.

Parameters:
  • arr (Array) – The input data to convert

  • eunit (str) – Unit for energy, by default keV.

  • tunit (str) – Unit for time, by default ns.

  • lunit (str) – Unit for distances, by default mm.

  • include_positions (bool) – If positions (xloc/yloc/zloc)

Returns:

The output table.

Return type:

Table

revertex.core.convert_output_pos(arr, *, lunit='mm')

Converts the vertices to the correct output format for pos information.

Parameters:
  • arr (Array) – The input data to convert.

  • lunit (str) – Unit for distances, by default mm.

Returns:

The output table.

Return type:

Table

revertex.core.write_remage_vtx(n, out_file, seed, generator, lunit='mm', **kwargs)

Save the vertices generatored by a particular vertex generator function.

This follows the convention defined by remage.

Parameters:
  • n (int) – The number of vertices to generate

  • out_file (str) – The path to the file to save the results.

  • seed (int | None) – The seed to the random number generator

  • generator (Callable) – A function generating the vertices (following the revertex specifications)

  • kwargs – The keyword arguments to the function

  • lunit (str)

Return type:

None

revertex.plot module

revertex.sampling module

revertex.sampling.sample_cylinder(r_range, z_range, size, seed, phi_range=(0, 6.283185307179586))

Generate points in a cylinder, returns the points as a 2D array

Parameters:
  • r_range (float) – The range of r to sample.

  • z_range (tuple) – The range of z to sample.

  • phi – The range of angles to sample.

  • size (int) – The number of points to generate.

  • seed (int | None) – The random seed for the rng.

  • phi_range (tuple)

revertex.sampling.sample_histogram(histo, size, *, seed=None)

Generate samples from a 1D or 2D histogram.

Based on approximating the histogram as a piecewise uniform, probability distribution.

Parameters:
  • histo (Hist) – The histogram to generate samples from.

  • size (int) – The number of samples to generate.

  • seed (int | None) – Random seed.

Returns:

an array of the samples (1D case) of a tuple of x, y samples (2D case)

Return type:

ndarray

revertex.sampling.sample_proportional_radius(r0, r1, size=10000, seed=None)

Sample from a distribution weighted by the radius. This is used for the surface sampling og shapes.

Based on sampling from a distribution:

\[P(r) \propto r\]

restricted to the range min(r0,r1) to max(r0,r1).

Parameters:
  • r0 (ArrayLike) – list of first radius, must have the same length as size.

  • r1 (ArrayLike) – list of second, must have the same length as size.

  • size (int) – number of samples.

  • seed (int | None) – random seed for rng.

revertex.utils module

revertex.utils._get_position(pv_name, reg)

Get the global position of a physical volume from the GDML

Parameters:
  • pv_name (str)

  • reg (Registry)

Return type:

list

revertex.utils.collect_isotopes(component, scale, isotopes, nist_registry, nist_element_z_to_name, pyg4, *, normalize_output=True, _is_recursive_call=False)

Recursively collect isotopes and their atomic fractions for a given material component.

This function handles components defined as isotopes, elements, or compounds in pyg4ometry. For isotopes, it directly adds the ZAID and atomic fraction to the isotopes dictionary (used as pid in SaG4n). For elements, it looks up the natural isotope abundances using the NIST registry. For compounds, it recursively processes the sub-components.

Parameters:
Return type:

None

revertex.utils.expand_regex(inputs, patterns)

Get a list of detectors from regex

This matches any wildcars with * or ? in the patterns.

Parameters:
  • inputs (list) – list of input strings to find matches in.

  • patterns (list) – list of patterns to search for.

Return type:

list

revertex.utils.find_mother_physical_volumes(pv, registry)

Find the mother physical volumes.

Parameters:
  • pv (PhysicalVolume)

  • registry (Registry)

Return type:

list[PhysicalVolume]

revertex.utils.get_borehole_volume(hpge, size=1000000)

Estimate the borehole volume (with MC)

Parameters:

hpge (pygeomhpges.HPGe)

revertex.utils.get_borehole_weights(hpges)

Get a weighting for each hpge in the hpges based on borehole volume

Parameters:

hpges (dict)

Return type:

list

revertex.utils.get_hpges(reg, detectors)

Extract the objects for each HPGe detector in reg and in the list of detectors

Parameters:
  • reg (pg4.geant4.registry)

  • detectors (str | list[str])

Return type:

tuple[dict, dict]

revertex.utils.get_surface_indices(hpge, surface_type)

Get which surface index corresponds to the desired surface type

Parameters:
  • hpge (HPGe)

  • surface_type (str | None)

Return type:

tuple

revertex.utils.get_surface_weights(hpges, surface_type)

Get a weighting for each hpge in the hpges based on surface area for a given surface_type

Parameters:
  • hpges (dict)

  • surface_type (str | None)

Return type:

list

revertex.utils.read_input_beta_csv(path, **kwargs)

Reads a CSV file into numpy arrays.

The file should have the following format:

energy_1, phase_space_1 energy_2, phase_space_2 energy_3, phase_space_3

Parameters:
  • path (str) – filepath to the csv file.

  • kwargs – keyword arguments to pass to np.genfromtxt

Return type:

tuple[ndarray, ndarray]

revertex.utils.setup_log(level=None)

Setup a colored logger for this package.

Parameters:

level (int | None) – initial log level, or None to use the default.

Return type:

None