Previous: Jython Shell Next: Site Configuration Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > Data Analysis

7.3.4 Jython Library

Module: grid

This is the doc for the grid module

GP2Z(gp):

Convert Geopotential (GP) to Height (Z)

applyToRange(function, data):

Apply the function name to each timestep of the data

applyToRangeValues(function, data):

Apply the function name to each value in each timestep of the data

averageOverTime(field, makeTimes):

Average the values in each time step If makeTimes is true (1) then we return a field mapping all of the times to the average. Else we just return the average

combineFields():

combine several fields together

differenceFromBaseTime(field):

set the value of each time step N: D(N)= D(N) - D(0)

exportGridToNetcdf(grid, filename):

Write out the grid data to CF compliant netCDF file

extractLatitudeFromNWPGrid(fieldimpl):

Get the latitude coordinate from a grid. Return a grid of the latitudes at each point.

extractLongitudeFromNWPGrid(fieldimpl):

Get the longitude coordinate from a grid. Return a grid of the longitudes at each point.

extractPressureFromNWPGrid(fieldimpl):

Get the pressure coordinate from a time series grid and return a grid of the pressure at all points. Input grid must have pressure or height (which is converted to pressure in the standard atmosphere). User must be sure input is a suitable FlatField.

getAltitude(z):

Change units from geopotential meters to meters

getNthTimeGrid(fieldimpl, Nth):

Get the Nth grid in time series of grids; User must be sure input is a suitable data field. returns a single time. Nth is an integer, >=0, <= max index of grid time series.

getSliceAtAltitude(fieldimpl, alt, unit):

Extract a 2D horizontal slice from a 3D grid at the given altitude; level is a real number; if unit is supplied, it must be compatible with meters (ft, fathoms, etc) param fieldimpl is a grid which may have one or more time steps.

getSliceAtLevel(fieldimpl, level):

Extract a 2D horizontal slice from a 3D grid at "Level." level is a real number; must be appropriate for the grid. param fieldimpl is a grid which may have one or more time steps.

horizontalAdvection(param, u, v):

horizontal advection

horizontalDivergence(param, u, v):

horizontal flux divergence

layerAverage(grid, top, bottom, unit):

Wrapper for calculating layer average

layerDiff(grid, top, bottom, unit):

Wrapper for calculating layer difference

lonFlip(grid):

Flip the longitudes in a grid from -180-180 to 0-360 (or vice-versa). Only works for cyclic rectilinear grids.

make2D(slice):

Make a 2D slice from a 3D slice at a single level

makeFlowField(a, b, c):

Make a vector from 3 components

makeVector(a,b,c) = [a,b,c]

makeTimeSequence(g):

Merge a set of single time grids/images into a time sequence

makeTopographyFromField(grid):

make a topography out of a grid

makeTrueVector(u, v):

true wind vectors

makeVector(a, b):

Make a vector from 2 components

makeVector(a,b) = [a,b]

maskGrid(grid, mask, value, resample):

mask one grid by the values in the other. value is the masking value

maxOverTime(field, makeTimes):

Take the max of the values in each time step If makeTimes is true (1) then we return a field mapping all of the times to the average. Else we just return the max

mergeTimeSequences(g):

Merge a set of time sequences of grids/images into a single time sequence. All grids/images must have the same parameter name

minOverTime(field, makeTimes):

Take the min of the values in each time step If makeTimes is true (1) then we return a field mapping all of the times to the average. Else we just return the min

newName(field, varname, copy):

create a new field with a new parameter name

newUnit(field, varname, unitname):

set the name and unit on a grid

noUnit(field):

remove the units from a grid

oldaverageOverTime(field, makeTimes):

@deprecated Average the values in each time step If makeTimes is true (1) then we return a field mapping all of the times to the average. Else we just return the average

resampleGrid(oldGrid, gridwithNewDomain):

display gridded data on a new domain

runave(grid, nave, option):

generate a running average:

Where:
grid = grid to average
nave - number of steps to average over
option - option for unsmoothed end points
0 - set to missing
1 - use symmetry
-1 - assume cyclic

substitute(data, low, high, newValue):

change values in data between low/high to newvalue

sumFromBaseTime(field):

set the value of each time step N: D(N)= D(N) + D(0)

sumOverTime(field, makeTimes):

Take the sum of the values in each time step If makeTimes is true (1) then we return a field mapping all of the times to the average. Else we just return the sum

timeStepDifference(field, offset):

set the value of each time step N: D(N)= D(N) - D(N+offset) where offset should be negative

timeStepSum(field, offset):

set the value of each time step N: D(N)= D(N) + D(N+offset) where offset should be negative

