461 lines
14 KiB
HTML
461 lines
14 KiB
HTML
<html>
|
|
<title>Smart Script Class - Procedure Methods</title>
|
|
<body>
|
|
|
|
|
|
<h1><a name="Proc"></a>Procedure Methods</h1>
|
|
<br>
|
|
<a href="#copyCmd">copyCmd</a>
|
|
<br>
|
|
<a href="#copyToCmd">copyToCmd</a>
|
|
<br>
|
|
<a href="#deleteCmd">deleteCmd</a>
|
|
<br>
|
|
<a href="#zeroCmd">zeroCmd</a>
|
|
<br>
|
|
<a href="#interpolateCmd">interpolateCmd</a>
|
|
<br>
|
|
<a href="#createFromScratchCmd">createFromScratchCmd</a>
|
|
<br>
|
|
<a href="#timeShiftCmd">timeShiftCmd</a>
|
|
<br>
|
|
<a href="#splitCmd">splitCmd</a>
|
|
<br>
|
|
<a href="#fragmentCmd">fragmentCmd</a>
|
|
<br>
|
|
<a href="#assignValueCmd">assignValueCmd</a>
|
|
<!-- Leave this comment for formatting purposes -->
|
|
<hr width="100%">
|
|
|
|
<h2>
|
|
<a name="procArgs"></a>Command Arguments</h2>
|
|
# These commands always apply to the
|
|
mutable
|
|
model only.
|
|
<br>
|
|
# name1, name2, name3 is a list of the
|
|
weather element names
|
|
<br>
|
|
# startHour is the starting hour for
|
|
the command offset from modelbase
|
|
<br>
|
|
# endHour is the ending hour for the
|
|
command offset from modelbase.
|
|
<br>
|
|
# The ending hour is NOT included in
|
|
the processing of the
|
|
<br>
|
|
# command.
|
|
<br>
|
|
# modelbase is the name of the model
|
|
to be used to determine base times
|
|
<br>
|
|
# Note that if this is "", then 0000z
|
|
from today will be
|
|
<br>
|
|
# used for the base time.
|
|
<br>
|
|
# modelsource is the name of the model
|
|
to be used in the copy command
|
|
<br>
|
|
# copyOnly is 0 for move and 1 for copy
|
|
only in the time shift command
|
|
<br>
|
|
# hoursToShift is the number of hours
|
|
to shift the data in time
|
|
<br>
|
|
# shift command
|
|
<br>
|
|
# DatabaseID
|
|
<br>
|
|
# Can be obtained in various ways:
|
|
<br>
|
|
# --By calling findDatabase (see below)
|
|
<br>
|
|
# --By calling getDatabase (see below)
|
|
with the result
|
|
<br>
|
|
# of a VariableList entry of type
|
|
"model"
|
|
or "D2D_model"
|
|
<br>
|
|
# TimeRange.
|
|
<br>
|
|
# Can be obtained in various ways:
|
|
<br>
|
|
# --As an argument passed into Smart
|
|
Tool or Procedure,
|
|
<br>
|
|
# --By calling getTimeRange (see below)
|
|
<br>
|
|
# --By calling createTimeRange (see
|
|
below)
|
|
<h2><a name="copyCmd"></a>copyCmd</h2>
|
|
def copyCmd(self, elements, databaseID, timeRange):
|
|
<br>
|
|
# copyCmd(['name1', 'name2', 'name3'],
|
|
databaseID, timeRange)
|
|
<br>
|
|
# Copies all grids for each weather
|
|
element from the given database
|
|
<br>
|
|
# into the weather element in the
|
|
mutable
|
|
database that overlaps
|
|
<br>
|
|
# the time range.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
# timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.copyCmd(['T',
|
|
'Wind'], databaseID, timeRange)
|
|
<br>
|
|
# will copy the Temperature and Wind
|
|
fields analysis through 48 hours
|
|
<br>
|
|
# from the latest NAM and place them
|
|
into the forecast.
|
|
<br>
|
|
#
|
|
<h2><a name="copyToCmd"></a>copyToCmd</h2>
|
|
def copyToCmd(self, elements, databaseID, timeRange):
|
|
<br>
|
|
# copyCmd([('srcName1', 'dstName1),
|
|
('srcName2', 'dstName2')], databaseID, timeRange)
|
|
<br>
|
|
# Copies all grids for each weather
|
|
element from the given database
|
|
<br>
|
|
# into the weather element in the
|
|
mutable
|
|
database that overlaps
|
|
<br>
|
|
# the time range. Both the source
|
|
<br>
|
|
# and destination names are given.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
# timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.copyToCmd([('T',
|
|
'MaxT'), ('MaxT', 'MinT')], databaseID, timeRange)
|
|
<br>
|
|
# will copy T to MaxT and MaxT to MinT
|
|
<br>
|
|
# from the latest NAM and place them
|
|
into the forecast.
|
|
<br>
|
|
#
|
|
<h2><a name="deleteCmd"></a>deleteCmd</h2>
|
|
def deleteCmd(self, elements, timeRange):
|
|
<br>
|
|
# deleteCmd(['name1', 'name2', 'name3'],
|
|
timeRange)
|
|
<br>
|
|
# Deletes all grids that overlap the
|
|
input time range for element
|
|
<br>
|
|
# in the mutable database.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
# timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.deleteCmd(['T',
|
|
'Wind'], databaseID, timeRange)
|
|
<br>
|
|
# will delete the Temperature and Wind
|
|
fields analysis up to
|
|
<br>
|
|
# but not including 48 hours relative
|
|
to the start time of
|
|
<br>
|
|
# the latest NAM model.
|
|
<br>
|
|
#
|
|
<h2><a name="zeroCmd"></a>zeroCmd</h2>
|
|
def zeroCmd(self, elements, timeRange):
|
|
<br>
|
|
# zeroCmd(['name1', 'name2', 'name3'],
|
|
timeRange)
|
|
<br>
|
|
# Assigns the minimum possible value
|
|
for scalar and vector, and "<nowx>"
|
|
<br>
|
|
# for weather for the parameter in the
|
|
mutable database for all grids
|
|
<br>
|
|
# that overlap the specified time range.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
# timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.zeroCmd(['T',
|
|
'Wind'], databaseID, timeRange)
|
|
<br>
|
|
# will zero the Temperature and Wind
|
|
grids through 48 hours
|
|
<br>
|
|
# relative to the start time of the
|
|
latest NAM model.
|
|
<br>
|
|
# </nowx>
|
|
<h2><a name="interpolateCmd"></a>interpolateCmd</h2>
|
|
def interpolateCmd(self, elements, timeRange, interpMode="GAPS",
|
|
interpState="SYNC",
|
|
interval=0, duration=0):
|
|
<br>
|
|
# interpolateCmd(['name1', 'name2',
|
|
'name3'], timeRange,
|
|
<br>
|
|
# interpMode="GAPS", interpState="SYNC",
|
|
interval=0, duration=0)
|
|
<br>
|
|
# Interpolates data in the forecast
|
|
for the named weather elements
|
|
<br>
|
|
# for the given timeRange.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
# timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.interpolateCmd(['T',
|
|
'Wind'], timeRange, "GAPS","SYNC")
|
|
<br>
|
|
# will interpolate the Temperature and
|
|
Wind grids up to but
|
|
<br>
|
|
# but not including 48 hours relative
|
|
to the start time of
|
|
<br>
|
|
#the latest NAM model.
|
|
<br>
|
|
# The interpolation will run in SYNC
|
|
mode i.e. completing before
|
|
<br>
|
|
# continuing with the procedure.
|
|
<br>
|
|
#
|
|
<h2><a name="createFromScratchCmd"></a>createFromScratchCmd</h2>
|
|
def createFromScratchCmd(self, elements, timeRange, repeat=0,
|
|
duration=0):
|
|
<br>
|
|
# createFromScratchCmd(['name1',
|
|
'name2'],
|
|
timeRange, repeat, duration)
|
|
<br>
|
|
# Creates one or more grids from scratch
|
|
over the given timeRange
|
|
<br>
|
|
# and assigns the default (minimum
|
|
possible
|
|
value for scalar
|
|
<br>
|
|
# and vector, "<nowx>" for weather).
|
|
<br>
|
|
# The repeat interval and duration (both
|
|
specified in hours) are
|
|
<br>
|
|
# used to control the number of grids
|
|
created. If 0 is specified for
|
|
<br>
|
|
# either one, than only 1 grid is
|
|
created
|
|
for the given time range. If
|
|
<br>
|
|
# valid numbers for duration and repeat
|
|
are given, then grids will
|
|
<br>
|
|
# be created every "repeat" hours and
|
|
they will have a duration
|
|
<br>
|
|
# of "duration" hours. If there is not
|
|
enough room remaining to create
|
|
<br>
|
|
# a grid with the full duration, then
|
|
no grid will be created in the space
|
|
<br>
|
|
# remaining. If you don't get the
|
|
desired
|
|
results, be sure that your input
|
|
<br>
|
|
# time range starts on a valid time
|
|
constraint for the element. If the
|
|
<br>
|
|
# element's time constraints (not the
|
|
values supplied in this routine) contains
|
|
<br>
|
|
# gaps (i.e., duration !=
|
|
repeatInterval),
|
|
then the repeat interval and
|
|
<br>
|
|
# duration will be ignored and grids
|
|
will be created for each possible
|
|
<br>
|
|
# constraint time.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
# timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.createFromScratchCmd(['T',
|
|
'Wind'], timeRange, 3, 1)
|
|
<br>
|
|
# will create the 1-hour Temperature
|
|
grids through 48 hours at
|
|
<br>
|
|
# 3 hour intervals relative to the start
|
|
time of the latest NAM model.
|
|
<br>
|
|
# </nowx>
|
|
<h2><a name="timeShiftCmd"></a>timeShiftCmd</h2>
|
|
def timeShiftCmd(self, elements, copyOnly, shiftAmount, timeRange):
|
|
<br>
|
|
# timeShiftCmd(['name1', 'name2'],
|
|
copyOnly,
|
|
shiftAmount, timeRange)
|
|
<br>
|
|
# Performs a time shift by the
|
|
shiftAmount
|
|
for all elements that
|
|
<br>
|
|
# overlap the time range.
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
# databaseID
|
|
= self.findDatabase("NAM") # Most recent NAM model
|
|
<br>
|
|
#
|
|
timeRange
|
|
= self.createTimeRange(0, 49, "Database", databaseID)
|
|
<br>
|
|
#
|
|
self.timeShiftCmd(['T',
|
|
'Wind'], 1, 3, timeRange)
|
|
<br>
|
|
#
|
|
<h2><a name="splitCmd"></a>splitCmd</h2>
|
|
def splitCmd(self, elements, timeRange):
|
|
<br>
|
|
# splitCmd(elements, timeRange)
|
|
<br>
|
|
# Splits any grid that falls on the
|
|
start time or ending time of the
|
|
<br>
|
|
# specified time range for the given
|
|
parameter in the mutable database.
|
|
<br>
|
|
#
|
|
<h2><a name="fragmentCmd"></a>fragmentCmd</h2>
|
|
def fragmentCmd(self, elements, timeRange):
|
|
<br>
|
|
# fragmentCmd(elements, timeRange)
|
|
<br>
|
|
# Fragments any grids that overlap the
|
|
input time range for the parm
|
|
<br>
|
|
# identified in the mutable database.
|
|
<br>
|
|
#
|
|
<h2><a name="assignValueCmd"></a>assignValueCmd</h2>
|
|
def assignValueCmd(self, elements, timeRange, value):
|
|
<br>
|
|
# assignValueCmd(elements, timeRange,
|
|
value)
|
|
<br>
|
|
# Assigns the specified value to all
|
|
grids points for the grids that
|
|
<br>
|
|
# overlap the specified time range,
|
|
for the weather element in the mutable
|
|
<br>
|
|
# database specified.
|
|
<br>
|
|
# value is:
|
|
<br>
|
|
# an Integer or Float for SCALAR
|
|
<br>
|
|
# a magnitude-direction tuple for
|
|
VECTOR:
|
|
e.g. (55,120)
|
|
<br>
|
|
# a text string for Weather which can
|
|
be obtained via the
|
|
<br>
|
|
# WxMethods WxString method
|
|
<br>
|
|
# Example:
|
|
<br>
|
|
#
|
|
<br>
|
|
# Scalar
|
|
<br>
|
|
# value = 60
|
|
<br>
|
|
#
|
|
self.assignValue(["T","Td"],
|
|
0, 12, 'NAM', value)
|
|
<br>
|
|
#
|
|
<br>
|
|
# Vector
|
|
<br>
|
|
# value = (15,
|
|
120)
|
|
<br>
|
|
#
|
|
self.assignValue(["Wind"],
|
|
0, 12, 'NAM', value)
|
|
<br>
|
|
#
|
|
<br>
|
|
# Weather
|
|
<br>
|
|
# from WxMethods
|
|
import *
|
|
<br>
|
|
# value
|
|
= WxString("Sct RW")
|
|
<br>
|
|
#
|
|
self.assignValue(["Wx"],
|
|
0, 12, 'NAM', value)
|
|
|
|
|
|
|