Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
0ae0a7aa
Commit
0ae0a7aa
authored
Mar 15, 2021
by
Gordian Edenhofer
Browse files
Clean up the zm handling in the density_estimator
parent
9851b9c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
demos/getting_started_density.py
View file @
0ae0a7aa
...
...
@@ -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"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment