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
df6b5347
There was a problem fetching the pipeline summary.
Commit
df6b5347
authored
7 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
more functionality
parent
d0485540
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty2go/plotting/plot.py
+50
-13
50 additions, 13 deletions
nifty2go/plotting/plot.py
with
50 additions
and
13 deletions
nifty2go/plotting/plot.py
+
50
−
13
View file @
df6b5347
...
@@ -65,7 +65,20 @@ def _makeplot(name):
...
@@ -65,7 +65,20 @@ def _makeplot(name):
else
:
else
:
raise
ValueError
(
"
file format not understood
"
)
raise
ValueError
(
"
file format not understood
"
)
def
plot
(
f
,
name
=
None
):
def
_limit_xy
(
**
kwargs
):
import
matplotlib.pyplot
as
plt
x1
,
x2
,
y1
,
y2
=
plt
.
axis
()
if
(
kwargs
.
get
(
"
xmin
"
))
is
not
None
:
x1
=
kwargs
.
get
(
"
xmin
"
)
if
(
kwargs
.
get
(
"
xmax
"
))
is
not
None
:
x2
=
kwargs
.
get
(
"
xmax
"
)
if
(
kwargs
.
get
(
"
ymin
"
))
is
not
None
:
y1
=
kwargs
.
get
(
"
ymin
"
)
if
(
kwargs
.
get
(
"
ymax
"
))
is
not
None
:
y2
=
kwargs
.
get
(
"
ymax
"
)
plt
.
axis
((
x1
,
x2
,
y1
,
y2
))
def
plot
(
f
,
**
kwargs
):
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
if
not
isinstance
(
f
,
Field
):
if
not
isinstance
(
f
,
Field
):
raise
TypeError
(
"
incorrect data type
"
)
raise
TypeError
(
"
incorrect data type
"
)
...
@@ -73,8 +86,25 @@ def plot (f,name=None):
...
@@ -73,8 +86,25 @@ def plot (f,name=None):
raise
ValueError
(
"
input field must have exactly one domain
"
)
raise
ValueError
(
"
input field must have exactly one domain
"
)
dom
=
f
.
domain
[
0
]
dom
=
f
.
domain
[
0
]
plt
.
gcf
().
set_size_inches
(
12
,
12
)
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
1
,
1
,
1
)
xsize
,
ysize
=
6
,
6
if
kwargs
.
get
(
"
xsize
"
)
is
not
None
:
xsize
=
kwargs
.
get
(
"
xsize
"
)
if
kwargs
.
get
(
"
ysize
"
)
is
not
None
:
ysize
=
kwargs
.
get
(
"
ysize
"
)
fig
.
set_size_inches
(
xsize
,
ysize
)
if
kwargs
.
get
(
"
title
"
)
is
not
None
:
ax
.
set_title
(
kwargs
.
get
(
"
title
"
))
if
kwargs
.
get
(
"
xlabel
"
)
is
not
None
:
ax
.
set_xlabel
(
kwargs
.
get
(
"
xlabel
"
))
if
kwargs
.
get
(
"
ylabel
"
)
is
not
None
:
ax
.
set_ylabel
(
kwargs
.
get
(
"
ylabel
"
))
cmap
=
plt
.
rcParams
[
'
image.cmap
'
]
if
kwargs
.
get
(
"
colormap
"
)
is
not
None
:
cmap
=
kwargs
.
get
(
"
colormap
"
)
if
isinstance
(
dom
,
RGSpace
):
if
isinstance
(
dom
,
RGSpace
):
if
len
(
dom
.
shape
)
==
1
:
if
len
(
dom
.
shape
)
==
1
:
npoints
=
dom
.
shape
[
0
]
npoints
=
dom
.
shape
[
0
]
...
@@ -82,7 +112,8 @@ def plot (f,name=None):
...
@@ -82,7 +112,8 @@ def plot (f,name=None):
xcoord
=
np
.
arange
(
npoints
,
dtype
=
np
.
float64
)
*
dist
xcoord
=
np
.
arange
(
npoints
,
dtype
=
np
.
float64
)
*
dist
ycoord
=
f
.
val
ycoord
=
f
.
val
plt
.
plot
(
xcoord
,
ycoord
)
plt
.
plot
(
xcoord
,
ycoord
)
_makeplot
(
name
)
_limit_xy
(
**
kwargs
)
_makeplot
(
kwargs
.
get
(
"
name
"
))
return
return
elif
len
(
dom
.
shape
)
==
2
:
elif
len
(
dom
.
shape
)
==
2
:
nx
=
dom
.
shape
[
0
]
nx
=
dom
.
shape
[
0
]
...
@@ -91,9 +122,14 @@ def plot (f,name=None):
...
@@ -91,9 +122,14 @@ def plot (f,name=None):
dy
=
dom
.
distances
[
1
]
dy
=
dom
.
distances
[
1
]
xc
=
np
.
arange
(
nx
,
dtype
=
np
.
float64
)
*
dx
xc
=
np
.
arange
(
nx
,
dtype
=
np
.
float64
)
*
dx
yc
=
np
.
arange
(
ny
,
dtype
=
np
.
float64
)
*
dy
yc
=
np
.
arange
(
ny
,
dtype
=
np
.
float64
)
*
dy
plt
.
imshow
(
f
.
val
,
extent
=
[
xc
[
0
],
xc
[
-
1
],
yc
[
0
],
yc
[
-
1
]])
im
=
ax
.
imshow
(
f
.
val
,
extent
=
[
xc
[
0
],
xc
[
-
1
],
yc
[
0
],
yc
[
-
1
]],
vmin
=
kwargs
.
get
(
"
zmin
"
),
vmax
=
kwargs
.
get
(
"
zmax
"
),
cmap
=
cmap
)
plt
.
colorbar
()
#from mpl_toolkits.axes_grid1 import make_axes_locatable
_makeplot
(
name
)
#divider = make_axes_locatable(ax)
#cax = divider.append_axes("right", size="5%", pad=0.05)
#plt.colorbar(im,cax=cax)
plt
.
colorbar
(
im
)
_limit_xy
(
**
kwargs
)
_makeplot
(
kwargs
.
get
(
"
name
"
))
return
return
elif
isinstance
(
dom
,
PowerSpace
):
elif
isinstance
(
dom
,
PowerSpace
):
xcoord
=
dom
.
kindex
xcoord
=
dom
.
kindex
...
@@ -102,7 +138,8 @@ def plot (f,name=None):
...
@@ -102,7 +138,8 @@ def plot (f,name=None):
plt
.
yscale
(
'
log
'
)
plt
.
yscale
(
'
log
'
)
plt
.
title
(
'
power
'
)
plt
.
title
(
'
power
'
)
plt
.
plot
(
xcoord
,
ycoord
)
plt
.
plot
(
xcoord
,
ycoord
)
_makeplot
(
name
)
_limit_xy
(
**
kwargs
)
_makeplot
(
kwargs
.
get
(
"
name
"
))
return
return
elif
isinstance
(
dom
,
HPSpace
):
elif
isinstance
(
dom
,
HPSpace
):
import
pyHealpix
import
pyHealpix
...
@@ -115,9 +152,9 @@ def plot (f,name=None):
...
@@ -115,9 +152,9 @@ def plot (f,name=None):
base
=
pyHealpix
.
Healpix_Base
(
int
(
np
.
sqrt
(
f
.
val
.
size
//
12
)),
"
RING
"
)
base
=
pyHealpix
.
Healpix_Base
(
int
(
np
.
sqrt
(
f
.
val
.
size
//
12
)),
"
RING
"
)
res
[
mask
]
=
f
.
val
[
base
.
ang2pix
(
ptg
)]
res
[
mask
]
=
f
.
val
[
base
.
ang2pix
(
ptg
)]
plt
.
axis
(
'
off
'
)
plt
.
axis
(
'
off
'
)
plt
.
imshow
(
res
)
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"
zmin
"
),
vmax
=
kwargs
.
get
(
"
zmax
"
),
cmap
=
cmap
)
plt
.
colorbar
()
plt
.
colorbar
(
orientation
=
"
horizontal
"
)
_makeplot
(
name
)
_makeplot
(
kwargs
.
get
(
"
name
"
)
)
return
return
elif
isinstance
(
dom
,
GLSpace
):
elif
isinstance
(
dom
,
GLSpace
):
import
pyHealpix
import
pyHealpix
...
@@ -131,9 +168,9 @@ def plot (f,name=None):
...
@@ -131,9 +168,9 @@ def plot (f,name=None):
res
[
mask
]
=
f
.
val
[
ilat
*
dom
.
nlon
+
ilon
]
res
[
mask
]
=
f
.
val
[
ilat
*
dom
.
nlon
+
ilon
]
plt
.
axis
(
'
off
'
)
plt
.
axis
(
'
off
'
)
plt
.
imshow
(
res
)
plt
.
imshow
(
res
,
vmin
=
kwargs
.
get
(
"
zmin
"
),
vmax
=
kwargs
.
get
(
"
zmax
"
),
cmap
=
cmap
)
plt
.
colorbar
()
plt
.
colorbar
(
orientation
=
"
horizontal
"
)
_makeplot
(
name
)
_makeplot
(
kwargs
.
get
(
"
name
"
)
)
return
return
raise
ValueError
(
"
Field type not(yet) supported
"
)
raise
ValueError
(
"
Field type not(yet) supported
"
)
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