Exemplo n.º 1
0
def scatter(data_1, data_2, panel=None, pointsize=None, width=400, height=400, xlabel=None, ylabel=None, title="VisAD Scatter", bottom=None, top=None, color=None):
  """
  Quick plot of a scatter diagram between <data_1> and <data_2>.
  <panel> is the name of a panel to put this into (default= make a new
  one), <pointsize> is the size of the scatter points (def = 1),
  <width> and <height> are the dimensions, <xlabel> and <ylabel> are
  the axes labels to use (def = names of data objects).  <title> is
  the phrase for the title bar.  Returns a reference to the display.
  """

  if isinstance(data_1,PyList) or isinstance(data_1,PyTuple):
    data_1 = field('data_1',data_1)

  if isinstance(data_2,PyList) or isinstance(data_2,PyTuple):
    data_2 = field('data_2',data_2)

  rng_1 = data_1.getType().getRange().toString()
  rng_2 = data_2.getType().getRange().toString()
  data = FieldImpl.combine((data_1,data_2))
  maps = subs.makeMaps(getRealType(rng_1),"x", getRealType(rng_2),"y")
  disp = subs.makeDisplay(maps)
  subs.addData("data", data, disp, constantMaps=subs.makeColorMap(color))
  subs.setBoxSize(disp, .70)
  showAxesScales(disp,1)
  #setAxesScalesFont(maps, Font("Monospaced", Font.PLAIN, 18))
  if pointsize is not None: subs.setPointSize(disp, pointsize)

  subs.setAspectRatio(disp, float(width)/float(height))
  subs.showDisplay(disp,width,height,title,bottom,top,panel)
  setAxesScalesLabel(maps, [xlabel, ylabel])
  return disp
Exemplo n.º 2
0
Arquivo: graph.py Projeto: visad/visad
def colorimage(red_data,
               green_data,
               blue_data,
               panel=None,
               colortable=None,
               width=400,
               height=400,
               title="VisAD Color Image"):
    """
  Display a color image, from three images <red_data>, <green_data>
  and <blue_data>.  <panel> is the name of a panel to put this into
  (default= make a new one), <colortable> is a color table to use (def
  = gray scale), <width> and <height> are the dimensions.  <title> is
  the phrase for the title bar.  Returns a reference to the display.

  """

    _comb_image = FieldImpl.combine([red_data, green_data, blue_data])
    dom_1 = RealType.getRealType(domainType(_comb_image, 0))
    dom_2 = RealType.getRealType(domainType(_comb_image, 1))
    rng = rangeType(_comb_image)
    maps = subs.makeMaps(dom_1, 'x', dom_2, 'y', rng[0], 'red', rng[1],
                         'green', rng[2], 'blue')

    disp = subs.makeDisplay(maps)
    subs.addData('comb', _comb_image, disp)
    subs.setBoxSize(disp, .80)
    subs.setAspectRatio(disp, float(width) / float(height))
    subs.showDisplay(disp, width, height, title, None, None, panel)
    return disp
Exemplo n.º 3
0
Arquivo: graph.py Projeto: visad/visad
def scatter(data_1,
            data_2,
            panel=None,
            pointsize=None,
            width=400,
            height=400,
            xlabel=None,
            ylabel=None,
            title="VisAD Scatter",
            bottom=None,
            top=None,
            color=None):
    """
  Quick plot of a scatter diagram between <data_1> and <data_2>.
  <panel> is the name of a panel to put this into (default= make a new
  one), <pointsize> is the size of the scatter points (def = 1),
  <width> and <height> are the dimensions, <xlabel> and <ylabel> are
  the axes labels to use (def = names of data objects).  <title> is
  the phrase for the title bar.  Returns a reference to the display.
  """

    if isinstance(data_1, PyList) or isinstance(data_1, PyTuple):
        data_1 = field('data_1', data_1)

    if isinstance(data_2, PyList) or isinstance(data_2, PyTuple):
        data_2 = field('data_2', data_2)

    rng_1 = data_1.getType().getRange().toString()
    rng_2 = data_2.getType().getRange().toString()
    data = FieldImpl.combine((data_1, data_2))
    maps = subs.makeMaps(getRealType(rng_1), "x", getRealType(rng_2), "y")
    disp = subs.makeDisplay(maps)
    subs.addData("data", data, disp, constantMaps=subs.makeColorMap(color))
    subs.setBoxSize(disp, .70)
    showAxesScales(disp, 1)
    #setAxesScalesFont(maps, Font("Monospaced", Font.PLAIN, 18))
    if pointsize is not None: subs.setPointSize(disp, pointsize)

    subs.setAspectRatio(disp, float(width) / float(height))
    subs.showDisplay(disp, width, height, title, bottom, top, panel)
    setAxesScalesLabel(maps, [xlabel, ylabel])
    return disp
