Skip to content

Commit

Permalink
Merge branch 'feature/snow-ensemble' of https://github.com/CoryMartin…
Browse files Browse the repository at this point in the history
…-NOAA/global-workflow into feature/snow-ensemble
  • Loading branch information
CoryMartin-NOAA committed Jun 7, 2024
2 parents aeb3f79 + 9145004 commit 06c8e3a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
4 changes: 4 additions & 0 deletions parm/config/gfs/config.esnowanl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export JEDI_FIX_YAML="${PARMgfs}/gdas/atm_jedi_fix.yaml.j2"
export SNOW_ENS_STAGE_TMPL="${PARMgfs}/gdas/snow_stage_ens_update.yaml.j2"
export SNOW_OROG_STAGE_TMPL="${PARMgfs}/gdas/snow_stage_orog.yaml.j2"

# Name of the executable that applies increment to bkg and its namelist template
export APPLY_INCR_EXE="${EXECgfs}/apply_incr.exe"
export APPLY_INCR_NML_TMPL="${PARMgfs}/gdas/snow/letkfoi/ens_apply_incr_nml.j2"

export io_layout_x=@IO_LAYOUT_X@
export io_layout_y=@IO_LAYOUT_Y@

Expand Down
3 changes: 3 additions & 0 deletions parm/gdas/snow_stage_ens_update.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mkdir:
- "{{ DATA }}//inc/ensmean"
{% for mem in range(1, NMEM_ENS + 1) %}
- "{{ DATA }}/bkg/mem{{ '%03d' % mem }}"
- "{{ DATA }}/anl/mem{{ '%03d' % mem }}"
{% endfor %}
copy:
######################################
Expand Down Expand Up @@ -96,7 +97,9 @@ copy:
{% set replace_term = tmpl_dict[key] %}
{% set com_prev_ns.COM_ATMOS_RESTART_MEM = com_prev_ns.COM_ATMOS_RESTART_MEM.replace(search_term, replace_term) %}
{% endfor %}
# we need to copy them to two places, one serves as the basis for the analysis
{% for tile in range(1, 7) %}
- ["{{ com_prev_ns.COM_ATMOS_RESTART_MEM }}/{{ bkg_time }}.sfc_data.tile{{ tile }}.nc", "{{ DATA }}/bkg/mem{{ '%03d' % mem }}/{{ bkg_time }}.sfc_data.tile{{ tile }}.nc"]
- ["{{ com_prev_ns.COM_ATMOS_RESTART_MEM }}/{{ bkg_time }}.sfc_data.tile{{ tile }}.nc", "{{ DATA }}/anl/mem{{ '%03d' % mem }}/{{ bkg_time }}.sfc_data.tile{{ tile }}.nc"]
{% endfor %}
{% endfor %}
45 changes: 31 additions & 14 deletions ush/python/pygfs/task/snowens_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def regridDetBkg(self) -> None:
f"--input_mosaic ./orog/det/{self.task_config.CASE}_mosaic.nc",
f"--input_dir ./bkg/det/",
f"--input_file {to_fv3time(self.task_config.bkg_time)}.sfc_data",
f"--scalar_field snodl",
f"--scalar_field snodl,slmsk",
f"--output_dir ./bkg/det_ensres/",
f"--output_file {to_fv3time(self.task_config.bkg_time)}.sfc_data",
f"--output_mosaic ./orog/ens/{self.task_config.CASE_ENS}_mosaic.nc",
Expand Down Expand Up @@ -210,6 +210,35 @@ def finalize(self) -> None:
Instance of the SnowEnsAnalysis object
"""

@staticmethod
@logit(logger)
def addEnsIncrements(self) -> None:
"""Loop through all ensemble members and apply increment to create
a surface analysis for snow
Parameters
----------
self : Analysis
Instance of the SnowEnsAnalysis object
"""
for mem in range(1, self.task_config.NMEM_ENS + 1):
# for now, just looping serially, should parallelize this eventually
logger.info(f"Now applying increment to member mem{mem:03}")
chdir(os.path.join(self.task_config.DATA, "anl", f"mem{mem:03}"))
memdict = {
'HOMEgfs': self.task_config.HOMEgfs,
'DATA': os.path.join(self.task_config.DATA, "anl", f"mem{mem:03}"),
'current_cycle': self.task_config.bkg_time,
'CASE_ENS': self.task_config.CASE_ENS,
'OCNRES': self.task_config.OCNRES,
'ntiles': 6,
'ENS_APPLY_INCR_NML_TMPL': self.task_config.ENS_APPLY_INCR_NML_TMPL,
'APPLY_INCR_EXE': self.task_config.APPLY_INCR_EXE,
'APRUN_APPLY_INCR': self.task_config.APRUN_APPLY_INCR,
}
self.add_increments(memdict)


@staticmethod
@logit(logger)
def get_bkg_dict(config: Dict) -> Dict[str, List[str]]:
Expand Down Expand Up @@ -251,7 +280,6 @@ def add_increments(config: Dict) -> None:
Dictionary of key-value pairs needed in this method
Should contain the following keys:
HOMEgfs
COM_ATMOS_RESTART_PREV
DATA
current_cycle
CASE
Expand All @@ -269,19 +297,8 @@ def add_increments(config: Dict) -> None:
All other exceptions
"""

# need backgrounds to create analysis from increments after LETKF
logger.info("Copy backgrounds into anl/ directory for creating analysis from increments")
template = f'{to_fv3time(config.current_cycle)}.sfc_data.tile{{tilenum}}.nc'
anllist = []
for itile in range(1, config.ntiles + 1):
filename = template.format(tilenum=itile)
src = os.path.join(config.COM_ATMOS_RESTART_PREV, filename)
dest = os.path.join(config.DATA, "anl", filename)
anllist.append([src, dest])
FileHandler({'copy': anllist}).sync()

logger.info("Create namelist for APPLY_INCR_EXE")
nml_template = config.APPLY_INCR_NML_TMPL
nml_template = config.ENS_APPLY_INCR_NML_TMPL
nml_data = Jinja(nml_template, config).render
logger.debug(f"apply_incr_nml:\n{nml_data}")

Expand Down

0 comments on commit 06c8e3a

Please sign in to comment.