Commit 20a1e800 authored by Theo Steininger's avatar 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
......@@ -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
......
......@@ -2,6 +2,7 @@ numpy
cython
mpi4py
matplotlib
plotly
ipython==5.3.0
nose
parameterized
......
......@@ -50,6 +50,8 @@ from spaces import *
from operators import *
from plotting import *
from probing import *
from sugar import *
......@@ -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',
......
from matplotlib_init import *
from descriptors import *
from plots import *
from figures import *
......
......@@ -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)
......
# -*- 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')
# -*- 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment