252 lines
8.5 KiB
HTML
252 lines
8.5 KiB
HTML
<html>
|
|
<title>Smart Script Class Grid Access</title>
|
|
<body>
|
|
|
|
<h1><a name="GridAccess"></a>Grid Access Methods</h1>
|
|
<p>
|
|
<a href="#getGrids">getGrids</a>
|
|
<br>
|
|
<a href="#taperGrid">taperGrid</a>
|
|
<br>
|
|
<a href="#directionTaperGrid">directionTaperGrid</a>
|
|
<br>
|
|
<a href="#getComposite">getComposite (numeric only)</a>
|
|
<br>
|
|
<a href="#getGridInfo">getGridInfo</a>
|
|
<br>
|
|
<hr width="100%">
|
|
|
|
<h2><a name="getGrids"></a>getGrids</h2>
|
|
def getGrids(self, model, element, level, timeRange,
|
|
mode="TimeWtAverage",
|
|
noDataError=1, mostRecentModel=0, cache=1):
|
|
<br>
|
|
# Get the value(s) for the given model,
|
|
element, and level
|
|
<br>
|
|
# at the x, y coordinate and over the
|
|
given timeRange.
|
|
<br>
|
|
#
|
|
<br>
|
|
# The resulting grid values can be
|
|
accessed
|
|
as follows:
|
|
<br>
|
|
# PoPGrid =
|
|
self.getGrids("Fcst","PoP","SFC",
|
|
GridTimeRange)
|
|
<br>
|
|
# popValue = PoPGrid[x][y]
|
|
<br>
|
|
#
|
|
<br>
|
|
# where x and y are integer grid
|
|
coordinates.
|
|
<h2><a name="taperGrid"></a>taperGrid</h2>
|
|
def taperGrid(self, editArea, taperFactor=5):
|
|
<br>
|
|
# Returns a 2-D Grid of values between
|
|
0-1 about the
|
|
<br>
|
|
# given edit area.
|
|
<br>
|
|
# These values can be applied by smart
|
|
tools to taper results.
|
|
<br>
|
|
#
|
|
<br>
|
|
# Argument:
|
|
<br>
|
|
# editArea: Reference data or None<br>
|
|
# (use editArea tool argument)
|
|
<br>
|
|
# taperFactor: If set to zero, will
|
|
do Full Taper
|
|
<br>
|
|
#
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# def preProcessTool(self, editArea):
|
|
<br>
|
|
# self._tGrid
|
|
= self.getTaperGrid(editArea, 5)
|
|
<br>
|
|
# def execute(self, variableElement):
|
|
<br>
|
|
# return =
|
|
variableElement + self._tGrid * 10.0
|
|
<br>
|
|
#
|
|
<h2><a name="directionTaperGrid"></a>directionTaperGrid</h2>
|
|
def directionTaperGrid(self, editArea, direction):
|
|
<br>
|
|
# Returns a 2-D Grid of values between
|
|
0-1 within the
|
|
<br>
|
|
# given edit area.
|
|
<br>
|
|
# E.g. if the Dir is W and x,y is
|
|
half-way
|
|
along the
|
|
<br>
|
|
# W to E vector within the given edit
|
|
area, the value of
|
|
<br>
|
|
# directionTaperGrid at x,y will be
|
|
.5
|
|
<br>
|
|
# These values can be applied by smart
|
|
tools to show
|
|
<br>
|
|
# spatial progress across an edit area.
|
|
<br>
|
|
#
|
|
<br>
|
|
# Argument:
|
|
<br>
|
|
# editArea : ReferenceData
|
|
or None
|
|
<br>
|
|
# (use editArea tool argument)
|
|
<br>
|
|
# direction : 16 point text direction
|
|
e.g. "NNW", "NW", etc.
|
|
<br>
|
|
#
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# def preProcessTool(self, editArea):
|
|
<br>
|
|
# self._spaceProgress
|
|
= self.directionTaperGrid(editArea, "NW")
|
|
<br>
|
|
# def execute(self, variableElement):
|
|
<br>
|
|
# return
|
|
variableElement * self._spaceProgress
|
|
<br>
|
|
#
|
|
<h2><a name="getComposite"></a>getComposite (numeric only)</h2>
|
|
def getComposite(self, WEname, GridTimeRange, exactMatch=1, onlyISC=0):
|
|
<br>
|
|
# Returns a composite grid
|
|
consisting
|
|
of the primary grid and any
|
|
<br>
|
|
# corresponding ISC grid, blended
|
|
together based on the mask information
|
|
<br>
|
|
# derived from the Grid Data
|
|
History.
|
|
Primary grid must exist. Returns
|
|
<br>
|
|
# the set of points that are valid
|
|
in the output grid. (Note the output
|
|
<br>
|
|
# grid consists of the primary
|
|
grid and isc grid. Any "invalid" points,
|
|
<br>
|
|
# indicate those areas that have
|
|
no isc data and are outside the home
|
|
<br>
|
|
# site's region. The returned
|
|
grid will have the primary data in
|
|
<br>
|
|
# the site's region.)
|
|
<br>
|
|
#
|
|
<br>
|
|
# A Python tuple is returned.
|
|
<br>
|
|
# For Scalar elements, the tuple
|
|
contains:
|
|
<br>
|
|
# a numeric grid of 1's and 0's
|
|
where 1 indicates a valid point
|
|
<br>
|
|
# a numeric grid of scalar values
|
|
<br>
|
|
# For Vector elements, the tuple
|
|
contains:
|
|
<br>
|
|
# a numeric grid of 1's and 0's
|
|
where 1 indicates a valid point
|
|
<br>
|
|
# a numeric grid of scalar values
|
|
representing magnitude
|
|
<br>
|
|
# a numeric grid of scalar values
|
|
representing direction
|
|
<br>
|
|
# For Weather elements, the tuple
|
|
contains:
|
|
<br>
|
|
# a numeric grid of 1's and 0's
|
|
where 1 indicates a valid point
|
|
<br>
|
|
# a numeric grid of byte values
|
|
representing the weather value
|
|
<br>
|
|
# list of keys corresponding to
|
|
the weather values
|
|
<br>
|
|
#
|
|
<br>
|
|
# For example:
|
|
<br>
|
|
# isc
|
|
= self.getComposite(WEname, GridTimeRange)
|
|
<br>
|
|
# if isc
|
|
is None:
|
|
<br>
|
|
|
|
#
|
|
self.noData()
|
|
<br>
|
|
# # See
|
|
if we are working with a Scalar or Vector element
|
|
<br>
|
|
# wxType
|
|
= variableElement_GridInfo.type()
|
|
<br>
|
|
# if
|
|
wxType
|
|
== 0: # SCALAR
|
|
<br>
|
|
|
|
#
|
|
bits, values = isc
|
|
<br>
|
|
# elif
|
|
wxType == 1: # VECTOR
|
|
<br>
|
|
|
|
#
|
|
bits, mag, dir = isc
|
|
<br>
|
|
<h2><a name="getGridInfo"></a>getGridInfo</h2>
|
|
def getGridInfo(self, model, element, level, timeRange,
|
|
mostRecentModel=0):
|
|
<br>
|
|
# Return the GridInfo object for the given weather element and timeRange<br>
|
|
# Example:<br>
|
|
# timeRange = self.getTimeRange("Today")<br>
|
|
# infoList = self.getGridInfo("Fcst", "T", "SFC", timeRange)<br>
|
|
# for info in infoList:<br>
|
|
# print "grid", info.gridTime()<br>
|
|
# <br>
|
|
# @param model: The model for which grid info is requested.<br>
|
|
# @type model: DatabaseId or String<br>
|
|
# @param element: The element for which grid info is requested.<br>
|
|
# @type element: String<br>
|
|
# @param level: The level for which grid info is requested.<br>
|
|
# @type level: String<br>
|
|
# @param timeRange: A time range over which grid info is requested.<br>
|
|
# @type timeRange: com.raytheon.uf.common.time.TimeRange or TimeRange<br>
|
|
# @param mostRecentModel: whether to use current time in request expr.<br>
|
|
# @type mostRecentModel: integer or boolean<br>
|
|
# @return: Java GridParmInfo object<br>
|