Exemplo n.º 4
0
def colorimage(red_data, green_data, blue_data, panel=None, colortable=None, width=400, height=400, title="VisAD Color Image"):
  """
  Display a color image, from three images <red_data>, <green_data>
  and <blue_data>.  <panel> is the name of a panel to put this into
  (default= make a new one), <colortable> is a color table to use (def
  = gray scale), <width> and <height> are the dimensions.  <title> is
  the phrase for the title bar.  Returns a reference to the display.

  """


  _comb_image = FieldImpl.combine( [red_data, green_data, blue_data])
  dom_1 = RealType.getRealType(domainType(_comb_image,0))
  dom_2 = RealType.getRealType(domainType(_comb_image,1))
  rng = rangeType(_comb_image)
  maps = subs.makeMaps(dom_1,'x', dom_2, 'y', rng[0], 'red',
     rng[1], 'green', rng[2], 'blue')

  disp = subs.makeDisplay(maps)
  subs.addData('comb',_comb_image,disp)
  subs.setBoxSize(disp, .80)
  subs.setAspectRatio(disp, float(width)/float(height))
  subs.showDisplay(disp,width,height,title,None,None,panel)
  return disp
Exemplo n.º 5
0
from visad.python.JPythonMethods import *
import subs, graph
from visad import Real, RealTuple, RealType, DataReferenceImpl
from visad.java3d import DefaultRendererJ3D
from visad.bom import DiscoverableZoom

a=load("../data/mcidas/AREA0007")
ds = a.getDomainSet()
xdim = ds.getX().getLength()
ydim = ds.getY().getLength()
print "Image size = ",ydim," by",xdim

cs = ds.getCoordinateSystem()

rangetype = a.getType().getRange()
maps=subs.makeMaps(RealType.Latitude, "y", RealType.Longitude, "x",
                   rangetype[0], "text")
disp=subs.makeDisplay3D(maps)

pcontrol = disp.getProjectionControl()
dzoom = DiscoverableZoom()
pcontrol.addControlListener(dzoom)

tcontrol = maps[2].getControl()
tcontrol.setAutoSize(1)

rends = []

for i in range (ydim/2, ydim/2 + 20):
  for j in range (xdim/2, xdim/2 + 20):

    ref = DataReferenceImpl("data")
Exemplo n.º 6
0
Arquivo: graph.py Projeto: visad/visad
def animation(data, width=400, height=500, title="VisAD Animation"):
    """
  Quick plot of an animation.  <data> is a list/tuple of iamges to
  animate.  <width> and <height> are the size, and <title> is the
  label for the titlebar.  Returns a reference to the display.
  """

    num_frames = len(data)

    frames = RealType.getRealType("frames")
    frames_type = RealTupleType(frames)

    image_type = data[0].getType()
    ndom = domainDimension(data[0])

    if ndom != 2:
        print "domain dimension must be 2!"
        return None

    dom_1 = RealType.getRealType(domainType(data[0], 0))
    dom_2 = RealType.getRealType(domainType(data[0], 1))

    nrng = rangeDimension(data[0])
    if (nrng != 3) and (nrng != 1):
        print "range dimension must be 1 or 3"
        return None

    # now create display scalar maps
    maps = None
    rng_1 = rangeType(data[0], 0)
    if nrng == 3:
        rng_2 = rangeType(data[0], 1)
        rng_3 = rangeType(data[0], 2)
        rng_red = None
        if (rng_1 == "Red"): rng_red = rng_1
        if (rng_2 == "Red"): rng_red = rng_2
        if (rng_3 == "Red"): rng_red = rng_3
        rng_green = None
        if (rng_1 == "Green"): rng_green = rng_1
        if (rng_2 == "Green"): rng_green = rng_2
        if (rng_3 == "Green"): rng_green = rng_3
        rng_blue = None
        if (rng_1 == "Blue"): rng_blue = rng_1
        if (rng_2 == "Blue"): rng_blue = rng_2
        if (rng_3 == "Blue"): rng_blue = rng_3

        if (rng_red is None) or (rng_green is None) or (rng_blue is None):
            print "3 Range components must be Red, Green and Blue"

        else:
            maps = subs.makeMaps(dom_1, "x", dom_2, "y",
                                 RealType.getRealType(rng_red), "red",
                                 RealType.getRealType(rng_green), "green",
                                 RealType.getRealType(rng_blue), "blue")

    else:
        maps = subs.makeMaps(dom_1, "x", dom_2, "y",
                             RealType.getRealType(rng_1), "rgb")

    frame_images = FunctionType(frames_type, image_type)
    frame_set = makeDomain(frames, 0, num_frames - 1, num_frames)
    frame_seq = FieldImpl(frame_images, frame_set)

    for i in range(0, num_frames):
        frame_seq.setSample(i, data[i])

    disp = subs.makeDisplay(maps)
    animap = ScalarMap(frames, Display.Animation)
    disp.addMap(animap)
    refimg = subs.addData("VisAD_Animation", frame_seq, disp)
    widget = AnimationWidget(animap, 500)
    subs.setAspectRatio(disp, float(width) / float(height))
    myAnimFrame(disp, widget, width, height, "Animation")

    return disp