uvFromWindDir(dir):

creating the vector field using the wind direction

wgt_runave(grid, wgts, option):

generate a weighted running average:

Where:
grid = grid to average
wgts - comma separated list of weights
option - option for unsmoothed end points
0 - set to missing
1 - use symmetry
-1 - assume cyclic

windShear(u, v, z, top, bottom, unit):

calculate the wind shear between discrete layers

shear = sqrt((u(top)-u(bottom))^2 + (v(top)-v(bottom))^2)/zdiff

windShearVector(u, v, top, bottom, unit):

calculate the u and v layer difference and return as vector

writeGridToXls(grid, filename):

Write out the grid data to an excel spreadsheet

Module: griddiag

This is the doc for the Grid Diagnostics module. These functions are based on the grid diagnostics from the GEneral Meteorological PAcKage (GEMPAK). Note that the names are case sensitive and some are named slightly different from GEMPAK functions to avoid conflicts with Jython built-ins (e.g. str).

In the following operators, scalar operands are named Sn and vector operands are named Vn. Lowercase u and v refer to the grid relative components of a vector.


GRAVITY():

Gravity constant

add(S1, S2, WA):

Addition

ADD (S1, S2) = S1 + S2
WA = use WEIGHTED_AVERAGE (default NEAREST_NEIGHBOR)

adv(S, V):

Horizontal Advection, negative by convention

ADV ( S, V ) = - ( u * DDX (S) + v * DDY (S) )

age(obs, geo):

Ageostrophic wind

AGE ( S ) = [ u (OBS) - u (GEO(S)), v (OBS) - v (GEO(S)) ]

atn2(S1, S2, WA):

Wrapper for atan2 built-in

ATN2 (S1, S2) = ATAN ( S1 / S2 )
WA = use WEIGHTED_AVERAGE (default NEAREST_NEIGHBOR)

avg(S1, S2):

Average of 2 scalars

AVG (S1, S2) = ( S1 + S2 ) / 2

avor(V):

Absolute Vorticity

AVOR ( V ) = VOR ( V ) + CORL(V)

circs(S, D):

Apply a circular aperature smoothing to the grid points. The weighting function is the circular aperature diffraction function. D is the radius of influence in grid increments, increasing D increases the smoothing. (default D=2)

circv(S, D):

Apply a circular aperature smoothing to the grid points. The weighting function is the circular aperature diffraction function. D is the radius of influence in grid increments, increasing D increases the smoothing. (default D=2)

corl(S):

Coriolis Parameter for all points in a grid

CORL = TWO_OMEGA*sin(latr)

cress(S, D):

Apply a Cressman smoothing to the grid points. The smoothed value is given by a weighted average of surrounding grid points. D is the radius of influence in grid increments, increasing D increases the smoothing. (default D=2)

cresv(S, D):

Apply a Cressman smoothing to the grid points. The smoothed value is given by a weighted average of surrounding grid points. D is the radius of influence in grid increments, increasing D increases the smoothing. (default D=2)

cros(V1, V2):

Vector cross product magnitude

CROS ( V1, V2 ) = u1 * v2 - u2 * v1

ddx(S):

Take the derivative with respect to the domain's X coordinate

ddy(S):

Take the derivative with respect to the domain's Y coordinate

defr(V):

Total deformation

DEF ( V ) = ( STRD (V) ** 2 + SHR (V) ** 2 ) ** .5

dirn(V):

North relative direction of a vector

DIRN ( V ) = DIRR ( un(v), vn(v) )

dirr(V):

Grid relative direction of a vector

div(V):

Horizontal Divergence

DIV ( V ) = DDX ( u ) + DDY ( v )

dot(V1, V2):

Vector dot product

DOT ( V1, V2 ) = u1 * u2 + v1 * v2

dvdx(V):

Partial x derivative of a vector

DVDX ( V ) = [ DDX (u), DDX (v) ]

dvdy(V):

Partial x derivative of a vector

DVDY ( V ) = [ DDY (u), DDY (v) ]

frnt(S, V):

Frontogenesis function from theta and the wind

FRNT ( THTA, V ) = 1/2 * MAG ( GRAD (THTA) ) * ( DEF * COS (2 * BETA) - DIV )

Where: BETA = ASIN ( (-DDX (THTA) * COS (PSI)
- DDY (THTA) * SIN (PSI))/
MAG ( GRAD (THTA) ) )
PSI = 1/2 ATAN2 ( SHR / STR )

geo(z):

geostrophic wind from height

GEO ( S ) = [ - DDY (S) * const / CORL, DDX (S) * const / CORL ]

