nifty8.re.correlated_field module#

class CorrelatedFieldMaker(prefix: str)[source]#

Bases: object

Construction 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 the CorrelatedFieldMaker, 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() and finalize() 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 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)[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.

hartley(p, axes=None)[source]#
matern_amplitude(grid, scale: Callable, cutoff: Callable, loglogslope: Callable, renormalize_amplitude: bool, prefix: str = '', kind: str = 'amplitude') Model[source]#

Constructs a function computing the amplitude of a Matérn-kernel power spectrum.

See nifty8.re.correlated_field.CorrelatedFieldMaker.add_fluctuations _matern for 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, 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

non_parametric_amplitude(grid, fluctuations: Callable, loglogavgslope: Callable, flexibility: Callable | None = None, asperity: Callable | None = None, prefix: str = '', kind: str = 'amplitude') Model[source]#

Constructs a function computing the amplitude of a non-parametric power spectrum

See nifty8.re.correlated_field.CorrelatedFieldMaker.add_fluctuations for 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