Working with Weather Data


The getIndex method -- Creating Weather Data   
The wxValue methods -- Examining Weather Data


Working with Weather-type elements in Numerical Python tools requires some special comments. A wx argument represents a 2-tuple: For example, if our keys are: then, the wxValues grid will have byte values of 0 where there is "Sct:RW:-:<NoVis>:", 1 where there is "Chc:T:-:<NoVis>:" and 2 where there is "Chc:SW:-:<NoVis>:"

The getIndex Method -- Creating Weather Data

The GFESuite method, "getIndex(uglyString, keys)" will return the byte value that corresponds to the given ugly string. It will add a new key if a new ugly string is requested. A Numerical Smart Tool or Smart Initialization method working with weather data must return a (wxValues, keys) tuple.   For example:

      def execute(self, Wx):
          # Assign Wx based on PoP

          # Separate the Weather argument into it's two components, wxValues and keys
          wxValues = Wx[0]
          keys = Wx[1]

          # Assign "SChc:RW:-:<NoVis>:"  where the PoP is less than 30
           wxValues = where(less(PoP,30),  self.getIndex("SChc:RW:-:<NoVis>:", keys),  wxValues)

          # Return the paired components as a tuple
           return (wxValues, keys)

The wxMask Method -- Examining Weather Data

The GFESuite method, "wxMask(wxTuple, query, isRegExpr)", allows you to examine the ugly string values in the numerical grid of byte values.   The method returns a mask,  i.e. a numeric grid of 0's and 1's, where the value is 1 if the given query succeeds.  It has the following arguments:
  • wxTuple -- a 2-tuple:
  • wxValues : numerical grid of byte values
  • keys : list of "ugly strings" where the index of the ugly string corresponds to the byte value in the wxValues grid.
  • query -- a text string representing a query
  • isreg -- if 1, the query is treated as a regular expression, otherwise as a literal string
  • Examples:

        # Here we want to treat the query as a regular expression to avoid confusion between "Chc" and "SChc"
        # This statement will assign PoP a value of 40 where the weather has a coverage of "Chc"
        PoP = where(self.wxMask(wxTuple, "^Chc:", 1),  40,   PoP)

         # Here we want to treat the query as a literal
         # This statement will assign PoP a value of 5 where the weather has type of "L"
         PoP = where(self.wxMask(wxTuple, ":L:"),  5,  PoP)

    Working with Discrete Data

    Working with Discrete-type elements in Numerical Python tools requires some special comments. A wx argument represents a 2-tuple: For example, if our keys are: then, the wxValues grid will have byte values of 0 where there is "SmCrftADV", 1 where there is "SnowADV^WChillADV" and 2 where there is "<None>"

    The getIndex Method -- Creating Discrete Data

    The GFESuite method, "getIndex(string, keys)" will return the byte value that corresponds to the given string. It will add a new key if a new  string is requested. A Numerical Smart Tool or Smart Initialization method working with discrete data must return a (wxValues, keys) tuple.   For example:

          def execute(self, Highlights, WindChill):
              # Assign Highlights based on WindChill

              # Separate the Discrete argument into it's two components, wxValues and keys
              wxValues = Highlights[0]
              keys = Highlights[1]

              # Assign "WChillADV"  where the WindChill is less than -20
               wxValues = where(less(WindChill,-20),  self.getIndex("WChillADV", keys),  wxValues)

              # Return the paired components as a tuple
               return (wxValues, keys)
     
     

    The discreteMask Method -- Examining Discrete Data

    The GFESuite method, "discreteMask(wxTuple, query, isRegExpr)", allows you to examine the  string values in the numerical grid of byte values.   The method returns a mask,  i.e. a numeric grid of 0's and 1's, where the value is 1 if the given query succeeds.  It has the following arguments:
  • wxTuple -- a 2-tuple:
  • wxValues : numerical grid of byte values
  • keys : list of "strings" where the index of the string corresponds to the byte value in the wxValues grid.
  • query -- a text string representing a query
  • isreg -- if 1, the query is treated as a regular expression, otherwise as a literal string