23 from init
import Oceanini, fbtr, g3, na, pget, prun, phase, psend
24 from util
import dateplushours, ysplitter, logi2int, jn2r
26 from track
import get_vitals, track_shorten
27 from exceptions
import *
34 oinit_d = {
"transatl":
"GDEM",
"eastpac":
"GDEM",
"westpac":
"GDEM",
35 "northind":
"GDEM",
"southind":
"GDEM",
"swpac":
"GDEM",
36 "sepac":
"GDEM",
"southatl":
"GDEM"}
40 odata_d = {
"L":(
"fbtr",
"natr",
"idtr"),
"E":(
"g3ep",
"naep",
"idep"),
41 "W":(
"g3wp",
"nawp",
"idwp"),
"A":(
"g3ni",
"nani",
"idni"),
42 "S":(
"g3si",
"nasi",
"idsi"),
"P":(
"g3sw",
"nasw",
"idsw"),
43 "X":(
"g3se",
"nase",
"idse"),
"C":(
"g3ep",
"naep",
"idep"),
44 "O":(
"g3wp",
"nawp",
"idwp"),
"B":(
"g3ni",
"nani",
"idni"),
45 "U":("g3sw","nasw","idsw"), "T":("g3wp","nawp","idwp"),
46 "Q":(
"g3sa",
"nasa",
"idsa")}
50 domain_d = {
"L":
"transatl",
"E":
"eastpac",
"W":
"westpac",
51 "A":
"northind",
"S":
"southind",
"P":
"swpac",
52 "X":
"sepac",
"C":
"eastpac",
"O":
"westpac",
53 "B":
"northind",
"U":"swpac", "T":"westpac",
56 def run_init(STORMNAME,STORMID,STARTDATE,
57 EXEChwrf,PARMhwrf,FIXhwrf,VITDIR,GFSDIR,
58 LCDIR,CSTREAM,COMIN,init_method=
None,logger=
None,
59 fcstlen=
None,outstep=
None,sync_frequently=
False,
61 """!Run the ocean initialization.
63 This is a wrapper around the pom.init module that selects the
64 right ocean initialization for the chosen basin and delivers the
65 output to the specified location.
67 @param STORMNAME Upper-case storm name for filenames (KATRINA)
68 @param STORMID Three character storm number and basin, upper-case (12L)
69 @param STARTDATE Simulation analysis time as a string, YYYYMMDDHH (2005082918)
70 @param EXEChwrf Directory with HWRF executables.
71 @param PARMhwrf Directory with HWRF parameter files.
72 @param FIXhwrf Directory with HWRF fixed files.
73 @param GFSDIR Directory with input files from GFS.
74 @param LCDIR Directory with loop current files
75 @param CSTREAM Directory to place files for the POM forecast to read.
76 @param COMIN HWRF final output directory.
77 @param sync_frequently If True, "sync" is run frequently
78 @param init_method The string name of the initialization method to
79 use. If this is unspecified, a suitable default is chosen. Allowed values: GDEM, NCODA.
81 @param logger a logging.Logger for log messages
83 @param fcstlen forecast length in hours
84 @param outstep output frequency in seconds (an integer)
86 @param kwargs Additional keyword arguments are passed to Oceanini subclass constructors."""
87 assert(GFSDIR.find(
'pom/output')<0)
88 sync_frequently=bool(sync_frequently)
89 if logger
is None: logger=logging.getLogger(
'pom')
90 if fcstlen
is None: fcstlen=126
91 if outstep
is None: outstep=86400
92 if outstep<540: outstep=540
95 (y4,mm,mm1,dd,hh)=ysplitter(STARTDATE)
96 BASIN=STORMID[2].upper()
99 DOMAIN = domain_d[BASIN]
100 if init_method
is None: init_method=oinit_d[domain_d[BASIN]]
101 if init_method ==
'GDEM':
105 ODATA = odata_d[BASIN][0]
106 prep = fbtr(
"OCEAN",DOMAIN,ODATA, SSTASIM,STORMNAME,STORMID,STARTDATE,
107 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
108 sync_frequently=sync_frequently,**kwargs)
109 elif init_method ==
'NCODA':
113 ODATA = odata_d[BASIN][1]
114 prep = na(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
115 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
116 sync_frequently=sync_frequently,**kwargs)
118 msg=(
"%s:ODATA is NOT Supported" %(oinit_d[domain_d[BASIN]]))
121 (DATA,DATA1) = prep.setpath()
124 infiles.getinp(prep,DATA)
126 if not runexes.setrun(prep,DATA):
127 msg=
'setrun failed for L domain prep'
130 elif BASIN ==
"E" or BASIN ==
"C":
132 DOMAIN = domain_d[BASIN]
133 if init_method
is None: init_method=oinit_d[domain_d[BASIN]]
134 if init_method ==
'GDEM':
138 ODATA = odata_d[BASIN][0]
139 prep = g3(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
140 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
141 sync_frequently=sync_frequently,**kwargs)
142 elif init_method ==
'NCODA':
146 ODATA = odata_d[BASIN][1]
147 prep = na(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
148 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
149 sync_frequently=sync_frequently,**kwargs)
151 msg=(
"%s:ODATA is NOT Supported" %(oinit_d[domain_d[BASIN]]))
154 (DATA,DATA1) = prep.setpath()
157 infiles.getinp(prep,DATA)
159 if not runexes.setrun(prep,DATA):
160 msg=
'setrun failed for E domain prep'
163 elif BASIN
in (
"W",
"A",
"S",
"P",
"X",
"O",
"B",
"U", "T", "Q"):
165 DOMAIN = domain_d[BASIN]
166 if init_method
is None: init_method=oinit_d[domain_d[BASIN]]
167 if init_method ==
'GDEM':
171 ODATA = odata_d[BASIN][0]
172 prep = g3(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
173 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
174 sync_frequently=sync_frequently,**kwargs)
175 elif init_method ==
'NCODA':
179 ODATA = odata_d[BASIN][1]
180 prep = na(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
181 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
182 sync_frequently=sync_frequently,**kwargs)
184 msg=(
"%s:ODATA is NOT Supported" %(oinit_d[domain_d[BASIN]]))
187 (DATA,DATA1) = prep.setpath()
190 infiles.getinp(prep,DATA)
192 if not runexes.setrun(prep,DATA):
193 msg=
'setrun failed for W/A/S/P/X/O/B/U/T/Q domain prep'
197 msg=(
"%s : Domain is NOT Supported" %(STORMID))
201 diag = phase(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
202 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
203 sync_frequently=sync_frequently,**kwargs)
204 (DATA,DATA1) = diag.setpath(
"PHASE1")
206 namelst(
"'MPIPOM-TC:"+STORMNAME+STORMID+
"'", STORMNAME,
207 "'"+y4+
"-"+mm+
"-"+dd+
" "+hh+
":00:00 +00:00'",0,
208 "'restart.phase0.nc'",2.0,2.0,prtd1,3,0.,logi2int(GEOVEL),NL)
210 infiles.getinp(diag,DATA1)
211 if not runexes.setrun(diag,DATA1):
212 msg=
'setrun failed for diag'
216 prog = phase(
"OCEAN",DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,
217 EXEChwrf,PARMhwrf,FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
218 sync_frequently=sync_frequently,**kwargs)
219 ymdh = dateplushours(ymdh, -72)
220 (DATA,DATA2) = prog.setpath(
"PHASE2")
221 (y4,mm,mm1,dd,hh)=ysplitter(ymdh)
222 namelst(
"'MPIPOM-TC:"+STORMNAME+STORMID+
"'", STORMNAME,
223 "'"+y4+
"-"+mm+
"-"+dd+
" "+hh+
":00:00 +00:00'",1,
224 "'restart.phase1.nc'",3.0,3.0,prtd1,1,9999.,logi2int(GEOVEL),NL)
226 if outfiles.sendout(diag,DATA1,
"restart.0001.nc",DATA2,
"restart.phase1.nc"):
227 vitfile = jn2r(VITDIR,
"syndat_tcvitals." + y4)
228 trackfile = jn2r(DATA2,
"track.full")
229 trackshort = jn2r(DATA2,
"track")
230 nvit = get_vitals(vitfile, CENTERID, STORMID, y4,trackfile)
231 nvit = track_shorten(trackfile,trackshort,STARTDATE)
233 infiles.getinp(prog,DATA2)
234 if runexes.setrun(prog,DATA2):
235 outfiles.sendout(prog,DATA2,
"restart.0001.nc",DATA,
"restart.phase2.nc")
237 outfiles.sendout(prog,DATA2,
"restart.phase1.nc",DATA,
"restart.phase2.nc")
239 outfiles.sendout(prog,DATA2,
"restart.phase1.nc",DATA,
"restart.phase2.nc")
247 (y4,mm,mm1,dd,hh)=ysplitter(STARTDATE)
248 namelst(
"'MPIPOM-TC:"+STORMNAME+STORMID+
"'", STORMNAME,
249 "'"+y4+
"-"+mm+
"-"+dd+
" "+hh+
":00:00 +00:00'",1,
250 "'restart.phase2.nc'",9999.,fcstlen/24.,prtd1,1,9999.,logi2int(GEOVEL),NL)
254 def main(STORMNAME, STORMID, STARTDATE,fcstlen=None):
255 """!Main program for testing the POM initialization outside of the HWRF workflow.
257 @warning Has many hard-coded paths that will need to be changed.
258 @param STORMNAME Upper-case storm name for filenames (KATRINA)
259 @param STORMID Three character storm number and basin, upper-case (12L)
260 @param STARTDATE Simulation analysis time as a string, YYYYMMDDHH (2005082918)
261 @param fcstlen forecast length in hours """
262 EXEChwrf =
"/mnt/pan2/projects/hur-uri/Biju.Thomas/trunk/exec/"
263 PARMhwrf =
"/mnt/pan2/projects/hur-uri/Biju.Thomas/parm/"
264 FIXhwrf =
"/mnt/pan2/projects/hur-uri/Biju.Thomas/fix/"
266 VITDIR =
"/mnt/lfs1/projects/hwrf-vd/hwrf-input/SYNDAT/"
267 GFSDIR =
"/pan2/projects/hur-uri/Biju.Thomas/ptmp/Biju.Thomas/./DATA/OCEAN/gfs."+STARTDATE+
'/'+STARTDATE
268 LCDIR =
"/mnt/lfs1/projects/hwrf-vd/hwrf-input/LOOP-CURRENT/"
269 LCDIR =
"/lfs1/projects/hwrf-vd/fix-files/hwrf-20130917-fix/fix/loop_curr/"
270 CSTREAM =
"/mnt/pan2/projects/hur-uri/Biju.Thomas/ptmp/Biju.Thomas/hwrf"+\
271 "/"+STARTDATE+
"/"+STORMID.lower()+
"/"+STORMNAME.upper()+\
273 COMIN =
"/mnt/pan2/projects/hur-uri/Biju.Thomas/ptmp/Biju.Thomas/hwrf/com/"+\
274 STARTDATE+
"/"+STORMID.lower()+
"/"
275 return run_init(STORMNAME,STORMID,STARTDATE,
276 EXEChwrf,PARMhwrf,FIXhwrf,VITDIR,GFSDIR,
277 LCDIR,CSTREAM,COMIN,fcstlen)
def main
Main program for testing the POM initialization outside of the HWRF workflow.
Raised when an unsupported basin is requested.
Raised when an impossible configuration is requested, such as an unsupported tropical basin...
def run_init(STORMNAME, STORMID, STARTDATE, EXEChwrf, PARMhwrf, FIXhwrf, VITDIR, GFSDIR, LCDIR, CSTREAM, COMIN, init_method=None, logger=None, fcstlen=None, outstep=None, sync_frequently=False, kwargs)
Run the ocean initialization.
Raised when a POM initialization program unexpectedly fails.