Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
72fee3d5
Commit
72fee3d5
authored
Nov 07, 2019
by
Philipp Arras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move amplitude operator to its own class
parent
c0177abb
Pipeline
#63187
failed with stages
in 4 minutes and 15 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
44 deletions
+58
-44
nifty5/library/correlated_fields.py
nifty5/library/correlated_fields.py
+58
-44
No files found.
nifty5/library/correlated_fields.py
View file @
72fee3d5
...
...
@@ -150,12 +150,9 @@ class _SpecialSum(EndomorphicOperator):
return
full
(
self
.
_tgt
(
mode
),
x
.
sum
())
class
CorrelatedFieldMaker
:
def
__init__
(
self
):
self
.
_amplitudes
=
[]
def
add_fluctuations_from_ops
(
self
,
target
,
fluctuations
,
flexibility
,
asperity
,
loglogavgslope
,
key
):
class
_Amplitude
(
Operator
):
def
__init__
(
self
,
target
,
fluctuations
,
flexibility
,
asperity
,
loglogavgslope
,
key
):
"""
fluctuations > 0
flexibility > 0
...
...
@@ -199,14 +196,31 @@ class CorrelatedFieldMaker:
mask
=
np
.
zeros
(
target
.
shape
)
mask
[
0
]
=
vol
adder
=
Adder
(
from_global_data
(
target
,
mask
))
ampl
=
adder
@
((
expander
@
fluctuations
)
*
normal_ampl
)
self
.
_op
=
adder
@
((
expander
@
fluctuations
)
*
normal_ampl
)
self
.
_amplitudes
.
append
(
ampl
)
self
.
_domain
=
self
.
_op
.
domain
self
.
_target
=
self
.
_op
.
target
def
add_fluctuations
(
self
,
target
,
fluctuations_mean
,
fluctuations_stddev
,
flexibility_mean
,
flexibility_stddev
,
asperity_mean
,
asperity_stddev
,
loglogavgslope_mean
,
loglogavgslope_stddev
,
prefix
):
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
return
self
.
_op
(
x
)
class
CorrelatedFieldMaker
:
def
__init__
(
self
):
self
.
_a
=
[]
def
add_fluctuations
(
self
,
target
,
fluctuations_mean
,
fluctuations_stddev
,
flexibility_mean
,
flexibility_stddev
,
asperity_mean
,
asperity_stddev
,
loglogavgslope_mean
,
loglogavgslope_stddev
,
prefix
=
''
):
fluctuations_mean
=
float
(
fluctuations_mean
)
fluctuations_stddev
=
float
(
fluctuations_stddev
)
flexibility_mean
=
float
(
flexibility_mean
)
...
...
@@ -233,16 +247,40 @@ class CorrelatedFieldMaker:
prefix
+
'asperity'
)
avgsl
=
_normal
(
loglogavgslope_mean
,
loglogavgslope_stddev
,
prefix
+
'loglogavgslope'
)
self
.
add_fluctuations_from_ops
(
target
,
fluct
,
flex
,
asp
,
avgsl
,
prefix
+
'spectrum'
)
self
.
_a
.
append
(
_Amplitude
(
target
,
fluct
,
flex
,
asp
,
avgsl
,
prefix
+
'spectrum'
)
)
def
finalize_from_op
(
self
,
zeromode
):
raise
NotImplementedError
def
finalize_from_op
(
self
,
zeromode
,
prefix
=
''
):
assert
isinstance
(
zeromode
,
Operator
)
hspace
=
makeDomain
([
dd
.
target
[
0
].
harmonic_partner
for
dd
in
self
.
_a
])
foo
=
np
.
ones
(
hspace
.
shape
)
zeroind
=
len
(
hspace
.
shape
)
*
(
0
,)
foo
[
zeroind
]
=
0
azm
=
Adder
(
from_global_data
(
hspace
,
foo
))
@
ValueInserter
(
hspace
,
zeroind
)
@
zeromode
n_amplitudes
=
len
(
self
.
_a
)
ht
=
HarmonicTransformOperator
(
hspace
,
space
=
0
)
for
i
in
range
(
1
,
n_amplitudes
):
ht
=
HarmonicTransformOperator
(
ht
.
target
,
space
=
i
)
@
ht
pd
=
PowerDistributor
(
hspace
,
self
.
_a
[
0
].
target
[
0
],
0
)
for
i
in
range
(
1
,
n_amplitudes
):
foo
=
PowerDistributor
(
pd
.
domain
,
self
.
_a
[
i
].
target
[
0
],
space
=
i
)
pd
=
pd
@
foo
spaces
=
tuple
(
range
(
n_amplitudes
))
a
=
ContractionOperator
(
pd
.
domain
,
spaces
[
1
:]).
adjoint
@
self
.
_a
[
0
]
for
i
in
range
(
1
,
n_amplitudes
):
co
=
ContractionOperator
(
pd
.
domain
,
spaces
[:
i
]
+
spaces
[(
i
+
1
):])
a
=
a
*
(
co
.
adjoint
@
self
.
_a
[
i
])
return
ht
(
azm
*
(
pd
@
a
)
*
ducktape
(
hspace
,
None
,
prefix
+
'xi'
))
def
finalize
(
self
,
offset_amplitude_mean
,
offset_amplitude_stddev
,
prefix
,
prefix
=
''
,
offset
=
None
):
"""
offset vs zeromode: volume factor
...
...
@@ -252,39 +290,16 @@ class CorrelatedFieldMaker:
assert
offset_amplitude_stddev
>
0
assert
offset_amplitude_mean
>
0
if
offset
is
not
None
:
raise
NotImplementedError
offset
=
float
(
offset
)
hspace
=
makeDomain
(
[
dd
.
target
[
0
].
harmonic_partner
for
dd
in
self
.
_amplitudes
])
azm
=
_lognormal_moment_matching
(
offset_amplitude_mean
,
offset_amplitude_stddev
,
prefix
+
'zeromode'
)
foo
=
np
.
ones
(
hspace
.
shape
)
zeroind
=
len
(
hspace
.
shape
)
*
(
0
,)
foo
[
zeroind
]
=
0
azm
=
Adder
(
from_global_data
(
hspace
,
foo
))
@
ValueInserter
(
hspace
,
zeroind
)
@
azm
ht
=
HarmonicTransformOperator
(
hspace
,
space
=
0
)
pd
=
PowerDistributor
(
hspace
,
self
.
_amplitudes
[
0
].
target
[
0
],
0
)
for
i
in
range
(
1
,
len
(
self
.
_amplitudes
)):
ht
=
HarmonicTransformOperator
(
ht
.
target
,
space
=
i
)
@
ht
pd
=
pd
@
PowerDistributor
(
pd
.
domain
,
self
.
_amplitudes
[
i
].
target
[
0
],
space
=
i
)
spaces
=
tuple
(
range
(
len
(
self
.
_amplitudes
)))
a
=
ContractionOperator
(
pd
.
domain
,
spaces
[
1
:]).
adjoint
(
self
.
_amplitudes
[
0
])
for
i
in
range
(
1
,
len
(
self
.
_amplitudes
)):
a
=
a
*
(
ContractionOperator
(
pd
.
domain
,
spaces
[:
i
]
+
spaces
[
(
i
+
1
):]).
adjoint
(
self
.
_amplitudes
[
i
]))
A
=
pd
@
a
return
ht
(
azm
*
A
*
ducktape
(
hspace
,
None
,
prefix
+
'xi'
))
return
self
.
finalize_from_op
(
azm
,
prefix
)
@
property
def
amplitudes
(
self
):
return
self
.
_a
mplitudes
return
self
.
_a
def
effective_total_fluctuation
(
self
,
fluctuations_means
,
...
...
@@ -292,7 +307,6 @@ class CorrelatedFieldMaker:
nsamples
=
100
):
namps
=
len
(
fluctuations_means
)
xis
=
np
.
random
.
normal
(
size
=
namps
*
nsamples
).
reshape
((
namps
,
nsamples
))
q
=
np
.
ones
(
nsamples
)
for
i
in
range
(
len
(
fluctuations_means
)):
m
,
sig
=
_lognormal_moments
(
fluctuations_means
[
i
],
...
...
Write
Preview
Markdown
is supported
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