from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

import numpy
from qt import *
from Timba.Plugins.display_image import *
from Timba.Plugins.realvsimag import *
from Timba.Plugins.plotting_functions import *
from QwtPlotImage import *
from QwtColorBar import *
from ND_Controller import *
from plot_printer import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='history_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

# The HistoryPlotter plots the contents of a MeqHistoryCollect node
class HistoryPlotter(GriddedPlugin):
  """ a class to plot the history of some parameter. It can be
      a scalar or an array """

  _icon = pixmaps.bars3d
  viewer_name = "History Plotter";
  def is_viewable (data):
    return len(data) > 0;
  is_viewable = staticmethod(is_viewable);

# the following global tables replicate similar tables found in the
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from PyQt4 import Qt
from Timba.Plugins.DataDisplayMainWindow_qt4 import *

from VellsData import *
from ResultsRange_qt4 import *
from BufferSizeDialog_qt4 import *
from plot_printer_qt4 import *

import itertools

from Timba.utils import verbosity
_dbg = verbosity(0,name='collections_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class CollectionsPlotter(GriddedPlugin):
  """ a class to visualize data, VellSets or visu data, that is 
      contained within a node's cache_result record. Objects of 
      this class are launched from the meqbrowser GUI """

  _icon = pixmaps.bars3d
  viewer_name = "Collections Plotter";
  def is_viewable (data):
    return len(data) > 0;
  is_viewable = staticmethod(is_viewable);

  def __init__(self,gw,dataitem,cellspec={},**opts):
Beispiel #3
0
from math import pi
import numpy

from qwt.qt.QtGui import QApplication, QSizePolicy, QMessageBox
from qwt.qt.QtGui import QPen, QColor, QWidget, QImage, QFont, QFontInfo, QMenu, QActionGroup, QAction
from qwt.qt.QtCore import Qt, pyqtSignal, QSize, QObject
from qwt import (QwtPlot, QwtPlotMarker, QwtPlotCurve, QwtPlotItem,
                 QwtLinearColorMap, QwtLogScaleEngine, QwtLinearScaleEngine,
                 QwtScaleMap, QwtScaleDraw, QwtScaleDiv)

HAS_TIMBA = False
try:
    from Timba.Plugins.QwtPlotImage_qt5 import QwtPlotImage
    from Timba.Plugins.QwtSpy_qt5 import Spy
    from Timba.utils import verbosity
    _dbg = verbosity(0, name='QwtColorBar')
    _dprint = _dbg.dprint
    _dprintf = _dbg.dprintf
    HAS_TIMBA = True
except:
    pass


# called by the QwtImagePlot class
def square(n, min, max):
    t = numpy.arange(min, max, float(max - min) / (n - 1))
    #return outer(cos(t), sin(t))
    return numpy.cos(t) * numpy.sin(t)[:, numpy.newaxis]


# square()
# -*- coding: utf-8 -*-
# standard preamble
from Timba.TDL import *
from Timba import pynode
from Timba import dmi
from Timba import utils
from Timba.Meq import meq
from Lions.PiercePoints.modules import PhaseScreen

Settings.forest_state.cache_policy = 100;

_dbg = utils.verbosity(0,name='test_pynode');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

initialized=False;

# This class is meant to illustrate the pynode interface. All pynodes
# need to be derived from the Timba.pynode.PyNode class.
class KolmogorovNode (pynode.PyNode):
    # An __init__ method is not necessary at all. If you do define your 
    # own for some reason, make sure you call pynode.PyNode.__init__() 
    def __init__ (self,*args):
        pynode.PyNode.__init__(self,*args);
        self.set_symdeps('domain');

    def update_state (self,mystate):
        global initialized;
        # mystate is a magic "state helper" object is used both to set up
        # initial/default state, and to update state on the fly later.
        
Beispiel #5
0
from PyQt4 import Qt
import PyQt4.Qwt5 as Qwt

#from qt import *
from QwtSpy_qt4 import *
#import Qwt5 as Qwt

import numpy
import math

#from UVPAxis import *
#from ComplexColorMap import *
from ImageScaler import *

from Timba.utils import verbosity
_dbg = verbosity(0, name='QwtPlotImage')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


# from scipy.pilutil
# note: low is set to 2, so that we can save a value of 0 for a flagged pixel
# and 1 for a pixel with Nans or Infs
def bytescale(data, limits, high=255, low=2):
    if data.dtype == numpy.uint8:
        return data
    high = high - low
    if limits[0] is None:
        limits[0] = data.min()
    if limits[1] is None:
        limits[1] = data.max()
Beispiel #6
0
#

import sys
# is numpy available?
global has_numpy
has_numpy = False
try:
  import numpy
  has_numpy = True
except:
  has_numpy = False

import math

from Timba.utils import verbosity
_dbg = verbosity(0,name='SolverData');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class SolverData:
   """ a class to store solver data and supply the
       data to the browser display """

   def __init__(self, data_label=''):
     self._data_label = data_label
     self._solver_array = None
     self.metrics_rank = None
     self.metrics_covar = None
     self.condition_numbers = None 
     self.cn_chi = None 
     self.metrics_chi_0 = None
global has_vtk
has_vtk = False
try:
  from Timba.Plugins.vtk_qt_3d_display import *
  has_vtk = True
except:
  pass

from display_image import *
from QwtColorBar import *
from ND_Controller import *
from plot_printer import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='plot_handler');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class plot_handler:

  def __init__(self):
    self.colorbar = None
    self.visu_plotter = None
    self.twoD_plotter = None
    self.plotPrinter = None
    self.ND_plotter = None
    self.layout = None
    self.layout_parent = None
    self.ND_Controls_2D = None  # used to select surfaces for 2D display
    self.ND_Controls_3D = None  # used to select cube for 3D display
Beispiel #8
0
from Timba.GUI.pixmaps import pixmaps
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from qt import *
from Timba.Plugins.plotting_functions import *
import plot_printer

from ResultsRange import *
from BufferSizeDialog import *
import os
import tempfile

from Timba.utils import verbosity
_dbg = verbosity(0,name='svg_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

# The following class is a python translation and adaption of the
# same C++ class in the picture.cpp program provided in the
# QT Assistant documentation for Qt3

class PictureDisplay(QWidget):
  """ a class for handling data destined for display within 
      a QPicture or QPixmap 
  """

  menu_table = {
    'Save Display in PNG Format': 321,
    }
Beispiel #9
0
try:
    import matplotlib
    from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
    from matplotlib.backends.backend_qt4 import NavigationToolbar2QT as NavigationToolbar
    from matplotlib.figure import Figure
    import pylab

    has_pylab = True
except:
    print " "
    print "*** matplotlib/pylab not imported! ***"
    print "The system will assume that matplotlib is not present."

from Timba.utils import verbosity

_dbg = verbosity(0, name="pylab_plotter")
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf

if has_pylab:

    class MyPylabPlotter(FigureCanvas):
        def __init__(self, parent=None, dpi=100):
            self.fig = Figure(dpi=dpi)
            FigureCanvas.__init__(self, self.fig)
            #    self.reparent(parent, QPoint(0, 0))
            #    self.setParent(Qt.QWidget())
            FigureCanvas.setSizePolicy(self, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding)
            FigureCanvas.updateGeometry(self)

        def sizeHint(self):
#from Timba.GUI.pixmaps import pixmaps
#from Timba.GUI import widgets
#from Timba.GUI.browsers import *
#from Timba import Grid

import sys
from PyQt4 import Qt
import PyQt4.Qwt5 as Qwt
from QwtSpy_qt4 import *
import numpy
import random

import printfilter_qt4

from Timba.utils import verbosity
_dbg = verbosity(0,name='histogramplot');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;


#  distance from (15,5) squared
def dist(x,y):
  return (x-15)**2+(y-5)**2
def imag_dist(x,y):
  return (x-10)**2+(y-10)**2
def RealDist(x,y):
  return (x)**2
def ImagDist(x,y):
  return (x-29)**2
#m = fromfunction(dist, (10,10))
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba.Meq import meq
from Timba import utils
from Timba.TDL import *
import math

_dbg = utils.verbosity(0, name='LSM_Sixpack')
_dprint = _dbg.dprint                    # use: _dprint(2, "abc")
_dprintf = _dbg.dprintf   








##########################################################################################
##########################################################################################
##########################################################################################

global has_vtk
has_vtk = False
try:
  from Timba.Plugins.vtk_qt4_3d_display import *
  has_vtk = True
except:
  pass

from Timba.Plugins.display_image_qt4 import *
from Timba.Plugins.QwtColorBar_qt4 import *
from Timba.Plugins.ND_Controller_qt4 import *
from Timba.Plugins.plot_printer_qt4 import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='plotting_functions');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