grad(S):

Gradient of a scalar

GRAD ( S ) = [ DDX ( S ), DDY ( S ) ]

gwfs(S, N):

Horizontal smoothing using normally distributed weights with theoretical response of 1/e for N * delta-x wave. Increasing N increases the smoothing. (default N=6)

gwfv(V, N):

Horizontal smoothing using normally distributed weights with theoretical response of 1/e for N * delta-x wave. Increasing N increases the smoothing. (default N=6)

inad(V1, V2):

Inertial advective wind

INAD ( V1, V2 ) = [ DOT ( V1, GRAD (u2) ), DOT ( V1, GRAD (v2) ) ]

jcbn(S1, S2):

Jacobian Determinant

JCBN ( S1, S2 ) = DDX (S1) * DDY (S2) - DDY (S1) * DDX (S2)

lap(S):

Laplacian operator

LAP ( S ) = DIV ( GRAD (S) )

latr(S):

Latitudue all points in a grid

lav(S, level1, level2, unit):

Layer Average of a multi layer grid

LAV ( S ) = ( S (level1) + S (level2) ) / 2.

ldf(S, level1, level2, unit):

Layer Difference

LDF ( S ) = S (level1) - S (level2)

mag():

Magnitude of a vector

mixr(temp, rh):

Mixing Ratio from Temperature, RH (requires pressure domain)

mul(S1, S2, WA):

Multiply

MUL (S1, S2) = S1 * S2
WA = use WEIGHTED_AVERAGE (default NEAREST_NEIGHBOR)

pvor(S, V):

Potetial Vorticity (usually from theta and wind)

quo(S1, S2, WA):

Divide

QUO (S1, S2) = S1 / S2
WA = use WEIGHTED_AVERAGE (default NEAREST_NEIGHBOR)

qvcl(THTA, V):

Q-vector ( K / m / s )

QVCL ( THTA, V ) = ( 1/( D (THTA) / DP ) ) * [ ( DOT ( DVDX (V), GRAD (THTA) ) ), ( DOT ( DVDY (V), GRAD (THTA) ) ) ]

qvec(S, V):

Q-vector at a level ( K / m / s )

QVEC ( S, V ) = [ - ( DOT ( DVDX (V), GRAD (S) ) ), - ( DOT ( DVDY (V), GRAD (S) ) ) ] where S can be any thermal paramenter, usually THTA.

rects(S, D):

Apply a rectangular aperature smoothing to the grid points. The weighting function is the product of the rectangular aperature diffraction function in the x and y directions. D is the radius of influence in grid increments, increasing D increases the smoothing. (default D=2)

rectv(S, D):

Apply a rectangular aperature smoothing to the grid points. The weighting function is the product of the rectangular aperature diffraction function in the x and y directions. D is the radius of influence in grid increments, increasing D increases the smoothing. (default D=2)

relh(temp, mixr):

Create Relative Humidity from Temperature, mixing ratio (requires pressure domain)

savg(S):

Average over whole grid

SAVG ( S ) = average of all non-missing grid point values

savs(S):

Average over grid subset

SAVS ( S ) = average of all non-missing grid point values in the subset area

sdiv(S, V):

Horizontal Flux Divergence

SDIV ( S, V ) = S * DIV ( V ) + DOT ( V, GRAD ( S ) )

shr(V):

Shear Deformation

SHR ( V ) = DDX ( v ) + DDY ( u )

sm5s(S):

Smooth a scalar grid using a 5-point smoother

SM5S ( S ) = .5 * S (i,j) + .125 * ( S (i+1,j) + S (i,j+1) + S (i-1,j) + S (i,j-1) )

sm5v(V):

Smooth a scalar grid using a 5-point smoother (see sm5s)

sm9s(S):

Smooth a scalar grid using a 9-point smoother

SM9S ( S ) = .25 * S (i,j) + .125 * ( S (i+1,j) + S (i,j+1) + S (i-1,j) + S (i,j-1) ) + .0625 * ( S (i+1,j+1) + S (i+1,j-1) + S (i-1,j+1) + S (i-1,j-1) )

sm9v(V):

Smooth a scalar grid using a 9-point smoother (see sm9s)

strd(V):

Stretching Deformation

STRD ( V ) = DDX ( u ) - DDY ( v )

sub(S1, S2, WA):

Subtract

SUB (S1, S2) = S1 - S2
WA = use WEIGHTED_AVERAGE (default NEAREST_NEIGHBOR)

thrm(S, level1, level2, unit):

Thermal wind

THRM ( S ) = [ u (GEO(S)) (level1) - u (GEO(S)) (level2), v (GEO(S)) (level1) - v (GEO(S)) (level2) ]

