Skip to content

Commit

Permalink
Add the capability to assimilate the MADIS snow depth data from GTS (#…
Browse files Browse the repository at this point in the history
…1836)

* Update the GDASApp's commit hash.
  • Loading branch information
jiaruidong2017 committed Sep 13, 2023
1 parent 5d04b65 commit ffa9445
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protocol = git
required = False

[GDASApp]
hash = ac8fdb1
hash = d347d22
local_path = sorc/gdas.cd
repo_url = https://github.com/NOAA-EMC/GDASApp.git
protocol = git
Expand Down
2 changes: 1 addition & 1 deletion parm/config/gfs/config.landanl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "BEGIN: config.landanl"
# Get task specific resources
. "${EXPDIR}/config.resources" landanl

obs_list_name=gdas_land_adpsfc_only.yaml
obs_list_name=gdas_land_gts_only.yaml
if [[ "${cyc}" = "18" ]]; then
obs_list_name=gdas_land_prototype.yaml
fi
Expand Down
1 change: 0 additions & 1 deletion parm/config/gfs/config.preplandobs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ echo "BEGIN: config.preplandobs"

export GTS_OBS_LIST="${HOMEgfs}/sorc/gdas.cd/parm/land/prep/prep_gts.yaml"
export BUFR2IODAX="${HOMEgfs}/exec/bufr2ioda.x"
export BUFR2IODAYAML="${HOMEgfs}/sorc/gdas.cd/test/testinput/bufr_adpsfc_snow.yaml"
export FIMS_NML_TMPL="${HOMEgfs}/sorc/gdas.cd/parm/land/prep/fims.nml.j2"
export IMS_OBS_LIST="${HOMEgfs}/sorc/gdas.cd/parm/land/prep/prep_ims.yaml"
export CALCFIMSEXE="${HOMEgfs}/exec/calcfIMS.exe"
Expand Down
2 changes: 1 addition & 1 deletion sorc/checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ if [[ ${checkout_gsi} == "YES" ]]; then
fi

if [[ ${checkout_gdas} == "YES" ]]; then
checkout "gdas.cd" "https://github.com/NOAA-EMC/GDASApp.git" "ac8fdb1"; errs=$((errs + $?))
checkout "gdas.cd" "https://github.com/NOAA-EMC/GDASApp.git" "d347d22"; errs=$((errs + $?))
fi

if [[ ${checkout_gsi} == "YES" || ${checkout_gdas} == "YES" ]]; then
Expand Down
54 changes: 28 additions & 26 deletions ush/python/pygfs/task/land_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def prepare_GTS(self) -> None:

# create a temporary dict of all keys needed in this method
localconf = AttrDict()
keys = ['DATA', 'current_cycle', 'COM_OBS', 'COM_ATMOS_RESTART_PREV',
keys = ['HOMEgfs', 'DATA', 'current_cycle', 'COM_OBS', 'COM_ATMOS_RESTART_PREV',
'OPREFIX', 'CASE', 'ntiles']
for key in keys:
localconf[key] = self.task_config[key]
Expand All @@ -87,46 +87,48 @@ def prepare_GTS(self) -> None:
logger.info("Copying GTS obs for bufr2ioda.x")
FileHandler(prep_gts_config.gtsbufr).sync()

# generate bufr2ioda YAML file
bufr2ioda_yaml = os.path.join(self.runtime_config.DATA, "bufr_adpsfc_snow.yaml")
logger.info(f"Generate BUFR2IODA YAML file: {bufr2ioda_yaml}")
temp_yaml = parse_j2yaml(self.task_config.BUFR2IODAYAML, self.task_config)
save_as_yaml(temp_yaml, bufr2ioda_yaml)
logger.info(f"Wrote bufr2ioda YAML to: {bufr2ioda_yaml}")

logger.info("Link BUFR2IODAX into DATA/")
exe_src = self.task_config.BUFR2IODAX
exe_dest = os.path.join(localconf.DATA, os.path.basename(exe_src))
if os.path.exists(exe_dest):
rm_p(exe_dest)
os.symlink(exe_src, exe_dest)

output_file = f"{localconf.OPREFIX}adpsfc_snow.nc4"
if os.path.isfile(f"{os.path.join(localconf.DATA, output_file)}"):
rm_p(output_file)

# execute BUFR2IODAX to convert GTS bufr data into IODA format
yaml_file = f"bufr_adpsfc_snow.yaml"
if not os.path.isfile(f"{os.path.join(localconf.DATA, yaml_file)}"):
logger.exception(f"{yaml_file} not found")
raise FileNotFoundError(f"{os.path.join(localconf.DATA, yaml_file)}")
# Create executable instance
exe = Executable(self.task_config.BUFR2IODAX)
exe.add_default_arg(os.path.join(localconf.DATA, f"{yaml_file}"))

logger.info(f"Executing {exe}")
try:
exe()
except OSError:
raise OSError(f"Failed to execute {exe}")
except Exception:
raise WorkflowException(f"An error occured during execution of {exe}")
def _gtsbufr2iodax(exe, yaml_file):
if not os.path.isfile(yaml_file):
logger.exception(f"{yaml_file} not found")
raise FileNotFoundError(yaml_file)

logger.info(f"Executing {exe}")
try:
exe(yaml_file)
except OSError:
raise OSError(f"Failed to execute {exe} {yaml_file}")
except Exception:
raise WorkflowException(f"An error occured during execution of {exe} {yaml_file}")

# Loop over entries in prep_gts_config.bufr2ioda keys
# 1. generate bufr2ioda YAML files
# 2. execute bufr2ioda.x
for name in prep_gts_config.bufr2ioda.keys():
gts_yaml = os.path.join(self.runtime_config.DATA, f"bufr_{name}_snow.yaml")
logger.info(f"Generate BUFR2IODA YAML file: {gts_yaml}")
temp_yaml = parse_j2yaml(prep_gts_config.bufr2ioda[name], localconf)
save_as_yaml(temp_yaml, gts_yaml)
logger.info(f"Wrote bufr2ioda YAML to: {gts_yaml}")

# execute BUFR2IODAX to convert {name} bufr data into IODA format
_gtsbufr2iodax(exe, gts_yaml)

# Ensure the IODA snow depth GTS file is produced by the IODA converter
# If so, copy to COM_OBS/
try:
FileHandler(prep_gts_config.gtsioda).sync()
except OSError as err:
logger.exception(f"{self.task_config.BUFR2IODAX} failed to produce {output_file}")
logger.exception(f"{self.task_config.BUFR2IODAX} failed to produce GTS ioda files")
raise OSError(err)

@logit(logger)
Expand Down

0 comments on commit ffa9445

Please sign in to comment.