Commit 9b3d5b5b authored by Philipp Arras's avatar Philipp Arras

Improve simple correlated field interface

parent 8c8530ce
Pipeline #77531 passed with stages
in 13 minutes and 18 seconds
......@@ -60,24 +60,19 @@ def main():
args = {
'offset_mean': 0,
'offset_std_mean': 1e-3,
'offset_std_std': 1e-6,
'offset_std': (1e-3, 1e-6),
# Amplitude of field fluctuations
'fluctuations_mean': 2.0, # 1.0
'fluctuations_stddev': 1.0, # 1e-2
'fluctuations': (2., 1.), # 1.0, 1e-2
# Exponent of power law power spectrum component
'loglogavgslope_mean': -2.0, # -3.0
'loglogavgslope_stddev': 0.5, # 0.5
'loglogavgslope': (-2., 0.5), # -3.0, 0.5
# Amplitude of integrated Wiener process power spectrum component
'flexibility_mean': 2.5, # 1.0
'flexibility_stddev': 1.0, # 0.5
'flexibility': (2.5, 1.), # 1.0, 0.5
# How ragged the integrated Wiener process component is
'asperity_mean': 0.5, # 0.1
'asperity_stddev': 0.5 # 0.5
'asperity': (0.5, 0.5) # 0.1, 0.5
}
correlated_field = ift.SimpleCorrelatedField(position_space, **args)
......
......@@ -40,26 +40,27 @@ class SimpleCorrelatedField(Operator):
spectrum, i.e. only one call of
:func:`~nifty7.library.correlated_fields.CorrelatedFieldMaker.add_fluctuations`.
"""
def __init__(self, target, offset_mean, offset_std_mean, offset_std_std,
fluctuations_mean, fluctuations_stddev, flexibility_mean,
flexibility_stddev, asperity_mean, asperity_stddev,
loglogavgslope_mean, loglogavgslope_stddev, prefix='',
def __init__(self, target, offset_mean, offset_std, fluctuations,
flexibility, asperity, loglogavgslope, prefix='',
harmonic_partner=None):
if harmonic_partner is None:
harmonic_partner = target.get_default_codomain()
else:
target.check_codomain(harmonic_partner)
harmonic_partner.check_codomain(target)
fluct = LognormalTransform(fluctuations_mean, fluctuations_stddev,
prefix + 'fluctuations', 0)
flex = LognormalTransform(flexibility_mean, flexibility_stddev,
prefix + 'flexibility', 0)
asp = LognormalTransform(asperity_mean, asperity_stddev,
prefix + 'asperity', 0)
avgsl = NormalTransform(loglogavgslope_mean, loglogavgslope_stddev,
prefix + 'loglogavgslope', 0)
zm = LognormalTransform(offset_std_mean, offset_std_std,
prefix + 'zeromode', 0)
for kk in [offset_std, fluctuations, loglogavgslope]:
if len(kk) != 2:
raise TypeError
for kk in [flexibility, asperity]:
if kk is None or len(kk) != 2:
raise TypeError
if flexibility is None and asperity is not None:
raise ValueError
fluct = LognormalTransform(*fluctuations, prefix + 'fluctuations', 0)
flex = LognormalTransform(*flexibility, prefix + 'flexibility', 0)
asp = LognormalTransform(*asperity, prefix + 'asperity', 0)
avgsl = NormalTransform(*loglogavgslope, prefix + 'loglogavgslope', 0)
zm = LognormalTransform(*offset_std, prefix + 'zeromode', 0)
pspace = PowerSpace(harmonic_partner)
twolog = _TwoLogIntegrations(pspace)
......
......@@ -139,20 +139,15 @@ def test_complicated_vs_simple(seed, domain):
loglogavgslope_stddev = _posrand()
prefix = 'foobar'
hspace = domain.get_default_codomain()
scf = ift.SimpleCorrelatedField(domain,
offset_mean,
offset_std_mean,
offset_std_std,
fluctuations_mean,
fluctuations_stddev,
flexibility_mean,
flexibility_stddev,
asperity_mean,
asperity_stddev,
loglogavgslope_mean,
loglogavgslope_stddev,
prefix=prefix,
harmonic_partner=hspace)
scf = ift.SimpleCorrelatedField(
domain,
offset_mean, (offset_std_mean, offset_std_std),
(fluctuations_mean, fluctuations_stddev),
(flexibility_mean, flexibility_stddev),
(asperity_mean, asperity_stddev),
(loglogavgslope_mean, loglogavgslope_stddev),
prefix=prefix,
harmonic_partner=hspace)
cfm = ift.CorrelatedFieldMaker.make(offset_mean, offset_std_mean,
offset_std_std, prefix)
cfm.add_fluctuations(domain,
......
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