Quick Reference to VisAD Python Interface Functions November 15, 2001 (update: February 26th, 2003) from JPythonMethods... data = load(string) Load a data file into 'a' from the named source 'string' a = load("myfile") a = load("adde://image?") a = load("http://host/mynetcdffile.nc") data = getNetcdfData(string_name, string_factor) Invokes the Netcdf File Adapter with an optional parameter (domain variable) to factor out. That is, the MathType of ( (a,b,c) -> v) can be pre-factored to (c-> ((a,b)->v)). This can be useful for large files. plot(data) Plot the data into a cell of the VisAD SpreadSheet - mappings will be guessed. plot(data,maps) Plot the data into a cell of the VisAD SpreadSheet - specifying the mappings. plot(data,editMaps) Plot the data into a cell of the VisAD SpreadSheet - if editMaps = 1, then the Mappings Dialog will pop up. plot(name, data) plot(name, data, maps) plot(name, data, editMaps) Plot as above, but in the named Window. plot(data, red, green, blue) plot(name, data, editMaps, red, green, blue) plot(name, data, editMaps, red, green, blue, maps) Plot as above, but use the colors specified clearplot() clearplot(name) Clear out the plot. saveplot(filename) saveplot(name, filename) Save the Plot into a JPEG file. saveplot(display, filename) Save a quick graph into a JPEG file. showAxesScales(display, boolean) setAxesScalesFont(maps, font) Things for the axes of graphs. data = hist(data, (dim, bins)) data = hist(data, (ranges)) data = hist(data, (ranges), (sizes)) Compute a binned dataset (useful for historgram-type analysis) See quickgraphs. data = field(values[]) data = field(range_name, values[]) data = field(domain_name, range_name, values[]) data = field(set, range_name, values[]) data = field(values[][]) data = field(range_name, values[][]) data = field(domain_1_name, domain_2_name, range_name, values[][]) data = field(set, range_name, values[][]) Make a data object from arrays of values (1D and 2D). data = replace(field, int[], Real) data = replace(field, int[], double) replace the values in each field(int[]) with the Real or double value. int = getDomainDimension(data) int = getRangeDimension(data) Get the number of components of the data's domain and range int[] = getDomainSizes(data) Get the dimension(s) of the component(s) of the domain sampling for data type = getDomainType(data) type = getRangeType(data) Get the Types of the domain and range for the data type = getType(data) Get the Type of the whole data object type = makeRealType(string) type = makeRealType(string, unit) type = makeType(string) Create new Type (or obtain an existing one with the string name); e.g., makeType(" (time->( (x,y)->value ) )" ) type = getDomainType(function_type) type = getRangeType(function_type) Get the Types of the domain and range for the given function type (useful when the function has been defined using makeType) string = domainType(data, int) string = rangeType(data, int) Get the name of the Types of the specific components of the domain or range. Unit = makeUnit(string) Create a Unit. set = makeDomain(int) set = makeDomain(type, int) set = makeDomain(double, double, int) set = makeDomain(type, double, double, int) make 1D domain set set = makeDomain(int, int) set = makeDomain(type, int, int) set = makeDomain(double, double, int, double, double, int) set = makeDomain(type, double, double, int, double, double, int) make 2D domain set set = makeDomain(double, double, int, double, double, int, double, double, int) set = makeDomain(type,double, double, int, double, double, int, double, double, int) make 3D domain set set = getDomainSet(data) Get the domain sampling set for this data object. data = combine(field[]) combine the array of fields into one data object. All fields must have the same sampling domain. data = resample(data, set) Resample the data into a new domain (specified by the sampling set) double = getValue(data) Get a single value from a Real object double[][] = getValues(data) Get an array of the range values of a Field - [component][sample] data = extract(data, type) data = extract(data, string) data = extract(data, int) Extract one range component from the data. data = domainFactor(data, type) data = domainFactor(data, int) Factor out one domain component (that is: ( (t,x,y->v ) can be factored to ( t-> ( (x,y)->v )) data = evaluate(data, Real) data = evaluate(data, double) Evaluate the data at the given point in the domain. int[] = find(data, string, double) int[] = find(data, string, data) Return pointers to samples where the data meets the criteria. For example: b = find(image, "gt", 100) returns a list of points (in b) of where image[k] > 100. data = mask(data, string, double) data = mask(data, string, data) Returns a new data (like an image or grid) of 1.0 at each point where the criteria is met; 0.0 at all other points. For example: d = mask(image, 'gt', 200) dumpTypes(data) General-purpose Type and Data information dump dumpType(data) Only lists information about MathTypes (useful for getting variable names from large objects on disk). Various math operations: data = abs(data) data = acos(data) data = acosDegrees(data) data = asin(data) data = asinDegrees(data) data = atan(data) data = atanDegrees(data) data = ceil(data) data = cos(data) data = cosDegrees(data) data = floor(data) data = log(data) data = rint(data) data = round(data) data = sin(data) data = sinDegrees(data) data = sqrt(data) data = tan(data) data = tanDegrees(data) data = max_data(data, data) data = min_data(data, data) data = atan2(data, data) data = atan2Degrees(data, data) data = max_data(data, double) data = min_data(data, double) data = atan2(data, double) data = atan2Degrees(data, double) data = max_data(double, data) data = min_data(double, data) data = atan2(double, data) data = atan2Degrees(double, data) data = fft(data) [data must be a Field] data = ifft(data) matrix = maxtrixMultiply(data, data) matrix = solve(data, data) matrix = inverse(data) matrix = transpose(data) double = det(data) double = norm1(data) double = norm2(data) double = normInf(data) double = normF(data) double = rank(data) double = cond(data) double = trace(data) JamaCholeskyDecomposition = chol(data) JamaEigenvalueDecomposition = eig(data) JamaLUDecomposition = lu(data) JamaQRDecomposition = qr(data) JamaSingularValueDecomposition = svd(data) from 'subs.py'............. (instance methods associated with the display are preceded by "disp." in their signature) disp = makeDisplay(maps) create (and return) a VisAD DisplayImpl and add the ScalarMaps, if any the VisAD box is resized to about 95% of the window. Use 3D if availble. disp = makeDisplay3D(maps) create (and return) a VisAD DisplayImplJ3D and add the ScalarMaps, if any the VisAD box is resized to about 95% of the window disp = makeDisplay2D(maps)" create (and return) a VisAD DisplayImplJ2D and add the ScalarMaps, if any the VisAD box is resized to about 95% of the window disp.saveDisplay(filename) saveDisplay(display, filename) save the display as a JPEG disp.addData(name, data, constantMaps=None, renderer=None, ref=None) addData(name, data, display, constantMaps=None, renderer=None, ref=None) add a Data object to a Display, and return a reference to the Data disp.setPointSize(size) setPointSize(display, size) set the size of points for point-type plots disp.setAspectRatio(ratio) setAspectRatio(display, ratio) define the aspects of width and height, as a ratio: width/height disp.setAspects(x, y, z) setAspects(display, x, y, z) define the relative sizes of the axes disp.maximizeBox() maximizeBox(display) a simple method for making the VisAD "box" 95% of the window size disp.setBoxSize(percent=.70) setBoxSize(display, percent=.70) a simple method for making the VisAD "box" some % of the window size disp.setBackgroundColor(color) setBackgroundColor(display,color) sets the display background color to 'c', which may be a string (like "white") or a java.awt.Color object. disp.setForegroundColor(color) setForegroundColor(display,color) sets the display foreground color to 'c', which may be a string (like "white") or a java.awt.Color object. disp.setCursorColor(color) setCursorColor(display,color) sets the display cursor color to 'c', which may be a string (like "white") or a java.awt.Color object. disp.setBoxColor(color) setBoxColor(display,color) sets the display VisAD "box" color to 'c', which may be a string (like "white") or a java.awt.Color object. disp.setBoxOn(on_off) setBoxOn(display,on_off) turns the 'wire frame VisAD box' on or off. x,y,z,disp = getDisplayMaps(display) return the x,y,z scalar maps for the display set = makeLine(domainType, points) make a 2D or 3D line, returns the Set so it can be added to the display or changed as needed ref = disp.drawLine(points[], color=None, mathtype=None) ref = drawLine(display, points[], color=None, mathtype=None) draw a line directly into the display; also return reference drawLine(display, domainType, points[], color=Color, mathtype=domainType) drawLine(name|display, points[], color=Color) "Color" is java.awt.Color disp.moveLine(ref, points[]) move the line referred to by 'ref' to the new location. ref = disp.drawString(string, point, color=None, center=0, font='futural') ref = drawString(display, string, point, color=None, center=0, font='futural') draw a string on the display disp.addMaps(maps[]) addMaps(display, maps[]) add an array of ScalarMaps to a Display disp.showDisplay(width=300, height=300, title=, bottom=, top=) showDisplay(display, width=300, height=300, title=, bottom=, top=) quick display of a Display object in a separate JFrame you can set the size and title, if you want... Use the bottom= and top= keywords to add these componenets (or panels) to the bottom and top of the VisAD display (which always is put in the Center). disp.addShape(type, scale=.1, color=None, index=None, autoScale=1) addShape(type, scale=.1, color=None, index=None, autoScale=1) Add a shape to the current display (see Shapes class, below). "type" can be 'cross', 'triangle', 'solid_square', or 'cube'. It may also be a user-defined VisADGeometryArray. Return value is the shape index (used for moveShape). disp.moveShape(index, coord) moveShape(index, coord) Move shape # 'index' to the coordinates 'coord', which is a list or tuple of coordinates in the display space, in the order (x,y,z). maps = makeMaps(RealType, name, RealType, name, ....) define ScalarMap(s) given pairs of (Type, name) where "name" is taken from the list, below. Return is a list of maps to use in constructing a display. maps = makeMaps(type_name, name, type_name, name, ....) define ScalarMap(s) given pairs of (type_name, name) where "type_name" is the (String) name of a valid ScalarType (RealType or TextType), and "name" is taken from the list, below. Return is a list of maps to use in constructing a display. ("x","y","z","lat","lon","rad","list","red","green", "blue","rgb","rgba","hue","saturation","value","hsv","cyan", "magenta","yellow","cmy","alpha","animation","selectvalue", "selectrange","contour","flow1x","flow1y","flow1z", "flow2x","flow2y","flow2z","xoffset","yoffset","zoffset", "shape","text","shapescale","linewidth","pointsize", "cylradius","cylazimuth","cylzaxis", "flow1elev","flow1azimuth","flow1radial", "flow2elev","flow2azimuth","flow2radial") data = changeRangeName(data, name) changes the name of the (single) Range Component in the object to be . The Unit of the original is inherited. class Shapes(display, shapemap) A class useful for manipulating many shapes on multiple displays. 'shapemap' is the name of the ScalarMap that has a RealType mapped to Display.Shape. This class has two methods: addShape(type, scale=.1, color=None, index=None, autoScale=1) moveShape(index, coord) class SelectField(selectMapName, data) SelectField aids in showing a series of data objects using the Display.SelectValue. 'data' should be an array of data with same MathTypes. This class has 3 methods: showIt(this, index) - shows field number 'index' getScalarMap(this) - returns the ScalarMap to add to display for this SelectField object getSelectField(this) - returns the Field to add to the display. class HandlePickEvent(display, handler) Helper class for interfacing to the VisAD Display when the user drags the mouse around with both buttons pressed (which causes a cursor to appear and the domain readout values to be shown). When the mouse buttons are released, the applications 'handler' will be called. 'handler' method should have two parameters: x,y that will get the domain coordinate values on the x and y axes. class RubberBandZoomer(display, requireKey, callback=callname) Class to define a Rubber Band Box zoom capability for a display. Once invoked, a drag with right mouse button creates a RubberBandBox. When released, the image is moved and zoomed to fill the window. The 'display' is just that. The 'requireKey' is 0 for no simultaneous key, =1 for CTRL, =2 for SHIFT. Useful because other manipulation renderers might get events as well. If the 'callname' is given, then when the box is zoomed, the samples array (x,y values of the upper left and lower right corners) will be passed to it. def zoomit(samples) Will force the display associated with this RBZ to be zoomed according to the samples given. This (along with the callback=) can be used to allow one display to zoom another. LinkBoxControl(myDisplay, otherDisplay) this class will link the actions (roam, zoom, etc) of one display to another. from 'graph.py'..... (Note that each of these returns a 'display' object.) mapimage(data, mapfilename): addeimage(): image(data, panel=None, colortable=None, width=400, height=400, title="VisAD Image"): scatter(data_1, data_2, panel=None, pointsize=None, width=400, height=400, xlabel=None, ylabel=None, title="VisAD Scatter"): histogram(data, bins=20, width=400, height=400, title="VisAD Histogram", color=None, panel=None): lineplot(data, panel=None, color=None, width=400, height=400, title="Line Plot"): contour(data, panel=None, enableLabels=1, interval=None, width=400, height=400, title="VisAD Contour Plot", interval = [int, low, high, base]): animation(data, panel=None, width=400, height=500, title="VisAD Animation"): The "panel=" keyword allows you to supply a Java container for the graph (like a panel or window). If you do, then the graphic will be placed into your container. Otherwise, a new frame is created and the display produced.