1 """!Functions called automatically before a cycle is launched.
3 This module contains utility functions for the hwrf.launcher.launch()
4 prelaunch argument. These functions edit the configuration of an
5 individual cycle before the cycle starts."""
13 __all__=[
'prelaunch_ungrib',
'prelaunch_rsmc',
'prelaunch_basin']
16 """!Changes the ungrib item and item2 based on the ensemble ID.
17 This is used to ensure ensemble member 0 uses the GEFS control,
18 which has a different item in the hwrf.input.DataCatalog."""
19 ens_overrides=conf.getbool(
'prelaunch',
'ensid_overrides')
21 logger.info(
'Ensemble ID overrides are disabled.')
23 ens=conf.getint(
'config',
'ENS',99)
24 item=conf.get(
'ungrib',
'item_E%02d'%ens,
'')
25 item2=conf.get(
'ungrib',
'item2_E%02d'%ens,
'')
27 logger.info(
'Overriding [ungrib] item=item_E%02d=%s'%(ens,item))
28 conf.set(
'ungrib',
'item',item)
30 logger.info(
'Overriding [ungrib] item2=item2_E%02d=%s'%(ens,item2))
31 conf.set(
'ungrib',
'item2',item2)
34 """!Change the ungrib table based on the year.
36 Modifies the tbl entry in the [ungrib] section based on the year
37 if a tbl$YEAR is available for the year of the cycle being run.
38 @param conf the hwrf.config.HWRFConfig to modify
39 @param logger the logging.Logger for log messages
40 @param cycle the cycle being run."""
41 ungrib_overrides=conf.getbool(
'prelaunch',
'ungrib_overrides')
42 if not ungrib_overrides:
43 logger.info(
'Ungrib overrides are disabled.')
50 tblYEARname=cyc.strftime(
"tbl%Y")
51 tblYEARvalue=conf.get(
"ungrib",tblYEARname,
'')
53 conf.set(
"ungrib",
'tbl',tblYEARvalue)
56 """!Modifies the configuration for the RSMC (JTWC, NHC, etc.)
58 Modifies the configuration to work differently for JTWC and NHC
59 storms. Searches for the rsmc_conf option in the [prelaunch]
60 section for the name of a configuration file to read, and reads it
62 @param conf the hwrf.config.HWRFConfig to modify
63 @param logger the logging.Logger for log messages
64 @param cycle the cycle being run."""
65 rsmc_overrides=conf.getbool(
'prelaunch',
'rsmc_overrides')
66 if not rsmc_overrides:
67 logger.info(
'RSMC overrides are disabled.')
71 rsmc=str(vit.center).upper()
72 rfile=conf.strinterp(
'prelaunch',
'{rsmc_conf}',RSMC=rsmc)
74 logger.warning(
'%s: RSMC override file is empty or non-existent'
79 """!Modifies the configuration for the basin.
81 @anchor prelaunch_basin_main
82 Modifies the configuration to work differently for each basin.
83 Searches for the basin_conf option in the [prelaunch] section for
84 the name of a configuration file to read, and reads it if it
85 exists. If it does not exist, searches for the no_basin_conf
86 section in [prelaunch] and runs that instead, if it exists.
87 @param conf the hwrf.config.HWRFConfig to modify
88 @param logger the logging.Logger for log messages
89 @param cycle the cycle being run."""
90 basin_overrides=conf.getbool(
'prelaunch',
'basin_overrides')
91 if not basin_overrides:
92 logger.info(
'Basin overrides are disabled.')
97 logger.warning(
'Cannot use basin overrides - conf.syndat is None')
99 bfile=conf.strinterp(
'prelaunch',
'{basin_conf}',vit=vit)
100 nfile=conf.strinterp(
'prelaunch',
'{no_basin_conf}',vit=vit)
102 if os.path.exists(bfile):
103 logger.warning(
'%s: reading basin override file'%(bfile,))
105 elif os.path.exists(nfile):
106 logger.warning(
'%s: basin override enabled, but file is '
107 'missing or empty; will read %s instead.'
111 logger.warning(
'%s: basin override enabled, and no "no_basin_file"'
112 'is available at %s; will not override defaults.'
This module provides a set of utility functions to do filesystem operations.
def prelaunch_basin(conf, logger, cycle)
Modifies the configuration for the basin.
def prelaunch_ensid(conf, logger)
Changes the ungrib item and item2 based on the ensemble ID.
def isnonempty(filename)
Returns True if the filename refers to an existent file that is non-empty, and False otherwise...
def to_datetime(d)
Converts the argument to a datetime.
Time manipulation and other numerical routines.
def prelaunch_ungrib(conf, logger, cycle)
Change the ungrib table based on the year.
def prelaunch_rsmc(conf, logger, cycle)
Modifies the configuration for the RSMC (JTWC, NHC, etc.)