Exemplo n.º 7
0
xset = set.getX()
yset = set.getY()
zset = set.getZ()

# get units, coordinate system and errors for the sampling
units = set.getSetUnits()
cs = set.getCoordinateSystem()
errors = set.getSetErrors()

# get the actual x, y and z values of the spatial sampling
xv = xset.getSamples()[0]
yv = yset.getSamples()[0]
zv = zset.getSamples()[0]

# create a display with mappings for our grid
maps = subs.makeMaps(d[0], "y", d[1], "x", d[2], "z", r, "contour")
maps[2].setRange(zv[0], zv[-1])
display = subs.makeDisplay(maps)
contourwidget = ContourWidget(maps[3])

# create an interactive slider for choosing a grid level
level = DataReferenceImpl("height")
slider = VisADSlider("level", int(1000.0 * zv[0]), int(1000.0 * zv[-1]),
                     int(1000.0 * zv[0]), 0.001, level, d[2])


# define a function for extracting a grid level at height 'z'
def makeSlice(z):
    # initialize arrays for a 2-D grid at height 'z'
    xs = []
    ys = []
Exemplo n.º 8
0
Arquivo: slice.py Projeto: visad/visad
xset = set.getX()
yset = set.getY()
zset = set.getZ()

# get units, coordinate system and errors for the sampling
units = set.getSetUnits()
cs = set.getCoordinateSystem()
errors = set.getSetErrors()

# get the actual x, y and z values of the spatial sampling
xv = xset.getSamples()[0]
yv = yset.getSamples()[0]
zv = zset.getSamples()[0]

# create a display with mappings for our grid
maps = subs.makeMaps(d[0], "y", d[1], "x", d[2], "z", r, "rgb")
maps[2].setRange(zv[0], zv[-1])
display = subs.makeDisplay(maps)

# create an interactive slider for choosing a grid level
level = DataReferenceImpl("height")
slider = VisADSlider("level", int(1000.0 * zv[0]), int(1000.0 * zv[-1]),
                     int(1000.0 * zv[0]), 0.001, level, d[2])


# define a function for extracting a grid level at height 'z'
def makeSlice(z):
    # initialize arrays for a 2-D grid at height 'z'
    xs = []
    ys = []
    zs = []
Exemplo n.º 9
0
xset = set.getX()
yset = set.getY()
zset = set.getZ()

# get units, coordinate system and errors for the sampling
units = set.getSetUnits()
cs = set.getCoordinateSystem()
errors = set.getSetErrors()

# get the actual x, y and z values of the spatial sampling
xv = xset.getSamples()[0]
yv = yset.getSamples()[0]
zv = zset.getSamples()[0]

# create a display with mappings for our grid
maps = subs.makeMaps(d[0], "y", d[1], "x", d[2], "z", r, "rgb")
maps[2].setRange(zv[0], zv[-1])
display = subs.makeDisplay(maps)

# create an interactive slider for choosing a grid level
level = DataReferenceImpl("height")
slider = VisADSlider("level", int(1000.0 * zv[0]),
                     int(1000.0 * zv[-1]),
                     int(1000.0 * zv[0]), 0.001,
                     level, d[2])

# define a function for extracting a grid level at height 'z'
def makeSlice(z):
  # initialize arrays for a 2-D grid at height 'z'
  xs = []
  ys = []
Exemplo n.º 10
0
from javax.swing import JFrame, JPanel
from java.awt import BorderLayout, GridLayout, Font

