Utilities
findDatabase
getDatabase
getTimeRange
createTimeRange
getSamplePoints
dayTime
determineTimeShift
getEditArea
saveEditArea
setActiveEditArea
clearActiveEditArea
setActiveElement
getActiveElement
getGridCellSwath
getLatLon
getLatLonGrids
getGridCell
getGrid2DBit
getGridTimes
getExprName
getModelName
getD2Dmodel
getParm
getParmByExpr
cacheElements
unCacheElements
loadWEGroup
unloadWE
saveElements
publishElements
combineMode
setCombineMode
getVectorEditMode
setVectorEditMode
getConfigItem
esat
findDatabase
def findDatabase(self, databaseName, version=0):
# Return a database id.
# databaseName can have the appended
type. E.g. "NAM" or "D2D_NAM"
# version is 0 (most recent), -1
(previous),
-2, etc.
# E.g.
# databaseID =
self.findDatabase("NAM",0)
# returns most recent NAM model
getDatabase
def getDatabase(self, databaseString):
# Return a database id.
# databaseString is the result of a
VariableList entry of type
# "model" or "D2D_model"
getTimeRange
def getTimeRange(self, timeRangeName):
# Returns TimeRange given
a time range name
# as defined in the GFE
# E.g.
# timeRange = self.getTimeRange("Today")
createTimeRange
def createTimeRange(self, startHour, endHour, mode="LT", dbID=None):
# Returns TimeRange given
by:
# startHour, endHour
# (range is startHour up to and not
including endHour)
# startHour and endHour are relative
to midnight of the
# current day either in Local or Zulu
time (see below)
# mode can be:
# "LT" : the startHour and endHour are
relative to local time
# "Zulu": relative to Zulu time,
# "Database": relative to a database
(e.g. model time.
# In this case, the databaseID for the
model must
# be supplied (see findDatabase)
#
# E.g.
# timeRange =
self.createTimeRange(0,121,"Zulu")
# databaseID = self.findDatabase("NAM")
# timeRange =
self.createTimeRange(120,241,"Database",databaseID)
getSamplePoints
def getSamplePoints(self, sampleSetName=None):
# Return a list of x,y tuples
representing
sample points
# sampleSet is the name of a saved
sample
set
# if sampleSet is None, the sample
points
will be
# those currently displayed on the GFE
dayTime
def dayTime(self, timeRange, startHour=6, endHour=18):
# Return 1 if start of timeRange is
between the
# startHour and endHour, Return 0
otherwise.
# Assume timeRange is GMT and convert
to local time.
determineTimeShift
def determineTimeShift(self):
# Returns the difference: Local time
- GMT in seconds
getEditArea
def getEditArea(self, editAreaName):
# Returns a ReferenceData object
given an edit area name
# as defined in the GFE
saveEditArea
def saveEditArea(self, editAreaName, refData):
# Saves the ReferenceData object
with the given name
setActiveEditArea
def setActiveEditArea(self, area):
# Set the ReferenceData area to
be the active one in the GFE
# Note: This will not take effect until
AFTER the smart tool or
# procedure is finished executing.
clearActiveEditArea
def clearActiveEditArea(self):
# Clear the active edit area in the
GFE
setActiveElement
def setActiveElement(self, model, element, level, timeRange,
colorTable=None,
minMax=None, fitToData=0):
# Set the given element to the active
one in the GFE
# A colorTable name may be given.
# A min/max range for the colorTable
may be given.
# If fitToData = 1, the color table
is fit to the data
#
# Example:
# self.setActiveElement("ISCDisc",
WEname+"Disc",
"SFC", GridTimeRange,
# colorTable="Discrepancy",
minMax=(-20,+20),
# fitToData=1)
#
getActiveElement
def getActiveElement(self):
# Return the parm for the current active
element
getGridCellSwath
def getGridCellSwath(self, editArea, cells):
# Returns a ReferenceData swath
of the given
# number of cells around the given an
edit area.
# The edit area must not be a query.
getLatLon
def getLatLon(self, x, y):
# Get the latitude/longitude values
for the given grid point
coords = Coordinate(float(x), float(y))
cc2D = self.getGridLoc().latLonCenter(coords)
return cc2D.y, cc2D.x
getLatLonGrids
def getLatLonGrids(self):
# Get the latitude/longitude grids
gridLoc = self.getGridLoc()
latLonGrid = gridLoc.getLatLonGrid().__numpy__[0];
latLonGrid = numpy.reshape(latLonGrid, (2,gridLoc.getNy().intValue(),
gridLoc.getNx().intValue()), order='F')
return latLonGrid[1], latLonGrid[0]
getGridCell
def getGridCell(self, lat, lon):
# Get the corresponding x,y values for
the given lat/lon
# Return None, None if the lat/lon is
outside the grid domain
getGrid2DBit
def getGrid2DBit(self, editArea):
# Returns a Grid of on/off values
indicating
whether
# or not the grid point is in the given
edit area.
# This could be used as follows in a
Smart Tool:
# def preProcessGrid(self):
# editArea = self.getEditArea("Area1")
# self.__area1Bits =
self.getGrid2DBit(editArea)
# editArea = self.getEditArea("Area2")
# self.__area2Bits =
self.getGrid2DBit(editArea)
#
# def execute(self, x, y):
# if self.__area1Bits.get(x,y) == 1:
#
# elif self.__area2Bits.get(x,y) ==
1:
#
#
getGridTimes
def getGridTimes(self, model, element, level, startTime, hours):
# Return the timeRange and gridTimes
for the number of hours
# FOLLOWING the given startTime
getExprName
def getExprName(self, model, element, level="SFC", mostRecent=0):
# Return an expressionName for the
element
# This method is complicated because
it is handling all the
# variations for the "model" argument.
For a description
# of the variations, see the "getValue"
documentation above.
getModelName
def getModelName(self, databaseString):
# Return the model name.
# databaseString is the result of a
VariableList entry of type
# "model" or "D2D_model"
getD2Dmodel
def getD2Dmodel(self, model):
# Given a GFE Surface model, return
the corresponding D2D model
getParm
def getParm(self, model, element, level, timeRange=None, mostRecent=0):
# Returns the parm object for the given
model, element, and level
getParmByExpr
def getParmByExpr(self, exprName):
# Returns the parm object for the given expression
cacheElements
def cacheElements(self, elementNames):
# This routine is deprecated - caching is controlled by the system.
unCacheElements
def unCacheElements(self, elementNames):
# This routine is deprecated
# Users may still call this method
# to delete temporary parms in the parm manager.
loadWEGroup
def loadWEGroup(self, groupName):
# Load the given weather element group
into the GFE
unloadWE
def unloadWE(self, model, element, level, mostRecent=0):
# Unload the given weather element from GFE
saveElements
def saveElements(self, elementList):
# Save the given Fcst elements to the
server
# Example:
# self.saveElements(["T","Td"])
publishElements
def publishElements(self, elementList, timeRange):
# Publish the given Fcst elements to
the server
# over the given time range
# Example:
# self.publishElements(["T","Td"],
timeRange)
combineMode
def combineMode(self):
# returns 1 if we are in COMBINE mode
and 0 if not
setCombineMode
def setCombineMode(self):
# call it like this
self.setCombineMode("Replace")
#or
self.setCombineMode("Combine")
getVectorEditMode
def getVectorEditMode(self):
# Returns Vector Edit mode in
the GFE
# mode:
#
"Magnitude
Only"
# "Vector
Only"
# "Both"
setVectorEditMode
def setVectorEditMode(self, mode):
# Sets the Vector Edit mode in
the GFE
# mode:
#
"Magnitude
only"
# "Vector
only"
# "Both"
getConfigItem
def getConfigItem(elf, itemName, default=None):
# Return the configuration file value for "itemName"
# If not found, return the default given
esat
def esat(self, temp):