nifty.re.correlated_field module#
- class CorrelatedFieldMaker(prefix: str)[source]#
Bases:
objectConstruction helper for hierarchical correlated field models.
The correlated field models are parametrized by creating square roots of power spectrum operators (“amplitudes”) via calls to
add_fluctuations*()that act on the targeted field subgrids. During creation of theCorrelatedFieldMaker, a global offset from zero of the field model can be defined and an operator applying fluctuations around this offset is parametrized.Creation of the model operator is completed by calling the method
finalize(), which returns the configured operator.See the method’s initialization,
add_fluctuations(),add_fluctuations_matern()andfinalize()for further usage information.- __init__(prefix: str)[source]#
Instantiate a CorrelatedFieldMaker object.
- Parameters:
prefix (string) – Prefix to the names of the parameters of the CF operator.
- add_fluctuations(shape: tuple | int, distances: tuple | float, fluctuations: tuple | Callable, loglogavgslope: tuple | Callable, flexibility: tuple | Callable | None = None, asperity: tuple | Callable | None = None, prefix: str = '', harmonic_type: str = 'fourier', non_parametric_kind: str = 'amplitude')[source]#
Adds a correlation structure to the to-be-made field.
Correlations are described by their power spectrum and the subgrid on which they apply.
Multiple calls to add_fluctuations are possible, in which case the constructed field will have the outer product of the individual power spectra as its global power spectrum.
The parameters fluctuations, flexibility, asperity and loglogavgslope configure either the amplitude or the power spectrum model used on the target field subgrid of type harmonic_type. It is assembled as the sum of a power law component (linear slope in log-log amplitude-frequency-space), a smooth varying component (integrated Wiener process) and a ragged component (un-integrated Wiener process).
- Parameters:
shape (tuple of int) – Shape of the position space grid
distances (tuple of float or float) – Distances in the position space grid
fluctuations (tuple of float (mean, std) or callable) – Total spectral energy, i.e. amplitude of the fluctuations (by default a priori log-normal distributed)
loglogavgslope (tuple of float (mean, std) or callable) – Power law component exponent (by default a priori normal distributed)
flexibility (tuple of float (mean, std) or callable or None) – Amplitude of the non-power-law power spectrum component (by default a priori log-normal distributed)
asperity (tuple of float (mean, std) or callable or None) – Roughness of the non-power-law power spectrum component; use it to accommodate single frequency peak (by default a priori log-normal distributed)
prefix (str) – Prefix of the power spectrum parameter names
harmonic_type (str) – Description of the harmonic partner domain in which the amplitude lives
non_parametric_kind (str) – If set to ‘amplitude’, the amplitude spectrum is described by the correlated field model parameters in the above. If set to ‘power’, the power spectrum is described by the correlated field model parameters in the above (by default set to ‘amplitude’).
See also
Variable structures in M87* from space, time and frequency resolved interferometry, Arras, Philipp and Frank, Philipp and Haim, Philipp and Knollmüller, Jakob and Leike, Reimar and Reinecke, Martin and Enßlin, Torsten, https://arxiv.org/abs/2002.05218 http://dx.doi.org/10.1038/s41550-021-01548-0
- add_fluctuations_matern(shape: tuple | int, distances: tuple | float, scale: tuple | Callable, cutoff: tuple | Callable, loglogslope: tuple | Callable, renormalize_amplitude: bool, prefix: str = '', harmonic_type: str = 'fourier', non_parametric_kind: str = 'amplitude')[source]#
Adds a Matérn-kernel correlation structure to the field to be made.
The Matérn-kernel spectrum is parametrized by
\[A(k) = \frac{a}{\left(1 + { \left(\frac{|k|}{b}\right) }^2\right)^{-c/4}}\]where \(a\) is called the scale parameter, \(b\) the represents the cutoff mode, and \(c\) the spectral index of the resulting power spectrum.
- Parameters:
shape (tuple of int) – Shape of the position space grid.
distances (tuple of float or float) – Distances in the position space grid.
scale (tuple of float (mean, std) or callable) – Total spectral energy, i.e. amplitude of the fluctuations (by default a priori log-normal distributed).
cutoff (tuple of float (mean, std) or callable) – Power law component exponent (by default a priori normal distributed).
loglogslope (tuple of float (mean, std) or callable or None) – Amplitude of the non-power-law power spectrum component (by default a priori log-normal distributed).
renormalize_amplitude (bool) – Whether the amplitude of the process should be renormalized to ensure that the scale parameter relates to the scale of the fluctuations along the specified axis.
prefix (str) – Prefix of the power spectrum parameter names.
harmonic_type (str) – Description of the harmonic partner domain in which the amplitude lives.
non_parametric_kind (str) – If set to ‘amplitude’, the amplitude spectrum is described by the Matérn kernel function in the above. If set to ‘power’, the power spectrum is described by the Matérn kernel function in the above (by default ‘amplitude’).
See also
Causal, Bayesian, & non-parametric modeling of the SARS-CoV-2 viral load vs. patient’s age, Guardiani, Matteo and Frank, Kostić Andrija and Edenhofer, Gordian and Roth, Jakob and Uhlmann, Berit and Enßlin, Torsten, https://arxiv.org/abs/2105.13483 https://doi.org/10.1371/journal.pone.0275011
- property amplitude: Callable#
Returns the added fluctuation, i.e. un-normalized amplitude
- property amplitude_total_offset: Callable#
Returns the total offset of the amplitudes
- property azm#
Alias for amplitude_total_offset
- finalize() → Model[source]#
Finishes off the model construction process and returns the constructed operator.
- property fluctuations: Tuple[Callable, ...]#
Returns the added fluctuations, i.e. un-normalized amplitudes
Their scales are only meaningful relative to one another. Their absolute scale bares no information.
- get_normalized_amplitudes() → Tuple[Callable, ...][source]#
Returns the normalized amplitude operators used in the final model
The amplitude operators are corrected for the otherwise degenerate zero-mode. Their scales are only meaningful relative to one another. Their absolute scale bares no information.
- property power_spectrum: Callable#
Returns the power spectrum
- set_amplitude_total_offset(offset_mean: float, offset_std: tuple | Callable)[source]#
Sets the zero-mode for the combined amplitude operator
- Parameters:
offset_mean (float) – Mean offset from zero of the correlated field to be made.
offset_std (tuple of float or callable) – Mean standard deviation and standard deviation of the standard deviation of the offset. No, this is not a word duplication. (By default a priori log-normal distributed)
- class HEALPixGrid(nside, shape, total_volume, harmonic_grid)#
Bases:
tuple- harmonic_grid#
Alias for field number 3
- nside#
Alias for field number 0
- shape#
Alias for field number 1
- total_volume#
Alias for field number 2
- class LMGrid(lmax, mmax, shape, power_distributor, mode_multiplicity, mode_lengths, relative_log_mode_lengths, log_volume)#
Bases:
tuple- lmax#
Alias for field number 0
- log_volume#
Alias for field number 7
- mmax#
Alias for field number 1
- mode_lengths#
Alias for field number 5
- mode_multiplicity#
Alias for field number 4
- power_distributor#
Alias for field number 3
- relative_log_mode_lengths#
Alias for field number 6
- shape#
Alias for field number 2
- class MaternAmplitude(grid: nifty.re.correlated_field.RegularCartesianGrid | nifty.re.correlated_field.RegularFourierGrid | nifty.re.correlated_field.HEALPixGrid | nifty.re.correlated_field.LMGrid, scale: Callable | None, cutoff: Callable, loglogslope: Callable, renormalize_amplitude: bool, prefix: str = '', kind: str = 'amplitude')[source]#
Bases:
Model- __init__(grid: RegularCartesianGrid | RegularFourierGrid | HEALPixGrid | LMGrid, scale: Callable | None, cutoff: Callable, loglogslope: Callable, renormalize_amplitude: bool, prefix: str = '', kind: str = 'amplitude')[source]#
Initializes a model that computes the amplitude of a Matérn-kernel power spectrum.
See
nifty.re.correlated_field.CorrelatedFieldMaker.add_fluctuations _maternfor more details on the parameters.See also
Causal, Bayesian, & non-parametric modeling of the SARS-CoV-2 viral load vs. patient’s age, Guardiani, Matteo and Frank, Philipp and Kostić, Andrija and Edenhofer, Gordian and Roth, Jakob and Uhlmann, Berit and Enßlin, Torsten, https://arxiv.org/abs/2105.13483 https://doi.org/10.1371/journal.pone.0275011
- cutoff: Callable#
- loglogslope: Callable#
- scale: Callable#
- class NonParametricAmplitude(grid: nifty.re.correlated_field.RegularCartesianGrid | nifty.re.correlated_field.RegularFourierGrid | nifty.re.correlated_field.HEALPixGrid | nifty.re.correlated_field.LMGrid, fluctuations: Callable | None, loglogavgslope: Callable, flexibility: Callable | None = None, asperity: Callable | None = None, prefix: str = '', kind: str = 'amplitude')[source]#
Bases:
Model- __init__(grid: RegularCartesianGrid | RegularFourierGrid | HEALPixGrid | LMGrid, fluctuations: Callable | None, loglogavgslope: Callable, flexibility: Callable | None = None, asperity: Callable | None = None, prefix: str = '', kind: str = 'amplitude')[source]#
Initializes a model which computes the amplitude of a non-parametric power spectrum.
See
nifty.re.correlated_field.CorrelatedFieldMaker.add_fluctuationsfor more details on the parameters.See also
Variable structures in M87* from space, time and frequency resolved interferometry, Arras, Philipp and Frank, Philipp and Haim, Philipp and Knollmüller, Jakob and Leike, Reimar and Reinecke, Martin and Enßlin, Torsten, https://arxiv.org/abs/2002.05218 http://dx.doi.org/10.1038/s41550-021-01548-0
- asperity: Callable | None#
- flexibility: Callable | None#
- fluctuations: Callable#
- loglogavgslope: Callable#
- class RegularCartesianGrid(shape, total_volume, distances, harmonic_grid)#
Bases:
tuple- distances#
Alias for field number 2
- harmonic_grid#
Alias for field number 3
- shape#
Alias for field number 0
- total_volume#
Alias for field number 1
- class RegularFourierGrid(shape, power_distributor, mode_multiplicity, mode_lengths, relative_log_mode_lengths, log_volume)#
Bases:
tuple- log_volume#
Alias for field number 5
- mode_lengths#
Alias for field number 3
- mode_multiplicity#
Alias for field number 2
- power_distributor#
Alias for field number 1
- relative_log_mode_lengths#
Alias for field number 4
- shape#
Alias for field number 0
- get_fourier_mode_distributor(shape: tuple | int, distances: tuple | float, uniqueness_rtol=1e-12)[source]#
Get the unique lengths of the Fourier modes, a mapping from a mode to its length index and the multiplicity of each unique Fourier mode length.
- Parameters:
shape (tuple of int or int) – Position-space shape.
distances (tuple of float or float) – Position-space distances.
- Returns:
mode_length_idx (jnp.ndarray) – Index in power-space for every mode in harmonic-space. Can be used to distribute power from a power-space to the full harmonic grid.
unique_mode_length (jnp.ndarray) – Unique length of Fourier modes.
mode_multiplicity (jnp.ndarray) – Multiplicity for each unique Fourier mode length.
uniqueness_rtol (float) – Relative tolerance to define unique lengths of harmonic mode vectors (k-vectors). Vectors with lengths that have a smaller relative distance to each other are treated identically
- get_spherical_mode_distributor(nside: int, lmax=None, mmax=None, uniqueness_rtol=1e-12, distance_dtype=<class 'numpy.float64'>)[source]#
Get the unique lengths of Spherical harmonic modes, a mapping from a mode to its length index and the multiplicity of each unique mode length.
- Parameters:
nside (int) – Nside of the HEALPix sphere for which the associated harmonic space is constructed
lmax (int, optional) – The maximum \(l\) value of any spherical harmonic coefficient \(a_{lm}\) that is represented by this object. Must be \(\ge 0\). If not supplied, it is set to nside * 2
mmax (int, optional) – The maximum \(m\) value of any spherical harmonic coefficient \(a_{lm}\) that is represented by this object. If not supplied, it is set to lmax. Must be \(\ge 0\) and \(\le\) lmax.
uniqueness_rtol (float) – Relative tolerance to define unique lengths of harmonic mode vectors (k-vectors). Vectors with lengths that have a smaller relative distance to each other are treated identically
distance_dtype (Any) – Dtype of the array of harmonic mode lengths canstructed internally
- Returns:
mode_length_idx (jnp.ndarray) – Index in power-space for every mode in harmonic-space. Can be used to distribute power from a power-space to the full harmonic grid.
unique_mode_length (jnp.ndarray) – Unique length of spherical modes.
mode_multiplicity (jnp.ndarray) – Multiplicity for each unique mode length.
- make_grid(shape, distances, harmonic_type) → RegularCartesianGrid | HEALPixGrid[source]#
Creates the grid for the amplitude model