Other GFESuite Programs - PowerPoint PPT Presentation

1 / 78
About This Presentation
Title:

Other GFESuite Programs

Description:

Register tools when downloaded to received bug notification, version updates, ... The program takes care of the metadata file needed. ... – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 79
Provided by: Mar5544
Category:

less

Transcript and Presenter's Notes

Title: Other GFESuite Programs


1
Smart Tools and Procedures
Tracy Hansen
2
Overview
  • Part 1
  • What are Smart Tools?
  • Executing Smart Tools
  • Creating Smart Tools
  • Part 2
  • Creating Smart Tools (cont)
  • SmartScript Library Methods
  • Part 3
  • Procedures
  • Utilities

3
What are Smart Tools?
4
Executing Smart Tools
  • Make Weather Element Editable
  • Set up Selection Time Range
  • Set up Edit Area
  • Execute Tool from Edit Action Dialog or Spatial
    Editor MB3 Popup Menu

5
Creating Smart Tools
  • From Edit Action Dialog MB3 Popup
  • Info...
  • Cut, Copy, Paste
  • Modify... or View...
  • New...
  • Rename...
  • Delete...

6

Creating Smart Tools
ToolType "numeric" from Numeric import
WeatherElementEdited "T"
import SmartScript class Tool (SmartScript.SmartSc
ript) def __init__(self, dbss)
SmartScript.SmartScript__init__(self,dbss)
def execute(self, T)
T T 5 return T
7
Creating Smart Tools Tool Arguments
  • Weather Elements
  • T, Wx, variableElement, MaxT_SFC_BOU_Eta
  • Topography
  • Topo
  • MaxGrid, MinGrid, SumGrid
  • T_MaxGrid, Td_SumGrid
  • GridTimeRange
  • GridInfo, GridHistory
  • Wx_GridInfo, T_GridHistory

8
Creating Smart Tools Conditionals
WeatherElementEdited "HeatIndex" def
execute(self, HeatIndex, T)
HeatIndex where(less(T,70), T,
where(less(T,85),
HeatIndex 10,
HeatIndex)) return HeatIndex
9
Creating Smart ToolsVariable Lists
  • Allow for run-time user input

VariableList ("Edit Coverage or
Uncertainty" , "Coverage", "radio",
"Coverage","Uncertainty"),
("Thunder Y/N" , "Y", "radio", "Y","N"),

10
Creating Smart Tools Variable Lists
  • numeric, alphaNumeric
  • radio, check
  • scale
  • model, D2D_model
  • label

11
Creating Smart ToolsVariable Lists
  • varDict argument to access user input

def execute(self, varDict)
coverageOrUncertainty varDict"Edit Coverage or
Uncertainty"
thunder varDict"Thunder Y/N"
if coverageOrUncertainty "Coverage"
assign coverage terms else
assign uncertainty terms if
thunder "Y" assign thunder
12
SmartScript Library
13
SmartScript LibraryGrid Access
  • getGrids

14
SmartScript LibraryModel
Fcst or Official self.getGrids(Fcst, T,
SFC, GridTimeRange)
siteID_type_model_modeltime
self.getGrids(BOU__Eta_Oct0112, T, SFC,
GridTimeRange)
self.getGrids(BOU__Eta, T, SFC,
GridTimeRange)
self.getGrids(BOU_D2D_ETA, t, MB750,
GridTimeRange)
15
SmartScript LibraryModel
Using Site ID for portability
def execute(self, GridTimeRange, varDict)
siteID self.getSiteID()
model self.siteID __Eta
self.getGrids(model, T, SFC,GridTimeRange)
16
SmartScript LibraryModel
Using VariableList VariableList ("Model",
"", "D2D_model")
def execute(self, GridTimeRange, varDict)
D2Dmodel varDict"Model"
self.getGrids(D2Dmodel, T,
SFC,GridTimeRange)
17
SmartScript Library Numeric Soundings
Temperature Cube t_c
Geopotential height Cube gh_c
Pressure Levels
MB700 MB750 MB800 MB850 MB900 MB950
18
SmartScript LibraryNumeric Sounding
19
SmartScript Library Numeric Soundings
VariableList ("Model", "", "D2D_model")

