awips2/cave/com.raytheon.viz.gfe/help/SmartInitExercises.html
root 133dc97f67 Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 06a8b51d6d [formerly 9f19e3f712 [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]
Former-commit-id: 9f19e3f712
Former-commit-id: a02aeb236c
2012-01-06 08:55:05 -06:00

438 lines
12 KiB
HTML

<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta content="text/html; charset=iso-8859-1"
http-equiv="Content-Type">
<meta
content="Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2smp i686) [Netscape]"
name="GENERATOR">
</head>
<body>
<h1>
Smart Initialization Exercises</h1>
May 14, 2004<br>
<hr style="width: 100%; height: 2px;"><br>
<br>
Performing these steps in an operational environment will mess up your
guidance.&nbsp; You should only perform these on an non-operational
setup.
<p>If you run out of time, please be sure to <a href="#cleanup">clean
up
your system</a> for the next participant.
</p>
<p><a href="#Exercise1">Exercise 1. Override the NAM algorithm for
Temperature</a>
<br>
<a href="#Exercise2">Exercise 2. Adding a new weather element and
algorithm</a>
<br>
<a href="#cleanup">Clean up the system</a>
<br>
<a href="#Answers">Answers</a>
<br>
&nbsp;
<br>
</p>
<hr width="100%">
<h2><a name="Exercise1"></a>Exercise 1. Override the NAM algorithm for
Temperature</h2>
The purpose of this exercise is to learn how to override existing
algorithms.&nbsp;
We will try three different examples.&nbsp; The first example will
simply
set the T to 32 degrees everywhere as a verification step to ensure
that
you have changed the algorithm correctly.
<br>
&nbsp;
<h3><a name="1a"></a>1a)&nbsp;Set the NAM algorithm for Temperature to
T=32</h3>
Create a new file in etc/SITE called MyNAM12.py.&nbsp; This will be
your
override file.&nbsp; Perhaps the best way to create this file is to
copy
the original etc/BASE/smartInit/NAM12.py into etc/SITE/MyNAM12.py and then modify
it.&nbsp;
Strip out all of the functions in the class except the calcT(), since
that
is the function we will be overriding.&nbsp; Refer to the documentation
on overriding a class -- you will need to make additional changes to
the
header of the file, the constructor, and the main declaration at the
bottom
of the class.
<p>Change the calcT() function to simply set an entire grid to
32.&nbsp;
Note you cannot simply set T=32, you need to create a numerical grid
first
of zeros, and then add 32 to it.
</p>
<p>Save your file.&nbsp; Run smart init by hand using the appropriate
command,
similar to this, from the bin directory:
<br>
<tt>ifpInit -t 20011117_1200 -a MyNAM</tt>
</p>
<p>Look at the NAM T grids on the GFE, did they get changed to the
constant
32 value?
</p>
<p><a href="#answer1a">Answers for exercise 1a</a>
<br>
&nbsp;
</p>
<h3><a name="1b"></a>1b)&nbsp;Set the NAM12 algorithm to use the 2m
Temperatures
directly</h3>
Modify your previously created MyNAM12.py.&nbsp; Change the algorithm
to
use the 2m temperatures (t_FHAG2).&nbsp; Don't forget that you want
degrees
Fahrenheit and the model has temperatures in Kelvin.
<p>Save your file. Run smart init by hand. Verify that the grids did
get
changed.
</p>
<p><a href="#answer1b">Answers for exercise 1b</a>
<br>
&nbsp;
</p>
<h3><a name="1c"></a>1c)&nbsp;Correct your algorithm for model and real
topographical
differences</h3>
Modify your previously created MyNAM12.py.&nbsp; Change the algorithm
to
use a fixed lapse rate based on the standard atmosphere.&nbsp; We will
assume 6.0 degrees Celsius per kilometer.&nbsp; Your topo and stopo
fields
are in meters, the t_FHAG2 is in degrees Kelvin.&nbsp; Don't forget to
convert the answer to Fahrenheit.
<p>Save your file.&nbsp; Run smart init by hand.&nbsp; Verify that the
grids did get changed.
</p>
<p><a href="#answer1c">Answers for exercise 1c</a>
<br>
&nbsp;
</p>
<h3><a name="1d"></a>1d)&nbsp;Putting your new algorithm into operation</h3>
In this exercise, we will be putting your new algorithm into operation
and verifying the correct steps have been made.&nbsp; Normally you will
need to stop the ifpServer, edit the localConfig.py file, change the
set
of INITMODULES to use your new MyNAM12, then restart the server.&nbsp;
Since
you really wouldn't see any changes until the next model run, before
you
restart your server, you should manually delete all NAM12 databases
under
release/data/databases/BASE/GRID/NAM12.
<p>Start the server, bring up the GFE, call up the NAM12 T grids.&nbsp;
When
smart init runs your module, the T grids should appear.
</p>
<p>To clean up the system, stop the ifpServer, remove the
localConfig.py
INITMODULES entry, and remove your MyNAM12.py* files from the etc/SITE
directory,
purge the grids again from the release/data/databases/BASE/GRID/NAM12
directory,
and restart the ifpServer.
</p>
<p><a href="#answer1d">Answers for exercise 1d</a>
<br>
&nbsp;
<br>
&nbsp;
</p>
<p></p>
<hr width="100%">
<h2><a name="Exercise2"></a>Exercise 2)&nbsp;Adding a new weather
element and
algorithm</h2>
In this exercise, we will be adding a new weather element to the NAM12
database,
called DewPointDepression, and then defining a new algorithm to
automatically
create it.&nbsp; Since this is a new element, you first must create the
localConfig.py entry to add the weather element.
<br>
&nbsp;
<h3><a name="2a"></a>2a) Define your new weather element.</h3>
<p><br>
Add the Dew&nbsp;Point Depression with the following characteristics
to your localConfig.py:
<br>
DPD =&nbsp;&nbsp;&nbsp; ("TdD", SCALAR, "F", "Dew Point Depression",
50, 0, 0)
</p>
<p>Be sure to identify this as a new parm for the NAM12 model.&nbsp;
Hint:&nbsp;parmsNAM12
is the variable name you need for your parm grouping.&nbsp; Set the
time
constraint to TC6, since the NAM12 comes in every 6 hours.
</p>
<p>Stop the ifpServer, then restart it.&nbsp; Bring up the GFE to
verify
that there is now a Dew Point Depression weather element in the NAM
database.<a href="#answer2a"></a>
</p>
<p><a href="#answer2a">Answers for exercise 2a</a>
<br>
&nbsp;
</p>
<h3><a name="2b"></a>2b)&nbsp;Create your algorithm and test it.</h3>
Create or modify the MyNAM12.py file in etc/SITE.&nbsp; You may leave
in
your calcT() from exercise #1 if desired.&nbsp; Add a new calc function
for Dew Point Depression.&nbsp; The equation is basically T - Td.&nbsp;
You can choose to calculate T-Td in one of two ways:
<ul>
<li>use the T and Td from the output IFP&nbsp;NAM12 database</li>
<li>use the t_FHAG2 from the input D2D&nbsp;NAM12 database, and then
calculate
dew point from the t_FHAG2 and rh_FHAG2.</li>
</ul>
Save your file.&nbsp; Run smart init by hand using the appropriate
command,
similar to this, from the bin directory:
<br>
<tt>ifpInit -t 20011117_1200 -a MyNAM12</tt>
<p>Look at the NAM dew point depression grids, compare with the T and
Td
grids with the sample tool to make sure you have done the equation
correctly.
</p>
<p><a href="#answer2b">Answers for exercise 2b</a>
</p>
<p></p>
<hr width="100%">
<h2><a name="cleanup"></a>Clean up your system</h2>
To clean up the system, stop the ifpServer, remove the localConfig.py
INITMODULES
and dew point depression entries, and remove your MyNAM12.py* files
from
the etc/SITE directory, purge the grids again from the
release/data/databases/BASE/GRID/NAM12
directory, and restart the ifpServer.
<br>
<hr width="100%">
<h2><a name="Answers"></a>Answers</h2>
<h3>
<a name="answer1a"></a>Answer for Exercise 1a</h3>
<tt>from NAM12 import *</tt>
<p><tt>class MyNAM12Forecaster(NAM12Forecaster):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; def __init__(self):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAM12Forecaster.__init__(self)</tt>
</p>
<p><tt>&nbsp;&nbsp;&nbsp; def calcT(self, t_FHAG2):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t = self._empty +&nbsp;32</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return t</tt>
<br>
<tt></tt>&nbsp;<tt></tt>
</p>
<p><tt>def main():</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; MyNAM12Forecaster().run()</tt>
</p>
<p><tt>if __name__ == "__main__":</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; main()</tt>
<br>
&nbsp;
<br>
&nbsp;
</p>
<h3><a name="answer1b"></a>Answer for Exercise 1b</h3>
<p><br>
<tt>from NAM12 import *</tt>
</p>
<p><tt>class MyNAM12Forecaster(NAM12Forecaster):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; def __init__(self):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAM12Forecaster.__init__(self)</tt>
</p>
<p><tt>&nbsp;&nbsp;&nbsp; def calcT(self, t_FHAG2):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.KtoF(t_FHAG2)</tt><tt></tt>
</p>
<p><tt>def main():</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; MyNAM12Forecaster().run()</tt>
</p>
<p><tt>if __name__ == "__main__":</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; main()</tt>
<br>
&nbsp;
<br>
&nbsp;
</p>
<h3><a name="answer1c"></a>Answer for Exercise 1c</h3>
<tt>from NAM12 import *</tt>
<p><tt>class MyNAM12Forecaster(NAM12Forecaster):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; def __init__(self):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAM12Forecaster.__init__(self)</tt>
</p>
<p><tt>&nbsp;&nbsp;&nbsp; def calcT(self, t_FHAG2, topo, stopo):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elevDiff = topo - stopo</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t = t_FHAG2
-&nbsp;(elevDiff
*&nbsp;6.0 / 1000)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.KtoF(t)</tt><tt></tt>
</p>
<p><tt>def main():</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; MyNAM12Forecaster().run()</tt>
</p>
<p><tt>if __name__ == "__main__":</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; main()</tt>
<br>
<tt></tt>&nbsp;
<br>
&nbsp;
<br>
&nbsp;
<br>
&nbsp;
</p>
<h3><a name="answer1d"></a>Answer for Exercise 1d</h3>
Entry in localConfig.py:
<p><tt>from serverConfig import *</tt>
<br>
<tt>import serverConfig</tt><tt></tt>
</p>
<p><tt>serverConfig.INITMODULES["MyNAM12"] = ["NAM12"]</tt>
<br>
<tt>del serverConfig.INITMODULES["NAM12"]</tt>
<br>
<tt></tt>&nbsp;
<br>
&nbsp;
</p>
<h3><a name="answer2a"></a>Answer for Exercise 2a</h3>
Entry in localConfig.py:
<p><tt>from serverConfig import *</tt>
<br>
<tt>import serverConfig</tt><tt></tt>
</p>
<p><tt>DPD =&nbsp;&nbsp;&nbsp; ("TdDepression", SCALAR, "F", "Dew Point
Depression", 50, 0, 0)</tt>
<br>
<tt>parmsNAM12 = [([DPD], TC6)]</tt>
<br>
<tt></tt>&nbsp;
<br>
<tt></tt>&nbsp;
<br>
<tt></tt>&nbsp;
</p>
<h3><a name="answer2b"></a>Answer for Exercise 2b</h3>
<tt>from NAM12 import *</tt>
<p><tt>class MyNAM12Forecaster(NAM12Forecaster):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; def __init__(self):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAM12Forecaster.__init__(self)</tt>
</p>
<p><tt>&nbsp;&nbsp;&nbsp; def calcTdD(self, T, Td):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return T-Td</tt><tt></tt>
</p>
<p><tt>def main():</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; MyNAM12Forecaster().run()</tt>
</p>
<p><tt>if __name__ == "__main__":</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; main()</tt><tt></tt>
</p>
<p>The alternative form, where you use the t_FHAG2 and rh_FHAG2 would
be
the following.&nbsp; Note that this method will not take advantage of
any
topographical corrections you have made in the temperatures:<tt></tt>
</p>
<p><tt>from NAM12 import *</tt>
</p>
<p><tt>class MyNAM12Forecaster(NAM12Forecaster):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; def __init__(self):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAM12Forecaster.__init__(self)</tt>
</p>
<p><tt>&nbsp;&nbsp;&nbsp; def calcTdD(self, t_FHAG2, rh_FHAG2):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; td = getTd(t_FHAG2,
rh_FHAG2)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; depression = t_FHAG2
- td</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return depression
*&nbsp;9.0
/ 5.0</tt><tt></tt>
</p>
<p><tt>&nbsp;&nbsp;&nbsp; def getTd(self, t, rh):</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # input/output in
degrees
K.</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; desat = clip(t, 0,
373.15)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; desat = where(less(t,
173.15), 3.777647e-05, t)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; desat = exp(26.660820
- desat * 0.0091379024 - 6106.3960 / desat)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; desat = desat * rh /
100.0</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; desat = 26.66082 -
log(desat)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; td = (desat -
sqrt(desat*desat-223.1986))/0.0182758048</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; td = where(greater(td,
t), t, td)</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return td</tt>
<br>
<tt></tt>&nbsp;
<br>
<tt></tt>&nbsp;<tt></tt>
</p>
<p><tt>def main():</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; MyNAM12Forecaster().run()</tt>
</p>
<p><tt>if __name__ == "__main__":</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp; main()</tt><tt></tt>
</p>
<p></p>
<hr width="100%"><br>
&nbsp;
<br>
&nbsp;
</body>
</html>