Former-commit-id:a02aeb236c
[formerly9f19e3f712
] [formerlya02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]] Former-commit-id:06a8b51d6d
Former-commit-id:8e80217e59
[formerly3360eb6c5f
] Former-commit-id:377dcd10b9
363 lines
10 KiB
HTML
363 lines
10 KiB
HTML
<html>
|
|
<title>GFESuite Documentation - </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="#getValue">getValue (point-based only)</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):
|
|
<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 : must be of type
|
|
AFPS.ReferenceData
|
|
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>
|
|
# taperGrid
|
|
= self.getTaperGrid(editArea, 5)
|
|
<br>
|
|
# def execute(self, x, y):
|
|
<br>
|
|
# result = value
|
|
* taperGrid[x][y]
|
|
<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 : must be of type
|
|
AFPS.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>
|
|
# spaceProgress
|
|
= self.directionTaperGrid(editArea, "NW")
|
|
<br>
|
|
# def execute(self, x, y):
|
|
<br>
|
|
# result = value
|
|
* spaceProgress[x][y]
|
|
<br>
|
|
#
|
|
<h2><a name="getValue"></a>getValue (point-based only)</h2>
|
|
def getValue(self, model, element, level, x, y, timeRange,
|
|
mode="TimeWtAverage",
|
|
noDataError=1, mostRecentModel=0):
|
|
<br>
|
|
# Point-based tools only.
|
|
<br>
|
|
# Get the value(s) for the given model,
|
|
element, and level
|
|
<br>
|
|
# at the x, y coordinate and over the
|
|
given timeRange.
|
|
<br>
|
|
# Examples:
|
|
<br>
|
|
# Get the following arguments in your
|
|
execute method:
|
|
<br>
|
|
# def execute(self, x, y, GridTimeRange,
|
|
varDict):
|
|
<br>
|
|
#
|
|
<br>
|
|
# Accessing values from the Fcst
|
|
database:
|
|
<br>
|
|
#
|
|
<br>
|
|
# T = self.getValue("Fcst", "T", "SFC",
|
|
x, y, GridTimeRange)
|
|
<br>
|
|
# PoP = self.getValue("Fcst", "PoP",
|
|
"SFC", x,y, GridTimeRange,
|
|
<br>
|
|
# noDataError=0)
|
|
<br>
|
|
#
|
|
<br>
|
|
# From an IFP model database:
|
|
<br>
|
|
#
|
|
<br>
|
|
# T = self.getValue("BOU__NAM_Oct3100",
|
|
"T", "SFC",x,y,GridTimeRange)
|
|
<br>
|
|
# T = self.getValue("BOU__NAM", "T",
|
|
"SFC",x,y,GridTimeRange)
|
|
<br>
|
|
#
|
|
<br>
|
|
# Or, using a variable:
|
|
<br>
|
|
#
|
|
<br>
|
|
# VariableList = [("Model:" , "",
|
|
"model")]
|
|
<br>
|
|
# def execute(self, x, y, GridTimeRange,
|
|
varDict):
|
|
<br>
|
|
# model = varDict["Model:"]
|
|
<br>
|
|
# T = self.getValue(model, "T",
|
|
"SFC",x,y,GridTimeRange)
|
|
<br>
|
|
#
|
|
<br>
|
|
# From D2D database:
|
|
<br>
|
|
#
|
|
<br>
|
|
# rh = self.getValue(
|
|
<br>
|
|
# "BOU_D2D_ETA", "rh", "MB850", x, y,
|
|
GridTimeRange)
|
|
<br>
|
|
# rh = self.getValue(
|
|
<br>
|
|
# "BOU_D2D_ETA_Oct3100", "rh",
|
|
"MB850",x,
|
|
y, GridTimeRange)
|
|
<br>
|
|
#
|
|
<br>
|
|
# Or, using a variable:
|
|
<br>
|
|
#
|
|
<br>
|
|
# VariableList = [("Model:" , "",
|
|
"D2D_model")]
|
|
<br>
|
|
# def execute(self, x, y, GridTimeRange,
|
|
varDict):
|
|
<br>
|
|
# model = varDict["Model:"]
|
|
<br>
|
|
# rh = self.getValue(model, "rh",
|
|
"MB850",
|
|
x, y, GridTimeRange)
|
|
<br>
|
|
#
|
|
<h2><a name="getComposite"></a>getComposite (numeric only)</h2>
|
|
def getComposite(self, WEname, GridTimeRange, exactMatch=1):
|
|
<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 a list of GridInfo
|
|
objects
|
|
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()
|