207 lines
No EOL
11 KiB
HTML
207 lines
No EOL
11 KiB
HTML
<html>
|
|
<title>Smart Script Class - Creating On-the-Fly Grids</title>
|
|
<body>
|
|
<h1><a name="OnFly"></a>Creating On-the-Fly Grids</h1>
|
|
<br>
|
|
<a href="#createGrid">createGrid</a>
|
|
<br>
|
|
<a href="#deleteGrid">deleteGrid</a>
|
|
<br>
|
|
<a href="#highlightGrids">highlightGrids</a>
|
|
<br>
|
|
<a href="#makeHeadlineGrid">makeHeadlineGrid</a>
|
|
<!-- Leave this comment for formatting purposes -->
|
|
<hr width="100%">
|
|
|
|
<h2>
|
|
<a name="createGrid"></a>createGrid</h2>
|
|
<p> def createGrid(self, model, element, elementType,
|
|
numericGrid, timeRange,<br>
|
|
|
|
descriptiveName=None, timeConstraints=None,<br>
|
|
|
|
precision=None, minAllowedValue=None,<br>
|
|
|
|
maxAllowedValue=None, units=None, rateParm=0,<br>
|
|
|
|
discreteKeys=None, discreteOverlap=None,<br>
|
|
|
|
discreteAuxDataLength=None, defaultColorTable=None):<br>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
# Creates a grid for the
|
|
given model and element.<br>
|
|
# If the model and element
|
|
do not already exist, creates them
|
|
on-the-fly <br>
|
|
# The descriptiveName,
|
|
timeConstraints, precision, minAllowedValue,<br>
|
|
# maxAllowedValue, units,
|
|
rateParm, discreteKeys, discreteOverlap,<br>
|
|
# and discreteAuxDataLength only need to be specified
|
|
for the first grid being created. These<br>
|
|
# values are ignored for
|
|
subsequent calls to createGrid() for<br>
|
|
# the same weather element.</p>
|
|
|
|
# For new parms, the defaultColorTable is the one to be used for<br>
|
|
# display. If not specified and not in the gfe configuration file,<br>
|
|
# a DEFAULT color table will be used.<br><br>
|
|
|
|
# DISCRETE elements require a definition for discreteKeys and<br>
|
|
# discreteOverlap. For
|
|
DISCRETE, the precision, minAllowedValue,<br>
|
|
# maxAllowedValue, and
|
|
rateParm are ignored.<br>
|
|
|
|
<br>
|
|
# Note that this works for
|
|
numeric grids only.<br>
|
|
# The arguments
|
|
exampleModel, exampleElement, and exampleLevel can be<br>
|
|
# supplied so that the new
|
|
element will have the same characteristics<br>
|
|
# (units, precision, etc.)
|
|
as the example element.<br>
|
|
#<br>
|
|
# model -- If you are
|
|
creating an "on-the-fly" element (i.e. not<br>
|
|
|
|
# in the server),
|
|
this should be a simple string with<br>
|
|
|
|
# with no special
|
|
characters. The site ID and other<br>
|
|
|
|
# information
|
|
will be added for you.<br>
|
|
|
|
# If you are
|
|
creating a grid for a model that exists<br>
|
|
|
|
# in the server,
|
|
follow the guidelines for the model<br>
|
|
|
|
# argument
|
|
described for the "getValue" command.<br>
|
|
# element -- This should be
|
|
a simple string with no special<br>
|
|
|
|
# characters.<br>
|
|
# elementType -- "SCALAR",
|
|
"VECTOR", "WEATHER", or "DISCRETE"<br>
|
|
# numericGrid -- a numpy grid<br>
|
|
# timeRange -- valid time
|
|
range for the grid. You may want<br>
|
|
|
|
# to use the
|
|
"createTimeRange" command<br>
|
|
#<br>
|
|
# The descriptiveName,
|
|
timeConstraints, precision, minAllowedValue,<br>
|
|
# precision,
|
|
minAllowedValue, maxAllowedValue, and units can be<br>
|
|
# used to define the
|
|
GridParmInfo needed. Note that timeConstraints<br>
|
|
# is not the Java version,
|
|
but a (startSec, repeatSec, durSec).<br>
|
|
#<br>
|
|
# Example:<br>
|
|
#
|
|
self.createGrid("ISCDisc", WEname+"Disc", "SCALAR", maxDisc,<br>
|
|
|
|
#
|
|
GridTimeRange, descriptiveName=WEname+"Disc")<br>
|
|
#<br>
|
|
<br>
|
|
|
|
</p>
|
|
<h2><a name="deleteGrid"></a>deleteGrid</h2>
|
|
def deleteGrid(self, model, element, level, timeRange):
|
|
<br>
|
|
# Deletes any grids for the given model
|
|
and element
|
|
<br>
|
|
# completely contained in the given
|
|
timeRange.
|
|
<br>
|
|
# If the model and element do not exist
|
|
or if there are no existing grids,
|
|
<br>
|
|
# no action is taken.
|
|
<h2><a name="highlightGrids"></a>highlightGrids</h2>
|
|
def highlightGrids(self, model, element, level, timeRange, color,
|
|
on=1):
|
|
<br>
|
|
# Highlight the grids in the given time
|
|
range using designated
|
|
<br>
|
|
# color. If "on" is 0, turn off the
|
|
highlight.
|
|
<p><a name="makeHeadlineGrid"></a><b>makeHeadlineGrid</b><b></b>
|
|
</p>
|
|
<p> def makeHeadlineGrid(self, headlineTable,
|
|
fcstGrid,
|
|
headlineGrid = None):
|
|
<br>
|
|
# This method defines a
|
|
headline grid based on the specified data.
|
|
<br>
|
|
# The headlineTable
|
|
parameter
|
|
must be a list of tuples each containing
|
|
<br>
|
|
# the threshold for each
|
|
headline category and headline label
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
#
|
|
headlineTable =[(15.0, 'SmCrftHSADV'),
|
|
<br>
|
|
|
|
#
|
|
(21.0, 'SmCrftADV'),
|
|
<br>
|
|
|
|
#
|
|
(34.0, 'GaleWRN'),
|
|
<br>
|
|
|
|
#
|
|
(47.0, 'StormWRN'),
|
|
<br>
|
|
|
|
#
|
|
(67.0, 'HurcnFrcWindWRN'),
|
|
<br>
|
|
|
|
#
|
|
]
|
|
<br>
|
|
# "fsctGrid" is the grid
|
|
that defines what headline category should
|
|
<br>
|
|
# be assigned.
|
|
"headlineGrid"
|
|
is the grid you wish to combine with
|
|
<br>
|
|
# the calculated grid.
|
|
This forces a combine even if the GFE is not
|
|
<br>
|
|
# in combine mode.
|
|
Omitting "headlineGrid" will cause the calculated
|
|
<br>
|
|
# grid to replace whatever
|
|
is in the GFE, no matter what the GFE's
|
|
<br>
|
|
# combine mode. Note that
|
|
a side effect of omitting the headline grid
|
|
<br>
|
|
# is that the GFE will end
|
|
up in replace mode after the tool completes.
|
|
<br>
|
|
|
|
</p> |