def execute(self, GridTimeRange, Topo, varDict)
D2Dmodel varDict"Model" levels "MB900",
"MB850", "MB800", "MB750",
"MB700", "MB650", "MB600", "MB550
gh_c, t_c self.makeNumericSounding(
D2Dmodel, "t", levels, GridTimeRange)
if gh_c is None self.noData()
20
SmartScript Library Numeric Soundings
def execute(self, GridTimeRange, Topo, varDict)
....
Topo_M self.convertFtToM(Topo)
T self._empty - 200
for i in xrange(gh_c.shape0) Go
up the atmosphere
notSet equal(T, -200)
aboveGround greater(gh_c, Topo_M)
readyToSet logical_and(notSet, aboveGround)
T where(readyToSet, t_ci, T)
return self.convertKtoF(T)
21
SmartScript LibraryConversion Methods
  • convertMsecToKts
  • convertKtoF, KtoF
  • convertFtoK, FtoK
  • convertFtToM
  • UVtoMagDir and MagDirToUV

22
Trouble-shooting Ideas
  • Run from terminal window to see Python error
    messages.
  • Use "print" statements.

print "Made it to this point." print
"myVariable", myVariable print "value at 25,
25 is", T2525
23
Smart Tool Repository (STR)http//isl715.nws.noaa
.gov/STR/index.php3
  • Provides an easy to use interface between
    developers of STs and the users. Promotes sharing
    of STs so that others can benefit from work done
    and not duplicate work.
  • Register tools when downloaded to received bug
    notification, version updates, and comments on
    the ST.
  • Users can also submit bugs and comments to the
    developer.
  • Upload a newly developed tool along with
    documentation and an installation guide. You can
    even post a ST idea that is in development
    without submitting the actual code.

24
Smart Tool Repository (STR)Downloading and
Adding a Tool
  • Use the Site Interface and choose your region
    and WFO ID
  • Choose Info on Tools and go to the ST you wish
    to download
  • Right click on the Download Software and use
    Save Link as. Do the same for the
    Documentation and Install files if available.
  • Move the ST to a location where GFE is running
    and open the ST with an editor such as vi or
    nedit.

25
Smart Tool Repository (STR)Downloading and
Adding a Tool (cont.)
  • 5) Make the downloaded ST part of the GFE
  • Use the new ifpServerText program to save the
    flat file into the GFESuite ifpServer. The
    program takes care of the metadata file needed.
  • 6) Use the STR to register this tool to receive
    e-mail notices of bugs and updates.

26
Smart Tool Repository (STR)Downloading and
Adding a Tool (cont.)
27
Executing Smart Tools Exercise
  • Convective Scenario
  • Winter Scenario

28
Creating Smart ToolsExercises
  • Tool-1
  • Tool-2
  • Tool-3
  • SmartScript-1 Accessing Grids Directly
  • SmartScript-2 Accessing Variable Grids Directly
  • SmartScript-3 Making and Accessing Soundings
  • SmartScript-4 Making and Accessing Soundings

