HWRF  trunk@4391
init.py
1 """!Combines Tasks from multiple modules into a single initialization object.
2 
3 This class combines Tasks from several hwrf modules to make two
4 different initialization systems: the InitBeforeGSI and the HWRFInit.
5 Also, the FGATInit is provided, which is an array of InitBeforeGSI,
6 one per FGAT time."""
7 
8 ##@var __all__
9 # Symbols exported by "from hwrf.init import *"
10 __all__=['HWRFInit','InitBeforeGSI','FGATInit']
11 
12 import os, datetime, pdb
17 
18 from produtil.run import alias, exe
19 from hwrf.hwrftask import HWRFTask
20 from hwrf.numerics import to_datetime_rel, to_timedelta, to_datetime, \
21  TimeMapping, to_fraction
22 from hwrf.regrib import clatlon
23 from hwrf.exceptions import NoSuchDomain, GribberError
24 
25 ########################################################################
27  """!Runs the deterministic model initialization.
28 
29  This class runs the WPS, real, prep_hybrid (if enabled), WRF
30  wrfanl and ghost jobs, and runs the tracker to find the parent
31  vortex. Passes that into the relocation (if enabled) to produce
32  the final vortex. It encapsulates that logic within one top-level
33  wrapper object, and provides a way to run several parts of the
34  initialization from a single function call."""
35 
36  ##@var outdir
37  # Output directory for the initialization. Individual components
38  # will be in subdirectories.
39 
40  ##@var ibdystep
41  # Timestep between boundary information for the 1 minute forecast
42 
43  ##@var ghost_domains
44  # List of ghost domains as hwrf.wrf.WRFDomain objects
45 
46  ##@var relocation
47  # The hwrf.relocation.Relocation group of tasks
48 
49  ##@var rstage1
50  # The hwrf.relocation.Stage1 task
51 
52  ##@var rstage2
53  # The hwrf.relocation.Stage2 task
54 
55  ##@var rstage3
56  # The hwrf.relocation.Stage3 task
57 
58  def _subworkdir(self,childname):
59  """!Helper function for constructor workdir arguments.
60 
61  Generates a workdir location for input to an HWRFTask
62  constructor by appending the child name as a new directory
63  path component after self.workdir.
64  @param childname the child task name"""
65  dir=os.path.join(self.workdir,childname)
66  return dir
67 
68  def _suboutdir(self,childname):
69  """!Helper function for constructor outdir arguments.
70 
71  Generates a outdir location for input to an HWRFTask
72  constructor by appending the child name as a new directory
73  path component after self.outdir.
74  @param childname the child task name"""
75  dir=os.path.join(self.outdir,childname)
76  return dir
77 
78  def __init__(self,ds,conf,section, wrf,initlen,fcstlen,outdir=None,
79  realfcst=False,wrfghost=None,prep=True,track=True,
80  in_ftime=None,in_atime=None,geogrid=None,
81  prep_one_time=None,relocate=True,modin=None,
82  ibdystep=None,fgat_times=None,prepfcst=None,**kwargs):
83  """!HWRFInit constructor.
84 
85  Creates the deterministic HWRF initialization. Which pieces
86  are selected, and how they are plugged in to one another, is
87  dependent on the input arguments.
88 
89  @param ds passed to Datum: the Datastore object for this Task
90  @param conf the conf object for this task
91  @param section the conf section for this task
92  @param wrf (required) the WRFSimulation representing the full WRF
93  forecast
94  @param initlen (required) the length of the real_nmm run for the
95  initialization
96  @param fcstlen (required) the length of the real_nmm run for the
97  full forecast
98  @param outdir The directory in intercom to receive output.
99  Default: intercom/{taskname}. Individual initialization
100  components will be in subdirectories.
101  @param realfcst Flag: do we need to run real for the full forecast
102  length?
103  @param wrfghost hwrf.wrf.WRFSimulation object for the wrfghost
104  files. If absent, no wrfghost-related jobs will be run
105  @param prep if True, use prep_hybrid input. This changes the way
106  in which real_nmm, ungrib and metgrid are run.
107  @param prepfcst If True AND prep=True, use prep_hybrid for
108  boundary conditions. This changes how realfcst, ungribfcst
109  and metgridfcst are run.
110  @param track Run a post, regribber and tracker on the wrfanl
111  history file for domain 1, to find the location of the
112  parent vortex.
113  @param in_ftime parent model forecast hour to treat as "time 0."
114  This is used for the FGAT to use GDAS forecasts as input
115  @param in_atime parent model analysis time. Default: start time
116  of wrf
117  @param geogrid Should be an hwrf.wps.Geogrid, or None. This is
118  used to avoid running expensive geogrid jobs multiple times
119  for multiple FGAT hours. (This is especially important for
120  hourly FGAT.) If None or missing, a Geogrid is created.
121  @param prep_one_time Flag. If True, pretend hour 0 is also
122  hour 1, 2, 3, and so on. This is only used by prep_hybrid,
123  and is intended to prevent expensive spectral to grid
124  transformations of hour 3 when only the analysis time is
125  needed from WRF.
126  @param relocate If True, vortex relocation is performed.
127  @param modin The modin argument to hwrf.relocate task constructors.
128  Default: in_dataset.upper()
129  @param ibdystep Optional: the boundary input frequency for the
130  ~1 minute forecasts. Default: bdystep.
131  @param fgat_times: the times at which FGAT is run.
132  @param kwargs Passed to hwrf.hwrftask.HWRFTask.__init__
133 
134  @note If "in_dataset" is in kwargs, it is the option sent to
135  hwrf.input.DataCatalog.locate used for obtaining input files
136  for Ungrib and PrepHybrid.
137 
138  ----------------------------------------------------------
139 
140  This constructor creates the following public member variables
141  or accessors. These are intended to be used to query various
142  components of the initialization. The scripting layer can run
143  the sub-objects via their run methods, or it can simply call
144  the self.run_* subroutines to run them in groups.
145 
146  Reference variables:
147  initlen -- timedelta for length of initialization
148  fcstlen -- timedelta for length of forecast
149  wrffcst -- Task for running or monitoring the WRF forecast
150  wrfdoms -- WRFDomain objects from that wrffcst object
151  wrfinit -- Task for running the wrfanl run of WRF
152  bdytimes -- an array of boundary times needed by the forecast run
153  ibdytimes -- an array of boundary times needed by the init
154  run of wrf
155 
156  Initialization-Length WRF Init:
157  geogrid -- the hwrf.wps.Geogrid object for running geogrid.exe
158  external_geogrid -- if a geogrid argument was sent to the
159  constructor, it is stored here
160  ungrib -- the hwrf.wps.Ungrib object for running ungrib
161  metgrid -- the hwrf.metgrid.Metgrid object for running metgrid
162  realinit -- the hwrf.fcsttask.RealNMM object for running real
163  for the WRF init jobs
164  runwrfanl -- the hwrf.fcsttask.WRFAnl4Trak object used to run
165  the WRF for to produce the wrfanl files and outer domain
166  time 0 wrfout file
167  wrfghost -- the WRFSimulation representing the ghost if
168  requested. This is the same as the wrfghost argument to
169  the constructor
170  runghost -- the hwrf.fcsttask.WRFGhost to run the ghost
171  if requested.
172 
173  Prep Hybrid:
174  prep -- the hwrf.prep.PrepHybrid object to run prep_hybrid.
175  The same prep object is used for both the init-length and
176  fcst-length initialization.
177 
178  Forecast-Length WRF Init:
179  ungribfcst -- the hwrf.wps.Ungrib object for running ungrib for
180  the full WRF forecast job, if prep=False
181  metgridfcst -- the hwrf.wps.Metgrid object for running metgrid
182  for the full WRF forecast job if prep=False
183  realfcst -- the hwrf.fcsttask.RealNMM object
184 
185  Parent domain vortex detection:
186  post -- if track=True, this is the hwrf.post.PostOneWRF
187  object used to post-process the wrfanl job's time 0 outer
188  domain wrfout file
189  gribber -- the hwrf.gribtask.GRIBTask object used to
190  regrib the output of self.post
191  tracker -- the hwrf.tracker.TrackerTask object used to
192  run the tracker on the gribber
193  """
194  super(HWRFInit,self).__init__(ds,conf,section,**kwargs)
195  self._prepfcst=bool(prepfcst)
196  if prepfcst and not prep:
197  raise NotImplementedError(
198  'When running prep_hybrid for boundary conditions, you '
199  'must also run it for initial conditions.')
200  if prep_one_time is None: prep_one_time=not prepfcst
201  self._prepfcst=prepfcst
202  so=self._suboutdir
203  sw=self._subworkdir
204  logger=self.log()
205  self._fgat_times=fgat_times
206  self.outdir=outdir
207  if outdir is None:
208  self.outdir=os.path.join(self.getdir('intercom'),self.taskname)
209 
210  ds=self.dstore
211  conf=self.conf
212 
213  self.initlen=to_datetime_rel(initlen,wrf.simstart())
214  self.fcstlen=to_datetime_rel(fcstlen,wrf.simstart())
215  assert(ibdystep is not None)
216  if ibdystep is None:
217  ibdystep=self.confint('ibdystep',0)
218  if ibdystep<1: ibdystep=None
219  self.ibdystep=ibdystep
220 
221  self.wrffcst=wrf.copy()
222  self.wrffcst.set_timing(end=self.fcstlen)
223  self.wrfdoms=[ d for d in self.wrffcst ]
224 
225  self.wrfinit=wrf.copy()
226 
227  self.wrfinit.set_timing(end=self.initlen)
228 
229  fwrf=self.wrffcst
230  iwrf=self.wrfinit
231  if ibdystep is not None:
232  self.wrfinit.set_bdystep(ibdystep)
233  moad=fwrf.get_moad()
234  bdytimes=[x for x in fwrf.bdytimes()]
235  self.bdytimes=[ x for x in fwrf.bdytimes() ]
236  self.ibdytimes=[ x for x in iwrf.bdytimes() ]
237 
238  if fwrf.bdystep() != iwrf.bdystep() and prep and realfcst:
239  raise NotImplementedError(
240  'You have asked me to run prep_hybrid to produce full '
241  'simulation length inputs AND you specified different '
242  'boundary input timesteps for the initialization-length '
243  'and forecast-length jobs. I cannot do that. You need '
244  'to either disable realfcst or disable prep_hybrid, or '
245  'use the same boundary input timesteps for forecast-length'
246  ' and initialization-length jobs.')
247 
248  starttime=iwrf.simstart()
249 
250  wpsloc=sw('wps')
251  assert(wpsloc.find(self.taskname+'/'+self.taskname)<0)
252 
253  # Local utility functions for generating conf section and
254  # subtask name
255  def c(s): return self.confstr(s,s)
256  def t(s): return '%s/%s'%(self.taskname,s)
257 
258  # Get additional options for datasets:
259  ungrib_opts=dict()
260  prep_opts=dict()
261  if 'in_dataset' in kwargs:
262  dst=kwargs['in_dataset']
263  ungrib_opts['in_dataset']=dst
264  prep_opts['in_dataset']=dst
265  if modin is None: modin=dst.upper()
266  if 'ungrib_one_time' in kwargs:
267  ungrib_opts['one_time']=bool(kwargs['ungrib_one_time'])
268  if modin is None: modin='GFS'
269 
270  if geogrid is not None:
271  self.external_geogrid=geogrid
272  else:
273  self.geogrid = hwrf.wps.Geogrid(ds, conf, c('geogrid'), fwrf,
274  self.wrfdoms,taskname=t('geogrid'),location=wpsloc,
275  workdir=wpsloc,outdir=so('wps'))
276  geogrid=self.geogrid
277 
278  if prep:
279  if fwrf.bdystep() != iwrf.bdystep():
280  pbdytimes=self.ibdytimes
281  else:
282  pbdytimes=self.bdytimes
283  self.prep = hwrf.prep.PrepHybrid(ds, conf, c('prep_hybrid'), fwrf,
284  geogrid.geodat(moad), times=pbdytimes, taskname=t('prep_hybrid'),
285  ftime=in_ftime,atime=in_atime,one_time=prep_one_time,
286  workdir=sw('prep_hybrid'),outdir=so('prep_hybrid'),**prep_opts)
287  # Tell ungrib and metgrid to run only the first hour:
288  endtime=starttime
289  else:
290  if section == 'gfsinit':
291  endtime=self.initlen
292  else:
293  endtime=starttime
294 
295  self._make_realinit(prep,ds,conf,fwrf,iwrf,endtime,wpsloc,in_atime,
296  in_ftime,ungrib_opts,geogrid,c,t,so,sw)
297 
298  if realfcst:
299  self._make_realfcst(prep,prepfcst,ds,conf,fwrf,fcstlen,wpsloc,
300  in_atime,in_ftime,ungrib_opts,geogrid,
301  c,t,so,sw)
302 
303  self.runwrfanl = hwrf.fcsttask.WRFAnl4Trak(ds, conf, c('wrfanl'), iwrf,
304  taskname=t('wrfanl'), workdir=sw('wrfanl'), outdir=so('wrfanl')) \
305  .add_metgrid(self.metgrid).add_geogrid(geogrid).add_real(self.realinit)
306  if track:
307  self._make_track(ds,conf,moad,starttime,c,t,so,sw)
308  if wrfghost is not None:
309  self._make_ghost(ds,conf,wrfghost,geogrid,c,t,so,sw)
310  if relocate:
311  self._make_relocate(ds,conf,wrfghost,track,modin,c,t,so,sw)
312 
313  def _make_realinit(self,prep,ds,conf,fwrf,iwrf,endtime,wpsloc,in_atime,
314  in_ftime,ungrib_opts,geogrid,c,t,so,sw):
315  """!Makes the ungrib, metgrid and realinit member variables.
316  @param prep True if prep_hybrid is in use
317  @param ds the produtil.datastore.Datastore object
318  @param conf the hwrf.config.HWRFConfig
319  @param fwrf the hwrf.wrf.WRFSimulation for the forecast-length run
320  @param iwrf the hwrf.wrf.WRFSimulation for the init-length run
321  @param endtime the end time of the iwrf
322  @param wpsloc directory in which to run WPS
323  @param in_atime the analysis time for the parent model
324  @param in_ftime the forecast time for the parent model that
325  corresponds to the analysis time of this HWRFInit
326  @param ungrib_opts - dict of keyword arguments to send to the hwrf.wps.Ungrib.__init__
327  @param geogrid the hwrf.wps.Geogrid
328  @param c - function to generate config section names for subtasks
329  @param t - function to generate task names for subtasks
330  @param so - function to generate outdirs for subtasks
331  @param sw - function to generate workdirs for subtasks"""
332  self.ungrib = hwrf.wps.Ungrib(ds, conf, c('ungrib'), fwrf,
333  self.wrfdoms,endtime=endtime, taskname=t('ungrib'),
334  location=wpsloc,in_atime=in_atime,in_ftime=in_ftime,
335  workdir=wpsloc,outdir=so('wps'),**ungrib_opts)
336  self.metgrid = hwrf.wps.Metgrid(ds, conf, c('metgrid'), fwrf,
337  self.wrfdoms,increment=self.ibdystep,endtime=endtime,taskname=t('metgrid'),
338  workdir=wpsloc,outdir=so('wps'),location=wpsloc)
339  self.realinit = hwrf.fcsttask.RealNMM(ds, conf, c('realinit'),
340  iwrf, taskname=t('realinit'),workdir=sw('realinit'),
341  outdir=so('realinit')) \
342  .add_metgrid(self.metgrid).add_geogrid(geogrid)
343  if prep:
344  self.realinit.add_prep_hybrid(self.prep)
345 
346  def _make_realfcst(self,prep,prepfcst,ds,conf,fwrf,fcstlen,wpsloc,
347  in_atime,in_ftime,ungrib_opts,geogrid,c,t,so,sw):
348  """!Makes the ungribfcst, metgridfcst and realfcst member variables:
349  @param prep True if prep_hybrid is in use
350  @param prepfcst True if prep_hybrid is in use for boundary conditions
351  @param ds the produtil.datastore.Datastore object
352  @param conf the hwrf.config.HWRFConfig
353  @param fwrf the WRFSimulation for the forecast-length run
354  @param fcstlen the length of the forecast as a datetime.time_delta
355  @param wpsloc directory in which to run WPS
356  @param in_atime the analysis time for the parent model
357  @param in_ftime the forecast time for the parent model that
358  corresponds to the analysis time of this HWRFInit
359  @param ungrib_opts dict of keyword arguments to send to
360  hwrf.wps.Ungrib.__init__
361  @param geogrid the hwrf.wps.Geogrid
362  @param c function to generate config section names for subtasks
363  @param t function to generate task names for subtasks
364  @param so function to generate outdirs for subtasks
365  @param sw function to generate workdirs for subtasks"""
366  if not prepfcst:
367  self.ungribfcst = hwrf.wps.Ungrib(ds, conf, c('ungrib'), fwrf,
368  self.wrfdoms,endtime=fcstlen, taskname=t('ungribfcst'),
369  location=wpsloc,in_atime=in_atime,in_ftime=in_ftime,
370  outdir=so('wpsfcst'),workdir=wpsloc,**ungrib_opts)
371  self.metgridfcst = hwrf.wps.Metgrid(ds, conf, c('metgrid'), fwrf,
372  self.wrfdoms,endtime=fcstlen, taskname=t('metgridfcst'),
373  outdir=so('wpsfcst'),workdir=wpsloc,location=wpsloc,
374  geogrid_from=self.geogrid)
375  self.realfcst = hwrf.fcsttask.RealNMM(ds, conf, c('realfcst'), fwrf,
376  outdir=so('realfcst'),workdir=sw('realfcst'),
377  taskname=t('realfcst')).add_geogrid(geogrid)
378  if prepfcst:
379  # Need to pull prep_hybrid data, and initial time metgrid:
380  self.realfcst.add_prep_hybrid(self.prep) \
381  .add_metgrid(self.metgrid)
382  else:
383  # Need to pull full forecast metgrid:
384  self.realfcst.add_metgrid(self.metgridfcst)
385 
386  def _make_track(self,ds,conf,moad,starttime,c,t,so,sw):
387  """!Makes the gribber and tracker member variables.
388  @param ds the produtil.datastore.Datastore object
389  @param conf the hwrf.config.HWRFConfig
390  @param moad the hwrf.wrf.WRFDomain for the outermost domain
391  @param starttime the start time of this HWRFInit's WRF simulations
392  @param c function to generate config section names for subtasks
393  @param t function to generate task names for subtasks
394  @param so function to generate outdirs for subtasks
395  @param sw function to generate workdirs for subtasks"""
396 
398  self.runwrfanl,[moad],conf,c('post'),time=starttime,
399  needcrtm=False,taskname=t('post'),outdir=so('post'),
400  workdir=sw('post'))
401 
402  # Regridding stuff:
403  grid1=hwrf.regrib.igrb1(self.post,domain=moad)
405  'part',hwrf.tracker.tracker_subset,None)
406  domloc=hwrf.regrib.FixedLocation(lat=conf['config','domlat'],
407  lon=conf['config','domlon'])
408  stormloc=hwrf.regrib.FixedLocation(lat=self.storminfo.lat,
409  lon=self.storminfo.lon)
410  basin=self.storminfo.pubbasin2
411  if ((basin.upper()=='AL' or basin.upper()=='EP') \
412  and domloc.ewcenter<360.0):
413  domloc.ewcenter+=360.0
414  r=hwrf.regrib.RegribMany(copygb=alias(exe(conf.getexe('copygb'))),
415  wgrib=alias(exe(conf.getexe('wgrib'))))
416  r.sync_frequently=self.confbool('sync_frequently',True)
417  r.add('p25grid',clatlon(domloc,res=[0.25,0.25],size=[90.,110.],
418  scan=136,n=[441,361]))
419  r.add('trkgrid',clatlon(stormloc,res=[0.25,0.25],size=[20.,20.],
420  scan=128,n=[81,81]))
421  r.add('quarter_degree',grid1*r.grid('p25grid'))
422  r.add('subset',r.GRIB('quarter_degree')/trksub)
423  r.add('hwrftrk',hwrf.tracker.vinttave(
424  r.GRIB('subset')*r.grid('trkgrid')))
425  basedir=os.path.join(self.getdir('intercom'),t('regribber'))
426  r.to_intercom(basedir+'/quarter_degree.grb','quarter_degree')
427  r.to_intercom(basedir+'/subset.grb','subset')
428  r.to_intercom(basedir+'/{out_prefix}.hwrftrk.grbf{fahr:02d}','hwrftrk')
430  ds,conf,c('regribber'),r,start=starttime,step=3600,end=starttime,
431  taskname=t('regribber'),atime=starttime,workdir=sw('regribber'))
433  ds,conf,c('tracker'),taskname=t('tracker'),start=starttime,
434  step=3600, end=starttime,outdir=so('tracker'),
435  workdir=sw('tracker'))
436  self.tracker.add_moving_grid(self.storminfo,self.gribber,'hwrftrk')
437  self.tracker.send_atcfunix(
438  'track0',self.outdir+'/gfs.track0.atcfunix')
439  def _make_ghost(self,ds,conf,wrfghost,geogrid,c,t,so,sw):
440  """!Makes the wrfghost, runghost and ghost_domains member variables.
441  @param ds the produtil.datastore.Datastore object
442  @param conf the hwrf.config.HWRFConfig
443  @param wrfghost the WRFSimulation for the ghost run of wrf
444  @param geogrid the hwrf.wps.Geogrid
445  @param c function to generate config section names for subtasks
446  @param t function to generate task names for subtasks
447  @param so function to generate outdirs for subtasks
448  @param sw function to generate workdirs for subtasks"""
449  self.wrfghost=wrfghost
451  ds, conf, c('wrfghost'), self.wrfghost, taskname=t('wrfghost'),
452  workdir=sw('ghost'),outdir=so('ghost'))\
453  .add_metgrid(self.metgrid).add_geogrid(geogrid)\
454  .add_real(self.realinit)
455  self.ghost_domains=[ d for d in self.wrfghost ]
456 
457  def _make_relocate_kwargs(self,ds,conf,wrfghost,track,modin,dest_dir,so,sw):
458  """!Makes a dict containing the keyword arguments to send in to
459  the constructor for the hwrf.relocate task(s).
460  @param ds the produtil.datastore.Datastore object
461  @param conf the hwrf.config.HWRFConfig
462  @param wrfghost the wrfghost argument to the constructor
463  @param track the track argument to the constructor
464  @param modin the modin argument to the constructor
465  @param dest_dir the directory in which to run the relocate
466  @param so function to generate outdirs for subtasks
467  @param sw function to generate workdirs for subtasks"""
468  kwargs=dict(
469  wrfanl=self.runwrfanl,wrfinput=self.realinit,sim=self.wrfinit,
470  domains=self.wrfdoms,ghost_domains=self.ghost_domains,
471  modin=modin,dest_dir=dest_dir,workdir=sw('relocate'),
472  outdir=so('relocate'))
473 
474  if wrfghost is not None: kwargs.update(wrfghost=self.runghost)
475  if track: kwargs.update(parentTrack=self.tracker,trackName='track0')
476  return kwargs
477 
478  def _make_relocate(self,ds,conf,wrfghost,track,modin,c,t,so,sw):
479  """!Makes the relocation, rstage1, rstage2 and rstage3 member
480  variables.
481  @param ds the produtil.datastore.Datastore object
482  @param conf the hwrf.config.HWRFConfig
483  @param wrfghost the wrfghost argument to the constructor
484  @param track the track argument to the constructor
485  @param modin the modin argument to the constructor
486  @param c function to generate config section names for subtasks
487  @param t function to generate task names for subtasks
488  @param so function to generate outdirs for subtasks
489  @param sw function to generate workdirs for subtasks"""
490  if wrfghost is None:
491  raise ArgumentError('When in HWRFInit.__init__, when '
492  'relocate=True, wrfghost must not be None')
493  dest_dir=os.path.join(self.workdir,'relocate')
494  kwargs=self._make_relocate_kwargs(ds,conf,wrfghost,track,modin,
495  dest_dir,so,sw)
496 
497  self.relocation=hwrf.relocate.Relocation(ds,conf,c('relocate'),
498  taskname_pattern=t('relocate.stage')+'%d',**kwargs)
499 
500  self.rstage1=self.relocation.rstage1
501  self.rstage2=self.relocation.rstage2
502  self.rstage3=self.relocation.rstage3
503 
504  def fgat_times(self):
505  """!Iterates over all fgat times, if known."""
506  if self.fgat_times is not None:
507  for t in self.fgat_times:
508  yield t
509 
510  def run_relocate(self):
511  """!Runs the relocate jobs, if present."""
512  if 'rstage1' in self.__dict__:
513  self.rstage1.delete_temp()
514  self.rstage1.run()
515  if 'rstage2' in self.__dict__:
516  self.rstage2.run()
517  if 'rstage3' in self.__dict__:
518  self.rstage3.run()
519  if self.rstage1.scrub and self.rstage2.scrub and \
520  self.rstage3.scrub:
521  self.rstage3.delete_temp()
522  def get_ftime(self):
523  """!Returns the parent model forecast hour treated as this
524  HWRFInit object's analysis time."""
525  return self._in_ftime
526  def get_atime(self):
527  """!Returns the parent model analysis time. The value of that
528  may differ from this HWRFInit object's analysis time."""
529  return self._in_atime
530 
531  ## Read-only property: forecast time of parent model used for
532  # initializing HWRF.
533  ftime=property(get_ftime,None,None,
534  """!Forecast time of parent model used for initializing HWRF.""")
535 
536  ## Read-only property: analysis time of parent model.
537  atime=property(get_atime,None,None,"""Analysis time of parent model.""")
538 
539  def run(self):
540  """!Runs all steps of the initialization in sequence."""
541  self.run_through_anl()
542  self.run_init_after_anl()
543  self.run_relocate()
544  self.run_real_bdy()
545 
546  def run_through_anl(self):
547  """!Runs the following jobs, if they are enabled: geogrid,
548  ungrib, metgrid, init-length prep_hybrid, init-length real_nmm
549  and wrfanl."""
550  self.log().warning('run_through_anl')
551  if 'geogrid' in self.__dict__:
552  self.geogrid.run()
553  self.ungrib.run()
554  self.metgrid.run()
555  if 'prep' in self.__dict__:
556  for i in xrange(len(self.ibdytimes)):
557  t=self.ibdytimes[i]
558  if t>self.initlen: break
559  self.prep.run_ipiece(i)
560  self.realinit.run()
561  self.runwrfanl.run()
563  """!Runs the following jobs if they are enabled: ghost, post,
564  gribber, tracker."""
565  logger=self.log()
566  logger.warning('run_init_after_anl')
567  if 'runghost' in self.__dict__:
568  produtil.rusage.getrlimit(logger=logger)
569  with produtil.rusage.rusage(logger=logger):
570  self.runghost.run()
571  if 'post' in self.__dict__:
572  with self.dstore.transaction() as t:
573  self.post.unrun()
574  self.gribber.unrun()
575  self.post.run(raiseall=True)
576  self.gribber.run()
577  if self.gribber.is_completed():
578  self.tracker.run()
579  else:
580  msg='Error regridding inputs to tracker. See earlier log messages for details.'
581  logger.error(msg)
582  raise GribberError(msg)
583  def run_real_bdy(self):
584  """!Runs boundary processing jobs.
585 
586  Runs the forecast-length versions of the following jobs if
587  they are enabled: ungribfcst, metgridfcst, prep_hybrid and
588  real. Note that ungribfcst and metgridfcst should be disabled
589  if prep_hybrid is enabled. That is done in the constructor
590  though; the run_real_bdy will happily run all four jobs if
591  requested."""
592  self.log().warning('run_real_bdy')
593  if 'ungribfcst' in self.__dict__:
594  self.ungribfcst.run()
595  if 'metgridfcst' in self.__dict__:
596  self.metgridfcst.run()
597  if 'realfcst' in self.__dict__:
598  if 'prep' in self.__dict__ and self._prepfcst:
599  for i in xrange(len(self.bdytimes)):
600  t=self.bdytimes[i]
601  if t in self.ibdytimes:
602  self.log().info(
603  '%s: skipping: is an initial bdy time (should '
604  'already be done)'%(t.strftime('%Y%m%d%H'),))
605  continue
606  self.prep.run_ipiece(i)
607  self.realfcst.run()
608  def inputiter(self):
609  """!Iterates over all needed input data
610 
611  Calls the inputiter for the ungrib, ungribfcst and prep
612  members, iterating over all data they need to run the
613  initialization."""
614  if 'ungrib' in self.__dict__:
615  for d in self.ungrib.inputiter(): yield d
616  if 'ungribfcst' in self.__dict__:
617  for d in self.ungribfcst.inputiter(): yield d
618  if 'prep' in self.__dict__:
619  for d in self.prep.inputiter(): yield d
620 
621  ##@var initlen
622  # timedelta for length of initialization
623 
624  ##@var fcstlen
625  # timedelta for length of forecast
626 
627  ##@var wrffcst
628  # Task for running or monitoring the WRF forecast
629 
630  ##@var wrfdoms
631  # WRFDomain objects from that wrffcst object
632 
633  ##@var wrfinit
634  # Task for running the ~1 minute forecast to generate wrfanl files.
635 
636  ##@var bdytimes
637  # An array of boundary times needed by the forecast run of WRF.
638 
639  ##@var ibdytimes
640  # An array of boundary times needed by the ~1 minute wrf forecast
641  # used to create wrfanl and ghost files.
642 
643  ##@var geogrid
644  # the hwrf.wps.Geogrid object for running geogrid.exe
645 
646  ##@var external_geogrid
647  # if a geogrid argument was sent to the constructor, it is stored here
648 
649  ##@var ungrib
650  # the hwrf.wps.Ungrib object for running ungrib
651 
652  ##@var metgrid
653  # the hwrf.metgrid.Metgrid object for running metgrid
654 
655  ##@var realinit
656  # the hwrf.fcsttask.RealNMM object for running real for the WRF init jobs
657 
658  ##@var runwrfanl
659  # the hwrf.fcsttask.WRFAnl4Trak object used to run the WRF for to
660  # produce the wrfanl files and outer domain time 0 wrfout file
661 
662  ##@var wrfghost
663  # the WRFSimulation representing the ghost if requested. This is
664  # the same as the wrfghost argument to the constructor
665 
666  ##@var runghost
667  # the hwrf.fcsttask.WRFGhost to run the ghost if requested.
668 
669  ##@var prep
670  # the hwrf.prep.PrepHybrid object to run prep_hybrid. The same
671  # prep object is used for both the init-length and fcst-length
672  # initialization.
673 
674  ##@var ungribfcst
675  # the hwrf.wps.Ungrib object for running ungrib for the full WRF
676  # forecast job, if prep=False
677 
678  ##@var metgridfcst
679  # the hwrf.wps.Metgrid object for running metgrid for the full WRF
680  # forecast job if prep=False
681 
682  ##@var realfcst
683  # the hwrf.fcsttask.RealNMM object
684 
685  ##@var post
686  # if track=True, this is the hwrf.post.PostOneWRF object used to
687  # post-process the wrfanl job's time 0 outer domain wrfout file
688 
689  ##@var gribber
690  # the hwrf.gribtask.GRIBTask object used to regrib the output of
691  # self.post
692 
693  ##@var tracker
694  # the hwrf.tracker.TrackerTask object used to run the tracker on
695  # the gribber
696 
697 ########################################################################
699  """!Runs the FGAT initialization for one FGAT member
700 
701  This class serves a similar purpose to its superclass, HWRFInit,
702  but is intended for initialization that runs before the GSI. It
703  has a modified list of arguments to the hwrf.relocate classes."""
704  def __init__(self,ds,conf,section,gsi_d01=None,gsi_d02=None,gsi_d03=None,
705  fgat_times=None, **kwargs):
706  """!Creates a new InitBeforeGSI object. See the
707  HWRFInit.__init__ for details.
708  @param ds passed to Datum: the Datastore object for this Task
709  @param conf the conf object for this task
710  @param section the conf section for this task
711  @param gsi_d01 passed to the hwrf.relocate constructors'
712  gsi_d01 argument
713  @param gsi_d02 passed to the hwrf.relocate constructors'
714  gsi_d02 argument
715  @param gsi_d03 passed to the hwrf.relocate constructors'
716  gsi_d03 argument
717  @param fgat_times array of FGAT times
718  @param kwargs All other keyword arguments are passed to
719  HWRFInit.__init__
720  """
721  assert(fgat_times is not None)
722  if not isinstance(fgat_times,list):
723  raise TypeError('In InitBeforeGSI.__init__, fgat_times must be a list or tuple, not a %s %s.'
724  %(type(fgat_times).__name__,repr(fgat_times)))
725  self._gsi_d01=gsi_d01
726  self._gsi_d02=gsi_d02
727  self._gsi_d03=gsi_d03
728  super(InitBeforeGSI,self).__init__(
729  ds,conf,section,fgat_times=fgat_times,**kwargs)
730  assert(self._fgat_times is not None)
731 
732  ##@var wrfghost
733  # The hwrf.wrf.WRFSimulation for the wrf ghost runs
734 
735  ##@var runghost
736  # The hwrf.fcsttask.WRFGhost for running the WRF for the ghost case
737 
738  def _make_relocate_kwargs(self,ds,conf,wrfghost,track,modin,dest_dir,
739  so,sw):
740  """!Makes the FGAT relocation.
741 
742  This serves the same purpose as the
743  HWRFInit._make_relocate_kwargs(), but it adds to those
744  arguments the gsi_d01, d02 and d03 sent to the constructor,
745  plus the fgat_times."""
746  assert(self._fgat_times is not None)
747  kwargs=super(InitBeforeGSI,self)._make_relocate_kwargs(
748  ds,conf,wrfghost,track,modin,dest_dir,so,sw)
749  kwargs.update(gsi_d01=self._gsi_d01, gsi_d02=self._gsi_d02,
750  gsi_d03=self._gsi_d03, fgat_times=self._fgat_times)
751  return kwargs
752  def _make_ghost(self,ds,conf,wrfghost,geogrid,c,t,so,sw):
753  """!Makes the wrfghost, runghost and ghost_domains member
754  variables.
755 
756  Overrides the HWRFInit._make_ghost() to use the
757  WRFGhostForPost class instead of WRFGhost in order to get the
758  wrfout "ghout_d0X" files for each domain for post-processing.
759 
760  @param ds the produtil.datastore.Datastore object
761  @param conf the hwrf.config.HWRFConfig
762  @param wrfghost the WRFSimulation for the ghost run of wrf
763  @param geogrid the hwrf.wps.Geogrid
764  @param c function to generate config section names for subtasks
765  @param t function to generate task names for subtasks
766  @param so function to generate outdirs for subtasks
767  @param sw function to generate workdirs for subtasks"""
768  self.wrfghost=wrfghost
770  ds, conf, c('wrfghost'), self.wrfghost, taskname=t('wrfghost'),
771  workdir=sw('ghost'),outdir=so('ghost'))\
772  .add_metgrid(self.metgrid).add_geogrid(geogrid)\
773  .add_real(self.realinit)
774  self.ghost_domains=[ d for d in self.wrfghost ]
775  ##@var ghost_domains
776  # List of domains for the ghost run of WRF (hwrf.wrf.WRFDomains objects)
777 
778 ########################################################################
780  """!The FGATInit represents an array of InitBeforeGSI objects, each run
781  for one forecast hour of some parent model (usually GDAS)."""
782 
783  ##@var outdir
784  # The directory in intercom to receive output. Individual
785  # initialization components will be in subdirectories.
786 
787  ##@var inits
788  # InitBeforeGSI objects for individual times.
789 
790  ##@var ftime2init
791  # A mapping from forecast time to InitBeforeGSI objects.
792 
793  def __init__(self,ds,conf,section, wrf,initlen,fcstlen,outdir=None,
794  realfcst=False,wrfghost=None,prep=True,track=True,
795  in_ftimes=None,in_atime=None,cycling_interval=6*3600,
796  gsi_d01=None,gsi_d02=None,gsi_d03=None,ibdystep=None,
797  prepfcst=True,**kwargs):
798  """!Creates an FGATInit, passing most arguments to the child
799  InitBeforeGSI objects' constructors. The cycling_interval is the
800  time to subtract from this model's analysis time to get the
801  parent model's analysis time. The default of six hours
802  (6*3600 as an int) is correct for the operational HWRF and
803  GDAS.
804 
805  @param ds passed to Datum: the Datastore object for this Task
806  @param conf the conf object for this task
807  @param section the conf section for this task
808  @param wrf (required) the WRFSimulation representing the full WRF
809  forecast
810  @param initlen (required) the length of the real_nmm run for the
811  initialization
812  @param fcstlen (required) the length of the real_nmm run for the
813  full forecast
814  @param outdir The directory in intercom to receive output.
815  Default: intercom/{taskname}. Individual initialization
816  components will be in subdirectories.
817  @param outdir The directory in intercom to receive output.
818  Default: intercom/{taskname}. Individual initialization
819  components will be in subdirectories.
820  @param realfcst Flag: do we need to run real for the full forecast
821  length?
822  @param wrfghost hwrf.wrf.WRFSimulation object for the wrfghost
823  files. If absent, no wrfghost-related jobs will be run
824  @param prep if True, use prep_hybrid input. This changes the way
825  in which real_nmm, ungrib and metgrid are run.
826  @param track Run a post, regribber and tracker on the wrfanl
827  history file for domain 1, to find the location of the
828  parent vortex.
829  @param in_ftimes array of parent model forecast hours to treat
830  as "time 0" for each FGAT time. This is used for the FGAT to
831  use GDAS forecasts as input
832  @param in_atime parent model analysis time. Default: start time
833  of wrf
834  @param cycling_interval HWRF cycling interval in seconds.
835  @param gsi_d01 passed to the hwrf.relocate constructors'
836  gsi_d01 argument
837  @param gsi_d02 passed to the hwrf.relocate constructors'
838  gsi_d02 argument
839  @param gsi_d03 passed to the hwrf.relocate constructors'
840  gsi_d03 argument
841  @param ibdystep Optional: the boundary input frequency for the
842  ~1 minute forecasts. Default: bdystep.
843  @param prepfcst If True AND prep=True, use prep_hybrid for
844  boundary conditions. This changes how realfcst, ungribfcst
845  and metgridfcst are run.
846  @param kwargs Other keyword arguments are passed to HWRFTask.__init__
847  """
848  if 'workdir' not in kwargs:
849  # FGATInit is a special case: its subtasks are directly
850  # under WORKhwrf.
851  kwargs['workdir']=conf.getdir('WORKhwrf')
852  super(FGATInit,self).__init__(ds,conf,section,**kwargs)
853 
854  log=self.log()
855 
856  self.outdir=outdir
857 
858  self._gsi_d01=gsi_d01
859  self._gsi_d02=gsi_d02
860  self._gsi_d03=gsi_d03
861 
862  if prepfcst and not prep:
863  raise NotImplementedError(
864  'When running prep_hybrid for boundary conditions, you '
865  'must also run it for initial conditions.')
866  self._prep=prep
867  self._prepfcst=prepfcst
868  self._track=track
869  self._wrf=wrf
870  self._wrfghost=wrfghost
871  self._initlen=initlen
872  self._fcstlen=fcstlen
873  self._realfcst=bool(realfcst)
874  if ibdystep is None:
875  ibdystep=self.confint('ibdystep',0)
876  if ibdystep<1: ibdystep=0
877  self._ibdystep=ibdystep
878 
879  if outdir is None: self.outdir=os.path.join(self.getdir('intercom'),
880  self.taskname)
881  self._cycling_interval=to_timedelta(cycling_interval)
882  if in_atime is None:
883  in_atime=wrf.simstart() - self._cycling_interval
884  self._in_atime=in_atime
885  if in_ftimes is None:
886  in_ftimes=[ to_datetime_rel(t,in_atime) \
887  for t in self._default_ftimes() ]
888  self._in_ftimes=[ t for t in in_ftimes ]
889  self.inits=list()
890  self.ftime2init=TimeMapping(self._in_ftimes, lambda : 1)
891  assert('ftime2init' in self.__dict__)
892 
893  # Get additional options for datasets:
894  dsopt=dict()
895  if 'in_dataset' in kwargs: dsopt['in_dataset']=kwargs['in_dataset']
896  assert('in_dataset' in dsopt)
897  assert(dsopt['in_dataset'] == 'gdas1')
898  self._make_inits(**dsopt)
899  assert(self.inits)
900 
901  ceninit=self.init_at_time(conf.cycle)
902  centrack=ceninit.rstage3.get_track()
903  log.info('centrack %s'%(centrack))
904  for fhr,init in self.fhr_and_init():
905  init.rstage3.centrack=centrack
906  def init_at_time(self,when):
907  """!Get the subtask for one time.
908 
909  Returns the initialization InitBeforeGSI object for the
910  specified time (the earliest time not before the specified
911  time). The time can be an absolute time (2015091418) or a
912  forecast hour (12), as long as it is accepted by the first
913  argument of to_datetime_rel. Raises an exception if the time
914  has no InitBeforeGSI objects."""
915  when=to_datetime_rel(when,self._in_atime)
916  return self.ftime2init[when]
917  def inputiter(self):
918  """!Iterates over needed input data.
919 
920  Calls all inputiter functions for all child objects, hence
921  iterating over all input sources required for all FGAT hours."""
922  for t,p in self.ftime2init.iteritems():
923  for d in p.inputiter():
924  yield d
925  def get_ghosts(self,domain):
926  """!Get all ghost output products.
927  @param domain The domain of interest, an hwrf.wrf.WRFDomain
928 
929  Returns a TimeMapping, mapping from init time to the ghost
930  product output from the runghost member of each init time."""
931  ret=TimeMapping(self._in_ftimes)
932  for t,p in self.ftime2init.iteritems():
933  i=self.init_at_time(t)
934  if 'runghost' in i.__dict__:
935  rg=i.runghost
936  gg=rg.get_ghost(domain)
937  ret[t]=gg
938  return ret
939  def get_relocates(self,domain=None):
940  """!Get hwrf.relocate.Stage3 objects or output products for
941  each FGAT time.
942 
943  Returns a TimeMapping of objects, one per init time. If a
944  domain is specified, the objects are the wrfinput or ghost
945  product output by the relocation for that domain. If a domain
946  is NOT specified, then the objects are the relocate stage 3
947  tasks.
948  @param domain The domain of interest."""
949  ret=TimeMapping(self._in_ftimes)
950  for t,p in self.ftime2init.iteritems():
951  i=self.init_at_time(t)
952  rr=i.rstage3
953  if domain is None:
954  ret[t]=rr
955  continue
956  assert(isinstance(rr,hwrf.relocate.Stage3))
957  rdom=i.wrfghost[domain]
958  if rdom.is_moad():
959  rg=rr.wrfinput_at_time(t,rdom)
960  else:
961  rg=rr.get_ghost(rdom)
962  if rg is None:
963  raise NoSuchDomain(
964  'Error: %s does not exist at time %s'
965  %(str(rdom),str(t)))
966  ret[t]=rg
967  return ret
968  def parent_fhrs(self):
969  """!Iterates over all fgat times as datetime.datetime objects."""
970  for ftime in self.ftime2init.iterkeys():
971  assert(isinstance(ftime,datetime.datetime))
972  yield ftime
973  def fhr_and_init(self):
974  """!Iterates over pairs of (fhr,init) where fhr is a
975  fraction.Fraction FGAT hour, and init is an InitBeforeGSI
976  object for that time."""
977  assert(self.inits)
978  for ftime,init in self.ftime2init.iteritems():
979  fhr=to_fraction(ftime-self._in_atime)/3600.0
980  yield fhr,init
981  def _default_ftimes(self):
982  """!Internal function that implements other iterators.
983 
984  This is an iterator that generates the default FGAT hours from
985  the configuration file. The iterator yields the forecast
986  times for the input model as datetime.datetime objects."""
987  start=self.conffloat('FGATSTR',-3.)*3600
988  step=self.conffloat('FGATINV',3)*3600
989  end=self.conffloat('FGATEND',3)*3600
990  if step<60:
991  raise ValueError('ERROR: in hwrf.init.FGATInit the FGATINV must '
992  'be at least one minute, but you provided %f '
993  'seconds'%(step,))
994  now=start
995  while now-30<=end: # use 30 second epsilon
996  assert(self._in_atime) is not None
997  assert(now is not None)
998  rel=to_datetime_rel(now,self._in_atime)
999  assert(rel is not None)
1000  yield to_datetime_rel(self._cycling_interval,rel)
1001  now+=step
1002  def _make_init(self,in_ftime,taskname,**kwargs):
1003  """!Internal implementation function that generates the
1004  InitBeforeGSI object for one FGAT time.
1005 
1006  @param in_ftime The forecast time of interest
1007  @param taskname The name of the child task
1008  @param kwargs Additional keyword arguments passed to
1009  InitBeforeGSI.__init__
1010  @returns the resulting InitBeforeGSI object"""
1011  wrf=self._wrf.copy()
1012  tstart=to_datetime_rel(in_ftime, self._in_atime)
1013  ftime=wrf.simend()-wrf.simstart()
1014  tend=tstart+ftime
1015  wrf.set_timing(start=tstart,end=tend)
1016  wrfghost=self._wrfghost.copy()
1017  wrfghost.set_timing(start=tstart,end=tend)
1018  in_ftime=in_ftime-self._in_atime
1019  fgat_times=[ t for t in self.parent_fhrs() ]
1020  assert(fgat_times is not None)
1021  child=InitBeforeGSI(ds=self.dstore,conf=self.conf,section=self.section,wrf=wrf,
1022  initlen=self._initlen,fcstlen=self._fcstlen,outdir=None,
1023  realfcst=self._realfcst,wrfghost=wrfghost,prep=self._prep,
1024  track=self._track,in_ftime=in_ftime,in_atime=self._in_atime,
1025  taskname=taskname,prep_one_time=True,ibdystep=self._ibdystep,
1026  gsi_d01=self._gsi_d01, gsi_d02=self._gsi_d02,
1027  gsi_d03=self._gsi_d03,fgat_times=fgat_times,
1028  prepfcst=self._prepfcst,ungrib_one_time=True,**kwargs)
1029  assert(child.ungrib.one_time)
1030  return child
1031  def _make_inits(self,**kwargs):
1032  """!Creates all child InitBeforeGSI objects.
1033 
1034  Creates InitBeforeGSI objects for all input times in
1035  self.ftime2init and self.inits. The self._make_init is used
1036  to make each individual object. The self.inits will be a list
1037  of InitBeforeGSI objects, and self.ftime2init will be a
1038  mapping from time to InitBeforeGSI.
1039  @param kwargs Passed to _make_init()"""
1040  assert('ftime2init' in self.__dict__)
1041  assert(self._in_ftimes)
1042  for in_ftime in self._in_ftimes:
1043  self.log().debug('process ftime %s'%(repr(in_ftime),))
1044  taskname=taskname='%s.t%s'%(self.taskname,in_ftime.strftime('%Y%m%d%H%M'))
1045  child=self._make_init(in_ftime,taskname,**kwargs)
1046  self.inits.append(child)
1047  assert(self.inits)
1048  self.ftime2init[in_ftime]=child
1049  def run(self):
1050  """!Runs all InitBeforeGSI.run() commands in sequence."""
1051  for init in self.inits: init.run()
1052  def run_through_anl(self):
1053  """!Runs all InitBeforeGSI.run_through_anl() commands in sequence."""
1054  for init in self.inits: init.run_through_anl()
1056  """!Runs all InitBeforeGSI.run_after_anl() commands in sequence."""
1057  for init in self.inits: init.run_init_after_anl()
1058  def run_real_bdy(self):
1059  """!Runs all InitBeforeGSI.run_real_bdy() commands in sequence."""
1060  for init in self.inits: init.run_real_bdy()
1061  def run_relocate(self):
1062  """!Runs all InitBeforeGSI.run_relocate() commands in sequence."""
1063  for init in self.inits: init.run_relocate()
post
if track=True, this is the hwrf.post.PostOneWRF object used to post-process the wrfanl job's time 0 o...
Definition: init.py:397
def _make_track(self, ds, conf, moad, starttime, c, t, so, sw)
Makes the gribber and tracker member variables.
Definition: init.py:386
rstage2
The hwrf.relocation.Stage2 task.
Definition: init.py:501
initlen
timedelta for length of initialization
Definition: init.py:213
external_geogrid
if a geogrid argument was sent to the constructor, it is stored here
Definition: init.py:271
def _make_realfcst(self, prep, prepfcst, ds, conf, fwrf, fcstlen, wpsloc, in_atime, in_ftime, ungrib_opts, geogrid, c, t, so, sw)
Makes the ungribfcst, metgridfcst and realfcst member variables:
Definition: init.py:347
Runs regrib operations on many input times, sending output to an hwrf.gribtask.GRIBTask.
Definition: regrib.py:311
ibdystep
Timestep between boundary information for the 1 minute forecast.
Definition: init.py:219
ungrib
the hwrf.wps.Ungrib object for running ungrib
Definition: init.py:332
def inputiter(self)
Iterates over all needed input data.
Definition: init.py:608
ghost_domains
List of ghost domains as hwrf.wrf.WRFDomain objects.
Definition: init.py:455
runs wrf to generate ghost (wrfanl) and wrfout files
Definition: fcsttask.py:1498
runghost
the hwrf.fcsttask.WRFGhost to run the ghost if requested.
Definition: init.py:450
taskname
Read-only property: the name of this task.
Definition: datastore.py:1134
gribber
the hwrf.gribtask.GRIBTask object used to regrib the output of self.post
Definition: init.py:429
The base class of tasks run by the HWRF system.
Definition: hwrftask.py:25
rstage1
The hwrf.relocation.Stage1 task.
Definition: init.py:500
def run_relocate(self)
Runs the relocate jobs, if present.
Definition: init.py:510
This is a HWRF task that encapsulates stage 3 of the vortex relocation which relocates and pastes the...
Definition: relocate.py:1583
This task runs the GFDL Vortex Tracker on HWRF output.
Definition: tracker.py:649
This is a HWRF task that horizontally interpolates the meteorological fields extracted by ungrib to t...
Definition: wps.py:1049
conf
This HWRFTask's hwrf.config.HWRFConfig object.
Definition: hwrftask.py:415
dstore
Read-only property, an alias for getdatastore(), the Datastore in which this Datum resides...
Definition: datastore.py:557
a HWRFTask subclass that runs real_nmm
Definition: fcsttask.py:1001
storminfo
The hwrf.storminfo.StormInfo describing the vitals information for the storm processed by this HWRFTa...
Definition: hwrftask.py:94
rstage3
The hwrf.relocation.Stage3 task.
Definition: init.py:502
def __init__(self, ds, conf, section, wrf, initlen, fcstlen, outdir=None, realfcst=False, wrfghost=None, prep=True, track=True, in_ftime=None, in_atime=None, geogrid=None, prep_one_time=None, relocate=True, modin=None, ibdystep=None, fgat_times=None, prepfcst=None, kwargs)
HWRFInit constructor.
Definition: init.py:82
def run_init_after_anl(self)
Runs the following jobs if they are enabled: ghost, post, gribber, tracker.
Definition: init.py:562
def _make_inits(self, kwargs)
Creates all child InitBeforeGSI objects.
Definition: init.py:1031
def fhr_and_init(self)
Iterates over pairs of (fhr,init) where fhr is a fraction.Fraction FGAT hour, and init is an InitBefo...
Definition: init.py:973
runs wrfanl and generates a track file
Definition: fcsttask.py:1343
def getrlimit
Gets the current resource limits.
Definition: rusage.py:132
This is an HWRFTask that post-processes output data for a single WRF stream, from several WRF domains...
Definition: post.py:212
geogrid
the hwrf.wps.Geogrid object for running geogrid.exe
Definition: init.py:273
wrffcst
Task for running or monitoring the WRF forecast.
Definition: init.py:221
def get_relocates
Get hwrf.relocate.Stage3 objects or output products for each FGAT time.
Definition: init.py:939
def confbool
Alias for self.conf.getbool for section self.section.
Definition: hwrftask.py:287
A GRIBBase that subsets GRIB files, keeping only certain parameters.
Definition: regrib.py:1366
section
The confsection in self.section for this HWRFTask (read-only)
Definition: hwrftask.py:422
wrfghost
the WRFSimulation representing the ghost if requested.
Definition: init.py:449
Base class of tasks run by HWRF.
Definition: hwrftask.py:1
A shell-like syntax for running serial, MPI and OpenMP programs.
Definition: run.py:1
relocation
The hwrf.relocation.Relocation group of tasks.
Definition: init.py:497
metgrid
the hwrf.metgrid.Metgrid object for running metgrid
Definition: init.py:336
def getdir
Alias for hwrf.config.HWRFConfig.get() for the "dir" section.
Definition: hwrftask.py:396
def init_at_time(self, when)
Get the subtask for one time.
Definition: init.py:906
outdir
The directory in which this task should deliver its final output.
Definition: hwrftask.py:176
def run_relocate(self)
Runs all InitBeforeGSI.run_relocate() commands in sequence.
Definition: init.py:1061
PrepHybrid runs the prep_hybrid program to transform GFS spectral files to the HWRF grid...
Definition: prep.py:1
Runs the real_nmm or wrf executables.
Definition: fcsttask.py:1
Runs the FGAT initialization for one FGAT member.
Definition: init.py:698
metgridfcst
the hwrf.wps.Metgrid object for running metgrid for the full WRF forecast job if prep=False ...
Definition: init.py:371
def get_ghosts(self, domain)
Get all ghost output products.
Definition: init.py:925
def run_real_bdy(self)
Runs boundary processing jobs.
Definition: init.py:583
def run_real_bdy(self)
Runs all InitBeforeGSI.run_real_bdy() commands in sequence.
Definition: init.py:1058
def parent_fhrs(self)
Iterates over all fgat times as datetime.datetime objects.
Definition: init.py:968
Time manipulation and other numerical routines.
Definition: numerics.py:1
Declares GRIBTask, which automates regribbing operations.
Definition: gribtask.py:1
This module allows querying resource usage and limits, as well as setting resource limits...
Definition: rusage.py:1
This module contains Tasks to run the WRF Preprocessing System (WPS): Geogrid, Ungrib and Metgrid...
Definition: wps.py:1
An hwrf.hwrftask.HWRFTask that performs regribbing operations.
Definition: gribtask.py:46
def get_atime(self)
Returns the parent model analysis time.
Definition: init.py:526
workdir
The directory in which this task should be run.
Definition: hwrftask.py:156
def confint
Alias for self.conf.getint for section self.section.
Definition: hwrftask.py:248
fcstlen
timedelta for length of forecast
Definition: init.py:214
def conffloat
Alias for self.conf.getfloat for section self.section.
Definition: hwrftask.py:274
Represents a specific location on the earth as a latitude, longitude pair.
Definition: regrib.py:1300
def fgat_times(self)
Iterates over all fgat times, if known.
Definition: init.py:504
def log
Obtain a logging domain.
Definition: hwrftask.py:425
def _make_relocate(self, ds, conf, wrfghost, track, modin, c, t, so, sw)
Makes the relocation, rstage1, rstage2 and rstage3 member variables.
Definition: init.py:478
def _subworkdir(self, childname)
Helper function for constructor workdir arguments.
Definition: init.py:58
Runs the deterministic model initialization.
Definition: init.py:26
def _make_relocate_kwargs(self, ds, conf, wrfghost, track, modin, dest_dir, so, sw)
Makes a dict containing the keyword arguments to send in to the constructor for the hwrf...
Definition: init.py:457
bdytimes
An array of boundary times needed by the forecast run of WRF.
Definition: init.py:235
inits
InitBeforeGSI objects for individual times.
Definition: init.py:889
ungribfcst
the hwrf.wps.Ungrib object for running ungrib for the full WRF forecast job, if prep=False ...
Definition: init.py:367
def run(self)
Runs all InitBeforeGSI.run() commands in sequence.
Definition: init.py:1049
def __init__(self, ds, conf, section, wrf, initlen, fcstlen, outdir=None, realfcst=False, wrfghost=None, prep=True, track=True, in_ftimes=None, in_atime=None, cycling_interval=6 *3600, gsi_d01=None, gsi_d02=None, gsi_d03=None, ibdystep=None, prepfcst=True, kwargs)
Creates an FGATInit, passing most arguments to the child InitBeforeGSI objects' constructors.
Definition: init.py:797
This is a HWRF task that extracts the meteorological fields from GRIB formatted files and write the f...
Definition: wps.py:637
def _make_ghost(self, ds, conf, wrfghost, geogrid, c, t, so, sw)
Makes the wrfghost, runghost and ghost_domains member variables.
Definition: init.py:439
vinttave
An alias for GRIB1VintTave.
Definition: tracker.py:388
Runs the Unified Post Processor on outputs from the WRF-NMM, producing E grid GRIB files as EGRIB1Pro...
Definition: post.py:1
This is a HWRF task that pre processes the geogrid to define the model domains and interpolates stati...
Definition: wps.py:536
def __init__(self, ds, conf, section, gsi_d01=None, gsi_d02=None, gsi_d03=None, fgat_times=None, kwargs)
Creates a new InitBeforeGSI object.
Definition: init.py:705
def _suboutdir(self, childname)
Helper function for constructor outdir arguments.
Definition: init.py:68
This module contains tasks to prepare input for the GFDL Vortex Tracker, run the tracker and deliver ...
Definition: tracker.py:1
def get_ftime(self)
Returns the parent model forecast hour treated as this HWRFInit object's analysis time...
Definition: init.py:522
def _default_ftimes(self)
Internal function that implements other iterators.
Definition: init.py:981
The FGATInit represents an array of InitBeforeGSI objects, each run for one forecast hour of some par...
Definition: init.py:779
Exceptions raised by the hwrf package.
Definition: exceptions.py:1
def run_init_after_anl(self)
Runs all InitBeforeGSI.run_after_anl() commands in sequence.
Definition: init.py:1055
def confstr
Alias for self.conf.getstr for section self.section.
Definition: hwrftask.py:261
def run_through_anl(self)
Runs all InitBeforeGSI.run_through_anl() commands in sequence.
Definition: init.py:1052
Describes regribbing operations using an algebraic structure.
Definition: regrib.py:1
prep
the hwrf.prep.PrepHybrid object to run prep_hybrid.
Definition: init.py:283
rusage
Alias for produtil.rusage.RUsage.
Definition: rusage.py:288
runs a short WRF simulation to generate wrfanl files named "ghost"
Definition: fcsttask.py:1300
def igrb1(task, kwargs)
This is a convenient alias for the GRIB1Selector constructor.
Definition: regrib.py:1956
def run(self)
Runs all steps of the initialization in sequence.
Definition: init.py:539
Exceptions for hwrf.regrib.GRIBTask for certain internal errors.
Definition: exceptions.py:292
This module implements Python classes that run the 2014 HWRF Relocation.
Definition: relocate.py:1
wrfinit
Task for running the ~1 minute forecast to generate wrfanl files.
Definition: init.py:225
Runs the prep_hybrid program on GFS spectral files.
Definition: prep.py:23
def _make_realinit(self, prep, ds, conf, fwrf, iwrf, endtime, wpsloc, in_atime, in_ftime, ungrib_opts, geogrid, c, t, so, sw)
Makes the ungrib, metgrid and realinit member variables.
Definition: init.py:314
Raised by hwrf.input when trying to get the wrong domain from its hwrf.relocate.Relocate child object...
Definition: exceptions.py:442
ibdytimes
An array of boundary times needed by the ~1 minute wrf forecast used to create wrfanl and ghost files...
Definition: init.py:236
def inputiter(self)
Iterates over needed input data.
Definition: init.py:917
realfcst
the hwrf.fcsttask.RealNMM object
Definition: init.py:375
realinit
the hwrf.fcsttask.RealNMM object for running real for the WRF init jobs
Definition: init.py:339
tracker
the hwrf.tracker.TrackerTask object used to run the tracker on the gribber
Definition: init.py:432
ftime2init
A mapping from forecast time to InitBeforeGSI objects.
Definition: init.py:890
runwrfanl
the hwrf.fcsttask.WRFAnl4Trak object used to run the WRF for to produce the wrfanl files and outer do...
Definition: init.py:303
def _make_init(self, in_ftime, taskname, kwargs)
Internal implementation function that generates the InitBeforeGSI object for one FGAT time...
Definition: init.py:1002
def run_through_anl(self)
Runs the following jobs, if they are enabled: geogrid, ungrib, metgrid, init-length prep_hybrid...
Definition: init.py:546
This represents all three stages of the relocate.
Definition: relocate.py:2189
wrfdoms
WRFDomain objects from that wrffcst object.
Definition: init.py:223