Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat snowDA templates to jinja2 #2371

Merged
merged 9 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ fix/wave

# Ignore parm file symlinks
#--------------------------
parm/config/config.base
parm/gldas
parm/gdas/aero
parm/gdas/atm
parm/gdas/io
parm/gdas/ioda
parm/gdas/snow
parm/gdas/soca
parm/monitor
parm/post/AEROSOL_LUTS.dat
parm/post/nam_micro_lookup.dat
Expand Down
40 changes: 21 additions & 19 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
[submodule "sorc/ufs_model.fd"]
path = sorc/ufs_model.fd
url = https://github.com/ufs-community/ufs-weather-model
ignore = dirty
path = sorc/ufs_model.fd
url = https://github.com/ufs-community/ufs-weather-model
ignore = dirty
[submodule "sorc/wxflow"]
path = sorc/wxflow
url = https://github.com/NOAA-EMC/wxflow
path = sorc/wxflow
url = https://github.com/NOAA-EMC/wxflow
branch = feature/jinja_includes
[submodule "sorc/gfs_utils.fd"]
path = sorc/gfs_utils.fd
url = https://github.com/NOAA-EMC/gfs-utils
path = sorc/gfs_utils.fd
url = https://github.com/NOAA-EMC/gfs-utils
[submodule "sorc/ufs_utils.fd"]
path = sorc/ufs_utils.fd
url = https://github.com/ufs-community/UFS_UTILS.git
path = sorc/ufs_utils.fd
url = https://github.com/ufs-community/UFS_UTILS.git
[submodule "sorc/verif-global.fd"]
path = sorc/verif-global.fd
url = https://github.com/NOAA-EMC/EMC_verif-global.git
path = sorc/verif-global.fd
url = https://github.com/NOAA-EMC/EMC_verif-global.git
[submodule "sorc/gsi_enkf.fd"]
path = sorc/gsi_enkf.fd
url = https://github.com/NOAA-EMC/GSI.git
path = sorc/gsi_enkf.fd
url = https://github.com/NOAA-EMC/GSI.git
[submodule "sorc/gdas.cd"]
path = sorc/gdas.cd
url = https://github.com/NOAA-EMC/GDASApp.git
path = sorc/gdas.cd
url = https://github.com/NOAA-EMC/GDASApp.git
branch = feature/gdasapp-snowDA-jinja2
[submodule "sorc/gsi_utils.fd"]
path = sorc/gsi_utils.fd
url = https://github.com/NOAA-EMC/GSI-Utils.git
path = sorc/gsi_utils.fd
url = https://github.com/NOAA-EMC/GSI-Utils.git
[submodule "sorc/gsi_monitor.fd"]
path = sorc/gsi_monitor.fd
url = https://github.com/NOAA-EMC/GSI-Monitor.git
path = sorc/gsi_monitor.fd
url = https://github.com/NOAA-EMC/GSI-Monitor.git
9 changes: 6 additions & 3 deletions parm/config/gfs/config.prepsnowobs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ echo "BEGIN: config.prepsnowobs"
# Get task specific resources
. "${EXPDIR}/config.resources" prepsnowobs

export GTS_OBS_LIST="${HOMEgfs}/sorc/gdas.cd/parm/snow/prep/prep_gts.yaml"
export GTS_OBS_LIST="${HOMEgfs}/parm/gdas/snow/prep/prep_gts.yaml.j2"
export IMS_OBS_LIST="${HOMEgfs}/parm/gdas/snow/prep/prep_ims.yaml.j2"

export BUFR2IODAX="${HOMEgfs}/exec/bufr2ioda.x"
export FIMS_NML_TMPL="${HOMEgfs}/sorc/gdas.cd/parm/snow/prep/fims.nml.j2"
export IMS_OBS_LIST="${HOMEgfs}/sorc/gdas.cd/parm/snow/prep/prep_ims.yaml"

export CALCFIMSEXE="${HOMEgfs}/exec/calcfIMS.exe"
export FIMS_NML_TMPL="${HOMEgfs}/parm/gdas/snow/prep/fims.nml.j2"

export IMS2IODACONV="${HOMEgfs}/ush/imsfv3_scf2ioda.py"

echo "END: config.prepsnowobs"
7 changes: 0 additions & 7 deletions parm/gdas/snow_jedi_fix.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions parm/gdas/snow_jedi_fix.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir:
- '{{ DATA }}/fv3jedi'
copy:
- ['{{ HOMEgfs }}/fix/gdas/fv3jedi/fv3files/akbk{{ npz }}.nc4', '{{ DATA }}/fv3jedi/akbk.nc4']
- ['{{ HOMEgfs }}/fix/gdas/fv3jedi/fv3files/fmsmpp.nml', '{{ DATA }}/fv3jedi/fmsmpp.nml']
- ['{{ HOMEgfs }}/fix/gdas/fv3jedi/fv3files/field_table_gfdl', '{{ DATA }}/fv3jedi/field_table']
- ['{{ HOMEgfs }}/sorc/gdas.cd/parm/io/fv3jedi_fieldmetadata_restart.yaml', '{{ DATA }}/fv3jedi/fv3jedi_fieldmetadata_restart.yaml']
12 changes: 12 additions & 0 deletions sorc/link_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ if [[ -d "${HOMEgfs}/sorc/gdas.cd" ]]; then
done
fi

#------------------------------
#--add GDASApp parm directory
#------------------------------
if [[ -d "${HOMEgfs}/sorc/gdas.cd" ]]; then
cd "${HOMEgfs}/parm/gdas" || exit 1
declare -a gdasapp_comps=("aero" "atm" "io" "ioda" "snow" "soca")
for comp in "${gdasapp_comps[@]}"; do
[[ -d "${comp}" ]] && rm -rf "${comp}"
${LINK_OR_COPY} "${HOMEgfs}/sorc/gdas.cd/parm/${comp}" .
done
fi

#------------------------------
#--add GDASApp files
#------------------------------
Expand Down
6 changes: 4 additions & 2 deletions ush/python/pygfs/task/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Analysis(Task):
def __init__(self, config: Dict[str, Any]) -> None:
super().__init__(config)
self.config.ntiles = 6
# Store location of GDASApp jinja2 templates
self.gdasapp_j2tmpl_dir = os.path.join(self.config.HOMEgfs, 'parm/gdas')

def initialize(self) -> None:
super().initialize()
Expand Down Expand Up @@ -56,7 +58,7 @@ def get_obs_dict(self) -> Dict[str, Any]:
a dictionary containing the list of observation files to copy for FileHandler
"""
logger.debug(f"OBS_LIST: {self.task_config['OBS_LIST']}")
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config)
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
logger.debug(f"obs_list_config: {obs_list_config}")
# get observers from master dictionary
observers = obs_list_config['observers']
Expand Down Expand Up @@ -88,7 +90,7 @@ def get_bias_dict(self) -> Dict[str, Any]:
a dictionary containing the list of observation bias files to copy for FileHandler
"""
logger.debug(f"OBS_LIST: {self.task_config['OBS_LIST']}")
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config)
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
logger.debug(f"obs_list_config: {obs_list_config}")
# get observers from master dictionary
observers = obs_list_config['observers']
Expand Down
11 changes: 5 additions & 6 deletions ush/python/pygfs/task/snow_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
FileHandler,
to_fv3time, to_YMD, to_YMDH, to_timedelta, add_to_datetime,
rm_p,
parse_j2yaml, parse_yamltmpl, save_as_yaml,
parse_j2yaml, save_as_yaml,
Jinja,
logit,
Executable,
Expand Down Expand Up @@ -99,7 +99,7 @@ def prepare_GTS(self) -> None:

def _gtsbufr2iodax(exe, yaml_file):
if not os.path.isfile(yaml_file):
logger.exception(f"{yaml_file} not found")
logger.exception(f"FATAL ERROR: {yaml_file} not found")
raise FileNotFoundError(yaml_file)

logger.info(f"Executing {exe}")
Expand Down Expand Up @@ -260,9 +260,9 @@ def initialize(self) -> None:
FileHandler({'mkdir': dirlist}).sync()

# stage fix files
jedi_fix_list_path = os.path.join(self.task_config.HOMEgfs, 'parm', 'gdas', 'snow_jedi_fix.yaml')
jedi_fix_list_path = os.path.join(self.task_config.HOMEgfs, 'parm', 'gdas', 'snow_jedi_fix.yaml.j2')
logger.info(f"Staging JEDI fix files from {jedi_fix_list_path}")
jedi_fix_list = parse_yamltmpl(jedi_fix_list_path, self.task_config)
jedi_fix_list = parse_j2yaml(jedi_fix_list_path, self.task_config)
FileHandler(jedi_fix_list).sync()

# stage backgrounds
Expand All @@ -271,10 +271,9 @@ def initialize(self) -> None:

# generate letkfoi YAML file
logger.info(f"Generate JEDI LETKF YAML file: {self.task_config.jedi_yaml}")
letkfoi_yaml = parse_j2yaml(self.task_config.JEDIYAML, self.task_config)
letkfoi_yaml = parse_j2yaml(self.task_config.JEDIYAML, self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
save_as_yaml(letkfoi_yaml, self.task_config.jedi_yaml)
logger.info(f"Wrote letkfoi YAML to: {self.task_config.jedi_yaml}")

# need output dir for diags and anl
logger.info("Create empty output [anl, diags] directories to receive output from executable")
newdirs = [
Expand Down