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
7b2f7e8f
Commit
7b2f7e8f
authored
Nov 12, 2019
by
Philipp Haim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DomainTuple capability for smoothslope
parent
203b56b0
Pipeline
#63450
failed with stages
in 18 minutes and 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
25 deletions
+40
-25
nifty5/library/correlated_fields.py
nifty5/library/correlated_fields.py
+40
-25
No files found.
nifty5/library/correlated_fields.py
View file @
7b2f7e8f
...
@@ -31,11 +31,13 @@ from ..operators.distributors import PowerDistributor
...
@@ -31,11 +31,13 @@ from ..operators.distributors import PowerDistributor
from
..operators.endomorphic_operator
import
EndomorphicOperator
from
..operators.endomorphic_operator
import
EndomorphicOperator
from
..operators.harmonic_operators
import
HarmonicTransformOperator
from
..operators.harmonic_operators
import
HarmonicTransformOperator
from
..operators.linear_operator
import
LinearOperator
from
..operators.linear_operator
import
LinearOperator
from
..operators.diagonal_operator
import
DiagonalOperator
from
..operators.operator
import
Operator
from
..operators.operator
import
Operator
from
..operators.simple_linear_operators
import
VdotOperator
,
ducktape
from
..operators.simple_linear_operators
import
VdotOperator
,
ducktape
from
..operators.value_inserter
import
ValueInserter
from
..operators.value_inserter
import
ValueInserter
from
..sugar
import
from_global_data
,
from_random
,
full
,
makeDomain
from
..sugar
import
from_global_data
,
from_random
,
full
,
makeDomain
#FIXME for all space operators, check if it is valid first (e.g. parse_space())
def
_lognormal_moment_matching
(
mean
,
sig
,
key
):
def
_lognormal_moment_matching
(
mean
,
sig
,
key
):
mean
,
sig
,
key
=
float
(
mean
),
float
(
sig
),
str
(
key
)
mean
,
sig
,
key
=
float
(
mean
),
float
(
sig
),
str
(
key
)
...
@@ -53,35 +55,38 @@ def _normal(mean, sig, key):
...
@@ -53,35 +55,38 @@ def _normal(mean, sig, key):
class
_SlopeRemover
(
EndomorphicOperator
):
class
_SlopeRemover
(
EndomorphicOperator
):
def
__init__
(
self
,
domain
,
logkl
):
def
__init__
(
self
,
domain
,
cooridinates
,
space
=
0
):
self
.
_domain
=
makeDomain
(
domain
)
self
.
_domain
=
makeDomain
(
domain
)
self
.
_sc
=
logkl
/
float
(
logkl
[
-
1
])
self
.
_sc
=
cooridinates
/
float
(
cooridinates
[
-
1
])
self
.
_space
=
space
self
.
_last
=
(
slice
(
None
),)
*
self
.
_domain
.
axes
[
space
][
0
]
+
(
-
1
,)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
def
apply
(
self
,
x
,
mode
):
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
self
.
_check_input
(
x
,
mode
)
x
=
x
.
to_global_data
()
x
=
x
.
to_global_data
()
if
mode
==
self
.
TIMES
:
if
mode
==
self
.
TIMES
:
res
=
x
-
x
[
-
1
]
*
self
.
_sc
res
=
x
-
x
[
self
.
_last
]
*
self
.
_sc
else
:
else
:
#NOTE Why not x.copy()?
res
=
np
.
zeros
(
x
.
shape
,
dtype
=
x
.
dtype
)
res
=
np
.
zeros
(
x
.
shape
,
dtype
=
x
.
dtype
)
res
+=
x
res
+=
x
res
[
-
1
]
-=
(
x
*
self
.
_sc
).
sum
(
)
res
[
self
.
_last
]
-=
(
x
*
self
.
_sc
).
sum
(
axis
=
self
.
_space
)
return
from_global_data
(
self
.
_tgt
(
mode
),
res
)
return
from_global_data
(
self
.
_tgt
(
mode
),
res
)
def
_make_slope_Operator
(
smooth
,
loglogavgslope
):
def
_make_slope_Operator
(
smooth
,
loglogavgslope
,
space
=
0
):
tg
=
smooth
.
target
tg
=
smooth
.
target
logkl
=
_log_k_lengths
(
tg
[
0
])
logkl
=
_log_k_lengths
(
tg
[
space
])
assert
logkl
.
shape
[
0
]
==
tg
[
0
].
shape
[
0
]
-
1
logkl
-=
logkl
[
0
]
logkl
-=
logkl
[
0
]
logkl
=
np
.
insert
(
logkl
,
0
,
0
)
logkl
=
np
.
insert
(
logkl
,
0
,
0
)
noslope
=
_SlopeRemover
(
tg
,
logkl
)
@
smooth
noslope
=
_SlopeRemover
(
tg
,
logkl
,
space
)
@
smooth
# FIXME Move to tests
# FIXME Move to tests
consistency_check
(
_SlopeRemover
(
tg
,
logkl
))
consistency_check
(
_SlopeRemover
(
tg
,
logkl
))
_t
=
VdotOperator
(
from_global_data
(
tg
,
logkl
)).
adjoint
expander
=
ContractionOperator
(
tg
,
spaces
=
space
).
adjoint
return
_t
@
loglogavgslope
+
noslope
_t
=
DiagonalOperator
(
from_global_data
(
tg
,
logkl
),
tg
,
spaces
=
space
)
return
_t
@
expander
@
loglogavgslope
+
noslope
def
_log_k_lengths
(
pspace
):
def
_log_k_lengths
(
pspace
):
return
np
.
log
(
pspace
.
k_lengths
[
1
:])
return
np
.
log
(
pspace
.
k_lengths
[
1
:])
...
@@ -165,7 +170,7 @@ class CorrelatedFieldMaker:
...
@@ -165,7 +170,7 @@ class CorrelatedFieldMaker:
self
.
_amplitudes
=
[]
self
.
_amplitudes
=
[]
def
add_fluctuations_from_ops
(
self
,
target
,
fluctuations
,
flexibility
,
def
add_fluctuations_from_ops
(
self
,
target
,
fluctuations
,
flexibility
,
asperity
,
loglogavgslope
,
key
,
space
):
asperity
,
loglogavgslope
,
key
,
space
=
0
):
"""
"""
fluctuations > 0
fluctuations > 0
flexibility > 0
flexibility > 0
...
@@ -180,23 +185,33 @@ class CorrelatedFieldMaker:
...
@@ -180,23 +185,33 @@ class CorrelatedFieldMaker:
assert
isinstance
(
target
[
space
],
PowerSpace
)
assert
isinstance
(
target
[
space
],
PowerSpace
)
twolog
=
_TwoLogIntegrations
(
target
,
space
)
twolog
=
_TwoLogIntegrations
(
target
,
space
)
#NOTE space might not be required here
dt
=
twolog
.
_logvol
dt
=
twolog
[
space
].
_logvol
sl
=
(
slice
(
None
),)
*
target
.
axes
[
space
][
0
]
sc
=
np
.
zeros
(
twolog
.
domain
.
shape
)
first
=
sl
+
(
0
,)
sc
[
0
]
=
sc
[
1
]
=
np
.
sqrt
(
dt
)
second
=
sl
+
(
1
,)
sc
=
from_global_data
(
twolog
.
domain
,
sc
)
expander
=
ContractionOperator
(
twolog
.
domain
,
spaces
=
space
).
adjoint
expander
=
VdotOperator
(
sc
).
adjoint
sigmasq
=
expander
@
flexibility
sqrt_t
=
np
.
zeros
(
twolog
.
domain
.
shape
)
sqrt_t
[
first
]
=
sqrt_t
[
second
]
=
np
.
sqrt
(
dt
)
sqrt_t
=
from_global_data
(
twolog
.
domain
,
sqrt_t
)
sqrt_t
=
DiagonalOperator
(
sqrt_t
,
twolog
.
domain
,
spaces
=
space
)
sigmasq
=
sqrt_t
@
expander
@
flexibility
#FIXME apply dist in asperity target domain, as it is smaller
#dist = np.zeros(asperity.target.shape)
#dist[first] = 1.
#dist = from_global_data(asperity.target, dist)
#dist = DiagonalOperator(dist, asperity.target, spaces = space)
#scale = sigmasq*(Adder(shift) @ expander @ dist @ asperity).sqrt()
dist
=
np
.
zeros
(
twolog
.
domain
.
shape
)
dist
=
np
.
zeros
(
twolog
.
domain
.
shape
)
dist
[
0
]
+=
1.
dist
+=
1.
dist
=
from_global_data
(
twolog
.
domain
,
dist
)
dist
=
from_global_data
(
twolog
.
domain
,
dist
)
scale
=
VdotOperator
(
dist
).
adjoint
@
asperity
dist
=
DiagonalOperator
(
dist
,
twolog
.
domain
,
spaces
=
space
)
shift
=
np
.
ones
(
scale
.
target
.
shape
)
shift
=
np
.
ones
(
twolog
.
domain
.
shape
)
shift
[
0
]
=
dt
**
2
/
12.
shift
[
first
]
=
dt
**
2
/
12.
shift
=
from_global_data
(
scale
.
target
,
shift
)
shift
=
from_global_data
(
twolog
.
domain
,
shift
)
scale
=
sigmasq
*
(
Adder
(
shift
)
@
scale
).
sqrt
()
scale
=
sigmasq
*
(
Adder
(
shift
)
@
dist
@
expander
@
asperity
).
sqrt
()
smooth
=
twolog
@
(
scale
*
ducktape
(
scale
.
target
,
None
,
key
))
smooth
=
twolog
@
(
scale
*
ducktape
(
scale
.
target
,
None
,
key
))
smoothslope
=
_make_slope_Operator
(
smooth
,
loglogavgslope
)
smoothslope
=
_make_slope_Operator
(
smooth
,
loglogavgslope
)
...
...
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