def create_ColorBar (layout,layout_parent, plotter, plotPrinter):
  """ this function adds a colorbar for 2-D displays """

  # create two color bars in case we are displaying complex arrays
  colorbar = {}
  for i in range(2):
    colorbar[i] =  QwtColorBar(colorbar_number= i, parent=layout_parent)
    colorbar[i].setMaxRange((-1, 1))
    Qt.QObject.connect(plotter, Qt.SIGNAL('max_image_range'), colorbar[i].handleRangeParms) 
    Qt.QObject.connect(plotter, Qt.SIGNAL('display_type'), colorbar[i].setDisplayType) 
    Qt.QObject.connect(plotter, Qt.SIGNAL('show_colorbar_display'), colorbar[i].showDisplay)
    Qt.QObject.connect(colorbar[i], Qt.SIGNAL('set_image_range'), plotter.setImageRange) 
# modules that are imported
from Timba.dmi import *
from Timba import utils
from Timba.Meq import meqds
from Timba.Meq.meqds import mqs
from Timba.GUI.pixmaps import pixmaps
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from PyQt4 import Qt
from plot_printer_qt4 import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='quickref_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class QuickRefPlotter(GriddedPlugin):
  """ a class to display quickref_help contents of a node in the browser """ 

  _icon = pixmaps.bars3d
  viewer_name = "QuickRef Display";
  def is_viewable (data):
    return len(data) > 0;
  is_viewable = staticmethod(is_viewable);

  def __init__(self,gw,dataitem,cellspec={},**opts):
    GriddedPlugin.__init__(self,gw,dataitem,cellspec=cellspec);
    """ Instantiate HippoDraw objects that are used to control
from Timba.dmi import *
from Timba import utils
from Timba.GUI.pixmaps import pixmaps
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from qt import *
import sihippo
print "HippoDraw version " + sihippo.__version__
from sihippo import *
from Timba.array import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='hippo_array_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class HippoArrayPlotter(GriddedPlugin):
  """ a class to plot raw arrays contained within a Meq tree """

  _icon = pixmaps.bars3d
  viewer_name = "Hippo Array Plotter";
  def is_viewable (data):
    return len(data) > 0;
  is_viewable = staticmethod(is_viewable);

  def __init__(self,gw,dataitem,cellspec={},**opts):
    GriddedPlugin.__init__(self,gw,dataitem,cellspec=cellspec);
    """ instantiate various HippoDraw objects that are needed to
  has_vtk = True
except:
  pass

from QwtPlotImage_qt4 import *
from QwtColorBar_qt4 import *
from SpectrumData import *
from VellsData import *
from SolverData import *
from ND_Controller_qt4 import *
from ResultsRange_qt4 import *
from BufferSizeDialog_qt4 import *
from plot_printer_qt4 import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='result_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class ResultPlotter(GriddedPlugin):
  """ a class to visualize data, VellSets or visu data, that is 
      contained within a node's cache_result record. Objects of 
      this class are launched from the meqbrowser GUI """

  _icon = pixmaps.bars3d
  viewer_name = "Result Plotter";
  def is_viewable (data):
    return len(data) > 0;
  is_viewable = staticmethod(is_viewable);

# the following global tables replicate similar tables found in the
#  email:				 courriel:
#  [email protected]	 [email protected]
#
#  National Research Council		 Conseil national de recherches
#      Canada				    Canada
#  Herzberg Institute of Astrophysics	 Institut Herzberg d'astrophysique
#  5071 West Saanich Rd.		 5071 West Saanich Rd.
#  Victoria BC V9E 2E7			 Victoria BC V9E 2E7
#  CANADA					 CANADA
#

import sys
import numpy

from Timba.utils import verbosity
_dbg = verbosity(0, name='SpectrumData')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


class SpectrumData:
    """ a class to store spectral data and supply the
       data to the browser display """
    def __init__(self, data_label='', string_tag=''):
        self._data_labels = data_label
        self._string_tag = string_tag
        self._active_plot = 0
        self.num_y_markers = 0
        self.y_marker_step = 0

        self._plot_dict = {}
from PyQt4 import Qt
import PyQt4.Qwt5 as Qwt

#from qt import *
from QwtSpy_qt4 import *
#import Qwt5 as Qwt

import numpy
import math

#from UVPAxis import *
#from ComplexColorMap import *
from ImageScaler import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='QwtPlotImage');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;


# from scipy.pilutil
# note: low is set to 2, so that we can save a value of 0 for a flagged pixel
# and 1 for a pixel with Nans or Infs
def bytescale(data, limits, high=255, low=2):
    if data.dtype == numpy.uint8:
        return data
    high = high - low
    if limits[0] is None:
        limits[0] = data.min()
    if limits[1] is None:
        limits[1] = data.max()
