Smart Tools and Procedures - PowerPoint PPT Presentation

smart tools and procedures n.
Skip this Video
Loading SlideShow in 5 Seconds..
Smart Tools and Procedures PowerPoint Presentation
Download Presentation
Smart Tools and Procedures

play fullscreen
1 / 78
Smart Tools and Procedures
Download Presentation
Download Presentation

Smart Tools and Procedures

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Smart Tools and Procedures Tracy Hansen Smart Tools and Procedures

  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 Smart Tools and Procedures

  3. Smart Tool User Input Modify Meteorological Algorithms Numerical Python Numerical Models Observations Topography Forecast Grids "On-the-fly" Elements What are Smart Tools? Smart Tools and Procedures

  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 Smart Tools and Procedures

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

  6. CreatingSmart Tools ToolType = "numeric" from Numeric import * WeatherElementEdited = "T" import SmartScript class Tool (SmartScript.SmartScript): def __init__(self, dbss): SmartScript.SmartScript__init__(self,dbss) def execute(self, T): T = T + 5 return T Smart Tools and Procedures

  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 Smart Tools and Procedures

  8. Creating Smart ToolsConditionals WeatherElementEdited = "HeatIndex" def execute(self, HeatIndex, T): HeatIndex = where(less(T,70), T, where(less(T,85), HeatIndex + 10, HeatIndex)) return HeatIndex Smart Tools and Procedures

  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"]), ] Smart Tools and Procedures

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

  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 Smart Tools and Procedures

  12. SmartScript Library Smart Tools and Procedures

  13. Level = “SFC” Model = “Fcst” TimeRange Element = “T” Mode = “TimeWtAverage” self.getGrids Numeric Grid for “T” SmartScript LibraryGrid Access getGrids Smart Tools and Procedures

  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) Smart Tools and Procedures

  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) Smart Tools and Procedures

  16. SmartScript LibraryModel # Using VariableList VariableList = [("Model:", "", "D2D_model")] def execute(self, GridTimeRange, varDict): D2Dmodel = varDict["Model:"] self.getGrids(D2Dmodel, “T”, “SFC”,GridTimeRange) Smart Tools and Procedures

  17. SmartScript Library Numeric Soundings Temperature Cube: t_c Geopotential height Cube: gh_c Pressure Levels MB700 MB750 MB800 MB850 MB900 MB950 Smart Tools and Procedures

  18. Model = “BOU_D2D_ETA” Element = “t” TimeRange Levels self.makeNumericSounding Numeric Cube for “gh” and Numeric Cube for “t” SmartScript LibraryNumeric Sounding Smart Tools and Procedures

  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() Smart Tools and Procedures

  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.shape[0]): # Go up the atmosphere notSet = equal(T, -200) aboveGround = greater(gh_c, Topo_M) readyToSet = logical_and(notSet, aboveGround) T = where(readyToSet, t_c[i], T) return self.convertKtoF(T) Smart Tools and Procedures

  21. SmartScript LibraryConversion Methods • convertMsecToKts • convertKtoF, KtoF • convertFtoK, FtoK • convertFtToM • UVtoMagDir and MagDirToUV Smart Tools and Procedures

  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", T[25][25] Smart Tools and Procedures

  23. Smart Tool Repository (STR) • 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. Smart Tools and Procedures

  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. Smart Tools and Procedures

  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. Smart Tools and Procedures

  26. Smart Tool Repository (STR)Downloading and Adding a Tool (cont.) Smart Tools and Procedures

  27. Executing Smart Tools Exercise • Convective Scenario • Winter Scenario Smart Tools and Procedures

  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 Smart Tools and Procedures

  29. Temperature Cube: t_c Geopotential height Cube: gh_c Pressure Levels MB700 MB750 MB800 MB850 MB900 MB950 SmartScript Library Numeric Soundings Smart Tools and Procedures

  30. height (height1, value1) (height2, value2) self.interpolateValues Interpolated value at height SmartScript LibraryInterpolateValues Smart Tools and Procedures

  31. height (height1, value1) (height2, value2) self.interpolateValues Interpolated value at height SmartScript LibraryInterpolateValues Smart Tools and Procedures

  32. height (height1, value1) (height2, value2) self.extrapolate Extrapolated value at height SmartScript LibraryExtrapolate Smart Tools and Procedures

  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 = Wind[0] dir = Wind[1] mag = mag + 5 return (mag, dir) Smart Tools and Procedures

  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 = ["Sct:RW:-:<NoVis>:", "Chc:T:-:<NoVis>:", "Chc:SW:-:<NoVis>:" ] Then the wxValues grid is 0 where "Sct:RW:-:<NoVis>:" 1 where "Chc:T:-:<NoVis>:" 2 where "Chc:SW:-:<NoVis>:" Smart Tools and Procedures

  35. Working with Weather Assigning Weather values: getIndex -- given a list of keys, returns the associated index byteValue = self.getIndex("SChc:RW:-:<NoVis>:",keys) byteValue = self.getIndex("Chc:RW:-:<NoVis>:",keys) # Special case for "NoWx" byteValue = self.getIndex("",keys) Smart Tools and Procedures

  36. Working with Weather #See examples/smartTools/ # 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("SChc:RW:-:<NoVis>:",keys), self.getIndex("Chc:RW:-:<NoVis>:",keys))) return (wxValues, keys) Smart Tools and Procedures

  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:") Smart Tools and Procedures

  38. Working with Weather # See examples/smartTools/ # 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 Smart Tools and Procedures

  39. SmartScript LibraryEdit Area Methods editArea = self.getEditArea(“Boulder”) areaMask = self.encodeEditArea(editArea) T = where(areaMask, T+10, T) Smart Tools and Procedures

  40. Smart Script LibraryMissing Data Mode • Set from GFE-->Editing 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. Smart Tools and Procedures

  41. SmartScript Library"On-the-Fly" Elements • "On-the-fly" Elements • ISC Discrepancies • Creating temporary weather elements self.createGrid(model, element, elementType, numericGrid, timeRange) Smart Tools and Procedures

  42. SmartScript Library"On-the-Fly" Elements WeatherElementEdited = “None” self.createGrid("Diff", "T_Diff", "Scalar", myGrid, GridTimeRange) Smart Tools and Procedures

  43. WEname GridTimeRange exactMatch self.getComposite Primary Grid plus corresponding ISC data Numeric mask indicating valid points SmartScript LibraryISC Data Smart Tools and Procedures

  44. SmartScript LibrarySaving Objects self.saveObject(objectName, object, category self.saveObject(“MyGrid”, numericGrid, “DiscrepancyValueGrids”) myGrid = self.getObject(“MyGrid”, “DiscrepancyValueGrids”) Smart Tools and Procedures

  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 Smart Tools and Procedures

  46. Smart ToolsScreenList ScreenList = ["SCALAR","VECTOR"] ScreenList = ["Td","T","MaxT","MinT"] Smart Tools and Procedures

  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.SmartScript.__init__(self, dbss) def preProcessTool(self, varDict): self._thunder = varDict["Thunder Y/N"] def execute(self, Wx): if self._thunder == "Y": # assign thunder Smart Tools and Procedures

  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.SmartScript.__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) Smart Tools and Procedures

  49. SmartScript LibraryComing Soon • A library of meteorological functions • Gradient • Curl • Dot product • Cross product • Advection • Others Smart Tools and Procedures

  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 Smart Tools and Procedures