Modules

References to functions in modules in ./lib directory. Most modules have an example to show usage.

colorschemes

Function Parameter Type Remark (http://geography.uoregon.edu/datagraphics/color_scales.htm)
rgb_gr2mg() none Returns color array for this color scheme (16 steps):
rgb_bl2dr() none Returns color array for this color scheme (18 steps):
rgb_bl2do() none Returns color array for this color scheme (18 steps):
rgb_bl2dr() none Returns color array for this color scheme:
rgb_bl2gr() none Returns color array for this color scheme (14 steps):
rgb_br2bl() none Returns color array for this color scheme (12 steps):
rgb_bl2or() none Returns color array for this color scheme (14 steps):
rgb_paired() none Returns color array for this color scheme (12 steps):

contour

Function Parameter Type Remark
colorbar(r, g, b, c, n=1, flag=true) array, array, array, array, number, true/false Returns a color bar object. Colors for contour values in c are given in r, g, and b. If n > 0, colors will be interpolated n times. If flag = true, the colorbar type is discrete.
contour_tri(X, Y, Z, I, n, so) matrix, matrix, matrix, matrix, integer, number Returns a line object containing contour lines the iso-value found in triangles resulted from matrix's delaunay() function.
contour_grid(Z, X, Y, iso) matrix, matrix, matrix, number, true/false Returns line object containing contour lines for the iso-value (iso) found in data (Z) at regular grids (X, Y).
contour_image(Z, fname, vmin=-1.e30, vmax=1.e30, r=1, g=1, b=1) matrix, string, numbers Save to fname the image whose colors vary according to Z and the colorbar. The optional parameters determine the color of data that are outside the range.
lattice(W, X, Y, Z) matrixes Returns a node object that contains lines and balls to form a lattice for the volume data at grids (X, Y, Z). the color of a ball vary with W values.
isosurface(W, X, Y, Z, iso) matrix, matrix, matrix, matrix, number Returns a polygon object that forms the iso-surface for the volume data W at grids (X, Y, Z) for the given iso-value. The isosurface encloses high W.
mesh_tri(X, Y, Z, I, n) matrix, matrix, matrix, matrix, integer Returns a polygon object containing triangles resulted from matrix's delaunay() function.
mesh_grid(Z, X, Y) matrix, matrix, matrix Returns a polygon object containing quads representing data (Z) at regular grids (X, Y).

dataproc

Function Parameter Type Remark
ridmissing(V, vmin=-1.e30, vmax=1.e30) pointer, number, number Removes missing data.
mlinear(A, Y) pointer, pointer Least square fitting of y = c0 + c1*x1 + c2*x2...
trigono(X, Y, period, ns) pointer, pointer, number, number Trigonometric polynomial curve fitting of y = a + b*x + c1*cos(x) + d1*sin(x) + c2*cos(2x) + d2*sin(2x)...
trigono_eval(X, coef, period, ns) pointer, array, number, number Evaluate trigonometric fitting.

map

Function Parameter Type Remark
map(gshhs, lon1=0, lon2=360, dlon=30, lat1=-90, lat2=90, dlat=30, scale=1) string, numbers Returns an array of zeGraph objects for generating an un-projected map. For publication, set scale to about 4 and save image to a file.
coast(gshhs, lon1=0, lon2=360, lat1=-90, lat2=90, z=0) string, numbers Returns a line object containing coast lines.
grid( lon1=0, lon2=360, dlon=30, lat1=-90, lat2=90, dlat=30, z=0) numbers Returns a line object containing latitude and longitude grid lines.
spheric(lon, lat) numbers Converts longitude-latitude to x-y-z on a unit sphere surface.
aitoff(lon, lat) numbers Aitoff projection.
denoyer(lon, lat) numbers Denoyer projection.
echert(lon, lat); numbers Eckert V projection.
wagner(lon, lat) numbers Wagner II projection.

globe

Function Parameter Type Remark
globe_map(r, grid, fname) number, number, string Returns an array of zeGraph objects for generating a globe with coastlines and grid lines. Coastline data are read from fname, a GSHHS data file.
globe_texture(r, grid, fname) number, number, string Returns an array that contains zeGraph objects for generating a globe with grid lines. The image given by fname will be wrapped on the globe surface.
globe_projection(r, lon, lat) numbers Converts longitude-latitude in degree to x-y-z on the surface of a sphere of radius r. The results are returned in an array.
globe_length(r, lon1, lat1, lon2, lat2) numbers Returns the great circle distance between P1(lon1, lat1) and P2(lon2, lat2) on a globe of radius r.
globe_line(r, lon1, lat1, lon2, lat2) numbers Returns a line object for drawing a line between P1(lon1, lat1) and P2(lon2, lat2) on the surface of a globe of radius r.
globe_lxyz(r, x1, y1, z1, x2, y2, z2) numbers Returns a line object for drawing a line between P1(x1, y1, z1) and P2(x2, y2, z2) on the surface of a globe of radius r. P1 and P2 are points on unit sphere.

plot2d

Function Parameter Type Remark
plot2d(w=512, h=512, x0=-1, x1=1, dx=.5, y0=-1, y1=1, dy=.5) numbers Defines a 2D-plot and returns an array of zeGraph objects for customizing axis, color, and etc. The plot size is w by h and axis ranges are defined by x-y parameters.
arrow2d(x, y, u, uscale, v, vscale, size=5) numbers Plots an arrow that starts at (x, y) and points toward (u, v) like a wind vector, and returns a line object. The size parameter determines arrow head size in pixel.
bar2d(x, y, w, h) numbers Plots a bar of width w and height h at (x, y) and returns a polygon object.
coast2d(gshhs, z=0) string, numbers Read coastline data from gshhs, plots coastlines, returns a line object.
frame2d(x, y, fill=false) array, array, true/false Plots a frame and return the line object.
image2d( x1, y1, x2, y2, filename) number, number, number, number, string Plots the image in fname in a rectangle with the bottom-left corner at (x1, y1) and the top-right corner at (x2, y2).
line2d(x, y) arrays Plots a frame and return a filled or unfilled polygon object.
point2d(x, y) arrays|umbers Plots a point or points and returns a point object.
symbol2d(x, y, symbol) number|array, number|array, symbol Puts a symbol created by shape2d() at (x, y).
text2d(x, y, str, halign=0, valign=-1) number, number, string, number, number Plots the text string at (x, y) in the plot and returns a text object. The text is horizontally centered if halign = 0, left aligned if halign < 0, right aligned if halign > 0, vertically centered if valign = 0, bottom aligned if valign < 0, and top aligned if valign > 0.
show2d() none Displays plot.
move2d(dx, dy) numbers Moves the plot away from the center by dx and dy pixels.
scale2d(xscale=1, yscale=1) numbers Scales plot in the view window. 0 < sx, xy < 1.

plot3d

Function Parameter Type Remark
plot3d(w=520, h=520, x0=-1, x1=1, dx=.5, y0=-1, y1=1, dy=.5, z0=-1, z1=1, dz=.5) numbers Defines 3D-plot and returns an array of zeGraph objects for customizing axis, color, and etc. The plot size is w by h and axis ranges are defined by x-y-z parameters.
coast3d(gshhs, z=0) string, number Read coastline from gshhs, plots the coastlines, and returns a line object.
image3d(p0, p1, p2, filename) array, array, array, string Plots the image in filename in a rectangle determined by points of p0, p1, p1+p2-p0, and p2.
line3d(x, y, z) arrays Plots a line and return the line object.
point3d(x, y, z) arrays Plots a point or points and returns a point object.
symbol3d(x, y, z, symbol) number|array, number|array, symbol Puts a symbol created by shape3d() at (x, y, z).
text3d(x, y, z, str, halign=0, valign=-1) number, number, number, string, number, number Plots the text string at (x, y, z) and returns a text object. The text is horizontally centered if halign = 0, left aligned if halign < 0, right aligned if halign > 0, vertically centered if valign = 0, bottom aligned if valign < 0, and top aligned if valign > 0.
show3d() none Displays plot.
move3d(dx, dy) numbers Moves the plot away from the center by dx and dy pixels.
scale3d(xscale, yscale, zscale) numbers Scales plot in the view window. 0 < xscale, yscale, zscale< 1.
rotate3d(rx, rz) numbers Rotates the plot about the global x-axis by rx degrees and about the global z-axis by rz degrees.

shapes2d

Function Parameter Type Remark
plus(size=5) number Returns a line object for drawing a plus symbol.
cross(size=5) number Returns a line object for drawing a cross symbol.
triangle(size=5) number Returns a polygon object for drawing a filled triangle symbol. You can set the fill mode to -1 to draw only the outline.
square(size=5) number Returns a polygon object for drawing a filled square symbol. You can set the fill mode to -1 to draw only the outline.
diamond(size=5) number Returns a polygon object for drawing a filled diamond symbol. You can set the fill mode to -1 to draw only the outline.
circle(size=5) number Returns a line object for drawing a circle symbol.
pie(size=5) number Returns a polygon object for drawing a filled circle symbol.

shapes3d

Function Parameter Type Remark
disk(n, r) numbers Returns a polygon object for drawing a disk on x-y plane with normal pointing to z. The slice number n determines the fineness, and the radius r determines the size.
cylinder(n, r, h) numbers Returns a polygon object for drawing a cylinder on x-y plane with height h along z-axis The slice number n determines the fineness, and the radius r determines the size.
cone(n, r, h) numbers Returns a polygon object for drawing a cone on x-y plane with height h along z-axis The slice number n determines the fineness, and the radius r determines the size.
sphere(n, r) numbers Returns a polygon object for drawing a sphere. The iteration number n (1 to 8) determines the fineness, and the radius r determines the size.

display

Function Parameter Type Remark
animate(render, object, rotx=-60, rotz=30) user, user, number, number Renders the image of a zeGraph scene to the screen. Then you can rotate the scene by mouse or arrow keys. The object should be set to rotate around z-axis and then around x-axis. See the example in the globe module;
graph(w=512, h=512) numbers Returns an array containing render, scene, node, and light for display shapes in the global coordinate system.
show(render) user Renders the image of a zeGraph scene to the screen.

utilities

Function Parameter Type Remark
tokenize(s, delimiter) string, string Returns tokens separated by the delimiter in an array.

special functions

Function Parameter Type Remark (Refer to Chapter 6 of Numerical Recipe in C)
gammaln(x) number Returns the value of ln(gamma(x)) for x > 0.
gammap(a, x) numbers Returns the value of incomplete gamma function P(a, x).
gammaq(a, x) numbers Returns the value of incomplete gamma function Q(a, x).
factorial(n) number Returns the value of n! 0 <= n < 170.
binomial(n, k) numbers Returns the binomial coefficient.
beta(z, w) numbers Returns the value of beta function.
betai(a, b, x) numbers Returns the value of incomplete beta function Ix(a, b).
betacf(a, b, x) numbers Evaluates continued fraction for incomplete beta function.
erf(x) number Returns the value of error function erf(x).
erfc(x) number Returns the value of complementary error function erfc(x).
erfcc(x) number Returns the value of complementary error function erfc(x) with fractional error everywhere less than 1.2 x 10e-7.

Statistics

Function Parameter Type Remark (Refer to Chapter 14-15 of Numerical Recipe in C)
moment(X, extra=false) matrix, boolean Given matrix, this routine returns its mean, average deviation, variance, and if estra=true, standard deviation, skewness, and kurtosis.
corr(X, Y) matrixes Given two matrixes X and Y, this routine computes their correlation coefficient r, the significance level at which the null hypothesis of zero correlation is disproved (probability whose small value indicates a significant correlation), and Fisher's z, whose value can be used in further statistical tests.
t_test(X, Y) matrixes Given matrixes X and Y, this routine returns Student's t and its significance probability, small values of probability indicating that the arrays have significantly different means. The data arrays are assumed to be drawn from populations with the same true variance.
tu_test(X, Y) matrixes Given matrixes X and Y, this routine returns Student's t and its significance probability, small values of probability indicating that the arrays have significantly different means. The data arrays are assumed to be drawn from populations with un-equal variance.
tp_test(X, Y) matrixes Given paired matrixes X and Y, this routine returns Student's t and its significance probability, small values of probability indicating a significant difference of means.
f_test(X, Y) matrixes Given matrixes X and Y, this routine returns the value of f, and its significance probability Small values of probability indicate that the two datasets have significantly different variances.
chi_test1(X, Y, nc=1) matrixes Given matrix X containing the observed numbers of events, and matrix Y containing the expected numbers of events, this routine returns the chi-square chisq and the significance probability A small value of probability indicates a significant difference between the distributions X and Y. nc is the number of constrains. Note: Y should be a known distribution.
chi_test2(X, Y, nc=0) matrixes Given matrix X containing the observed numbers of events, and matrix Y containing the expected numbers of events, this routine returns the chi-square chisq and the significance probability A small value of probability indicates a significant difference between the distributions X and Y. nc is the number of constrains. Note: X and Y are observations.
fit(X, Y) matrixes

Linear fit: Given a set of data points in matrixes X and Y, fit them to a straight line y = a + bx by minimizing chi-square. Returned are a, b and their respective probable uncertainties siga and sigb, the chi-square chi2.

Multi-linear fit: When X and Y have different size, try to fit them to * y = c0 + c1*x1 + c2*x2... Then the first n rows X will be replaced by the parameter variance matrix, Y replaced by coefficients, and the function returns ssq/(n-m)