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
10
Issues
10
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
4af129bb
Commit
4af129bb
authored
Jul 13, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tweaks
parent
79a6fd2f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
27 deletions
+29
-27
demos/getting_started_1.py
demos/getting_started_1.py
+10
-10
nifty5/__init__.py
nifty5/__init__.py
+1
-1
nifty5/plotting/plot.py
nifty5/plotting/plot.py
+18
-16
No files found.
demos/getting_started_1.py
View file @
4af129bb
...
@@ -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
=
1
mode
=
0
if
mode
==
0
:
if
mode
==
0
:
# One dimensional regular grid
# One dimensional regular grid
position_space
=
ift
.
RGSpace
([
1024
])
position_space
=
ift
.
RGSpace
([
1024
])
...
@@ -104,14 +104,14 @@ if __name__ == '__main__':
...
@@ -104,14 +104,14 @@ if __name__ == '__main__':
# PLOTTING
# PLOTTING
rg
=
isinstance
(
position_space
,
ift
.
RGSpace
)
rg
=
isinstance
(
position_space
,
ift
.
RGSpace
)
if
rg
and
len
(
position_space
.
shape
)
==
1
:
if
rg
and
len
(
position_space
.
shape
)
==
1
:
ift
.
add_
plot
([
HT
(
MOCK_SIGNAL
),
GR
.
adjoint
(
data
),
HT
(
m
)],
ift
.
plot
([
HT
(
MOCK_SIGNAL
),
GR
.
adjoint
(
data
),
HT
(
m
)],
label
=
[
'Mock signal'
,
'Data'
,
'Reconstruction'
],
label
=
[
'Mock signal'
,
'Data'
,
'Reconstruction'
],
alpha
=
[
1
,
.
3
,
1
],
alpha
=
[
1
,
.
3
,
1
])
name
=
'getting_started_1.png'
)
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)))
ift
.
plot_finish
(
1
,
2
,
xsize
=
10
,
ysize
=
4
,
title
=
"getting_started_1"
)
else
:
else
:
ift
.
add_plot
(
HT
(
MOCK_SIGNAL
),
title
=
'Mock Signal'
,
name
=
'mock_signal.png'
)
ift
.
plot
(
HT
(
MOCK_SIGNAL
),
title
=
'Mock Signal'
)
ift
.
add_plot
(
mask_to_nan
(
mask
,
(
GR
*
Mask
).
adjoint
(
data
)),
ift
.
plot
(
mask_to_nan
(
mask
,
(
GR
*
Mask
).
adjoint
(
data
)),
title
=
'Data'
)
title
=
'Data'
,
name
=
'data.png'
)
ift
.
plot
(
HT
(
m
),
title
=
'Reconstruction'
)
ift
.
add_plot
(
HT
(
m
),
title
=
'Reconstruction'
,
name
=
'reconstruction.png'
)
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)))
ift
.
add_plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)),
name
=
'residuals.png'
)
ift
.
plot_finish
(
2
,
2
,
xsize
=
10
,
ysize
=
8
,
title
=
"getting_started_1"
)
ift
.
plot
()
nifty5/__init__.py
View file @
4af129bb
...
@@ -73,7 +73,7 @@ from .minimization.line_energy import LineEnergy
...
@@ -73,7 +73,7 @@ from .minimization.line_energy import LineEnergy
from
.minimization.energy_sum
import
EnergySum
from
.minimization.energy_sum
import
EnergySum
from
.sugar
import
*
from
.sugar
import
*
from
.plotting.plot
import
add_plot
,
plot
from
.plotting.plot
import
plot
,
plot_finish
from
.library.amplitude_model
import
make_amplitude_model
from
.library.amplitude_model
import
make_amplitude_model
from
.library.gaussian_energy
import
GaussianEnergy
from
.library.gaussian_energy
import
GaussianEnergy
...
...
nifty5/plotting/plot.py
View file @
4af129bb
...
@@ -23,7 +23,12 @@ import os
...
@@ -23,7 +23,12 @@ import os
import
numpy
as
np
import
numpy
as
np
from
..compat
import
*
from
..compat
import
*
from
..
import
Field
,
GLSpace
,
HPSpace
,
PowerSpace
,
RGSpace
,
dobj
from
..field
import
Field
from
..domains.gl_space
import
GLSpace
from
..domains.hp_space
import
HPSpace
from
..domains.power_space
import
PowerSpace
from
..domains.rg_space
import
RGSpace
from
..
import
dobj
# relevant properties:
# relevant properties:
# - x/y size
# - x/y size
...
@@ -209,12 +214,6 @@ def _plot(f, ax, **kwargs):
...
@@ -209,12 +214,6 @@ def _plot(f, ax, **kwargs):
alpha
=
[
alpha
]
alpha
=
[
alpha
]
dom
=
dom
[
0
]
dom
=
dom
[
0
]
#fig = plt.figure()
#ax = fig.add_subplot(1, 1, 1)
#xsize = kwargs.pop("xsize", 6)
#ysize = kwargs.pop("ysize", 6)
#fig.set_size_inches(xsize, ysize)
ax
.
set_title
(
kwargs
.
pop
(
"title"
,
""
))
ax
.
set_title
(
kwargs
.
pop
(
"title"
,
""
))
ax
.
set_xlabel
(
kwargs
.
pop
(
"xlabel"
,
""
))
ax
.
set_xlabel
(
kwargs
.
pop
(
"xlabel"
,
""
))
ax
.
set_ylabel
(
kwargs
.
pop
(
"ylabel"
,
""
))
ax
.
set_ylabel
(
kwargs
.
pop
(
"ylabel"
,
""
))
...
@@ -231,7 +230,6 @@ def _plot(f, ax, **kwargs):
...
@@ -231,7 +230,6 @@ def _plot(f, ax, **kwargs):
_limit_xy
(
**
kwargs
)
_limit_xy
(
**
kwargs
)
if
label
!=
([
None
]
*
len
(
f
)):
if
label
!=
([
None
]
*
len
(
f
)):
plt
.
legend
()
plt
.
legend
()
#_makeplot(kwargs.get("name"))
return
return
elif
len
(
dom
.
shape
)
==
2
:
elif
len
(
dom
.
shape
)
==
2
:
f
=
f
[
0
]
f
=
f
[
0
]
...
@@ -251,7 +249,6 @@ def _plot(f, ax, **kwargs):
...
@@ -251,7 +249,6 @@ def _plot(f, ax, **kwargs):
# plt.colorbar(im,cax=cax)
# plt.colorbar(im,cax=cax)
plt
.
colorbar
(
im
)
plt
.
colorbar
(
im
)
_limit_xy
(
**
kwargs
)
_limit_xy
(
**
kwargs
)
#_makeplot(kwargs.get("name"))
return
return
elif
isinstance
(
dom
,
PowerSpace
):
elif
isinstance
(
dom
,
PowerSpace
):
plt
.
xscale
(
'log'
)
plt
.
xscale
(
'log'
)
...
@@ -265,7 +262,6 @@ def _plot(f, ax, **kwargs):
...
@@ -265,7 +262,6 @@ def _plot(f, ax, **kwargs):
_limit_xy
(
**
kwargs
)
_limit_xy
(
**
kwargs
)
if
label
!=
([
None
]
*
len
(
f
)):
if
label
!=
([
None
]
*
len
(
f
)):
plt
.
legend
()
plt
.
legend
()
#_makeplot(kwargs.get("name"))
return
return
elif
isinstance
(
dom
,
HPSpace
):
elif
isinstance
(
dom
,
HPSpace
):
f
=
f
[
0
]
f
=
f
[
0
]
...
@@ -282,7 +278,6 @@ def _plot(f, ax, **kwargs):
...
@@ -282,7 +278,6 @@ def _plot(f, ax, **kwargs):
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"zmin"
),
vmax
=
kwargs
.
get
(
"zmax"
),
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"zmin"
),
vmax
=
kwargs
.
get
(
"zmax"
),
cmap
=
cmap
,
origin
=
"lower"
)
cmap
=
cmap
,
origin
=
"lower"
)
plt
.
colorbar
(
orientation
=
"horizontal"
)
plt
.
colorbar
(
orientation
=
"horizontal"
)
#_makeplot(kwargs.get("name"))
return
return
elif
isinstance
(
dom
,
GLSpace
):
elif
isinstance
(
dom
,
GLSpace
):
f
=
f
[
0
]
f
=
f
[
0
]
...
@@ -300,7 +295,6 @@ def _plot(f, ax, **kwargs):
...
@@ -300,7 +295,6 @@ def _plot(f, ax, **kwargs):
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"zmin"
),
vmax
=
kwargs
.
get
(
"zmax"
),
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"zmin"
),
vmax
=
kwargs
.
get
(
"zmax"
),
cmap
=
cmap
,
origin
=
"lower"
)
cmap
=
cmap
,
origin
=
"lower"
)
plt
.
colorbar
(
orientation
=
"horizontal"
)
plt
.
colorbar
(
orientation
=
"horizontal"
)
#_makeplot(kwargs.get("name"))
return
return
raise
ValueError
(
"Field type not(yet) supported"
)
raise
ValueError
(
"Field type not(yet) supported"
)
...
@@ -308,15 +302,23 @@ def _plot(f, ax, **kwargs):
...
@@ -308,15 +302,23 @@ def _plot(f, ax, **kwargs):
_plots
=
[]
_plots
=
[]
_kwargs
=
[]
_kwargs
=
[]
def
add_
plot
(
f
,
**
kwargs
):
def
plot
(
f
,
**
kwargs
):
_plots
.
append
(
f
)
_plots
.
append
(
f
)
_kwargs
.
append
(
kwargs
)
_kwargs
.
append
(
kwargs
)
def
plot
(
**
kwargs
):
def
plot_finish
(
nx
,
ny
,
**
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
:
plt
.
suptitle
(
kwargs
.
pop
(
"title"
))
xsize
=
kwargs
.
pop
(
"xsize"
,
6
)
ysize
=
kwargs
.
pop
(
"ysize"
,
6
)
fig
.
set_size_inches
(
xsize
,
ysize
)
for
i
in
range
(
nplot
):
for
i
in
range
(
nplot
):
ax
=
fig
.
add_subplot
(
n
plot
,
1
,
i
+
1
)
ax
=
fig
.
add_subplot
(
n
x
,
ny
,
i
+
1
)
_plot
(
_plots
[
i
],
ax
,
**
_kwargs
[
i
])
_plot
(
_plots
[
i
],
ax
,
**
_kwargs
[
i
])
_makeplot
(
None
)
_makeplot
(
kwargs
.
pop
(
"name"
,
None
))
_plots
=
[]
_kwargs
=
[]
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