Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
79a6fd2f
Commit
79a6fd2f
authored
6 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
experiment
parent
de0a55da
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
demos/getting_started_1.py
+7
-7
7 additions, 7 deletions
demos/getting_started_1.py
nifty5/__init__.py
+1
-1
1 addition, 1 deletion
nifty5/__init__.py
nifty5/plotting/plot.py
+27
-11
27 additions, 11 deletions
nifty5/plotting/plot.py
with
35 additions
and
19 deletions
demos/getting_started_1.py
+
7
−
7
View file @
79a6fd2f
...
...
@@ -46,7 +46,7 @@ if __name__ == '__main__':
# FIXME description of the tutorial
# Choose problem geometry and masking
mode
=
0
mode
=
1
if
mode
==
0
:
# One dimensional regular grid
position_space
=
ift
.
RGSpace
([
1024
])
...
...
@@ -104,14 +104,14 @@ if __name__ == '__main__':
# PLOTTING
rg
=
isinstance
(
position_space
,
ift
.
RGSpace
)
if
rg
and
len
(
position_space
.
shape
)
==
1
:
ift
.
plot
([
HT
(
MOCK_SIGNAL
),
GR
.
adjoint
(
data
),
HT
(
m
)],
ift
.
add_
plot
([
HT
(
MOCK_SIGNAL
),
GR
.
adjoint
(
data
),
HT
(
m
)],
label
=
[
'
Mock signal
'
,
'
Data
'
,
'
Reconstruction
'
],
alpha
=
[
1
,
.
3
,
1
],
name
=
'
getting_started_1.png
'
)
else
:
ift
.
plot
(
HT
(
MOCK_SIGNAL
),
title
=
'
Mock Signal
'
,
name
=
'
mock_signal.png
'
)
ift
.
plot
(
mask_to_nan
(
mask
,
(
GR
*
Mask
).
adjoint
(
data
)),
ift
.
add_
plot
(
HT
(
MOCK_SIGNAL
),
title
=
'
Mock Signal
'
,
name
=
'
mock_signal.png
'
)
ift
.
add_
plot
(
mask_to_nan
(
mask
,
(
GR
*
Mask
).
adjoint
(
data
)),
title
=
'
Data
'
,
name
=
'
data.png
'
)
ift
.
plot
(
HT
(
m
),
title
=
'
Reconstruction
'
,
name
=
'
reconstruction.png
'
)
ift
.
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)),
name
=
'
residuals.png
'
)
ift
.
add_
plot
(
HT
(
m
),
title
=
'
Reconstruction
'
,
name
=
'
reconstruction.png
'
)
ift
.
add_
plot
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)),
name
=
'
residuals.png
'
)
ift
.
plot
()
This diff is collapsed.
Click to expand it.
nifty5/__init__.py
+
1
−
1
View file @
79a6fd2f
...
...
@@ -73,7 +73,7 @@ from .minimization.line_energy import LineEnergy
from
.minimization.energy_sum
import
EnergySum
from
.sugar
import
*
from
.plotting.plot
import
plot
from
.plotting.plot
import
add_plot
,
plot
from
.library.amplitude_model
import
make_amplitude_model
from
.library.gaussian_energy
import
GaussianEnergy
...
...
This diff is collapsed.
Click to expand it.
nifty5/plotting/plot.py
+
27
−
11
View file @
79a6fd2f
...
...
@@ -169,7 +169,7 @@ def _register_cmaps():
plt
.
register_cmap
(
cmap
=
LinearSegmentedColormap
(
"
Plus Minus
"
,
pm_cmap
))
def
plot
(
f
,
**
kwargs
):
def
_
plot
(
f
,
ax
,
**
kwargs
):
import
matplotlib.pyplot
as
plt
_register_cmaps
()
if
isinstance
(
f
,
Field
):
...
...
@@ -209,12 +209,12 @@ def plot(f, **kwargs):
alpha
=
[
alpha
]
dom
=
dom
[
0
]
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
1
,
1
,
1
)
#
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
)
#
xsize = kwargs.pop("xsize", 6)
#
ysize = kwargs.pop("ysize", 6)
#
fig.set_size_inches(xsize, ysize)
ax
.
set_title
(
kwargs
.
pop
(
"
title
"
,
""
))
ax
.
set_xlabel
(
kwargs
.
pop
(
"
xlabel
"
,
""
))
ax
.
set_ylabel
(
kwargs
.
pop
(
"
ylabel
"
,
""
))
...
...
@@ -231,7 +231,7 @@ def plot(f, **kwargs):
_limit_xy
(
**
kwargs
)
if
label
!=
([
None
]
*
len
(
f
)):
plt
.
legend
()
_makeplot
(
kwargs
.
get
(
"
name
"
))
#
_makeplot(kwargs.get("name"))
return
elif
len
(
dom
.
shape
)
==
2
:
f
=
f
[
0
]
...
...
@@ -251,7 +251,7 @@ def plot(f, **kwargs):
# plt.colorbar(im,cax=cax)
plt
.
colorbar
(
im
)
_limit_xy
(
**
kwargs
)
_makeplot
(
kwargs
.
get
(
"
name
"
))
#
_makeplot(kwargs.get("name"))
return
elif
isinstance
(
dom
,
PowerSpace
):
plt
.
xscale
(
'
log
'
)
...
...
@@ -265,7 +265,7 @@ def plot(f, **kwargs):
_limit_xy
(
**
kwargs
)
if
label
!=
([
None
]
*
len
(
f
)):
plt
.
legend
()
_makeplot
(
kwargs
.
get
(
"
name
"
))
#
_makeplot(kwargs.get("name"))
return
elif
isinstance
(
dom
,
HPSpace
):
f
=
f
[
0
]
...
...
@@ -282,7 +282,7 @@ def plot(f, **kwargs):
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"
zmin
"
),
vmax
=
kwargs
.
get
(
"
zmax
"
),
cmap
=
cmap
,
origin
=
"
lower
"
)
plt
.
colorbar
(
orientation
=
"
horizontal
"
)
_makeplot
(
kwargs
.
get
(
"
name
"
))
#
_makeplot(kwargs.get("name"))
return
elif
isinstance
(
dom
,
GLSpace
):
f
=
f
[
0
]
...
...
@@ -300,7 +300,23 @@ def plot(f, **kwargs):
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"
zmin
"
),
vmax
=
kwargs
.
get
(
"
zmax
"
),
cmap
=
cmap
,
origin
=
"
lower
"
)
plt
.
colorbar
(
orientation
=
"
horizontal
"
)
_makeplot
(
kwargs
.
get
(
"
name
"
))
#
_makeplot(kwargs.get("name"))
return
raise
ValueError
(
"
Field type not(yet) supported
"
)
_plots
=
[]
_kwargs
=
[]
def
add_plot
(
f
,
**
kwargs
):
_plots
.
append
(
f
)
_kwargs
.
append
(
kwargs
)
def
plot
(
**
kwargs
):
import
matplotlib.pyplot
as
plt
nplot
=
len
(
_plots
)
fig
=
plt
.
figure
()
for
i
in
range
(
nplot
):
ax
=
fig
.
add_subplot
(
nplot
,
1
,
i
+
1
)
_plot
(
_plots
[
i
],
ax
,
**
_kwargs
[
i
])
_makeplot
(
None
)
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