HWRF  trunk@4391
exhwrf_merge.py
1 #! /usr/bin/env python
2 
3 ##@namespace scripts.exhwrf_merge
4 # Merges the exhwrf_relocate and exhwrf_gsi outputs to create the
5 # final input to the exhwrf_forecast.
6 #
7 # @note This job should NOT be run if GSI is disabled. When using
8 # relocated GFS or GEFS analysis as input to the forecast, the
9 # exhwrf_merge is superfluous and will harm the forecast.
10 
11 import os, sys, produtil.log, produtil.setup
12 from produtil.log import jlogger
13 import hwrf.gsi
14 
15 def fail(msg):
16  """!Log a message to the produtil.log.jlogger and exit with status 2
17  @param msg the error message """
18  jlogger.error(msg)
19  sys.exit(2)
20 
21 def main():
22  """!Run the hwrf.relocation.Merge."""
23  ENV=os.environ
24  init_model=ENV.get('INIT_MODEL','GDAS1').lower()
25  if init_model!='gfs' and init_model!='gdas1':
26  fail('Aborting: init_model="%s" must be "gfs" or "gdas1"'
27  %(init_model,))
28 
29  import hwrf_expt
31  conf=hwrf_expt.conf
32  logger=conf.log('exhwrf_merge')
33  if init_model=='gfs':
34  jlogger.info('MERGE does not need to be run for INIT_MODEL=GFS')
35  hwrf_expt.gfs_merge.run()
36  elif not hwrf_expt.conf.getbool('config','run_gsi'):
37  jlogger.info('GSI is disabled via configuration settings. '
38  'This job need not be run.')
39  sys.exit(0)
40  elif not hwrf.gsi.get_gsistatus(conf,'gsi_d02',logger) and \
41  not hwrf.gsi.get_gsistatus(conf,'gsi_d03',logger):
42  jlogger.info('GSI status file claims GSI is disabled for both '
43  'domains. This job need not be run.')
44  sys.exit(0)
45  else:
46  hwrf_expt.gdas_merge.run()
47 
48 if __name__=='__main__':
49  try:
51  jlogger.info('exhwrf_merge is starting')
52  main()
53  jlogger.info('exhwrf_merge has completed')
54  except Exception as e:
55  jlogger.critical('HWRF merge is aborting: '+str(e),exc_info=True)
56  sys.exit(2)
Contains setup(), which initializes the produtil package.
Definition: setup.py:1
def init_module
Initializes the HWRF object structure.
Definition: hwrf_expt.py:384
def fail(msg)
Log a message to the produtil.log.jlogger and exit with status 2.
Definition: exhwrf_merge.py:15
def get_gsistatus
Checks the gsi status for a specific domain.
Definition: gsi.py:1273
def setup(ignore_hup=False, dbnalert_logger=None, jobname=None, cluster=None, send_dbn=None, thread_logger=False, thread_stack=2 **24, kwargs)
Initializes the produtil package.
Definition: setup.py:15
Runs the GSI data assimilation on the HWRF system.
Definition: gsi.py:1
Configures logging.
Definition: log.py:1
def main()
Run the hwrf.relocation.Merge.
Definition: exhwrf_merge.py:21