Commit 0ae0a7aa authored by Gordian Edenhofer's avatar Gordian Edenhofer
Browse files

Clean up the zm handling in the density_estimator

parent 9851b9c1
......@@ -32,8 +32,9 @@ import nifty7 as ift
def density_estimator(
domain, exposure=1., pad=1., cf_fluctuations=None
domain, exposure=1., pad=1., cf_fluctuations=None, cf_azm_uniform=None
):
cf_azm_uniform_sane_default = (0., 20.)
cf_fluctuations_sane_default = {
"scale": (0.5, 0.3),
"cutoff": (7.0, 3.0),
......@@ -44,6 +45,8 @@ def density_estimator(
dom_scaling = 1. + np.broadcast_to(pad, (len(domain.axes), ))
if cf_fluctuations is None:
cf_fluctuations = cf_fluctuations_sane_default
if cf_azm_uniform is None:
cf_azm_uni = cf_azm_uniform_sane_default
domain_padded = []
for d_scl, d in zip(dom_scaling, domain):
......@@ -69,15 +72,16 @@ def density_estimator(
cf_fl = cf_fluctuations
cfmaker.add_fluctuations_matern(d, **cf_fl, prefix=f"ax{i}")
scalar_domain = ift.DomainTuple.scalar_domain()
uniform = ift.UniformOperator(scalar_domain, loc=0., scale=20.)
zm = uniform.ducktape("zeromode") # defines the zeromode operator with unifrom prior
cfmaker.set_amplitude_total_offset(0., zm)
uniform = ift.UniformOperator(scalar_domain, *cf_azm_uni)
zm = uniform.ducktape("zeromode")
zm_offset_mean = 0. # The zero-mode should be inferred only from the data
cfmaker.set_amplitude_total_offset(zm_offset_mean, zm)
correlated_field = cfmaker.finalize(0)
domain_shape = tuple(d.shape for d in domain)
slc = ift.SliceOperator(correlated_field.target, domain_shape)
signal = slc @ ift.exp(correlated_field)
signal = ift.exp(slc @ correlated_field)
# Cache the result of the correlated field to use it several times
signal_cache = signal.ducktape_left("signal_cache")
signal_plchr = ift.FieldAdapter(signal.target, "signal_cache")
......
Supports Markdown
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