Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nifty_tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
nifty_tutorial
Commits
30f93091
Commit
30f93091
authored
6 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Refactor wf example
parent
f2530492
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
1_wiener_filter.py
+3
-18
3 additions, 18 deletions
1_wiener_filter.py
helpers/generate_data.py
+14
-0
14 additions, 0 deletions
helpers/generate_data.py
with
17 additions
and
18 deletions
1_wiener_filter.py
+
3
−
18
View file @
30f93091
...
...
@@ -18,7 +18,7 @@
import
numpy
as
np
import
nifty5
as
ift
from
helpers
import
plot_WF
from
helpers
import
generate_wf_data
,
plot_WF
np
.
random
.
seed
(
42
)
...
...
@@ -26,23 +26,13 @@ np.random.seed(42)
position_space
=
ift
.
RGSpace
(
256
)
# Generate data and signal
harmonic_space
=
position_space
.
get_default_codomain
()
HT
=
ift
.
HartleyOperator
(
harmonic_space
,
target
=
position_space
)
N
=
ift
.
ScalingOperator
(
0.1
,
position_space
)
S_k
=
ift
.
create_power_operator
(
harmonic_space
,
lambda
k
:
1
/
(
10.
+
k
**
2.5
))
s
=
HT
(
S_k
.
draw_sample
())
d
=
s
+
N
.
draw_sample
()
np
.
save
(
'
data.npy
'
,
d
.
to_global_data
())
np
.
save
(
'
signal.npy
'
,
s
.
to_global_data
())
# End generate data and signal
prior_spectrum
=
lambda
k
:
1
/
(
10.
+
k
**
2.5
)
data
,
ground_truth
=
generate_wf_data
(
position_space
,
prior_spectrum
)
R
=
ift
.
GeometryRemover
(
position_space
)
data_space
=
R
.
target
data
=
np
.
load
(
'
data.npy
'
)
data
=
ift
.
from_global_data
(
data_space
,
data
)
ground_truth
=
np
.
load
(
'
signal.npy
'
)
ground_truth
=
ift
.
from_global_data
(
position_space
,
ground_truth
)
plot_WF
(
'
data
'
,
ground_truth
,
data
)
...
...
@@ -51,11 +41,6 @@ N = ift.ScalingOperator(0.1, data_space)
harmonic_space
=
position_space
.
get_default_codomain
()
HT
=
ift
.
HartleyOperator
(
harmonic_space
,
target
=
position_space
)
def
prior_spectrum
(
k
):
return
1
/
(
10.
+
k
**
2.5
)
S_h
=
ift
.
create_power_operator
(
harmonic_space
,
prior_spectrum
)
S
=
HT
@
S_h
@
HT
.
adjoint
...
...
This diff is collapsed.
Click to expand it.
helpers/generate_data.py
+
14
−
0
View file @
30f93091
...
...
@@ -38,3 +38,17 @@ def generate_bernoulli_data(signal_response):
rate
=
signal_response
(
ground_truth
).
to_global_data
()
d
=
np
.
random
.
binomial
(
1
,
rate
)
return
ift
.
from_global_data
(
signal_response
.
target
,
d
),
ground_truth
def
generate_wf_data
(
domain
,
spectrum
):
harmonic_space
=
domain
.
get_default_codomain
()
HT
=
ift
.
HartleyOperator
(
harmonic_space
,
target
=
domain
)
N
=
ift
.
ScalingOperator
(
0.1
,
domain
)
S_k
=
ift
.
create_power_operator
(
harmonic_space
,
spectrum
)
s
=
HT
(
S_k
.
draw_sample
()).
to_global_data
()
d
=
(
s
+
N
.
draw_sample
()).
to_global_data
()
return
d
,
s
def
generate_mysterious_data
(
domain
):
return
generate_wf_data
(
domain
,
lambda
k
:
5
/
((
7
**
2
-
k
**
2
)
**
2
+
3
**
2
*
k
**
2
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment