Skip to content

Commit

Permalink
Merge branch 'develop' into feature/oops_example
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMartin-NOAA committed Aug 8, 2023
2 parents 78a1aeb + 7b67146 commit 289352c
Show file tree
Hide file tree
Showing 20 changed files with 579 additions and 218 deletions.
4 changes: 2 additions & 2 deletions parm/soca/berror/saber_blocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ components:
read_from_file: 1
date: '{{ATM_WINDOW_MIDDLE}}'
basename: ./static_ens/
ocn_filename: 'ocn.filtered.%mem%.incr.{{ATM_WINDOW_BEGIN}}.nc'
ice_filename: 'ice.filtered.%mem%.incr.{{ATM_WINDOW_BEGIN}}.nc'
ocn_filename: 'ocn.pert.steric.%mem%.{{ATM_WINDOW_BEGIN}}.nc'
ice_filename: 'ice.pert.ens.%mem%.{{ATM_WINDOW_BEGIN}}.PT0S.nc'
state variables: [tocn, socn, ssh, uocn, vocn, cicen, hicen, hsnon]
pattern: '%mem%'
nmembers: ${CLIM_ENS_SIZE}
Expand Down
66 changes: 36 additions & 30 deletions parm/soca/berror/soca_apply_steric.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
input geometry:
geometry:
geom_grid_file: soca_gridspec.nc
mom6_input_nml: mom_input.nml
fields metadata: fields_metadata.yaml

output geometry:
geom_grid_file: soca_gridspec.nc
mom6_input_nml: mom_input.nml
fields metadata: fields_metadata.yaml
date: '{{ATM_WINDOW_BEGIN}}'

layers variable: [hocn]

increment variables: [tocn, socn, uocn, vocn, ssh, hocn]

set increment variables to zero: [ssh]

vertical geometry:
read_from_file: 1
basename: ./INPUT/
ocn_filename: MOM.res.nc
date: '{{ATM_WINDOW_BEGIN}}'

soca increments:
number of increments: ${CLIM_ENS_SIZE}
pattern: '%mem%'
template:
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./static_ens/
ocn_filename: 'ocn.pert.ens.%mem%.{{ATM_WINDOW_BEGIN}}.PT0S.nc'
read_from_file: 1

linear variable change:
input variables: [tocn, socn, ssh, uocn, vocn, hocn, cicen, hicen, hsnon]
output variables: [tocn, socn, ssh, uocn, vocn, hocn, cicen, hicen, hsnon]
do inverse: false
linear variable changes:
- linear variable change name: BkgErrFILT
ocean_depth_min: 500 # zero where ocean is shallower than 500m
rescale_bkgerr: 0.3 # rescale perturbation
rescale_bkgerr: 1.0 # rescale perturbation
efold_z: 1500.0 # Apply exponential decay
- linear variable change name: BalanceSOCA # linear steric height from (T,S) perturbation

increments:
- date: '{{ATM_WINDOW_BEGIN}}'
input variables: [tocn, socn, ssh, uocn, vocn, hocn, cicen, hicen, hsnon]
input:
read_from_file: 1
basename: ./static_ens/
ocn_filename: 'ocn.bal.ens.MEMNUM.{{ATM_WINDOW_BEGIN}}.PT0S.nc'
ice_filename: 'ice.bal.ens.MEMNUM.{{ATM_WINDOW_BEGIN}}.PT0S.nc'
date: '{{ATM_WINDOW_BEGIN}}'
state variables: [ssh, tocn, socn, uocn, vocn, cicen, hicen, hsnon]
- linear variable change name: BalanceSOCA
trajectory:
read_from_file: 1
state variables: [tocn, socn, uocn, vocn, ssh, hocn, layer_depth, mld]
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./INPUT/
ocn_filename: MOM.res.nc
ice_filename: cice.res.nc
date: '{{ATM_WINDOW_BEGIN}}'
state variables: [cicen, hicen, hsnon, socn, tocn, uocn, vocn, ssh, hocn, mld, layer_depth]
output:
datadir: ./static_ens
exp: filtered.MEMNUM
type: incr
date: '{{ATM_WINDOW_BEGIN}}'
read_from_file: 1

