Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teresa Weßels
empyre
Commits
d590ac9a
Commit
d590ac9a
authored
5 years ago
by
Jan Caron
Browse files
Options
Downloads
Patches
Plain Diff
plottools: removed old unreachable code!
parent
52a134d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyramid/plottools.py
+3
-99
3 additions, 99 deletions
pyramid/plottools.py
with
3 additions
and
99 deletions
pyramid/plottools.py
+
3
−
99
View file @
d590ac9a
...
...
@@ -378,7 +378,7 @@ def plot_3d_to_2d(dim_uv, axis=None, figsize=None, dpi=100, mag=1, close_3d=True
# TODO: Look at https://docs.enthought.com/mayavi/mayavi/tips.html and implement!
from
mayavi
import
mlab
if
figsize
is
None
:
figsize
=
FIGSIZE_DEFAULT
figsize
=
FIGSIZE_DEFAULT
if
axis
is
None
:
_log
.
debug
(
'
axis is None
'
)
fig
=
plt
.
figure
(
figsize
=
figsize
,
dpi
=
dpi
)
...
...
@@ -391,7 +391,7 @@ def plot_3d_to_2d(dim_uv, axis=None, figsize=None, dpi=100, mag=1, close_3d=True
# (needs screen resolution, hardcode now, later: https://github.com/rr-/screeninfo):
# IF resolution of mayavi image is smaller than screen resolution:
tmpdir
=
tempfile
.
mkdtemp
()
temp_path
=
'
temp.png
'
#TODO:
os.path.join(tmpdir, 'temp.png')
temp_path
=
os
.
path
.
join
(
tmpdir
,
'
temp.png
'
)
print
(
'
Temp file created
'
)
try
:
mlab
.
savefig
(
temp_path
,
magnification
=
mag
)
...
...
@@ -401,7 +401,7 @@ def plot_3d_to_2d(dim_uv, axis=None, figsize=None, dpi=100, mag=1, close_3d=True
except
Exception
as
e
:
raise
e
finally
:
#TODO:
os.remove(temp_path)
os
.
remove
(
temp_path
)
os
.
rmdir
(
tmpdir
)
# In both cases, log mappable shape and do the rest:
if
close_3d
:
...
...
@@ -413,102 +413,6 @@ def plot_3d_to_2d(dim_uv, axis=None, figsize=None, dpi=100, mag=1, close_3d=True
return
format_axis
(
axis
,
**
kwargs
)
if
dim_uv
is
None
:
dim_uv
=
self
.
dim
[
1
:]
axis
.
imshow
(
imgmap
,
extent
=
[
0
,
dim_uv
[
0
],
0
,
dim_uv
[
1
]],
origin
=
'
upper
'
)
kwargs
.
setdefault
(
'
scalebar
'
,
False
)
kwargs
.
setdefault
(
'
hideaxes
'
,
True
)
# TODO: RETURN AXIS AND FORMAT AFTER! kwargs are for quiverplot (do some defaults here,
# TODO not adding stuff like colorbars!!!!)!!!!
return
plottools
.
format_axis
(
axis
,
**
kwargs
)
# OLD
res
=
tuple
((
int
(
i
*
dpi
)
for
i
in
figsize
))
print
(
f
'
res:
{
res
}
'
)
self
.
plot_quiver3d
(
figsize
=
res
,
labels
=
False
,
orientation
=
False
,
mode
=
'
arrow
'
)
if
mag
>
1
:
# Use temp files:
tmpdir
=
tempfile
.
mkdtemp
()
temp_path
=
'
temp.png
'
#TODO:os.path.join(tmpdir, 'temp.png')
print
(
'
Temp file created
'
)
try
:
mlab
.
savefig
(
temp_path
,
magnification
=
mag
)
# size=(10, 10),
print
(
'
SAVED! now load?
'
)
imgmap
=
np
.
asarray
(
Image
.
open
(
temp_path
))
print
(
'
LOADED!
'
)
except
Exception
as
e
:
raise
e
finally
:
#TODO:os.remove(temp_path)
os
.
rmdir
(
tmpdir
)
else
:
# Use screenshot (returns array WITH alpha!):
# TODO: saving images does NOT give alpha -> set bgcolor there and remove alpha here!
imgmap
=
mlab
.
screenshot
(
mode
=
'
rgba
'
,
antialiased
=
True
)
self
.
_log
.
info
(
f
'
mappable shape:
{
imgmap
.
shape
[
:
2
]
}
(res.:
{
res
}
)
'
)
if
imgmap
.
shape
[
0
]
<
res
[
0
]
or
imgmap
.
shape
[
1
]
<
res
[
1
]:
import
warnings
warnings
.
warn
(
f
'
Shape of created image
{
imgmap
.
shape
[
:
2
]
}
is smaller than the
'
+
'
calculated resolution {res} for at least one axis. This might lead
'
+
'
to distorted images. Try other values for dpi, figsize or a
'
+
'
monitor with larger resolution!
'
)
mlab
.
close
(
mlab
.
gcf
())
if
dim_uv
is
None
:
dim_uv
=
self
.
dim
[
1
:]
axis
.
imshow
(
imgmap
,
extent
=
[
0
,
dim_uv
[
0
],
0
,
dim_uv
[
1
]],
origin
=
'
upper
'
)
kwargs
.
setdefault
(
'
scalebar
'
,
False
)
kwargs
.
setdefault
(
'
hideaxes
'
,
True
)
return
plottools
.
format_axis
(
axis
,
**
kwargs
)
# # OLD
# res = tuple((int(i * dpi) for i in figsize))
# print(f'res: {res}')
# self.plot_quiver3d(figsize=res, labels=False, orientation=False, mode='arrow')
# if mag > 1: # Use temp files:
# tmpdir = tempfile.mkdtemp()
# temp_path = 'temp.png'#TODO:os.path.join(tmpdir, 'temp.png')
# print('Temp file created')
# try:
# mlab.savefig(temp_path, magnification=mag) # size=(10, 10),
# print('SAVED! now load?')
# imgmap = np.asarray(Image.open(temp_path))
# print('LOADED!')
# except Exception as e:
# raise e
# finally:
# #TODO:os.remove(temp_path)
# os.rmdir(tmpdir)
# else: # Use screenshot (returns array WITH alpha!):
# # TODO: saving images does NOT give alpha -> set bgcolor there and remove alpha here!
# imgmap = mlab.screenshot(mode='rgba', antialiased=True)
# self._log.info(f'mappable shape: {imgmap.shape[:2]} (res.: {res})')
# if imgmap.shape[0] < res[0] or imgmap.shape[1] < res[1]:
# import warnings
# warnings.warn(f'Shape of created image {imgmap.shape[:2]} is smaller than the '
# +'calculated resolution {res} for at least one axis. This might lead '
# +'to distorted images. Try other values for dpi, figsize or a '
# +'monitor with larger resolution!')
# mlab.close(mlab.gcf())
# if dim_uv is None:
# dim_uv = self.dim[1:]
# axis.imshow(imgmap, extent=[0, dim_uv[0], 0, dim_uv[1]], origin='upper')
# kwargs.setdefault('scalebar', False)
# kwargs.setdefault('hideaxes', True)
# return plottools.format_axis(axis, **kwargs)
# TODO: Florians way of shifting axes labels (should already be in somewhere):
# for i in [1, 3]:
# axs[i].yaxis.set_label_position('right')
...
...
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