pygrace

Python bindings for grace, based on Nathan Gray's gracePlot
  • Requires grace and Numeric
  • Download pygrace source tarfile
  • Installation
  • unzup and unpack the gzipped tar archive
    $ tar -xvzf pygrace-0.3.tgz
    
    install the package
    $ python setup.py build
    $ python setup.py install
    
  • Documentation
  • import the grace class
    >>> from pygrace import grace
    
    instantiate the grace class
    >>> pg = grace()
    
    get help
    >>> pg.doc()
    Methods:
      prompt() --> start interactive session
      eval(command) --> execute a grace command
      put(name,val) --> put variable into interactive session
      get(name) --> get variable from interactive session
      who([name]) --> return the existing grace variables
      delete(name) --> destroy selected pylab variables
      restart() --> restart a grace window
    Notes:
      grace and Numeric must be installed, grace also relies on (open)motif
    
    use grace methods directly from the python interpreter
    >>> from Numeric import *
    >>> x = []
    >>> for i in range(21): x.append(i*pi/10)
    ... 
    >>> pg.plot(x,sin(x))
    
    push python variables into grace and interact with grace scripting language
    >>> pg.put('x',x)
    >>> pg.put('y',cos(x))
    >>> pg.eval('s0 line color 2')
    >>> pg.eval('plot(x,y)')
    
    use the interactive grace prompt
    >>> pg.prompt()
    grace interface:
    vars=
         y
         x
    grace> histoPlot(y)
    grace> s0 fill color 3
    grace> redraw()
    grace> exit
    
    check variables in grace session
    >>> pg.who().keys()
    ['y', 'x']
    >>> pg.who('x')
    [0.0, 0.31415926535897931, 0.62831853071795862, 0.94247779607693793,
    1.2566370614359172, 1.5707963267948966, 1.8849555921538759,
    2.1991148575128552, 2.5132741228718345, 2.8274333882308138,
    3.1415926535897931, 3.455751918948772, 3.7699111843077517,
    4.0840704496667311, 4.3982297150257104, 4.7123889803846897,
    5.026548245743669, 5.3407075111026483, 5.6548667764616276,
    5.9690260418206069, 6.2831853071795862] get variables back into python from grace >>> cosx = pg.get('y') use shortcuts for put, eval, and get >>> pg.z = 0.5 >>> pg('print z') 0.5 >>> pg.z + 1 1.5 delete variables from grace >>> pg.delete('x') >>> pg.delete('y')
  • Versions
  • 0.3: 05/23/06
     added examples directory
     shortcuts for put, get, & eval
    0.2: 06/20/05
     put() & get() now handle sequence elements, slices, etc.
    0.1: 06/17/05
     initial; python bindings for grace
     interactive grace prompt
     embed python into grace
     'plot' for 2-D line plots
     'histoPlot' for 2-D histograms
    
    pygrace plot of sin(x) pygrace histoPlot of cos(x)

    pyIDL

    Python bindings for IDL, based on Andrew McMurry's python-IDL
  • Requires ITT's IDL and numarray
  • Download pyIDL source tarfile
  • Installation
  • unzup and unpack the gzipped tar archive
    $ tar -xvzf pyIDL-0.6.tgz
    
    set environment variables
    (paths will depend on IDL installation and platform)
    $ export IDL_VERSION = '6.4'
    $ export IDL_INCDIR = '/itt/idl/external/include'
    $ export IDL_BINDIR = '/itt/idl/bin/bin.linux.x86'
    $ export X11_LIBDIR = '/usr/lib/'  (linux only)
    
    install the package
    $ python setup.py build
    $ python setup.py install
    
    (alternatively, a Makefile is included)
    
  • Documentation
  • import the idl class
    >>> from pyIDL import idl
    
    instantiate the idl class
    >>> ri = idl()
    
    get help
    >>> print ri.doc()
    Python-IDL bindings
        eval(command):
            execute an IDL command
        get(name,[array,allowNone]):
            fetch a variable from IDL
        put(name,value,[array,type,allowNone]):
            push a variable to IDL
        who([name,local,stdout]):
            print/return the IDL/local variables
        help([name]):
            print the IDL help message (for a variable)
        delete(name):
            destroy selected IDL variables
        map([name]):
            get the IDL data type mapping
        prompt():
            an interactive IDL session
        _print(value):
            print using the IDL print command
    
    push python variables into IDL and interact with IDL scripting language
    >>> from numarray import *
    >>> x = []
    >>> for i in range(21): x.append(i*pi/10)
    ...
    >>> ri.put('x',x)
    >>> ri.eval('y = sin(x)')
    >>> ri.eval('plot, x,y')
    
    use the interactive prompt
    >>> ri.prompt()
    IDL interface:
    % At $MAIN$
    X               DOUBLE    = Array[21]
    Y               DOUBLE    = Array[21]
    Compiled Procedures:
        $MAIN$
    
    Compiled Functions:
    
    IDL> IF x[0] LT 1 $
    IDL> THEN print, x
           0.0000000      0.31415927      0.62831853      0.94247780      1.2566371
           1.5707963       1.8849556       2.1991149       2.5132741      2.8274334
           3.1415927       3.4557519       3.7699112       4.0840704      4.3982297
           4.7123890       5.0265482       5.3407075       5.6548668      5.9690260
           6.2831853
    IDL> exit
    
    check variables in IDL session
    >>> ri.who().keys()
    ['Y', 'X']
    >>> ri.who('y')
    [0.0, 0.3090169943749474, 0.58778525229247314, 0.80901699437494745,
     0.95105651629515353, 1.0, 0.95105651629515364, 0.80901699437494745,
     0.58778525229247325, 0.30901699437494751, 1.2246063538223773e-16,
    -0.3090169943749469, -0.58778525229247303, -0.80901699437494734,
    -0.95105651629515353, -1.0, -0.95105651629515364, -0.80901699437494756,
    -0.58778525229247336, -0.30901699437494762, -2.4492127076447545e-16]
    
    get variables back into python from IDL
    >>> sinx = ri.get('y')
    
    use shortcuts for put, eval, and get
    >>> ri.z = 0.5
    >>> ri('print, z')
           0.50000000
    >>> ri.z + 1
    1.5
    
    delete variables from IDL
    >>> ri.delete('x')
    >>> ri.delete('y')
    
    use IDL function/procedure directly from python
    >>> ri.sin(x)
    [0.0, 0.3090169943749474, 0.58778525229247314, 0.80901699437494745,
     0.95105651629515353, 1.0, 0.95105651629515364, 0.80901699437494745,
     0.58778525229247325, 0.30901699437494751, 1.2246063538223773e-16,
    -0.3090169943749469, -0.58778525229247303, -0.80901699437494734,
    -0.95105651629515353, -1.0, -0.95105651629515364, -0.80901699437494756,
    -0.58778525229247336, -0.30901699437494762, -2.4492127076447545e-16]
    
  • Versions
  • 0.6: 07/18/07
     added support for idl_6.4
     fixed boolean support in direct IDL function/procedure calls
    0.5: 04/18/07
     fixed support for python2.5
    0.4.1: 12/01/06
     fixed support for mac os
    0.4: 10/06/06
     added support for idl_6.3
     improved support for NumPy
     removed dependency on Numeric
    0.3: 06/09/06
     improved support for Numeric
     added _print
     extended examples
    0.2: 05/19/06
     added examples directory
     support for 64-bit platforms
     shortcuts for put, get, eval
     access IDL functions/procedures from python
    0.1: 06/21/05
     initial; python bindings for RSI's IDL
     interactive IDL prompt
    
    pyidl plot of sin(x)





    These packages are licensed and distributed under the ARCS and DANSE projects, and are also available via anonymous cvs. Please see the ARCS software homepage for further information, or the DANSE wiki for usage and location of cvs repositories the for ARCS and DANSE projects.

    Return to Mike McKerns' homepage