image = load("AREA0007")
print "Done reading data..."

dom = getDomain(image)
d = domainType(image)
r = rangeType(image)

# max lines & elements of image
NELE = dom.getX().getLength()
LINES = dom.getY().getLength()

# subs for image in display-1
m = subs.makeMaps(d[0],"x",d[1],"y",r[0],"rgb")
d1 = subs.makeDisplay(m)
subs.setBoxSize(d1,.80)

# add the image to the display
refimg = subs.addData("image", image, d1)

# now the second panel
m2 = subs.makeMaps(d[0],"x",r[0],"y")
m2[1].setRange(0, 255)
d2 = subs.makeDisplay(m2)
subs.setBoxSize(d2,.80)

# get the desired format of the Data (line->(element->value))
# factoring works because image has a 2-D rectangular sampling
byline = domainFactor(image,d[1])
Exemplo n.º 11
0
xset = set.getX()
yset = set.getY()
zset = set.getZ()

# get units, coordinate system and errors for the sampling
units = set.getSetUnits()
cs = set.getCoordinateSystem()
errors = set.getSetErrors()

# get the actual x, y and z values of the spatial sampling
xv = xset.getSamples()[0]
yv = yset.getSamples()[0]
zv = zset.getSamples()[0]

# create a display with mappings for our grid
maps = subs.makeMaps(d[0], "y", d[1], "x", d[2], "z", r, "contour")
maps[2].setRange(zv[0], zv[-1])
display = subs.makeDisplay(maps)
contourwidget = ContourWidget(maps[3])

# create an interactive slider for choosing a grid level
level = DataReferenceImpl("height")
slider = VisADSlider("level", int(1000.0 * zv[0]),
                     int(1000.0 * zv[-1]),
                     int(1000.0 * zv[0]), 0.001,
                     level, d[2])

# define a function for extracting a grid level at height 'z'
def makeSlice(z):
  # initialize arrays for a 2-D grid at height 'z'
  xs = []
Exemplo n.º 12
0
def testvisad():
    from visad import RealType, Real, FunctionType, FlatField, RealTuple
    from visad.java3d import DisplayImplJ3D, DirectManipulationRendererJ3D
    from visad.java2d import DisplayImplJ2D, DirectManipulationRendererJ2D
    import subs

    # make Types for our data
    ir_radiance = RealType("ir_raidance")
    count = RealType("count")
    ir_histogram = FunctionType(ir_radiance, count)
    vis_radiance = RealType("vis_radiance")

    # make up the data values...
    histogram = FlatField.makeField(ir_histogram, 64, 0)
    direct = Real(ir_radiance, 2.0)
    direct_tuple = RealTuple( (Real(count, 1.0), Real(ir_radiance,2.0), Real(vis_radiance, 1.0)) )

    # create the scalar mappings for display 0
    maps0=subs.makeMaps(vis_radiance,"z", ir_radiance,"x",
                                        count, "y", count,"green")
    # make display 0 a 3-D display
    dpys0 = subs.makeDisplay3D(maps0)
    subs.setPointSize(dpys0, 5.0)

    # add the data to display 0 and keep the references
    ref_hist = subs.addData("histo", histogram, dpys0,
                    renderer=DirectManipulationRendererJ3D())
    ref_dir = subs.addData("dir", direct, dpys0,
                    renderer=DirectManipulationRendererJ3D())
    ref_dir_tuple = subs.addData("dir_tup", direct_tuple, dpys0,
                    renderer=DirectManipulationRendererJ3D())

    # create the scalar mappings for display 1
    maps1 = subs.makeMaps(ir_radiance,"x", count,"y", count,"green")

    # make display 1 a 2-D display
    dpys1 = subs.makeDisplay2D(maps1)
    subs.setPointSize(dpys1, 5.0)

    # add the data to this display, but use the references from
    # the previous one so the direct manipulations interact with both
    subs.addData("histo", histogram, dpys1,
            renderer=DirectManipulationRendererJ2D(), ref=ref_hist)
    subs.addData("dir", direct, dpys1,
            renderer=DirectManipulationRendererJ2D(), ref=ref_dir)
    subs.addData("dir_tup", direct_tuple, dpys1,
            renderer=DirectManipulationRendererJ2D(), ref=ref_dir_tuple)

    # function to clean up when display window is closed
    def cleanup(event):
        dpys0.destroy()
        dpys1.destroy()
        frame.dispose()

    # create window for display and add the dspy displays to it
    from javax.swing import JPanel, JFrame
    from java.awt import GridLayout
    panel1 = JPanel()
    panel1.add(dpys0.getComponent())
    panel2 = JPanel()
    panel2.add(dpys1.getComponent())

    frame = JFrame("Test35", windowClosing=cleanup)
    pane = frame.getContentPane()
    pane.setLayout(GridLayout(1,2))
    pane.add(panel1)
    pane.add(panel2)
    frame.setSize(600,300)
    frame.setVisible(1)