output increment:
datadir: ./static_ens/
date: '{{ATM_WINDOW_BEGIN}}'
exp: tmp
type: incr
output file: 'ocn.pert.steric.%mem%.{{ATM_WINDOW_BEGIN}}.nc'
pattern: '%mem%'
2 changes: 1 addition & 1 deletion parm/soca/berror/soca_clim_ens_perts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ ensemble:

recentered output:
datadir: ./static_ens
exp: bal
exp: pert
type: ens
date: '{{ATM_WINDOW_BEGIN}}'
31 changes: 31 additions & 0 deletions parm/soca/berror/soca_postproc_stddev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
geometry:
geom_grid_file: soca_gridspec.nc
mom6_input_nml: mom_input.nml
fields metadata: fields_metadata.yaml

date: '{{ATM_WINDOW_BEGIN}}'

layers variable: [hocn]

increment variables: [tocn, socn, uocn, vocn, ssh, hocn]

set increment variables to zero: [ssh]

vertical geometry:
read_from_file: 1
basename: ./INPUT/
ocn_filename: MOM.res.nc
date: '{{ATM_WINDOW_BEGIN}}'

soca increment:
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./static_ens/
ocn_filename: 'ocn.orig_ens_stddev.incr.{{ATM_WINDOW_BEGIN}}.nc'
read_from_file: 1

output increment:
datadir: ./
date: '{{ATM_WINDOW_BEGIN}}'
exp: filtered
type: incr
output file: 'ocn.orig_ens_stddev.incr.{{ATM_WINDOW_BEGIN}}.nc'
1 change: 0 additions & 1 deletion parm/soca/variational/3dvarfgat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ variational:
fields metadata: ./fields_metadata.yaml
ninner: !ENV ${SOCA_NINNER}
gradient norm reduction: 1e-10
test: on
diagnostics:
departures: ombg

Expand Down
3 changes: 2 additions & 1 deletion parm/soca/variational/socaincr2mom6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ soca increment:
ocn_filename: 'ocn.3dvarfgat_pseudo.incr.{{ATM_WINDOW_MIDDLE}}.nc'
read_from_file: 1

mom6 iau increment:
output increment:
datadir: ./
date: '{{ATM_WINDOW_BEGIN}}'
exp: mom6_iau
type: incr
output file: inc.nc
15 changes: 12 additions & 3 deletions scripts/exgdas_global_marine_analysis_bmat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ fi
################################################################################
# Compute the ens std. dev, ignore ssh variance
# TODO (G): Implement what's below into one single oops application
# 0 - Compute moments of original ensemble, used at the diag of the first
# 0 - Compute moments of original ensemble, used at the diag of the first
# component of the hybrid B
# 1 - Ensemble perturbations:
# o Vertically Interpolate to the deterministic layers
# o Recenter around 0 to create an ensemble of perturbations
# o Recenter around 0 to create an ensemble of perurbations
# 2 - Filter members and apply the linear steric height balance to each members
# 3 - Copy h from deterministic to unbalanced perturbations
# 4 - Compute moments of converted ensemble perturbations
Expand All @@ -131,6 +131,15 @@ if [ $err -gt 0 ]; then
exit $err
fi

# Zero out std. dev of ssh to use the balance as a strong constraint
# TODO: Apply the inverse of the balance
clean_yaml soca_clim_ens_moments.yaml
$APRUN_OCNANAL $JEDI_BIN/gdas_incr_handler.x soca_postproc_stddev.yaml
export err=$?; err_chk
if [ $err -gt 0 ]; then
exit $err
fi

# Compute ensemble perturbations, vertically remap to cycle's vertical geometry
clean_yaml soca_clim_ens_perts.yaml
$APRUN_OCNANAL $JEDI_BIN/soca_ensrecenter.x soca_clim_ens_perts.yaml
Expand All @@ -141,7 +150,7 @@ fi