29
SmartScript Library Numeric Soundings
30
SmartScript LibraryInterpolateValues
31
SmartScript LibraryInterpolateValues
32
SmartScript LibraryExtrapolate
33
Vector Weather Elements
WeatherElementEdited "Wind" import
SmartScript class Tool (SmartScript.SmartScript)
def __init__(self, dbss)
SmartScript.SmartScript__init__(self,dbss)
def execute(self, Wind) mag Wind0
dir Wind1 mag mag 5
return (mag, dir)
34
Working with Weather
Numeric Weather is a 2-tuple
wxValues -- Numeric Grid of bytes
keys -- list of "ugly strings" where the the
index of the ugly string
corresponds to the byte value in the wxValues
grid.
Keys "SctRW-ltNoVisgt",
"ChcT-ltNoVisgt",
"ChcSW-ltNoVisgt"
Then the wxValues grid is 0 where
"SctRW-ltNoVisgt"
1 where "ChcT-ltNoVisgt"
2 where
"ChcSW-ltNoVisgt"
35
Working with Weather
Assigning Weather values getIndex -- given a
list of keys, returns the
associated index
byteValue self.getIndex("SChcRW-ltNoVisgt",key
s)
byteValue self.getIndex("ChcRW-ltNoVisgt",keys
)
Special case for "NoWx" byteValue
self.getIndex("",keys)
36
Working with Weather
See examples/smartTools/Convective_SmartTool.py
Creating Wx from PoP
def execute(self, PoP, Wx) wxValues, keys
Wx
wxValues \ where(less(PoP, 10),
self.getIndex("",keys),
where(less(PoP,20) , self.getIndex("SChcRW
-ltNoVisgt",keys),
self.getIndex("ChcRW-ltNoVisgt",keys)))
return (wxValues, keys)
37
Working with Weather
Querying Weather values wxMask -- given a Wx
tuple and a string expression,
return 1 if there is a match

found self.wxMask(Wx, "Iso")
found self.wxMask(Wx, "R")
38
Working with Weather
See examples/smartTools/PoP_From_Wx.py
Creating PoP from Wx
def execute(self, PoP,Wx) PoP
where(self.wxMask(Wx, "Iso"), 10, PoP)
PoP where(self.wxMask(Wx, "Sct"), 20, PoP)
return PoP
39
SmartScript LibraryEdit Area Methods
editArea self.getEditArea(Boulder)
areaMask self.encodeEditArea(editArea)
T where(areaMask, T10, T)
40
Smart Script LibraryMissing Data Mode
  • Set from GFE--gtEditing Modes Menu
  • When there is missing data
  • Stop -- stop execution
  • Skip -- Skips the grid and reports it
  • Create -- If possible, creates a grid via
    interpolation. If in the Fcst database, the new
    grid can be saved.

41
SmartScript Library"On-the-Fly" Elements
  • "On-the-fly" Elements
  • ISC Discrepancies
  • Creating temporary weather elements

self.createGrid(model, element, elementType,
numericGrid, timeRange)
42
SmartScript Library"On-the-Fly" Elements
WeatherElementEdited None
self.createGrid("Diff", "T_Diff", "Scalar",
myGrid, GridTimeRange)
43
SmartScript LibraryISC Data
44
SmartScript LibrarySaving Objects
self.saveObject(objectName, object, category
self.saveObject(MyGrid, numericGrid,
DiscrepancyValueGrids)
myGrid self.getObject(MyGrid,
DiscrepancyValueGrids)
45
Smart Script LibraryError Handling
  • abort -- abort with user-supplied error message
  • noData -- abort with a No Data error
  • cancel -- abort with no error message
  • statusBarMsg -- sends message to the Status Bar

46
Smart ToolsScreenList
ScreenList "SCALAR","VECTOR" ScreenList
"Td","T","MaxT","MinT"
47
Creating Smart Tools Reserved Methods
  • execute
  • preProcessTool, postProcessTool
  • Actions that need to be done once per tool

class Tool (SmartScript.SmartScript) def
__init__(self, dbss) SmartScript.SmartScr
ipt.__init__(self, dbss) def
preProcessTool(self, varDict)
self._thunder varDict"Thunder Y/N" def
execute(self, Wx) if self._thunder
"Y" assign thunder
48
Creating Smart Tools Creating Your Own Methods
  • Name preceeded by underscore
  • "self" used in call and in "def" argument list

Class Tool (SmartScript.SmartScript) def
__init__(self, dbss) SmartScript.SmartScr
ipt.__init__(self, dbss) def execute(self,
QPF, T) SnowRatio
self._getSnowRatio(T) SnowAmt QPF
SnowRatio return SnowAmt def
_getSnowRatio(self, T) return where(
less(T, 20), 18,
where( less(T, 21), 14, 10)
49
SmartScript LibraryComing Soon
  • A library of meteorological functions
  • Gradient
  • Curl
  • Dot product
  • Cross product
  • Advection
  • Others

50
SmartScript LibraryExercises
  • SmartScript-5 Making and Accessing Soundings
  • SmartScript-6 Creating Elements "On-the-Fly"
  • SmartScript-7 Working with Weather
  • SmartScript-8 Working with Weather

51
Procedures
52
SmartScript LibraryProcedure Commands
  • copyCmd
  • createFromScratchCmd
  • assignValueCmd
  • zeroCmd
  • interpolateCmd
  • timeShiftCmd
  • splitCmd, fragmentCmd, deleteCmd

53
SmartScript LibraryProcedure Commands
  • copyCmd

54
SmartScript LibraryTime Ranges
Active timeRange in GFE def execute(self,
editArea, timeRange)
Get Selection Time Range todayRange
self.getTimeRange(Today)
Create Time Range with startHour,
endHour todayRange self.createTimeRange(6, 18,
LT)
55
SmartScript LibraryDatabases
databaseID
Find database -- databaseName, version
databaseID self.findDatabase(Eta, 0)

databaseID self.findDatabase(D2D_ETA, -1)
56
SmartScript LibraryDatabases
databaseID
Get database -- result of VariableList
VariableList ("Model", "", "D2D_model")
def execute(self, varDict) D2Dmodel
varDict"Model"
databaseID self.getDatabase(D2Dmodel)
57
SmartScript LibraryProcedure Commands
  • createFromScratchCmd

58
SmartScript LibraryProcedure Commands
  • assignValueCmd

59
SmartScript LibraryProcedure Commands
  • zeroCmd

60
SmartScript LibraryProcedure Commands
  • interpolateCmd

61
SmartScript LibraryProcedure Commands
  • interpolateCmd

62
SmartScript LibraryProcedure Commands
  • timeShiftCmd

63
SmartScript LibraryProcedure Commands
  • splitCmd

64
SmartScript LibraryProcedure Commands
  • fr agmentCmd

65
SmartScript LibraryProcedure Commands
  • deleteCmd

66
SmartScript LibraryProcedure Commands
Creating a Time Range model
varDict"Model" databaseID self.getDatabase(mod
el) timeRange_0_60 self.createTimeRange(
0, 60, "DatabaseID", databaseID)
Copy from model elements T, Wind,
Wx self.copyCmd(elements, databaseID,
timeRange_0_60)
67
SmartScript LibraryProcedure Commands
Find most recent Eta model databaseID
self.findDatabase("Eta", version0)
Copy grids self.copyCmd( "T", "Td",
"Wind", databaseID, timeRange_0_60)
68
SmartScript LibraryProcedure Commands
  • callSmartTool

69
SmartScript LibraryProcedure Commands
Create Grids self.createFromScratchCmd(
"MixHgt", timeRange_0_60, repeat6, duration1)
Get edit area toolEditArea self.getEditArea("B
oulder")
Call Smart Tool self.callSmartTool("MixHgt_Init
", "MixHgt",
toolEditArea, timeRange_0_60)
70
ProcedurescallSmartTool and VariableLists
Smart Tool, "MyTool" VariableList
("Threshold", 10, "numeric")
def execute(self, varDict) threshold
varDict"Threshold"
71
ProcedurescallSmartTool and VariableLists
Procedure VariableList
("Model", "", "model"),
("Threshold", 10, "numeric")
def execute(self, varDict) This
call will pass varDict which has variables for
both the Procedure and the Smart Tool
self.callSmartTool( "MyTool",
"T", editArea, timeRange, varDict)
72
SmartScript LibraryProcedure Commands
  • getGridCellSwath
  • saveEditArea
  • setActiveElement
  • cacheElements, uncacheElements

73
SmartScript Library
Procedure commands
Smart Tool commands
getEditArea
createFromScratch
makeNumericSounding
extrapolate
interpolateCmd
createTimeRange
getGrids
callSmartTool
getGrids
74
Background Procedures
  • runProcedure command

./runProcedure
-n procedure name
-u userID
-c config file
-a edit area name
-t time range
75
Background Procedures
./runProcedure -n Proc1 -u ifpUser -c
gfeConfig -a
CO_Boulder -t Tonight
76
Utilities
  • Allows for sharing of common methods among Smart
    Tools and Procedures

77
SmartScript LibraryProgress Dialog
import MyDialog def execute(self, editArea,
timeRange)
Display dialog dialog MyDialog.MyDialog(
None, Status, Loading Grids)
Do stuff
Close dialog dialog.top().destroy()
78
Procedures and UtilitiesExercises
  • Procedure-1
  • Procedure-2
  • Procedure-3
  • Utility-1
Write a Comment
User Comments (0)
About PowerShow.com