Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
20a1e800
Commit
20a1e800
authored
Apr 25, 2017
by
Theo Steininger
Browse files
Made module import for plotting modular and infer backend for matplotlib dynamically.
parent
01fea702
Pipeline
#11723
failed with stage
in 8 minutes and 34 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
20a1e800
...
...
@@ -8,7 +8,8 @@ RUN \
libopenmpi-dev libatlas-base-dev libfftw3-bin libfftw3-dev
\
libfftw3-double3 libfftw3-long3 libfftw3-mpi-dev libfftw3-mpi3
\
libfftw3-quad3 libfftw3-single3 libhdf5-10 libhdf5-dev
\
libhdf5-openmpi-10 libhdf5-openmpi-dev hdf5-tools
libhdf5-openmpi-10 libhdf5-openmpi-dev hdf5-tools
\
python-tk
# python dependencies
ADD
ci/requirements.txt /tmp/requirements.txt
...
...
ci/requirements.txt
View file @
20a1e800
...
...
@@ -2,6 +2,7 @@ numpy
cython
mpi4py
matplotlib
plotly
ipython==5.3.0
nose
parameterized
...
...
nifty/__init__.py
View file @
20a1e800
...
...
@@ -50,6 +50,8 @@ from spaces import *
from
operators
import
*
from
plotting
import
*
from
probing
import
*
from
sugar
import
*
nifty/config/nifty_config.py
View file @
20a1e800
...
...
@@ -17,7 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
from
distutils.version
import
LooseVersion
as
lv
import
numpy
as
np
import
keepers
...
...
@@ -28,13 +27,12 @@ __all__ = ['dependency_injector', 'nifty_configuration']
dependency_injector
=
keepers
.
DependencyInjector
(
[(
'mpi4py.MPI'
,
'MPI'
),
'pyHealpix'
,
'plotly'
])
'plotly'
,
'pylab'
,
'healpy'
])
dependency_injector
.
register
(
'pyfftw'
,
lambda
z
:
hasattr
(
z
,
'FFTW_MPI'
))
dependency_injector
.
register
(
'healpy'
,
lambda
z
:
lv
(
z
.
__version__
)
>=
lv
(
'1.8.1'
))
# Initialize the variables
variable_fft_module
=
keepers
.
Variable
(
'fft_module'
,
...
...
nifty/plotting/__init__.py
View file @
20a1e800
from
matplotlib_init
import
*
from
descriptors
import
*
from
plots
import
*
from
figures
import
*
...
...
nifty/plotting/figures/multi_figure.py
View file @
20a1e800
...
...
@@ -2,15 +2,19 @@
import
numpy
as
np
from
plotly.tools
import
make_subplots
from
nifty
import
dependency_injector
as
gdi
from
figure_base
import
FigureBase
from
figure_3D
import
Figure3D
plotly
=
gdi
.
get
(
'plotly'
)
class
MultiFigure
(
FigureBase
):
def
__init__
(
self
,
rows
,
columns
,
subfigures
=
None
,
title
=
None
,
width
=
None
,
height
=
None
):
if
'plotly'
not
in
gdi
:
raise
ImportError
(
"The module plotly is needed but not available."
)
super
(
MultiFigure
,
self
).
__init__
(
title
,
width
,
height
)
self
.
subfigures
=
np
.
empty
((
rows
,
columns
),
dtype
=
np
.
object
)
self
.
subfigures
[:]
=
subfigures
...
...
@@ -36,7 +40,8 @@ class MultiFigure(FigureBase):
specs_setter
=
\
lambda
z
:
{
'is_3d'
:
True
}
if
isinstance
(
z
,
Figure3D
)
else
{}
sub_specs
=
np
.
vectorize
(
specs_setter
)(
sub_specs
)
multi_figure_plotly_object
=
make_subplots
(
self
.
rows
,
multi_figure_plotly_object
=
plotly
.
tools
.
make_subplots
(
self
.
rows
,
self
.
columns
,
subplot_titles
=
sub_titles
,
specs
=
sub_specs
)
...
...
nifty/plotting/matplotlib_init.py
0 → 100644
View file @
20a1e800
# -*- coding: utf-8 -*-
import
os
__all__
=
[]
try
:
import
matplotlib
except
ImportError
:
pass
else
:
try
:
display
=
os
.
environ
[
'DISPLAY'
]
except
KeyError
:
matplotlib
.
use
(
'Agg'
)
else
:
if
display
==
''
:
matplotlib
.
use
(
'Agg'
)
nifty/plotting/plots/heatmaps/mollweide.py
View file @
20a1e800
# -*- coding: utf-8 -*-
import
pylab
import
healpy.projaxes
as
PA
import
healpy.pixelfunc
as
pixelfunc
from
nifty
import
dependency_injector
as
gdi
from
heat_map
import
HeatMap
pylab
=
gdi
.
get
(
'pylab'
)
healpy
=
gdi
.
get
(
'healpy'
)
class
Mollweide
(
HeatMap
):
def
__init__
(
self
,
data
,
label
=
''
,
line
=
None
,
marker
=
None
,
webgl
=
False
,
smoothing
=
False
):
# smoothing 'best', 'fast', False
if
'pylab'
not
in
gdi
:
raise
ImportError
(
"The module pylab is needed but not available."
)
if
'healpy'
not
in
gdi
:
raise
ImportError
(
"The module healpy is needed but not available."
)
data
=
self
.
_mollview
(
data
)
super
(
Mollweide
,
self
).
__init__
(
data
,
label
,
line
,
marker
,
webgl
,
smoothing
)
def
_mollview
(
self
,
x
,
xsize
=
800
):
x
=
pixelfunc
.
ma_to_array
(
x
)
x
=
healpy
.
pixelfunc
.
ma_to_array
(
x
)
f
=
pylab
.
figure
(
None
,
figsize
=
(
8.5
,
5.4
))
extent
=
(
0.02
,
0.05
,
0.96
,
0.9
)
ax
=
PA
.
HpxMollweideAxes
(
f
,
extent
)
ax
=
healpy
.
projaxes
.
HpxMollweideAxes
(
f
,
extent
)
img
=
ax
.
projmap
(
x
,
nest
=
False
,
xsize
=
xsize
)
return
img
Write
Preview
Supports
Markdown
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