Commit 4528dc6a authored by Lukas Platz's avatar Lukas Platz

made zero mode prior params optional in SLAmplitude

parent 3ac39d77
Pipeline #44418 failed with stages
in 9 minutes and 55 seconds
...@@ -118,7 +118,7 @@ def CepstrumOperator(target, a, k0): ...@@ -118,7 +118,7 @@ def CepstrumOperator(target, a, k0):
return sym @ qht @ makeOp(cepstrum.sqrt()) return sym @ qht @ makeOp(cepstrum.sqrt())
def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq, def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za=None, zq=None,
keys=['tau', 'phi', 'zero_mode']): keys=['tau', 'phi', 'zero_mode']):
'''Operator for parametrizing smooth amplitudes (square roots of power '''Operator for parametrizing smooth amplitudes (square roots of power
spectra). spectra).
...@@ -168,10 +168,10 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq, ...@@ -168,10 +168,10 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq,
LogRGSpace (see :class:`ExpTransform`). LogRGSpace (see :class:`ExpTransform`).
iv : float iv : float
Prior standard deviation of y-intercept of power law. Prior standard deviation of y-intercept of power law.
za : float za : float, optional
The alpha-parameter of the inverse-gamma distribution. The alpha-parameter of the inverse-gamma distribution.
Setting the a seperate prior on the zeroGmode of the amplitude model. Setting the a seperate prior on the zeroGmode of the amplitude model.
zq : float zq : float, optional
The q-parameter of the inverse-gamma distribution. The q-parameter of the inverse-gamma distribution.
Returns Returns
...@@ -186,10 +186,17 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq, ...@@ -186,10 +186,17 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq,
a, k0 = float(a), float(k0) a, k0 = float(a), float(k0)
sm, sv, im, iv = float(sm), float(sv), float(im), float(iv) sm, sv, im, iv = float(sm), float(sv), float(im), float(iv)
za, zq = float(za), float(zq)
if sv <= 0 or iv <= 0: if sv <= 0 or iv <= 0:
raise ValueError raise ValueError
if za != None and zq != None:
separate_zero_mode_prior = True
za, zq = float(za), float(zq)
else:
separate_zero_mode_prior = False
if za != None or zq != None:
raise ValueError("za and zq have to be given together")
et = ExpTransform(target, n_pix) et = ExpTransform(target, n_pix)
dom = et.domain[0] dom = et.domain[0]
...@@ -208,16 +215,19 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq, ...@@ -208,16 +215,19 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za, zq,
# Combine linear and smooth component # Combine linear and smooth component
loglog_ampl = 0.5*(smooth + linear) loglog_ampl = 0.5*(smooth + linear)
zero_mode = ValueInserter(et.target, (0,)*len(et.target.shape)) if not separate_zero_mode_prior:
# Go from loglog-space to linear-linear-space
mask = np.ones(et.target.shape) return et @ loglog_ampl.exp()
mask[(0,)*len(et.target.shape)] = 0. else:
mask = from_global_data(et.target, mask) zero_mode = ValueInserter(et.target, (0,)*len(et.target.shape))
mask = DiagonalOperator(mask)
zero_mode = zero_mode @ InverseGammaOperator( mask = np.ones(et.target.shape)
zero_mode.domain, za, zq) @ FieldAdapter( mask[(0,)*len(et.target.shape)] = 0.
zero_mode.domain, keys[2]) mask = from_global_data(et.target, mask)
# Go from loglog-space to linear-linear-space mask = DiagonalOperator(mask)
print(keys[2] + " mean: ", (zq/(1+za))) zero_mode = zero_mode @ InverseGammaOperator(
zero_mode.domain, za, zq) @ FieldAdapter(
return (mask @ (et @ loglog_ampl.exp()) + zero_mode) zero_mode.domain, keys[2])
print(keys[2] + " mean: ", (zq/(1+za)))
return mask @ (et @ loglog_ampl.exp()) + zero_mode
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