Commit e6eb8d06 authored by Julian Ruestig's avatar Julian Ruestig 📡

Also zero_mode in CorrelatedField

parent 0696bcac
Pipeline #44169 failed with stages
in 5 minutes and 30 seconds
......@@ -31,7 +31,7 @@ from ..sugar import from_global_data
from ..library.inverse_gamma_operator import InverseGammaOperator
def CorrelatedField(target, amplitude_operator, name='xi', codomain=None):
def CorrelatedField(target, amplitude_operator, q=1e-5, name='xi', codomain=None):
"""Constructs an operator which turns a white Gaussian excitation field
into a correlated field.
......@@ -75,11 +75,22 @@ def CorrelatedField(target, amplitude_operator, name='xi', codomain=None):
power_distributor = PowerDistributor(h_space, p_space)
A = power_distributor(amplitude_operator)
vol = h_space.scalar_dvol**-0.5
zero_mode = ValueInserter(, (0,)*len(
mask = np.ones(
mask[(0,)*len(] = 0.
mask = from_global_data(, mask)
mask = DiagonalOperator(mask)
zero_mode = zero_mode @ InverseGammaOperator(
zero_mode.domain, 0.5, q) @ FieldAdapter(
zero_mode.domain, "zero_mode")
# When doubling the resolution of `tgt` the value of the highest k-mode
# will scale with a square root. `vol` cancels this effect such that the
# same power spectrum can be used for the spaces with the same volume,
# different resolutions and the same object in them.
return ht(vol*A*ducktape(h_space, None, name))
return ht(vol*(mask@A+zero_mode)*ducktape(h_space, None, name))
def MfCorrelatedField(target, amplitudes, q=1e-14, name='xi'):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment