HWRF  trunk@4391
exhwrf_ensda_output.py
1 #! /usr/bin/env python
2 
3 ##@namespace scripts.exhwrf_ensda_output
4 #This script exists only for dependency tracking with Rocoto. It
5 #creates the storm*.done file for a cycle in the case where the DA
6 #ensemble is enabled. If the DA ensemble is disabled, the
7 #exhwrf_output job would do that instead.
8 
9 import sys, os
11 from produtil.log import jlogger
12 from hwrf.ensda import read_ensda_flag_file
13 
14 def main():
15  """!Checks to see if all ensda jobs (exhwrf_ensda) ran
16  correctly. Creates the "donefile" if so."""
17  import hwrf_expt
18  hwrf_expt.init_module(make_ensemble_da=True)
19 
20  conf=hwrf_expt.conf
21  run_ensemble_da=conf.getbool('config','run_ensemble_da')
22  ensda_flag_file=conf.getstr('tdrcheck','tdr_flag_file')
23  run_ensda=read_ensda_flag_file(ensda_flag_file)
24  if run_ensemble_da and run_ensda:
25  ensda_size=conf.getint('hwrf_da_ens','ensda_size')
26  else:
27  jlogger.info('ENSDA was not run.')
28  ensda_size=0
29 
30  logger=conf.log('output')
31 
32  bad=False
33  for ens in xrange(ensda_size):
34  imemb=ens+1
35  omemb=hwrf_expt.ensda.member(hwrf_expt.conf.cycle,imemb)
36  for prod in omemb.products():
37  if not prod.location:
38  logger.warning('ensda %03d: No product: %s'%(imemb,prod.did,))
39  bad=True
40  elif not prod.available:
41  logger.warning(
42  'ensda %03d: product %s not available (location %s)'%(
43  imemb,repr(prod.did),repr(prod.location)))
44  bad=True
45  else:
46  dest='%s/%s.ensda_%03d.%s'%(
47  hwrf_expt.conf.getdir('com'),
48  hwrf_expt.conf.getstr('config','out_prefix'),
49  imemb,os.path.basename(prod.location))
50  if not os.path.exists(dest):
51  logger.warning('ensda %03d: %s: does not exist'
52  %(imemb,dest,))
53  bad=True
54  elif os.path.getsize(dest)<1:
55  logger.warning('ensda %03d: %s: is empty'%(imemb,dest))
56  bad=True
57  else:
58  logger.info('ensda %03d: %s exists and is non-empty.'
59  %(imemb,dest))
60 
61  if bad:
62  logger.critical(
63  'HWRF data assimilation ensemble products are missing.')
64  sys.exit(1)
65 
66 if __name__=='__main__':
67  try:
69  jlogger.info('ensda_output is starting')
70  main()
71  jlogger.info('ensda_output is completed')
72  except Exception as e:
73  jlogger.critical('ensda_output is aborting: '+str(e),exc_info=True)
74  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 main()
Checks to see if all ensda jobs (exhwrf_ensda) ran correctly.
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
Utilities for ensemble-based data assimilation.
Definition: ensda.py:1
Configures logging.
Definition: log.py:1