thta(temp):

Potential Temperature from Temperature (requires pressure domain)

thte(temp, rh):

Equivalent Potential Temperature from Temperature and Relative humidity (requires pressure domain)

un(V):

North relative u component

ur(V):

Grid relative u component

vadd(V1, V2):

add the components of 2 vectors

VADD (V1, V2) = [ u1+u2, v1+v2 ]

vecn(S1, S2):

Make a true nort vector from two components

VECN ( S1, S2 ) = [ S1, S2 ]

vecr(S1, S2):

Make a vector from two components

VECR ( S1, S2 ) = [ S1, S2 ]

vlav(V, level1, level2, unit):

calculate the vector layer average

VLDF(V) = [(u(level1) - u(level2))/2, (v(level1) - v(level2))/2]

vldf(V, level1, level2, unit):

calculate the vector layer difference

VLDF(V) = [u(level1) - u(level2), v(level1) - v(level2)]

vmul(V1, V2):

Multiply the components of 2 vectors

VMUL (V1, V2) = [ u1*u2, v1*v2 ]

vn(V):

North relative v component

vor(V):

Relative Vorticity

VOR ( V ) = DDX ( v ) - DDY ( u )

vquo(V1, V2):

Divide the components of 2 vectors

VQUO (V1, V2) = [ u1/u2, v1/v2 ]

vr(V):

Grid relative v component

vsub(V1, V2):

subtract the components of 2 vectors

VSUB (V1, V2) = [ u1-u2, v1-v2 ]

wshr(V, Z, top, bottom):

Magnitude of the vertical wind shear in a layer

WSHR ( V ) = MAG [ VLDF (V) ] / LDF (Z)

xav(S):

Average along a grid row

XAV (S) = ( S (X1) + S (X2) + ... + S (KXD) ) / KNT KXD = number of points in row KNT = number of non-missing points in row XAV for a row is stored at every point in that row.

xsum(S):

Sum along a grid row

XSUM (S) = ( S (X1) + S (X2) + ... + S (KXD) ) KXD = number of points in row XSUM for a row is stored at every point in that row.

yav(S):

Average along a grid column

YAV (S) = ( S (Y1) + S (Y2) + ... + S (KYD) ) / KNT KYD = number of points in column KNT = number of non-missing points in column

ysum(S):

Sum along a grid column

YSUM (S) = ( S (Y1) + S (Y2) + ... + S (KYD) ) KYD = number of points in row YSUM for a column is stored at every point in that column.

zav(S):

Average across the levels of a grid at all points

ZAV (S) = ( S (Z1) + S (Z2) + ... + S (KZD) ) / KNT KZD = number of levels KNT = number of non-missing points in column

zsum(S):

Sum across the levels of a grid at all points

ZSUM (S) = ( S (Z1) + S (Z2) + ... + S (KZD) ) KYD = number of levels ZSUM for a vertical column is stored at every point

Module: ensemble

This is the doc for the ensemble grid module

ens_mode(grid):

mode value

ens_prcntl(grid, percent):

percentile value

ens_savg(grid):

basic ensemble average

ens_smax(grid):

max value of all member

ens_smin(grid):

min value of all member

ens_srng(grid):

max - min grid value

ens_ssprd(grid):

basic ensemble average

ens_uprob(grid, logicalOp1, pValue1, and_or, logicalOp2, pValue2, exptdLoBound, exptdUpBound):

ensemble univariate probability calculation

Module: image


combineRGB(red, green, blue):

combine 3 images as an RGB image

makeNavigatedImage(d, ulLat, ulLon, lrLat, lrLon):

This takes a image data object and a lat/lon bounding box and adds a lat/lon domain to the data. Use it in conjunction with a formula:

Module: climate

This is the doc for the climate module. These functions are useful for creating climate features from grids (means, anomalies, standard deviations). Function names are based on NCL function names.

calcDayAnom(daily, ltm, asPercent):

Calculate the daily anomaly from a long term mean.
grid - daily values
ltm - long term mean (climatology)
asPercent - if 1, return percentage of climatology normal (+/-)

calcMonAnom(monthly, ltm, normalize):

Calculate the monthly anomaly from a long term mean. The number of timesteps in ltm must be 12 and the monthly data must start in January.

clmDay(grid, use366):

Create a daily climatology from a grid of daily data over a period of years.

clmMon(grid):

Create a monthly climatology from a grid of monthly data over a period of years. The number of timesteps must be a multiple of 12.

stdMon(grid):

Create monthly standard deviations from a grid of monthly data over a period of years. The number of timesteps must be a multiple of 12.