# Vertical filtering of the 3D perturbations and recompute the steric height perturbation
clean_yaml soca_apply_steric.yaml
$APRUN_OCNANAL $JEDI_BIN/soca_convertincrement.x soca_apply_steric.yaml
$APRUN_OCNANAL $JEDI_BIN/gdas_incr_handler.x soca_apply_steric.yaml
export err=$?; err_chk
if [ $err -gt 0 ]; then
exit $err
Expand Down
2 changes: 1 addition & 1 deletion scripts/exgdas_global_marine_analysis_chkpt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ EOF
--out "${mom6_iau_incr}" \
--nsst_yaml "nsst.yaml"
else
$APRUN_OCNANAL ${JEDI_BIN}/gdas_socaincr2mom6.x socaincr2mom6.yaml
$APRUN_OCNANAL ${JEDI_BIN}/gdas_incr_handler.x socaincr2mom6.yaml
fi
export err=$?
if [ $err -gt 0 ]; then
Expand Down
20 changes: 8 additions & 12 deletions scripts/exgdas_global_marine_analysis_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,18 @@ def find_clim_ens(input_date):
# generate YAMLS file for diag of clim. ens. B
berror_yaml_dir = os.path.join(gdas_home, 'parm', 'soca', 'berror')

logging.info(f"---------------- generate soca_clim_moments.yaml")
logging.info(f"---------------- generate soca_clim_ens_moments.yaml")
berr_yaml = os.path.join(anl_dir, 'soca_clim_ens_moments.yaml')
berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_clim_ens_moments.yaml')
config = YAMLFile(path=berr_yaml_template)
config = Template.substitute_structure(config, TemplateConstants.DOUBLE_CURLY_BRACES, envconfig.get)
config = Template.substitute_structure(config, TemplateConstants.DOLLAR_PARENTHESES, envconfig.get)
config.save(berr_yaml)

logging.info(f"---------------- generate soca_postproc_stddev.yaml")
berr_yaml = os.path.join(anl_dir, 'soca_postproc_stddev.yaml')
berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_postproc_stddev.yaml')
config = YAMLFile(path=berr_yaml_template)
config = Template.substitute_structure(config, TemplateConstants.DOUBLE_CURLY_BRACES, envconfig.get)
config.save(berr_yaml)

logging.info(f"---------------- generate soca_clim_ens_perts.yaml")
Expand All @@ -376,16 +382,6 @@ def find_clim_ens(input_date):
config = YAMLFile(path=berr_yaml_template)
config = Template.substitute_structure(config, TemplateConstants.DOUBLE_CURLY_BRACES, envconfig.get)
config = Template.substitute_structure(config, TemplateConstants.DOLLAR_PARENTHESES, envconfig.get)
member_template = config['increments'][0]
ocn_fname_tmpl = member_template['input']['ocn_filename']
ice_fname_tmpl = member_template['input']['ice_filename']
config['increments'] = []
for n in range(1, clim_ens_size+1):
member = copy.deepcopy(member_template)
member['input']['ocn_filename'] = member['input']['ocn_filename'].replace("MEMNUM", str(n))
member['input']['ice_filename'] = member['input']['ice_filename'].replace("MEMNUM", str(n))
member['output']['exp'] = member['output']['exp'].replace("MEMNUM", str(n))
config['increments'].append(member)
config.save(berr_yaml)

