Exemple #1
0
def available_backends():
    """Return a list of the available backends."""
    import os
    from scitools.misc import check_if_module_exists
    files = os.listdir(os.path.dirname(__file__))
    files.remove('template_.py')
    if '__init__.py' in files:
        files.remove('__init__.py')
    backends = [f for f in files if f.endswith('_.py')]
    available = []
    print '\nChecking if you have all the Easyviz backends...'
    for b in backends:
        module = 'scitools.easyviz.' + b[:-3]
        try:
            check_if_module_exists(module, abort=False, raise_exception=True, msg='')
            available.append(module[17:])
        except:
            pass
            #print "You can't use the %s backend" % module
    return available
Exemple #2
0
def available_backends():
    """Return a list of the available backends."""
    import os
    from scitools.misc import check_if_module_exists
    files = os.listdir(os.path.dirname(__file__))
    files.remove('template_.py')
    if '__init__.py' in files:
        files.remove('__init__.py')
    backends = [f for f in files if f.endswith('_.py')]
    available = []
    print '\nChecking if you have all the Easyviz backends...'
    for b in backends:
        module = 'scitools.easyviz.' + b[:-3]
        try:
            check_if_module_exists(module,
                                   abort=False,
                                   raise_exception=True,
                                   msg='')
            available.append(module[17:])
        except:
            pass
            #print "You can't use the %s backend" % module
    return available