Exemplo n.º 13
0
def animation(data, width=400, height=500, title="VisAD Animation"):
  """
  Quick plot of an animation.  <data> is a list/tuple of iamges to
  animate.  <width> and <height> are the size, and <title> is the
  label for the titlebar.  Returns a reference to the display.
  """

  num_frames = len(data)

  frames = RealType.getRealType("frames")
  frames_type = RealTupleType( frames )

  image_type = data[0].getType()
  ndom = domainDimension(data[0])

  if ndom != 2:
    print "domain dimension must be 2!"
    return None

  dom_1 = RealType.getRealType(domainType(data[0],0) )
  dom_2 = RealType.getRealType(domainType(data[0],1)) 

  nrng = rangeDimension(data[0])
  if (nrng != 3) and (nrng != 1):
    print "range dimension must be 1 or 3"
    return None

  # now create display scalar maps
  maps = None
  rng_1 = rangeType(data[0],0)
  if nrng == 3:
    rng_2 = rangeType(data[0],1)
    rng_3 = rangeType(data[0],2)
    rng_red = None
    if (rng_1 == "Red"): rng_red = rng_1
    if (rng_2 == "Red"): rng_red = rng_2
    if (rng_3 == "Red"): rng_red = rng_3
    rng_green = None
    if (rng_1 == "Green"): rng_green = rng_1
    if (rng_2 == "Green"): rng_green = rng_2
    if (rng_3 == "Green"): rng_green = rng_3
    rng_blue = None
    if (rng_1 == "Blue"): rng_blue = rng_1
    if (rng_2 == "Blue"): rng_blue = rng_2
    if (rng_3 == "Blue"): rng_blue = rng_3

    if (rng_red is None) or (rng_green is None) or (rng_blue is None):
      print "3 Range components must be Red, Green and Blue"

    else:
      maps = subs.makeMaps(dom_1,"x", dom_2,"y", RealType.getRealType(rng_red), "red", RealType.getRealType(rng_green), "green", RealType.getRealType(rng_blue), "blue")

  else:
    maps = subs.makeMaps(dom_1,"x", dom_2, "y", RealType.getRealType(rng_1), "rgb")

  frame_images = FunctionType(frames_type, image_type)
  frame_set = makeDomain(frames, 0, num_frames-1, num_frames)
  frame_seq = FieldImpl(frame_images, frame_set)

  for i in range(0,num_frames):
    frame_seq.setSample(i, data[i])

  disp = subs.makeDisplay(maps)
  animap = ScalarMap(frames, Display.Animation)
  disp.addMap(animap)
  refimg = subs.addData("VisAD_Animation", frame_seq, disp)
  widget = AnimationWidget(animap, 500) 
  subs.setAspectRatio(disp, float(width)/float(height))
  myAnimFrame(disp, widget, width, height, "Animation")

  return disp
Exemplo n.º 14
0
from visad.python.JPythonMethods import *
import subs, graph
from visad import Real, RealTuple, RealType, DataReferenceImpl
from visad.java3d import DefaultRendererJ3D
from visad.bom import DiscoverableZoom

a = load("../data/mcidas/AREA0007")
ds = a.getDomainSet()
xdim = ds.getX().getLength()
ydim = ds.getY().getLength()
print "Image size = ", ydim, " by", xdim

cs = ds.getCoordinateSystem()

rangetype = a.getType().getRange()
maps = subs.makeMaps(RealType.Latitude, "y", RealType.Longitude, "x",
                     rangetype[0], "text")
disp = subs.makeDisplay3D(maps)

pcontrol = disp.getProjectionControl()
dzoom = DiscoverableZoom()
pcontrol.addControlListener(dzoom)

tcontrol = maps[2].getControl()
tcontrol.setAutoSize(1)

rends = []

for i in range(ydim / 2, ydim / 2 + 20):
    for j in range(xdim / 2, xdim / 2 + 20):

        ref = DataReferenceImpl("data")