logging.info(f"---------------- generate soca_ensweights.yaml")
Expand Down
55 changes: 25 additions & 30 deletions scripts/exgdas_global_marine_analysis_vrfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
config = plotConfig(grid_file=grid_file,
data_file=data_file,
lats=np.arange(-60, 60, 10),
variables_zonal=['Temp', 'Salt'],
variables_horiz=['Temp', 'Salt', 'ave_ssh'],
allbounds={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1],
'ave_ssh': [-0.1, 0.1]},
variables_zonal={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1]},
variables_horiz={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1],
'ave_ssh': [-0.1, 0.1]},
colormap='RdBu',
comout=os.path.join(comout, 'vrfy', 'incr'))
ocnIncPlotter = statePlotter(config)
Expand All @@ -66,10 +66,9 @@
config = plotConfig(grid_file=grid_file,
data_file=data_file,
lats=np.arange(-60, 60, 10),
variables_horiz=['aicen', 'hicen', 'hsnon'],
allbounds={'aicen': [-0.2, 0.2],
'hicen': [-0.5, 0.5],
'hsnon': [-0.1, 0.1]},
variables_horiz={'aicen': [-0.2, 0.2],
'hicen': [-0.5, 0.5],
'hsnon': [-0.1, 0.1]},
colormap='RdBu',
projs=['North', 'South'],
comout=os.path.join(comout, 'vrfy', 'incr'))
Expand All @@ -83,10 +82,9 @@
data_file = os.path.join(comout, f'{RUN}.t'+cyc+'z.iceana.nc')
config = plotConfig(grid_file=grid_file,
data_file=data_file,
variables_horiz=['aicen', 'hicen', 'hsnon'],
allbounds={'aicen': [0.0, 1.0],
'hicen': [0.0, 4.0],
'hsnon': [0.0, 0.5]},
variables_horiz={'aicen': [0.0, 1.0],
'hicen': [0.0, 4.0],
'hsnon': [0.0, 0.5]},
colormap='jet',
projs=['North', 'South', 'Global'],
comout=os.path.join(comout, 'vrfy', 'ana'))
Expand All @@ -100,10 +98,9 @@
data_file = os.path.join(com_ice_history, f'{RUN}.t{gcyc}z.icef006.nc')
config = plotConfig(grid_file=grid_file,
data_file=data_file,
variables_horiz=['aice_h', 'hs_h', 'hi_h'],
allbounds={'aice_h': [0.0, 1.0],
'hs_h': [0.0, 4.0],
'hi_h': [0.0, 0.5]},
variables_horiz={'aice_h': [0.0, 1.0],
'hs_h': [0.0, 4.0],
'hi_h': [0.0, 0.5]},
colormap='jet',
projs=['North', 'South', 'Global'],
comout=os.path.join(comout, 'vrfy', 'bkg'))
Expand All @@ -117,10 +114,9 @@
data_file = os.path.join(comout, f'{RUN}.t'+cyc+'z.ocnana.nc')
config = plotConfig(grid_file=grid_file,
data_file=data_file,
variables_horiz=['ave_ssh', 'Temp', 'Salt'],
allbounds={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
variables_horiz={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'ana'))
ocnAnaPlotter = statePlotter(config)
Expand All @@ -133,10 +129,9 @@
data_file = os.path.join(com_ocean_history, f'{RUN}.t{gcyc}z.ocnf006.nc')
config = plotConfig(grid_file=grid_file,
data_file=data_file,
variables_horiz=['ave_ssh', 'Temp', 'Salt'],
allbounds={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
variables_horiz={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'bkg'))
ocnBkgPlotter = statePlotter(config)
Expand All @@ -150,11 +145,11 @@
config = plotConfig(grid_file=grid_file,
data_file=data_file,
lats=np.arange(-60, 60, 10),
variables_zonal=['Temp', 'Salt'],
variables_horiz=['Temp', 'Salt', 'ave_ssh'],
allbounds={'Temp': [0, 2],
'Salt': [0, 0.2],
'ave_ssh': [0, 0.1]},
variables_zonal={'Temp': [0, 2],
'Salt': [0, 0.2]},
variables_horiz={'Temp': [0, 2],
'Salt': [0, 0.2],
'ave_ssh': [0, 0.1]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'bkgerr'))
bkgErrPlotter = statePlotter(config)
Expand Down
2 changes: 1 addition & 1 deletion test/soca/gw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ foreach(jjob ${jjob_list})
endforeach()

# Test gdas/oops applications
set(ctest_list "socahybridweights" "socaincr2mom6")
set(ctest_list "socahybridweights" "incr_handler")
foreach(ctest ${ctest_list})
set(TEST ${ctest})
set(EXEC ${PROJECT_BINARY_DIR}/bin/gdas_${ctest}.x)
Expand Down
Loading

0 comments on commit 289352c

Please sign in to comment.