179 lines
6.7 KiB
HTML
179 lines
6.7 KiB
HTML
<html>
|
|
<title>GFESuite Documentation - Working With Weather Data</title>
|
|
<body>
|
|
<h1 align=center>
|
|
<a NAME="WorkingwithWeatherData"></a>Working with Weather Data</h1>
|
|
<br><p><a href="#ThegetIndexMethod--CreatingWeatherData">The
|
|
getIndex method -- Creating Weather Data</a><!-- Leave this comment for formatting purposes -->
|
|
<br><a href="#ThewxValuesMethod--ExaminingWeatherData">The
|
|
wxValue methods -- Examining Weather Data</a><!-- Leave this comment for formatting purposes -->
|
|
<br></p><hr width="100%">
|
|
|
|
Working with Weather-type elements in Numerical Python tools requires some
|
|
special comments. A wx argument represents a 2-tuple:
|
|
<ul>
|
|
<li>
|
|
wxValues : numerical grid of byte values</li>
|
|
|
|
<li>
|
|
keys : list of "ugly strings" where the index of the ugly string corresponds
|
|
to the byte value in the wxValues grid.</li>
|
|
</ul>
|
|
For example, if our keys are:
|
|
<ul>
|
|
<li>
|
|
"Sct:RW:-:<NoVis>:"</li>
|
|
|
|
<li>
|
|
"Chc:T:-:<NoVis>:"</li>
|
|
|
|
<li>
|
|
"Chc:SW:-:<NoVis>:"</li>
|
|
</ul>
|
|
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>:"
|
|
<h2 align=center>
|
|
<a NAME="ThegetIndexMethod--CreatingWeatherData"></a>The getIndex Method
|
|
-- Creating Weather Data</h2>
|
|
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:
|
|
<p> def execute(self, Wx):
|
|
<br> # Assign Wx
|
|
based on PoP
|
|
<p> # Separate the
|
|
Weather argument into it's two components, wxValues and keys
|
|
<br> wxValues = Wx[0]
|
|
<br> keys = Wx[1]
|
|
<p> # Assign "SChc:RW:-:<NoVis>:"
|
|
where the PoP is less than 30
|
|
<br> wxValues
|
|
= where(less(PoP,30), self.getIndex("SChc:RW:-:<NoVis>:", keys),
|
|
wxValues)
|
|
<p> # Return the
|
|
paired components as a tuple
|
|
<br> return
|
|
(wxValues, keys)
|
|
<h2 align=center>
|
|
<a NAME="ThewxValuesMethod--ExaminingWeatherData"></a>The wxMask Method
|
|
-- Examining Weather Data</h2>
|
|
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:
|
|
<blockquote>
|
|
<li>
|
|
wxTuple -- a 2-tuple:</li>
|
|
|
|
<blockquote>
|
|
<li>
|
|
wxValues : numerical grid of byte values</li>
|
|
|
|
<li>
|
|
keys : list of "ugly strings" where the index of the ugly string corresponds
|
|
to the byte value in the wxValues grid.</li>
|
|
</blockquote>
|
|
|
|
<li>
|
|
query -- a text string representing a query</li>
|
|
|
|
<li>
|
|
isreg -- if 1, the query is treated as a regular expression, otherwise
|
|
as a literal string</li>
|
|
</blockquote>
|
|
Examples:
|
|
<p> # Here we want to treat the query as a regular expression
|
|
to avoid confusion between "Chc" and "SChc"
|
|
<br> # This statement will assign PoP a value of 40 where
|
|
the weather has a coverage of "Chc"
|
|
<br> PoP = where(self.wxMask(wxTuple, "^Chc:", 1),
|
|
40, PoP)
|
|
<p> # Here we want to treat the query as a literal
|
|
<br> # This statement will assign PoP a value of
|
|
5 where the weather has type of "L"
|
|
<br> PoP = where(self.wxMask(wxTuple, ":L:"),
|
|
5, PoP)
|
|
<h2 align=center>
|
|
<a NAME="WorkingwithDiscreteData"></a>Working with Discrete Data</h2>
|
|
Working with Discrete-type elements in Numerical Python tools requires
|
|
some special comments. A wx argument represents a 2-tuple:
|
|
<ul>
|
|
<li>
|
|
wxValues : numerical grid of byte values</li>
|
|
|
|
<li>
|
|
keys : list of "strings" where the index of the string corresponds
|
|
to the byte value in the wxValues grid.</li>
|
|
</ul>
|
|
For example, if our keys are:
|
|
<ul>
|
|
<li>
|
|
"SmCrftADV"</li>
|
|
|
|
<li>
|
|
"SnowADV^WChillADV"</li>
|
|
|
|
<li>
|
|
"<None>"</li>
|
|
</ul>
|
|
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>"
|
|
<h2 align=center>
|
|
<a NAME="ThegetIndexMethod--CreatingDiscreteData"></a>The getIndex Method
|
|
-- Creating Discrete Data</h2>
|
|
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:
|
|
<p> def execute(self, Highlights, WindChill):
|
|
<br> # Assign Highlights
|
|
based on WindChill
|
|
<p> # Separate the
|
|
Discrete argument into it's two components, wxValues and keys
|
|
<br> wxValues = Highlights[0]
|
|
<br> keys = Highlights[1]
|
|
<p> # Assign "WChillADV"
|
|
where the WindChill is less than -20
|
|
<br> wxValues
|
|
= where(less(WindChill,-20), self.getIndex("WChillADV", keys),
|
|
wxValues)
|
|
<p> # Return the
|
|
paired components as a tuple
|
|
<br> return
|
|
(wxValues, keys)
|
|
<br>
|
|
<br>
|
|
<h2 align=center>
|
|
<a NAME="ThewxValuesMethod--ExaminingWeatherData"></a>The discreteMask
|
|
Method -- Examining Discrete Data</h2>
|
|
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:
|
|
<blockquote>
|
|
<li>
|
|
wxTuple -- a 2-tuple:</li>
|
|
|
|
<blockquote>
|
|
<li>
|
|
wxValues : numerical grid of byte values</li>
|
|
|
|
<li>
|
|
keys : list of "strings" where the index of the string corresponds to the
|
|
byte value in the wxValues grid.</li>
|
|
</blockquote>
|
|
|
|
<li>
|
|
query -- a text string representing a query</li>
|
|
|
|
<li>
|
|
isreg -- if 1, the query is treated as a regular expression, otherwise
|
|
as a literal string</li>
|
|
</blockquote>
|
|
</body>
|
|
</html>
|