Re: Usage of FomulaManager

Hi Mathias,

I recommend that you look into using visad.python.RunJPython
(which in turn uses org.python.util.PythonInterpreter - see

for details).

RunJPython's exec() method lets you execute a line of Python
code, its eval() method executes a line and returns its value
(this treats the line of Python as a formula), its execfile()
method executes a program in a file, its set() method sets
values of variables, and its get() method returns values of
variables. Note that the Jython implementation beautifully
uses Java reflection so that every Java Object can be an object
in the untyped Python language.

The formula manager is great, but we have adopted the VisAD
connection to Python as our main direction for supporting
user scripts. We are providing lots of methods for simplified
access to VisAD from Python, as docuemnted in Tom's excellent
tutorial at:

Note also that the VisAD/Python connection gives us something
that has been my goal since I started VisAD in 1990: integration
of scientific metadata into ordinary programming language syntax.
So if you say 'image = image1 - image2' georeferencing and unit
conversions are implicit in the arithmetical operation. Or if
'map' is a map outline file, you can say 'image[map[i]]' to get
the image pixel at the location of the i-th map point.


Mathias Stümpert wrote:
> Hi everybody,
> I want to implement a "Command Line" in my application in a way that I
> am able to both resolve mathematical equations with my VisAD-Data
> objects like the FormulaManager does and that I am able to execute
> commands like list() but also methods in my classes like
> DisplayImpl.addMap(ScalarMap). Therefore the command line has to be able
> to parse expressions like the following examples:
> display.addMap(xmap)
> x=y+z
> display.addData(x)
> list(display.getAllData())
> ...
> where display, xmap, x, y and z are Objects but not necessarily
> visad.Thing objects. Is there a way to construct a FormulaManager that
> is able to parse all these expressions or do I have to do some kind of
> pre-parsing which filters everything the FormulaManager is not able to
> parse.
> Is there a way to get Exceptions or "error reports" from the
> FormulaManager if it was not able to parse the line?
> Is there a general documentation of the visad.formula package? I only
> found the docs and examples included in the package and its
> documentation.
> Many thanks in advance, Mathias
> ------------------------------------------------------------
> Mathias Stümpert
> email: mathias@xxxxxxxxxxxx
> homepage:

Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738

  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: