Skip to content

Commit

Permalink
use Template to build restart paths in atmens_analysis (NOAA-EMC#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
RussTreadon-NOAA committed Apr 27, 2023
1 parent 0f1c2cf commit 3253bfd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ush/python/pygfs/task/atmens_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

from pygw.attrdict import AttrDict
from pygw.file_utils import FileHandler
from pygw.timetools import add_to_datetime, to_fv3time, to_timedelta, to_YMDH
from pygw.timetools import add_to_datetime, to_fv3time, to_timedelta, to_YMDH, to_YMD
from pygw.fsutils import rm_p, chdir
from pygw.yaml_file import parse_yamltmpl, parse_j2yaml, save_as_yaml
from pygw.logger import logit
from pygw.executable import Executable
from pygw.exceptions import WorkflowException
from pygw.template import Template, TemplateConstants
from pygfs.task.analysis import Analysis

logger = getLogger(__name__.split('.')[-1])
Expand Down Expand Up @@ -233,7 +234,19 @@ def get_bkg_dict(self, task_config: Dict[str, Any]) -> Dict[str, List[str]]:
dirlist.append(os.path.join(task_config.DATA, 'bkg', memchar))

# get FV3 restart files, this will be a lot simpler when using history files
rst_dir = os.path.join(task_config.COM_TOP_ENS_GES, memchar, 'model_data/atmos/restart')
template = task_config.COM_ATMOS_RESTART_TMPL
tmpl_dict = {
'ROTDIR': task_config.ROTDIR,
'RUN': self.runtime_config.RUN,
'YMD': to_YMD(task_config.previous_cycle),
'HH': task_config.previous_cycle.strftime('%H')
}

# get FV3 restart files, this will be a lot simpler when using history files
tmpl_dict['MEMDIR'] = memchar
rst_dir = Template.substitute_structure(template, TemplateConstants.DOLLAR_CURLY_BRACE, tmpl_dict.get)
os.makedirs(rst_dir, mode=0o775, exist_ok=True)

run_dir = os.path.join(task_config.DATA, 'bkg', memchar)

# atmens DA needs coupler
Expand Down

0 comments on commit 3253bfd

Please sign in to comment.