Skip to content

Commit

Permalink
IAU changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMartin-NOAA committed Jun 10, 2024
1 parent b029f90 commit 18aaafa
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 22 deletions.
6 changes: 6 additions & 0 deletions jobs/JGLOBAL_PREP_SNOW_OBS
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ if [[ -e "${pgmout}" ]] ; then
cat "${pgmout}"
fi

##########################################
# Remove the Temporary working directory
##########################################
cd ${DATAROOT}
[[ ${KEEPDATA} = "NO" ]] && rm -rf ${DATA}

exit 0
6 changes: 6 additions & 0 deletions jobs/JGLOBAL_SNOW_ANALYSIS
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ if [[ -e "${pgmout}" ]] ; then
cat "${pgmout}"
fi

##########################################
# Remove the Temporary working directory
##########################################
cd ${DATAROOT}
[[ ${KEEPDATA} = "NO" ]] && rm -rf ${DATA}

exit 0
6 changes: 6 additions & 0 deletions jobs/JGLOBAL_SNOW_ENSEMBLE_ANALYSIS
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ if [[ -e "${pgmout}" ]] ; then
cat "${pgmout}"
fi

##########################################
# Remove the Temporary working directory
##########################################
cd ${DATAROOT}
[[ ${KEEPDATA} = "NO" ]] && rm -rf ${DATA}

exit 0
12 changes: 10 additions & 2 deletions parm/gdas/snow_stage_ens_update.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ copy:
{% 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"]
- ["{{ com_prev_ns.COM_ATMOS_RESTART_MEM }}/{{ current_cycle | to_fv3time }}.sfc_data.tile{{ tile }}.nc", "{{ DATA }}/bkg/mem{{ '%03d' % mem }}/{{ current_cycle | to_fv3time }}.sfc_data.tile{{ tile }}.nc"]
- ["{{ com_prev_ns.COM_ATMOS_RESTART_MEM }}/{{ current_cycle | to_fv3time }}.sfc_data.tile{{ tile }}.nc", "{{ DATA }}/anl/mem{{ '%03d' % mem }}/{{ current_cycle | to_fv3time }}.sfc_data.tile{{ tile }}.nc"]
{% endfor %}
{% if DOIAU %}
# if using IAU, also need backgrounds copied at the beginning of the window
# 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 }}/{{ SNOW_WINDOW_BEGIN | to_fv3time }}.sfc_data.tile{{ tile }}.nc", "{{ DATA }}/bkg/mem{{ '%03d' % mem }}/{{ SNOW_WINDOW_BEGIN | to_fv3time }}.sfc_data.tile{{ tile }}.nc"]
- ["{{ com_prev_ns.COM_ATMOS_RESTART_MEM }}/{{ SNOW_WINDOW_BEGIN | to_fv3time }}.sfc_data.tile{{ tile }}.nc", "{{ DATA }}/anl/mem{{ '%03d' % mem }}/{{ SNOW_WINDOW_BEGIN | to_fv3time }}.sfc_data.tile{{ tile }}.nc"]
{% endfor %}
{% endif %}
{% endfor %}
62 changes: 42 additions & 20 deletions ush/python/pygfs/task/snowens_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,26 +225,48 @@ def addEnsIncrements(self) -> None:
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}")
logger.info(f'{os.path.join(self.task_config.DATA, "anl", f"mem{mem:03}")}')
memdict = AttrDict(
{
'HOMEgfs': self.task_config.HOMEgfs,
'DATA': os.path.join(self.task_config.DATA, "anl", f"mem{mem:03}"),
'DATAROOT': self.task_config.DATA,
'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,
'MYMEM': f"{mem:03}",
}
)
self.add_increments(memdict)

bkg_times = []
# no matter what, we want to process the center of the window
bkg_times.append(self.task_config.current_cycle)
# if DOIAU, we need to copy the increment to be valid at the center of the window
# and compute the analysis there to restart the model
if self.task_config.DOIAU:
logger.info("Copying increments to beginning of window")
template_in = f'snowinc.{to_fv3time(self.task_config.SNOW_WINDOW_BEGIN)}.sfc_data.tile{{tilenum}}.nc'
template_out = f'snowinc.{to_fv3time(self.task_config.current_cycle)}.sfc_data.tile{{tilenum}}.nc'
inclist = []
for itile in range(1, 7):
filename_in = template_in.format(tilenum=itile)
filename_out = template_out.format(tilenum=itile)
src = os.path.join(self.task_config.DATA, 'inc', 'ensmean', filename_in)
dest = os.path.join(self.task_config.DATA, 'inc', 'ensmean', filename_out)
inclist.append([src, dest])
FileHandler({'copy': inclist}).sync()
# if running with IAU, we also need an analysis at the beginning of the window
bkg_times.append(self.task_config.SNOW_WINDOW_BEGIN)

for bkg_time in bkg_times:
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}")
logger.info(f'{os.path.join(self.task_config.DATA, "anl", f"mem{mem:03}")}')
memdict = AttrDict(
{
'HOMEgfs': self.task_config.HOMEgfs,
'DATA': os.path.join(self.task_config.DATA, "anl", f"mem{mem:03}"),
'DATAROOT': self.task_config.DATA,
'current_cycle': 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,
'MYMEM': f"{mem:03}",
}
)
self.add_increments(memdict)

@staticmethod
@logit(logger)
Expand Down

0 comments on commit 18aaafa

Please sign in to comment.