Exemple #3
0
    [<scitools.easyviz.common.Line object at 0xb15645ac>]
    >>> subplot(2,2,4)
    >>> plot(x,x**3,'r+',title='subplot(2,2,4)')
    [<scitools.easyviz.common.Line object at 0xb31596ac>]
    >>> ax = axes(viewport=[0.1, 0.55, 0.9, 0.9])
    >>> plot(ax,x,cos(x),'bd--',axis=[-2,4,-1,2]')

"""

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

if check_if_module_exists(
        'pygrace',
        msg=
        'You need to install the pygrace package from http://www.cacr.caltech.edu/~mmckerns/pygrace.html (Not PyGrace from sourceforge!) and the grace program.',
        abort=False):
    from pygrace import grace_np
else:
    raise ImportError('Cannot import grace_np from pygrace')


class GraceBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""
Exemple #4
0
  from scitools.easyviz import *

REQUIREMENTS:

Matplotlib

"""
from __future__ import division

from .common import *
from scitools.numpyutils import floor, linspace, array
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists
from .misc import _update_from_config_file

check_if_module_exists('matplotlib', msg='You need to install the Matplotlib package.', abort=False)

import matplotlib
import matplotlib.colors
# Override values from the matplotlib configuration file with values
# from scitools.cfg before importing pylab
_update_from_config_file(matplotlib.rcParams, section='matplotlib')
matplotlib.interactive(True)
from matplotlib.font_manager import fontManager, FontProperties
import matplotlib.pyplot as pylab
from mpl_toolkits.mplot3d import axes3d, Axes3D
import re


class MatplotlibBackend(BaseClass):
    def __init__(self):
Exemple #5
0
"""

from __future__ import division

from common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

import os
import tempfile

VISIT_ARGS = os.environ.get('VISIT_ARGS', ["-nosplash"])
if isinstance(VISIT_ARGS, str):
    VISIT_ARGS = VISIT_ARGS.split()

check_if_module_exists('visit', msg='You need to install the VisIt package. Also make sure the visit Python module is in the PYTHONPATH environment variable.', abort=False)
import visit
for arg in VISIT_ARGS:
    visit.AddArgument(arg)
visit.Launch()


class VisitBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        self.figure(self.getp('curfig'))
Exemple #6
0
    [<scitools.easyviz.common.Line object at 0xb15645ac>]
    >>> subplot(2,2,4)
    >>> plot(x,x**3,'r+',title='subplot(2,2,4)')
    [<scitools.easyviz.common.Line object at 0xb31596ac>]
    >>> ax = axes(viewport=[0.1, 0.55, 0.9, 0.9])
    >>> plot(ax,x,cos(x),'bd--',axis=[-2,4,-1,2]')

"""

from __future__ import division

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

if check_if_module_exists('pygrace', msg='You need to install the pygrace package from http://www.cacr.caltech.edu/~mmckerns/pygrace.html (Not PyGrace from sourceforge!) and the grace program.', abort=False):
    from pygrace import grace_np
else:
    raise ImportError('Cannot import grace_np from pygrace')


class GraceBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # Set docstrings of all functions to the docstrings of BaseClass
        # The exception is if something is very different
Exemple #7
0
    >>> plot(ax, x, y2, 'b--')
    [<scitools.easyviz.common.Line object at 0xb2c36d0c>]
    >>>

  The optional argument viewport to the axes command must specify a list with
  four elements [left,bottom,right,top] where each of the elements defines
  the margins around the axes.

"""

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

check_if_module_exists('veusz',
                       msg='You need to install the Veusz package.',
                       abort=False)

import veusz.embed
import os


class VeuszBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # Set docstrings of all functions to the docstrings of BaseClass
Exemple #8
0
REQUIREMENTS:

pyx

TODO:

- add support for mesh and surf (requires PyX from svn)

"""


from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

check_if_module_exists('pyx', msg='You need to install the PyX package.', abort=False)
import pyx
import math


class PyXBackend(BaseClass):

    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # Set docstrings of all functions to the docstrings of BaseClass
        # The exception is if something is very different
Exemple #9
0
* Let _DXFigure be based on DXServer rather than just DX.

* In addition look at curve plotting (Plot module), caxis, colorbar,
  meshc/surfc, ...

"""


from __future__ import division

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

check_if_module_exists('DX', msg='You need to install the py2dx package.', abort=False)
import DX
import Tkinter
import tempfile


DXMACROS = '/usr/share/dx/samples/macros'
DXMACROS = os.environ.get('DXMACROS', DXMACROS)


class _DXFigure(object):
    def __init__(self, plt, width=640, height=480, depth=24, title='',
                 hw_render_mode='opengl'):
        # create the GUI:
        self.plt = plt
        self.width = width
Exemple #10
0
    [<scitools.easyviz.common.Line object at 0xb2c36d0c>]
    >>>

  The optional argument viewport to the axes command must specify a list with
  four elements [left,bottom,right,top] where each of the elements defines
  the margins around the axes.

"""

from __future__ import division

from common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

check_if_module_exists('veusz', msg='You need to install the Veusz package.', abort=False)

import veusz.embed
import os


class VeuszBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # Set docstrings of all functions to the docstrings of BaseClass
        # The exception is if something is very different
Exemple #11
0
Pmw
BLT

TODO:

- add support for multiple axes (what about hardcopy then?)

"""


from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists
from scitools.numpyutils import floor, linspace, array

check_if_module_exists('Pmw', msg='You need to install the Pmw package.', abort=False)
import Pmw
import tkinter


class BltBackend(BaseClass):

    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # Set docstrings of all functions to the docstrings of BaseClass
        # The exception is if something is very different
Exemple #12
0
"""

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

try:
    from scikits.mlabwrap import mlab
except ImportError:
    try:
        from mlabwrap import mlab
    except ImportError:
        # mlabwrap is not available
        check_if_module_exists('mlabwrap',
                               msg='You need to install the mlabwrap package.',
                               abort=False)


class MatlabBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # self.figure(self.getp('curfig'))
        pass

    def _set_scale(self, ax):
Exemple #13
0
* How can we treat NaNs?
  (see http://www.opendx.org/cgi-bin/forum/YaBB.pl?num=1155198504)

* Let _DXFigure be based on DXServer rather than just DX.

* In addition look at curve plotting (Plot module), caxis, colorbar,
  meshc/surfc, ...

"""


from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

check_if_module_exists('DX', msg='You need to install the py2dx package.', abort=False)
import DX
import tkinter
import tempfile


DXMACROS = '/usr/share/dx/samples/macros'
DXMACROS = os.environ.get('DXMACROS', DXMACROS)


class _DXFigure(object):

    def __init__(self, plt, width=640, height=480, depth=24, title='',
                 hw_render_mode='opengl'):
        # create the GUI:
        self.plt = plt
Exemple #14
0
"""

from __future__ import division

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import check_if_module_exists

try:
    from scikits.mlabwrap import mlab
except ImportError:
    try:
        from mlabwrap import mlab
    except ImportError:
        # mlabwrap is not available
        check_if_module_exists("mlabwrap", msg="You need to install the mlabwrap package.", abort=False)


class MatlabBackend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        # self.figure(self.getp('curfig'))
        pass

    def _set_scale(self, ax):
        """Set linear or logarithmic (base 10) axis scale."""