If you run out of time, please be sure to clean up your system for the next participant.
Exercise 1. Override the NAM algorithm for
Temperature
Exercise 2. Adding a new weather element and
algorithm
Clean up the system
Answers
Change the calcT() function to simply set an entire grid to 32. Note you cannot simply set T=32, you need to create a numerical grid first of zeros, and then add 32 to it.
Save your file. Run smart init by hand using the appropriate
command,
similar to this, from the bin directory:
ifpInit -t 20011117_1200 -a MyNAM
Look at the NAM T grids on the GFE, did they get changed to the constant 32 value?
Save your file. Run smart init by hand. Verify that the grids did get changed.
Save your file. Run smart init by hand. Verify that the grids did get changed.
Start EDEX, bring up the GFE, call up the NAM12 T grids. When smart init runs your module, the T grids should appear.
To clean up the system, stop EDEX, remove the localConfig.py INITMODULES entry, and remove your MyNAM12.py* files from the /release/edex/data/utility/edex_static/site/SITE/smartinit directory, purge the grids again from the release/edex/data/hdf5/gfe/NAM12 directory; then connect to the metadata database and issue SQL "delete from gfe where dbid like '%NAM12%';". Finally, restart EDEX.
Add the DewPointDepression with the following characteristics
to your localConfig.py:
DPD = ("TdD", SCALAR, "F", "Dew Point Depression",
50, 0, 0)
Be sure to identify this as a new parm for the NAM12 model. Hint: parmsNAM12 is the variable name you need for your parm grouping. Set the time constraint to TC6, since the NAM12 comes in every 6 hours.
Stop EDEX, then restart it. Bring up the GFE to verify that there is now a Dew Point Depression weather element in the NAM database.
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.
class MyNAM12Forecaster(NAM12Forecaster):
def __init__(self):
NAM12Forecaster.__init__(self)
def calcT(self, t_FHAG2):
t = self._empty + 32
return t
def main():
MyNAM12Forecaster().run()
from NAM12 import *
class MyNAM12Forecaster(NAM12Forecaster):
def __init__(self):
NAM12Forecaster.__init__(self)
def calcT(self, t_FHAG2):
return self.KtoF(t_FHAG2)
def main():
MyNAM12Forecaster().run()
class MyNAM12Forecaster(NAM12Forecaster):
def __init__(self):
NAM12Forecaster.__init__(self)
def calcT(self, t_FHAG2, topo, stopo):
elevDiff = topo - stopo
t = t_FHAG2
- (elevDiff
* 6.0 / 1000)
return self.KtoF(t)
def main():
MyNAM12Forecaster().run()
from serverConfig import *
import serverConfig
serverConfig.INITMODULES["MyNAM12"] = ["NAM12"]
del serverConfig.INITMODULES["NAM12"]
from serverConfig import *
import serverConfig
DPD = ("TdDepression", SCALAR, "F", "Dew Point
Depression", 50, 0, 0)
parmsNAM12 = [([DPD], TC6)]
class MyNAM12Forecaster(NAM12Forecaster):
def __init__(self):
NAM12Forecaster.__init__(self)
def calcTdD(self, T, Td):
return T-Td
def main():
MyNAM12Forecaster().run()
The alternative form, where you use the t_FHAG2 and rh_FHAG2 would be the following. Note that this method will not take advantage of any topographical corrections you have made in the temperatures:
from NAM12 import *
class MyNAM12Forecaster(NAM12Forecaster):
def __init__(self):
NAM12Forecaster.__init__(self)
def calcTdD(self, t_FHAG2, rh_FHAG2):
td = getTd(t_FHAG2,
rh_FHAG2)
depression = t_FHAG2
- td
return depression
* 9.0
/ 5.0
def getTd(self, t, rh):
# input/output in
degrees
K.
desat = clip(t, 0,
373.15)
desat = where(less(t,
173.15), 3.777647e-05, t)
desat = exp(26.660820
- desat * 0.0091379024 - 6106.3960 / desat)
desat = desat * rh /
100.0
desat = 26.66082 -
log(desat)
td = (desat -
sqrt(desat*desat-223.1986))/0.0182758048
td = where(greater(td,
t), t, td)
return td
def main():
MyNAM12Forecaster().run()