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

Add IAU to snow DA (and its test) #2610

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b0656aa
start to add new task
CoryMartin-NOAA May 9, 2024
d16119d
add new j-job
CoryMartin-NOAA May 9, 2024
b4c97f8
Save to do some initial testing
CoryMartin-NOAA May 9, 2024
3667349
more updates
CoryMartin-NOAA May 9, 2024
accc4f4
Merge branch 'NOAA-EMC:develop' into feature/snow-ensemble
CoryMartin-NOAA May 14, 2024
e565f21
Merge branch 'develop' into feature/snow-ensemble
CoryMartin-NOAA May 16, 2024
81b7b6e
end of day commit
CoryMartin-NOAA May 16, 2024
3aaa8f6
End of day/week commit
CoryMartin-NOAA May 17, 2024
7085716
Merge branch 'NOAA-EMC:develop' into feature/snow-ensemble
CoryMartin-NOAA May 17, 2024
29641b2
save
CoryMartin-NOAA May 20, 2024
531136a
Merge branch 'feature/snow-ensemble' of https://github.com/CoryMartin…
CoryMartin-NOAA May 20, 2024
c124a41
Pull ensemble snow DA work out of this branch
CoryMartin-NOAA May 20, 2024
9d53f4b
turn on iau
CoryMartin-NOAA May 20, 2024
ad566e0
make norm happy again
CoryMartin-NOAA May 20, 2024
fae970d
Apply suggestions from code review
CoryMartin-NOAA May 20, 2024
5612d23
address great reviewer comments
CoryMartin-NOAA May 21, 2024
aa638e8
Merge branch 'develop' into feature/snow-iau
CoryMartin-NOAA May 22, 2024
0d0bfa1
Merge branch 'develop' into feature/snow-iau
aerorahul May 24, 2024
30bd93e
clean-up exglobal_atmos_sfcanl.sh and update the j-job for COMIN/COMOUT
aerorahul May 24, 2024
a625a11
shellcheck j-job
aerorahul May 24, 2024
15ec7f1
shellcheck exscript
aerorahul May 24, 2024
d4a2d97
Merge pull request #2 from aerorahul/patch/2610
CoryMartin-NOAA May 24, 2024
33e3d7c
Apply suggestions from code review
aerorahul May 24, 2024
9f0b727
Apply suggestions from code review
aerorahul May 24, 2024
ea7a371
Apply suggestions from code review
aerorahul May 24, 2024
840150b
Update exglobal_atmos_sfcanl.sh
CoryMartin-NOAA May 28, 2024
50d8d23
Update exglobal_atmos_sfcanl.sh
CoryMartin-NOAA May 28, 2024
57c7811
Merge branch 'develop' into feature/snow-iau
aerorahul May 28, 2024
6c05085
Merge branch 'develop' into feature/snow-iau
WalterKolczynski-NOAA May 28, 2024
8992431
Merge branch 'develop' into feature/snow-iau
CoryMartin-NOAA May 31, 2024
e870421
Merge branch 'develop' into feature/snow-iau
CoryMartin-NOAA Jun 3, 2024
3e5eea6
Revert CDATE for IAU beginning of window
CoryMartin-NOAA Jun 3, 2024
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
1 change: 0 additions & 1 deletion ci/cases/yamls/atmaerosnowDA_defaults_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defaults:
!INC {{ HOMEgfs }}/parm/config/gfs/yaml/defaults.yaml
base:
DOIAU: "NO"
DO_JEDISNOWDA: "YES"
ACCOUNT: {{ 'SLURM_ACCOUNT' | getenv }}
22 changes: 11 additions & 11 deletions scripts/exglobal_atmos_sfcanl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,14 @@ if [[ ${DOIAU} = "YES" ]]; then
# update surface restarts at the beginning of the window, if IAU
# For now assume/hold dtfanl.nc valid at beginning of window
for n in $(seq 1 ${ntiles}); do
${NCP} "${COM_ATMOS_RESTART_PREV}/${bPDY}.${bcyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${bPDY}.${bcyc}0000.sfcanl_data.tile${n}.nc"
${NLN} "${COM_ATMOS_RESTART_PREV}/${bPDY}.${bcyc}0000.sfc_data.tile${n}.nc" "${DATA}/fnbgsi.00${n}"
if [[ ${DO_JEDISNOWDA:-"NO"} = "YES" ]]; then
src_dir="${COM_SNOW_ANALYSIS}"
CoryMartin-NOAA marked this conversation as resolved.
Show resolved Hide resolved
else
src_dir="${COM_ATMOS_RESTART_PREV}"
fi
CoryMartin-NOAA marked this conversation as resolved.
Show resolved Hide resolved
${NCP} "${src_dir}/${bPDY}.${bcyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${bPDY}.${bcyc}0000.sfcanl_data.tile${n}.nc"
${NLN} "${src_dir}/${bPDY}.${bcyc}0000.sfc_data.tile${n}.nc" "${DATA}/fnbgsi.00${n}"
${NLN} "${COM_ATMOS_RESTART}/${bPDY}.${bcyc}0000.sfcanl_data.tile${n}.nc" "${DATA}/fnbgso.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}_grid.tile${n}.nc" "${DATA}/fngrid.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${n}.nc" "${DATA}/fnorog.00${n}"
Expand All @@ -185,14 +190,9 @@ fi

# Update surface restarts at middle of window
for n in $(seq 1 ${ntiles}); do
if [[ ${DO_JEDISNOWDA:-"NO"} = "YES" ]]; then
${NCP} "${COM_SNOW_ANALYSIS}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc"
else
${NCP} "${COM_ATMOS_RESTART_PREV}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc"
fi
${NLN} "${COM_ATMOS_RESTART_PREV}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" "${DATA}/fnbgsi.00${n}"
${NCP} "${src_dir}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc"
${NLN} "${src_dir}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" "${DATA}/fnbgsi.00${n}"
${NLN} "${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc" "${DATA}/fnbgso.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}_grid.tile${n}.nc" "${DATA}/fngrid.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${n}.nc" "${DATA}/fnorog.00${n}"
Expand Down
115 changes: 76 additions & 39 deletions ush/python/pygfs/task/snow_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def execute(self) -> None:
keys = ['HOMEgfs', 'DATA', 'current_cycle',
'COM_ATMOS_RESTART_PREV', 'COM_SNOW_ANALYSIS', 'APREFIX',
'SNOWDEPTHVAR', 'BESTDDEV', 'CASE', 'OCNRES', 'ntiles',
'APRUN_SNOWANL', 'JEDIEXE', 'jedi_yaml',
'APRUN_SNOWANL', 'JEDIEXE', 'jedi_yaml', 'DOIAU', 'SNOW_WINDOW_BEGIN',
'APPLY_INCR_NML_TMPL', 'APPLY_INCR_EXE', 'APRUN_APPLY_INCR']
for key in keys:
localconf[key] = self.task_config[key]
Expand Down Expand Up @@ -357,13 +357,19 @@ def finalize(self) -> None:
FileHandler(yaml_copy).sync()

logger.info("Copy analysis to COM")
template = f'{to_fv3time(self.task_config.current_cycle)}.sfc_data.tile{{tilenum}}.nc'
bkgtimes = []
if self.task_config.DOIAU:
# need both beginning and middle of window
bkgtimes.append(self.task_config.SNOW_WINDOW_BEGIN)
bkgtimes.append(self.task_config.current_cycle)
anllist = []
for itile in range(1, self.task_config.ntiles + 1):
filename = template.format(tilenum=itile)
src = os.path.join(self.task_config.DATA, 'anl', filename)
dest = os.path.join(self.task_config.COM_SNOW_ANALYSIS, filename)
anllist.append([src, dest])
for bkgtime in bkgtimes:
template = f'{to_fv3time(bkgtime)}.sfc_data.tile{{tilenum}}.nc'
for itile in range(1, self.task_config.ntiles + 1):
filename = template.format(tilenum=itile)
CoryMartin-NOAA marked this conversation as resolved.
Show resolved Hide resolved
src = os.path.join(self.task_config.DATA, 'anl', filename)
dest = os.path.join(self.task_config.COM_SNOW_ANALYSIS, filename)
anllist.append([src, dest])
FileHandler({'copy': anllist}).sync()

logger.info('Copy increments to COM')
Expand Down Expand Up @@ -542,6 +548,8 @@ def add_increments(config: Dict) -> None:
APPLY_INCR_NML_TMPL
APPLY_INCR_EXE
APRUN_APPLY_INCR
DOIAU
SNOW_WINDOW_BEGIN

Raises
------
Expand All @@ -553,38 +561,67 @@ def add_increments(config: Dict) -> None:

# 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'
bkgtimes = []
if config.DOIAU:
# want analysis at beginning and middle of window
bkgtimes.append(config.SNOW_WINDOW_BEGIN)
bkgtimes.append(config.current_cycle)
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])
for bkgtime in bkgtimes:
template = f'{to_fv3time(bkgtime)}.sfc_data.tile{{tilenum}}.nc'
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_data = Jinja(nml_template, config).render
logger.debug(f"apply_incr_nml:\n{nml_data}")

nml_file = os.path.join(config.DATA, "apply_incr_nml")
with open(nml_file, "w") as fho:
fho.write(nml_data)

logger.info("Link APPLY_INCR_EXE into DATA/")
exe_src = config.APPLY_INCR_EXE
exe_dest = os.path.join(config.DATA, os.path.basename(exe_src))
if os.path.exists(exe_dest):
rm_p(exe_dest)
os.symlink(exe_src, exe_dest)

# execute APPLY_INCR_EXE to create analysis files
exe = Executable(config.APRUN_APPLY_INCR)
exe.add_default_arg(os.path.join(config.DATA, os.path.basename(exe_src)))
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}")
if config.DOIAU:
logger.info("Copying increments to beginning of window")
template_in = f'snowinc.{to_fv3time(config.current_cycle)}.sfc_data.tile{{tilenum}}.nc'
template_out = f'snowinc.{to_fv3time(config.SNOW_WINDOW_BEGIN)}.sfc_data.tile{{tilenum}}.nc'
inclist = []
for itile in range(1, config.ntiles + 1):
filename_in = template_in.format(tilenum=itile)
filename_out = template_out.format(tilenum=itile)
src = os.path.join(config.DATA, 'anl', filename_in)
dest = os.path.join(config.DATA, 'anl', filename_out)
inclist.append([src, dest])
FileHandler({'copy': inclist}).sync()

# loop over times to apply increments
for bkgtime in bkgtimes:
logger.info("Processing analysis valid: {bkgtime}")
logger.info("Create namelist for APPLY_INCR_EXE")
nml_template = config.APPLY_INCR_NML_TMPL
nml_config = {
'current_cycle': bkgtime,
'CASE': config.CASE,
'DATA': config.DATA,
'HOMEgfs': config.HOMEgfs,
'OCNRES': config.OCNRES,
}
nml_data = Jinja(nml_template, nml_config).render
logger.debug(f"apply_incr_nml:\n{nml_data}")

nml_file = os.path.join(config.DATA, "apply_incr_nml")
with open(nml_file, "w") as fho:
fho.write(nml_data)

logger.info("Link APPLY_INCR_EXE into DATA/")
exe_src = config.APPLY_INCR_EXE
exe_dest = os.path.join(config.DATA, os.path.basename(exe_src))
if os.path.exists(exe_dest):
rm_p(exe_dest)
os.symlink(exe_src, exe_dest)

# execute APPLY_INCR_EXE to create analysis files
exe = Executable(config.APRUN_APPLY_INCR)
exe.add_default_arg(os.path.join(config.DATA, os.path.basename(exe_src)))
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}")
Loading