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
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
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
bedbdb64
Commit
bedbdb64
authored
Jul 13, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust demos
parent
4af129bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
27 deletions
+25
-27
demos/bernoulli_demo.py
demos/bernoulli_demo.py
+4
-3
demos/getting_started_1.py
demos/getting_started_1.py
+5
-3
demos/getting_started_3.py
demos/getting_started_3.py
+12
-9
nifty5/plotting/plot.py
nifty5/plotting/plot.py
+4
-12
No files found.
demos/bernoulli_demo.py
View file @
bedbdb64
...
@@ -88,6 +88,7 @@ if __name__ == '__main__':
...
@@ -88,6 +88,7 @@ if __name__ == '__main__':
reconstruction
=
sky
.
at
(
H
.
position
).
value
reconstruction
=
sky
.
at
(
H
.
position
).
value
ift
.
plot
(
reconstruction
,
title
=
'reconstruction'
,
name
=
'reconstruction.png'
)
ift
.
plot
(
reconstruction
,
title
=
'reconstruction'
)
ift
.
plot
(
GR
.
adjoint_times
(
data
),
title
=
'data'
,
name
=
'data.png'
)
ift
.
plot
(
GR
.
adjoint_times
(
data
),
title
=
'data'
)
ift
.
plot
(
sky
.
at
(
mock_position
).
value
,
title
=
'truth'
,
name
=
'truth.png'
)
ift
.
plot
(
sky
.
at
(
mock_position
).
value
,
title
=
'truth'
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"results"
,
name
=
"bernoulli.png"
)
demos/getting_started_1.py
View file @
bedbdb64
...
@@ -46,7 +46,7 @@ if __name__ == '__main__':
...
@@ -46,7 +46,7 @@ if __name__ == '__main__':
# FIXME description of the tutorial
# FIXME description of the tutorial
# Choose problem geometry and masking
# Choose problem geometry and masking
mode
=
0
mode
=
1
if
mode
==
0
:
if
mode
==
0
:
# One dimensional regular grid
# One dimensional regular grid
position_space
=
ift
.
RGSpace
([
1024
])
position_space
=
ift
.
RGSpace
([
1024
])
...
@@ -108,10 +108,12 @@ if __name__ == '__main__':
...
@@ -108,10 +108,12 @@ if __name__ == '__main__':
label
=
[
'Mock signal'
,
'Data'
,
'Reconstruction'
],
label
=
[
'Mock signal'
,
'Data'
,
'Reconstruction'
],
alpha
=
[
1
,
.
3
,
1
])
alpha
=
[
1
,
.
3
,
1
])
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)))
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)))
ift
.
plot_finish
(
1
,
2
,
xsize
=
10
,
ysize
=
4
,
title
=
"getting_started_1"
)
ift
.
plot_finish
(
nx
=
2
,
ny
=
1
,
xsize
=
10
,
ysize
=
4
,
title
=
"getting_started_1"
)
else
:
else
:
ift
.
plot
(
HT
(
MOCK_SIGNAL
),
title
=
'Mock Signal'
)
ift
.
plot
(
HT
(
MOCK_SIGNAL
),
title
=
'Mock Signal'
)
ift
.
plot
(
mask_to_nan
(
mask
,
(
GR
*
Mask
).
adjoint
(
data
)),
title
=
'Data'
)
ift
.
plot
(
mask_to_nan
(
mask
,
(
GR
*
Mask
).
adjoint
(
data
)),
title
=
'Data'
)
ift
.
plot
(
HT
(
m
),
title
=
'Reconstruction'
)
ift
.
plot
(
HT
(
m
),
title
=
'Reconstruction'
)
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)))
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)))
ift
.
plot_finish
(
2
,
2
,
xsize
=
10
,
ysize
=
8
,
title
=
"getting_started_1"
)
ift
.
plot_finish
(
nx
=
4
,
ny
=
1
,
xsize
=
20
,
ysize
=
4
,
title
=
"getting_started_1"
)
demos/getting_started_3.py
View file @
bedbdb64
...
@@ -83,13 +83,14 @@ if __name__ == '__main__':
...
@@ -83,13 +83,14 @@ if __name__ == '__main__':
INITIAL_POSITION
=
ift
.
from_random
(
'normal'
,
H
.
position
.
domain
)
INITIAL_POSITION
=
ift
.
from_random
(
'normal'
,
H
.
position
.
domain
)
position
=
INITIAL_POSITION
position
=
INITIAL_POSITION
ift
.
plot
(
signal
.
at
(
MOCK_POSITION
).
value
,
name
=
'truth.png'
)
ift
.
plot
(
signal
.
at
(
MOCK_POSITION
).
value
,
title
=
'ground truth'
)
ift
.
plot
(
R
.
adjoint_times
(
data
),
name
=
'data.png'
)
ift
.
plot
(
R
.
adjoint_times
(
data
),
title
=
'data'
)
ift
.
plot
([
A
.
at
(
MOCK_POSITION
).
value
],
name
=
'power.png'
)
ift
.
plot
([
A
.
at
(
MOCK_POSITION
).
value
],
title
=
'power'
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"setup"
,
name
=
"setup.png"
)
# number of samples used to estimate the KL
# number of samples used to estimate the KL
N_samples
=
20
N_samples
=
20
for
i
in
range
(
5
):
for
i
in
range
(
2
):
H
=
H
.
at
(
position
)
H
=
H
.
at
(
position
)
samples
=
[
H
.
metric
.
draw_sample
(
from_inverse
=
True
)
samples
=
[
H
.
metric
.
draw_sample
(
from_inverse
=
True
)
for
_
in
range
(
N_samples
)]
for
_
in
range
(
N_samples
)]
...
@@ -99,17 +100,19 @@ if __name__ == '__main__':
...
@@ -99,17 +100,19 @@ if __name__ == '__main__':
KL
,
convergence
=
minimizer
(
KL
)
KL
,
convergence
=
minimizer
(
KL
)
position
=
KL
.
position
position
=
KL
.
position
ift
.
plot
(
signal
.
at
(
position
).
value
,
name
=
'reconstruction.png'
)
ift
.
plot
(
signal
.
at
(
position
).
value
,
title
=
"reconstruction"
)
ift
.
plot
([
A
.
at
(
position
).
value
,
A
.
at
(
MOCK_POSITION
).
value
],
ift
.
plot
([
A
.
at
(
position
).
value
,
A
.
at
(
MOCK_POSITION
).
value
],
name
=
'power.png'
)
title
=
"power"
)
ift
.
plot_finish
(
nx
=
2
,
xsize
=
12
,
ysize
=
6
,
title
=
"loop"
,
name
=
"loop.png"
)
sc
=
ift
.
StatCalculator
()
sc
=
ift
.
StatCalculator
()
for
sample
in
samples
:
for
sample
in
samples
:
sc
.
add
(
signal
.
at
(
sample
+
position
).
value
)
sc
.
add
(
signal
.
at
(
sample
+
position
).
value
)
ift
.
plot
(
sc
.
mean
,
name
=
'avrg.png'
)
ift
.
plot
(
sc
.
mean
,
title
=
"mean"
)
ift
.
plot
(
ift
.
sqrt
(
sc
.
var
),
name
=
'std.png'
)
ift
.
plot
(
ift
.
sqrt
(
sc
.
var
),
title
=
"std deviation"
)
powers
=
[
A
.
at
(
s
+
position
).
value
for
s
in
samples
]
powers
=
[
A
.
at
(
s
+
position
).
value
for
s
in
samples
]
ift
.
plot
([
A
.
at
(
position
).
value
,
A
.
at
(
MOCK_POSITION
).
value
]
+
powers
,
ift
.
plot
([
A
.
at
(
position
).
value
,
A
.
at
(
MOCK_POSITION
).
value
]
+
powers
,
name
=
'power.png'
)
title
=
"power"
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"results"
,
name
=
"results.png"
)
nifty5/plotting/plot.py
View file @
bedbdb64
...
@@ -86,16 +86,6 @@ def _makeplot(name):
...
@@ -86,16 +86,6 @@ def _makeplot(name):
elif
extension
==
".png"
:
elif
extension
==
".png"
:
plt
.
savefig
(
name
)
plt
.
savefig
(
name
)
plt
.
close
()
plt
.
close
()
# elif extension==".html":
# import mpld3
# mpld3.save_html(plt.gcf(),fileobj=name,no_extras=True)
# import plotly.offline as py
# import plotly.tools as tls
# plotly_fig = tls.mpl_to_plotly(plt.gcf())
# py.plot(plotly_fig,filename=name)
# py.plot_mpl(plt.gcf(),filename=name)
# import bokeh
# bokeh.mpl.to_bokeh(plt.gcf())
else
:
else
:
raise
ValueError
(
"file format not understood"
)
raise
ValueError
(
"file format not understood"
)
...
@@ -306,18 +296,20 @@ def plot(f, **kwargs):
...
@@ -306,18 +296,20 @@ def plot(f, **kwargs):
_plots
.
append
(
f
)
_plots
.
append
(
f
)
_kwargs
.
append
(
kwargs
)
_kwargs
.
append
(
kwargs
)
def
plot_finish
(
nx
,
ny
,
**
kwargs
):
def
plot_finish
(
**
kwargs
):
global
_plots
,
_kwargs
global
_plots
,
_kwargs
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
nplot
=
len
(
_plots
)
nplot
=
len
(
_plots
)
fig
=
plt
.
figure
()
fig
=
plt
.
figure
()
if
"title"
in
kwargs
:
if
"title"
in
kwargs
:
plt
.
suptitle
(
kwargs
.
pop
(
"title"
))
plt
.
suptitle
(
kwargs
.
pop
(
"title"
))
nx
=
kwargs
.
pop
(
"nx"
,
1
)
ny
=
kwargs
.
pop
(
"ny"
,
1
)
xsize
=
kwargs
.
pop
(
"xsize"
,
6
)
xsize
=
kwargs
.
pop
(
"xsize"
,
6
)
ysize
=
kwargs
.
pop
(
"ysize"
,
6
)
ysize
=
kwargs
.
pop
(
"ysize"
,
6
)
fig
.
set_size_inches
(
xsize
,
ysize
)
fig
.
set_size_inches
(
xsize
,
ysize
)
for
i
in
range
(
nplot
):
for
i
in
range
(
nplot
):
ax
=
fig
.
add_subplot
(
n
x
,
ny
,
i
+
1
)
ax
=
fig
.
add_subplot
(
n
y
,
nx
,
i
+
1
)
_plot
(
_plots
[
i
],
ax
,
**
_kwargs
[
i
])
_plot
(
_plots
[
i
],
ax
,
**
_kwargs
[
i
])
_makeplot
(
kwargs
.
pop
(
"name"
,
None
))
_makeplot
(
kwargs
.
pop
(
"name"
,
None
))
_plots
=
[]
_plots
=
[]
...
...
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