# -*- coding: utf-8 -*-
# standard preamble
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

from Timba.TDL import *
from Timba import pynode
from Timba import dmi
from Timba import utils
from Timba.Meq import meq
from Lions.PiercePoints.modules import PhaseScreen

Settings.forest_state.cache_policy = 100

_dbg = utils.verbosity(0, name='test_pynode')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf

initialized = False

# This class is meant to illustrate the pynode interface. All pynodes
# need to be derived from the Timba.pynode.PyNode class.


class KolmogorovNode(pynode.PyNode):
    # An __init__ method is not necessary at all. If you do define your
    # own for some reason, make sure you call pynode.PyNode.__init__()

    def __init__(self, *args):
        pynode.PyNode.__init__(self, *args)
#

from Timba.dmi import *
from Timba import utils
from Timba.Meq import meqds
from Timba.Meq.meqds import mqs
from Timba.GUI.pixmaps import pixmaps
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from Timba.Plugins.display_image_qt4 import *
from Timba.Plugins.plotting_functions_qt4 import *

from Timba.utils import verbosity
_dbg = verbosity(0,name='array_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

global has_vtk
has_vtk = False
try:
  from Timba.Plugins.vtk_qt4_3d_display import *
  has_vtk = True
except:
  pass

import numpy

from PyQt4 import Qt
import PyQt4.Qwt5 as Qwt
#  email:				 courriel:
#  [email protected]	 [email protected]
#
#  National Research Council		 Conseil national de recherches
#      Canada				    Canada
#  Herzberg Institute of Astrophysics	 Institut Herzberg d'astrophysique
#  5071 West Saanich Rd.		 5071 West Saanich Rd.
#  Victoria BC V9E 2E7			 Victoria BC V9E 2E7
#  CANADA					 CANADA
#

import sys
import numpy

from Timba.utils import verbosity
_dbg = verbosity(0,name='SpectrumData');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class SpectrumData:
   """ a class to store spectral data and supply the
       data to the browser display """

   def __init__(self, data_label='', string_tag=''):
     self._data_labels = data_label
     self._string_tag = string_tag
     self._active_plot = 0
     self.num_y_markers = 0
     self.y_marker_step = 0

     self._plot_dict = {}
Beispiel #21
0
# sys.argv is not present when embedding a Python interpreter, but some
# packages (i.e. numarray) seem to fall over when it is not found. So we
# inject it
if not hasattr(sys,'argv'):
  setattr(sys,'argv',['meqkernel']);

# now import the rest
from Timba import dmi
from Timba import utils
import meqserver_interface
import sys
import imp
import os.path


_dbg = utils.verbosity(0,name='meqkernel');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

_header_handlers = [];
_footer_handlers = [];

def reset ():
  global _header_handlers;
  global _footer_handlers;
  _header_handlers = [];
  _footer_handlers = [];
  
# helper function to set node state  
def set_state (node,**fields):
  """helper function to set the state of a node specified by name or
# -*- coding: utf-8 -*-
# standard preamble
from Timba.TDL import *
from Timba import pynode
from Timba import dmi
from Timba import utils
from Timba.Meq import meq
from Lions.PiercePoints.modules import PhaseScreen

Settings.forest_state.cache_policy = 100

_dbg = utils.verbosity(0, name="test_pynode")
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf

initialized = False

# This class is meant to illustrate the pynode interface. All pynodes
# need to be derived from the Timba.pynode.PyNode class.


class KolmogorovNode(pynode.PyNode):
    # An __init__ method is not necessary at all. If you do define your
    # own for some reason, make sure you call pynode.PyNode.__init__()

    def __init__(self, *args):
        pynode.PyNode.__init__(self, *args)
        self.set_symdeps("domain")

    def update_state(self, mystate):
        global initialized
Beispiel #23
0
global has_vtk
has_vtk = False
try:
    from Timba.Plugins.vtk_qt_3d_display import *
    has_vtk = True
except:
    pass

from display_image import *
from QwtColorBar import *
from ND_Controller import *
from plot_printer import *

from Timba.utils import verbosity
_dbg = verbosity(0, name='plot_handler')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


class plot_handler:
    def __init__(self):
        self.colorbar = None
        self.visu_plotter = None
        self.twoD_plotter = None
        self.plotPrinter = None
        self.ND_plotter = None
        self.layout = None
        self.layout_parent = None
        self.ND_Controls_2D = None  # used to select surfaces for 2D display
        self.ND_Controls_3D = None  # used to select cube for 3D display
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

import numpy
from qt import *
from Timba.Plugins.display_image import *
from Timba.Plugins.realvsimag import *
from Timba.Plugins.plotting_functions import *
from QwtPlotImage import *
from QwtColorBar import *
from ND_Controller import *
from plot_printer import *

from Timba.utils import verbosity
_dbg = verbosity(0, name='history_plotter')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


# The HistoryPlotter plots the contents of a MeqHistoryCollect node
class HistoryPlotter(GriddedPlugin):
    """ a class to plot the history of some parameter. It can be
      a scalar or an array """

    _icon = pixmaps.bars3d
    viewer_name = "History Plotter"

    def is_viewable(data):
        return len(data) > 0
Beispiel #25
0
    from Timba.Meq import meqds
    from Timba.Meq.meqds import mqs
    from Timba.GUI.pixmaps import pixmaps
    from Timba.GUI import widgets
    from Timba.GUI.browsers import *
    from Timba import Grid

    from Timba.Plugins.display_image_qt5 import QwtImageDisplay
    from Timba.Plugins.QwtPlotImage_qt5 import QwtPlotImage
    from Timba.Plugins.QwtColorBar_qt5 import QwtColorBar
    from Timba.Plugins.ND_Controller_qt5 import ND_Controller
    import Timba.Plugins.plotting_functions_qt5 as plot_func
    #from Timba.Plugins.plot_printer_qt5 import *

    from Timba.utils import verbosity
    _dbg = verbosity(0, name='array_plotter')
    _dprint = _dbg.dprint
    _dprintf = _dbg.dprintf
    HAS_TIMBA = True
except:
    pass

global has_vtk
has_vtk = False


class ArrayPlotter(GriddedPlugin):
    """ a class to plot raw arrays contained within a Meq tree """

    _icon = pixmaps.bars3d
    viewer_name = "Array Plotter"
Beispiel #26
0
#
#
# Copyright (C) 2002-2007
# The MeqTree Foundation & 
# ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba import utils

_dbg = utils.verbosity(0,name='gw');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

__all__ = [ '_dbg','_dprint','_dprintf' ];
Beispiel #27
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from PyQt4.Qt import *
from Kittens.widgets import PYSIGNAL

from Timba.utils import verbosity

_dbg = verbosity(0,name='widgets');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

# ====== DataDroppableWidget ===================================================
# A metaclass implementing a data-droppable widget.
# Use, e.g., DataDroppableWidget(QToolButton) to create a class that
# subclasses QToolButton, handles data-drop events, and emits an
# itemDropped() signal.
#
def DataDroppableWidget (parent_class):
  class widgetclass (parent_class):
    def __init__ (self,*args):
      parent_class.__init__(self,*args);
      self.setAcceptDrops(True);
      self._accept_drops_from_children = False;
global has_pylab
has_pylab = False
try:
  import matplotlib
  from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.backends.backend_qt4 import NavigationToolbar2QT as NavigationToolbar
  from matplotlib.figure import Figure
  import pylab
  has_pylab = True
except:
  print ' '
  print '*** matplotlib/pylab not imported! ***'
  print 'The system will assume that matplotlib is not present.'

from Timba.utils import verbosity
_dbg = verbosity(0,name='pylab_plotter');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

if has_pylab:
 class MyPylabPlotter(FigureCanvas):
   
   def __init__(self, parent=None, dpi=100):
     self.fig = Figure(dpi=dpi)
     FigureCanvas.__init__(self, self.fig)
#    self.reparent(parent, QPoint(0, 0))
#    self.setParent(Qt.QWidget())
     FigureCanvas.setSizePolicy(self,
                                Qt.QSizePolicy.Expanding,
                                Qt.QSizePolicy.Expanding)
     FigureCanvas.updateGeometry(self)
Beispiel #29
0
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from qt import *
from Timba.Plugins.plotting_functions import *
import plot_printer

from ResultsRange import *
from BufferSizeDialog import *
import os
import tempfile

from Timba.utils import verbosity

_dbg = verbosity(0, name="svg_plotter")
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf

# The following class is a python translation and adaption of the
# same C++ class in the picture.cpp program provided in the
# QT Assistant documentation for Qt3


class PictureDisplay(QWidget):
    """ a class for handling data destined for display within 
      a QPicture or QPixmap 
  """

    menu_table = {"Save Display in PNG Format": 321}
# or write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba.dmi import *
from Timba import utils
from Timba import dmi_repr
from Timba.GUI.pixmaps import pixmaps
from Timba import Grid
from Timba.GUI.browsers import GriddedPlugin, PrecisionPopupMenu
from qt import *
from qttable import *

_dmirepr = dmi_repr.dmi_repr()

_dbg = utils.verbosity(0, name='array_browser')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


class ArrayTable(QTable):
    extra_col_width = 1
    # extra column margins, in units of a charcter's width
    extra_row_height = .05
    # extra row margin, in units of a character's height

    def __init__(self, parent, **args):
        QTable.__init__(self, parent, *args)
        font = QFont("Fixed",
                     QFontInfo(QApplication.font()).pointSize())
        font.setFixedPitch(True)
#  email:				 courriel:
#  [email protected]	 [email protected]
#
#  National Research Council		 Conseil national de recherches
#      Canada				    Canada
#  Herzberg Institute of Astrophysics	 Institut Herzberg d'astrophysique
#  5071 West Saanich Rd.		 5071 West Saanich Rd.
#  Victoria BC V9E 2E7			 Victoria BC V9E 2E7
#  CANADA					 CANADA
#

from PyQt4 import Qt
import sys

from Timba.utils import verbosity
_dbg = verbosity(0, name='ND')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


# the AxisRange class is directly adapted from the Qt/PyQt
# tutorial code examples
class AxisRange(Qt.QWidget):
    """ a spinbox and a slider, either of which can be used to specify
        a value from within an allowed range
    """
    def __init__(self, axis_number=1, axis_parms=None, parent=None, name=""):
        """ specify the layout of the spinbox and the slider """
        Qt.QWidget.__init__(self, parent)

        self.button = Qt.QPushButton(' ', self)
# sys.argv is not present when embedding a Python interpreter, but some
# packages (i.e. numarray) seem to fall over when it is not found. So we
# inject it
if not hasattr(sys,'argv'):
  setattr(sys,'argv',['meqkernel']);

# now import the rest
from Timba import dmi
from Timba import utils
import meqserver_interface
import sys
import imp
import os.path


_dbg = utils.verbosity(0,name='meqkernel');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

_header_handlers = [];
_footer_handlers = [];

def reset ():
  global _header_handlers;
  global _footer_handlers;
  _header_handlers = [];
  _footer_handlers = [];
  
# helper function to set node state  
def set_state (node,**fields):
  """helper function to set the state of a node specified by name or
Beispiel #33
0
#  [email protected]	 [email protected]
#
#  National Research Council		 Conseil national de recherches
#      Canada				    Canada
#  Herzberg Institute of Astrophysics	 Institut Herzberg d'astrophysique
#  5071 West Saanich Rd.		 5071 West Saanich Rd.
#  Victoria BC V9E 2E7			 Victoria BC V9E 2E7
#  CANADA					 CANADA
#

import sys

from Timba.utils import verbosity
from Timba.Plugins.plotting_functions_qt4 import *

_dbg = verbosity(0,name='VellsData');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class VellsData:
   """ A class for handling and extracting Vells data for display """

   def __init__(self):
     self._active_plane = 0
     self._active_perturb = None

     self._plot_vells_dict = {}
     self._plot_flags_dict = {}
     self._plot_labels = {}
     self._key_menu_labels = {}
     self._menu_labels = {}
Beispiel #34
0
from qwt.qt.QtGui import QApplication, QGridLayout, QWidget
from qwt.qt.QtCore import Qt, QObject, pyqtSignal

# modules that are imported

HAS_TIMBA = False
try:
  from Timba import utils
  from Timba.Meq import meqds
  from Timba.Meq.meqds import mqs
  from Timba.GUI.pixmaps import pixmaps
  from Timba.GUI import widgets
  from Timba.GUI.browsers import *
  from Timba import Grid
  from Timba.utils import verbosity
  _dbg = verbosity(0,name='quickref_plotter');
  _dprint = _dbg.dprint;
  _dprintf = _dbg.dprintf;
  HAS_TIMBA = True
except:
  pass

#print('HAS_TIMBA = ', HAS_TIMBA)

class QuickRefPlotter(GriddedPlugin):
  """ a class to display quickref_help contents of a node in the browser """ 

  _icon = pixmaps.bars3d
  viewer_name = "QuickRef Display";
  def is_viewable (data):
    return len(data) > 0;
Beispiel #35
0
#
#
# Copyright (C) 2002-2007
# The MeqTree Foundation &
# ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba import utils

_dbg = utils.verbosity(0, name='gw')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf

__all__ = ['_dbg', '_dprint', '_dprintf']
from qwt.qt.QtCore import Qt

import numpy

# modules that are imported

HAS_TIMBA = False
try:
    from Timba import utils
    from Timba.GUI import widgets
    from Timba.Plugins.display_image_qt5 import QwtImageDisplay
    from Timba.Plugins.QwtColorBar_qt5 import QwtColorBar
    from Timba.Plugins.ND_Controller_qt5 import ND_Controller

    from Timba.utils import verbosity
    _dbg = verbosity(0, name='plotting_functions')
    _dprint = _dbg.dprint
    _dprintf = _dbg.dprintf
    HAS_TIMBA = True
except:
    pass


def create_ColorBar(layout, layout_parent, plotter, plotPrinter):
    """ this function adds a colorbar for 2-D displays """

    # create two color bars in case we are displaying complex arrays
    colorbar = {}
    for i in range(2):
        colorbar[i] = QwtColorBar(colorbar_number=i, parent=layout_parent)
        colorbar[i].setMaxRange((-1, 1))
#  email:				 courriel:
#  [email protected]	 [email protected]
#
#  National Research Council		 Conseil national de recherches
#      Canada				    Canada
#  Herzberg Institute of Astrophysics	 Institut Herzberg d'astrophysique
#  5071 West Saanich Rd.		 5071 West Saanich Rd.
#  Victoria BC V9E 2E7			 Victoria BC V9E 2E7
#  CANADA					 CANADA
#

from PyQt4 import Qt
import sys

from Timba.utils import verbosity
_dbg = verbosity(0,name='ND');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

# the AxisRange class is directly adapted from the Qt/PyQt 
# tutorial code examples
class AxisRange(Qt.QWidget):
    """ a spinbox and a slider, either of which can be used to specify
        a value from within an allowed range
    """
    def __init__(self, axis_number=1, axis_parms=None,parent=None, name=""):
        """ specify the layout of the spinbox and the slider """
        Qt.QWidget.__init__(self, parent)

        self.button = Qt.QPushButton(' ', self)
        self.axis_number = axis_number
# or write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba.dmi import *
from Timba import utils
from Timba import dmi_repr
from Timba.GUI.pixmaps import pixmaps
from Timba import Grid
from Timba.GUI.browsers import GriddedPlugin,PrecisionPopupMenu
from qt import *
from qttable import *

_dmirepr = dmi_repr.dmi_repr();

_dbg = utils.verbosity(0,name='array_browser');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class ArrayTable(QTable):
  extra_col_width  = 1;   # extra column margins, in units of a charcter's width
  extra_row_height = .05;  # extra row margin, in units of a character's height

  def __init__(self,parent,**args):
    QTable.__init__(self,parent,*args);
    font = QFont("Fixed",QFontInfo(QApplication.font()).pointSize());
    font.setFixedPitch(True);
    self.setFont(font);
    self.setSelectionMode(QTable.NoSelection);
    self._arr = None;
    self._prec = (None,'f');
#  National Research Council		 Conseil national de recherches
#      Canada				    Canada
#  Herzberg Institute of Astrophysics	 Institut Herzberg d'astrophysique
#  5071 West Saanich Rd.		 5071 West Saanich Rd.
#  Victoria BC V9E 2E7			 Victoria BC V9E 2E7
#  CANADA					 CANADA
#

#from Timba.GUI.pixmaps import pixmaps
from QwtPlotImage_qt4 import *
from math import log
from math import exp
import numpy

from Timba.utils import verbosity
_dbg = verbosity(0,name='QwtColorBar');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

# called by the QwtImagePlot class
def square(n, min, max):
    t = numpy.arange(min, max, float(max-min)/(n-1))
    #return outer(cos(t), sin(t))
    return numpy.cos(t)*numpy.sin(t)[:,numpy.newaxis]
# square()



colorbar_instructions = \
'''The colorbar displays the current range of intensities in the corresponding image display. You can interact with the colorbar to change the range of intensities displayed in the image.<br><br>
Button 1 (Left): If you click the <b>left</b> mouse button on a location inside the colorbar and then drag it, a rectangular square will be seen. When you release the left mouse button, the range of intensity defined in the vertical (Y) direction will now specify the maximum range of intensity that will be shown in the image display. Image pixels with values greater or less than the selected range will be plotted with the maximum or minimum allowed values. The color rainbow or grayscale will always cover the specified range of pixels, so you can obtain increased detail by zooming in on an intensity range.<br><br>
HAS_TIMBA = False
try:
    from Timba.dmi import *
    from Timba import utils
    from Timba.Meq import meqds
    from Timba.Meq.meqds import mqs
    from Timba.GUI.pixmaps import pixmaps
    from Timba.GUI import widgets
    from Timba.GUI.browsers import *
    from Timba import Grid
    from Timba.Plugins.VellsData import VellsData
    from Timba.Plugins.ResultsRange_qt5 import ResultsRange
    from Timba.Plugins.DataDisplayMainWindow_qt5 import DisplayMainWindow

    from Timba.utils import verbosity
    _dbg = verbosity(0, name='collections_plotter')
    _dprint = _dbg.dprint
    _dprintf = _dbg.dprintf
    HAS_TIMBA = True
except:
    import traceback
    traceback.print_exc()
    print("Cannot import Plotting and GUI plugins... plotting will not work!!")


class CollectionsPlotter(GriddedPlugin):
    """ a class to visualize data, VellSets or visu data, that is 
      contained within a node's cache_result record. Objects of 
      this class are launched from the meqbrowser GUI """

    _icon = pixmaps.bars3d
from Timba.dmi import *
from Timba import utils
from Timba.GUI.pixmaps import pixmaps
from Timba.GUI import widgets
from Timba.GUI.browsers import *
from Timba import Grid

from qt import *
import sihippo
print "HippoDraw version " + sihippo.__version__
from sihippo import *
from Timba.array import *

from Timba.utils import verbosity
_dbg = verbosity(0, name='hippo_array_plotter')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


class HippoArrayPlotter(GriddedPlugin):
    """ a class to plot raw arrays contained within a Meq tree """

    _icon = pixmaps.bars3d
    viewer_name = "Hippo Array Plotter"

    def is_viewable(data):
        return len(data) > 0

    is_viewable = staticmethod(is_viewable)
Beispiel #42
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba.Meq import meq
from Timba import utils
from Timba.TDL import *
import math

_dbg = utils.verbosity(0, name='LSM_Sixpack')
_dprint = _dbg.dprint  # use: _dprint(2, "abc")
_dprintf = _dbg.dprintf

##########################################################################################
##########################################################################################
##########################################################################################


class Sixpack:
    """
    Constructors:
    Sixpack(stokesI=sI,stokesQ=sQ,stokesU=sU,stokesV=sV,ra=RA,dec=Dec,label=label): 
    by default, stokesI=1.0 and dec=pi/2 and all other node stubs are zero
    
    Sixpack(stokesI=sI,stokesQ=sQ,stokesU=sU,stokesV=sV,ra=RA,dec=Dec,ns=ns,label=label): 
Beispiel #43
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba import dmi
from Timba import utils
from Timba.TDL import Meq

try:
  import meqserver_interface
except:
  pass;

_dbg = utils.verbosity(0,name='pynode');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class PyNode (object):
  """Base class for implementing PyNodes. This class runs on the
  kernel side. Provides interface to the C++ node object, plus various
  helpful methods.
  """;
  def __init__ (self,name,node_baton):
    import meqserver_interface
    _dprintf(2,"created PyNode '%s'");
    self.name = name;
    self._baton = node_baton;
    if hasattr(self,'update_state'):
      self.set_state_impl = self._state_handler; 
Beispiel #44
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from Timba import dmi
from Timba import utils
from Timba.TDL import Meq

try:
  from Timba import meqserver_interface
except:
  pass

_dbg = utils.verbosity(0,name='pynode');
_dprint = _dbg.dprint;
_dprintf = _dbg.dprintf;

class PyNode (object):
  """Base class for implementing PyNodes. This class runs on the
  kernel side. Provides interface to the C++ node object, plus various
  helpful methods.
  """;
  def __init__ (self,name,node_baton):
    from Timba import meqserver_interface
    _dprintf(2,"created PyNode '%s'");
    self.name = name;
    self._baton = node_baton;
    if hasattr(self,'update_state'):
      self.set_state_impl = self._state_handler; 
#from Timba.GUI.pixmaps import pixmaps
#from Timba.GUI import widgets
#from Timba.GUI.browsers import *
#from Timba import Grid

import sys
from PyQt4 import Qt
import PyQt4.Qwt5 as Qwt
from QwtSpy_qt4 import *
import numpy
import random

import printfilter_qt4

from Timba.utils import verbosity
_dbg = verbosity(0, name='histogramplot')
_dprint = _dbg.dprint
_dprintf = _dbg.dprintf


#  distance from (15,5) squared
def dist(x, y):
    return (x - 15)**2 + (y - 5)**2


def imag_dist(x, y):
    return (x - 10)**2 + (y - 10)**2


def RealDist(x, y):
    return (x)**2