synthesizer.utils.precision¶
A module for controlling the default output precision.
Synthesizer computes spectra, lines, photometry and other outputs at a
user-controllable floating-point precision. Every function that produces a
floating-point output takes an out_dtype argument; when this is left
unset (None) the global default defined here is used.
The global default is float64. To halve the memory footprint of outputs across the board, set the default to float32 once at the top of a script:
import numpy as np from synthesizer import set_default_out_dtype
set_default_out_dtype(np.float32)
Individual calls can always override the global default by passing
out_dtype explicitly.
Note that out_dtype only controls output arrays. Input arrays (particle
data and grids) are used at whatever precision they are provided at and are
never cast or copied behind the scenes; see the precision documentation for
the rules on mixing input precisions.
Functions
- synthesizer.utils.precision.get_default_out_dtype()[source]¶
Return the global default output dtype.
- Returns:
The current global default output dtype.
- Return type:
np.dtype
- synthesizer.utils.precision.resolve_out_dtype(out_dtype)[source]¶
Resolve a function’s out_dtype argument to a concrete dtype.
- Parameters:
out_dtype (np.dtype/type/None) – The out_dtype argument as passed by the caller. None means “use the global default”.
- Returns:
The dtype outputs should be allocated with.
- Return type:
np.dtype