Module: maps


applyFunctionToValuesInField(function, field, min, max, inside):

applyFunctionToValuesInRange(function, range, timeStep, min, max, inside):

applyToIndices(function, range, timeStep, indices):

averageFromMap(field, mapSets):

averageFromMapAndClip(field, mapSets):

filterMaps(mapSets, propName, operator, value):

Return a new set of maps whose property propName satisfies the given operator/value. The operators can be ==,!=, <,>,<=,>=, match, !match

getMapProperty(polygon, propName):

Get the named property from the given mapData

getMapsWithProperty(mapSets, propName, value):

Return a new set of maps that have the given property value

make3DMap(map, topo):

Make a 3d map. map - map line data - topo - topography dataset

makeFieldFromMapBounds(mapSets, length1, length2, fill, unit):

Make a field whos lat/lon area is the bounds of the given mapSet. It has length1 points in the x and length2 in the y. Fill it with the fill value and the given unit

mapsAbsoluteValue(originalValues, newValues, indexArray):

mapsApplyToField(function, field, mapSets, inside):

mapSets defines a set of polygons. This procedure fills the areas in the field are enclosed by each polygon with the average value within that area

mapsApplyToRange(function, range, timeStep, mapSets, inside):

mapsAverage(originalValues, newValues, indexArray):

mapsMax(originalValues, newValues, indexArray, value):

mapsMin(originalValues, newValues, indexArray, value):

mapsSetValue(originalValues, newValues, indexArray, value):

subsetFromMap(field, mapSets, fillValue, inverse):

mapSets defines a set of polygons. This procedure fills the areas in the field that are not enclosed by the polygons with the fill value. If inverse is 1 then it fills the areas that are enclosed

subsetRangeFromMap(range, timeStep, mapSets, fillValue, inverse):

mapSets defines a set of polygons. This procedure fills the areas in the field that are not enclosed by the polygons with the fill value. If inverse is 1 then it fills the areas that are enclosed

subsetRangeWithProperty(range, mapSets):

test code

subsetWithProperty(field, mapSets):

test code

testIndexToLatLon(field, mapSets):

Test out the GridUtil.getLatLons method. Call this with some grid field and a set of maps

testIndexToLatLon2(field, mapSets):

Test out the GridUtil.getLatLons method. Call this with some grid field and a set of maps

Module: shell

A set of utilities for selecting data and creating displays. For use from the Jython shell.

clear():

Clear the shell

createDisplay(displayType, data, dataName):

create a display of type displayType. Right click in input field to select particular displayType. The data is can be a data object, a datachoice or a list of data or datachoices The dataName is used to name the data, i.e., its the parameter name

findDataSource(name):

Find the data source object with the given name. If no name is given then this will return the first (non-formula) data source

getData(dataSourceName, dataChoiceName):

Find the data source with the given name and the data choice on that data source with the given name. If no dataSourceName is given then use the first one in the list If no dataChoiceName is given then use the first one held by the data source Return the data for the data choice. If no data source or data choice is found then return null

getDataChoice(dataSourceName, dataChoiceName):

Find the data source with the given name and the data choice on that data source with the given name. If no dataSourceName is given then use the first one in the list If no dataChoiceName is given then use the first one held by the data source Return the data choice If no data source or data choice is found then return null

listVars():

List all of the variables defined in the shell's interpreter

makeDataSource(path, type):

Create a datasource from the given file name or url. The optional type parameter is used to specify the type of data

printType(data):

Print out the math type of the given data

selectData(name1, name2, name3, name4, name5):

Select up to 5 data fields. This returns a List of the actual Data objects

selectDataChoice(name1, name2, name3, name4, name5):

Select up to 5 data choices. This returns a List of the data choices, not the actual Data To get the data do:

dataList.get(0).getData(None)

setDataChoices(dataSource):

The given dataSource can be an actual data source or the name of a data source. This procedure will define a set of jython variables that correspond to the data choices held by the given data source.

setDataSources():

This procedure will define a set of jython variables, 'dataSource0, dataSource1, ...' that correspond to loaded data sources.

showLib():

Bring up the jython library dialog

Module: misc

A set of miscellaneous utilities.

cloneArray(array):

A utility to make a 2 dimensional float array filled with the given value

idveval(formula):

evaluate a formula and return a DerivedDataChoice

makeFloatArray(rows, cols, value):

A utility to make a 2 dimensional float array filled with the given value

printSounding(sounding):

Print out the values of the sounding data

printSoundings(d):

Print out the values of the set of sounding data

 


Previous: Jython Shell Next: Site Configuration Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > Data Analysis