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

Faster/Better ens. B processing/recentering #594

Merged
merged 10 commits into from
Sep 8, 2023
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if(BUILD_GDASBUNDLE)
ecbuild_bundle( PROJECT gsw GIT "https://github.com/jcsda-internal/GSW-Fortran.git" BRANCH develop )

# Core JEDI repositories
ecbuild_bundle( PROJECT oops GIT "https://github.com/jcsda/oops.git" BRANCH develop )
ecbuild_bundle( PROJECT oops GIT "https://github.com/jcsda/oops.git" BRANCH develop)
ecbuild_bundle( PROJECT vader GIT "https://github.com/jcsda/vader.git" BRANCH develop )
ecbuild_bundle( PROJECT saber GIT "https://github.com/jcsda/saber.git" BRANCH develop )
ecbuild_bundle( PROJECT ioda GIT "https://github.com/jcsda/ioda.git" BRANCH develop )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ linear variable change:
- linear variable change name: BkgErrFILT
ocean_depth_min: 500 # zero where ocean is shallower than 500m
rescale_bkgerr: 1.0 # rescale perturbation
efold_z: 1500.0 # Apply exponential decay
efold_z: 2500.0 # Apply exponential decay
- linear variable change name: BalanceSOCA
trajectory:
state variables: [tocn, socn, uocn, vocn, ssh, hocn, layer_depth, mld]
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./INPUT/
ocn_filename: MOM.res.nc
read_from_file: 1

trajectory:
state variables: [tocn, socn, uocn, vocn, ssh, hocn, layer_depth, mld]
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./INPUT/
ocn_filename: MOM.res.nc
read_from_file: 1

output increment:
datadir: ./static_ens/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ensemble:
basename: ./static_ens/
ocn_filename: ocn.%mem%.nc
ice_filename: ice.%mem%.nc
remap_filename: ./INPUT/MOM.res.nc
state variables: [tocn, socn, ssh, uocn, vocn, hocn, cicen, hicen, hsnon]
pattern: '%mem%'
nmembers: ${CLIM_ENS_SIZE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ensemble:
basename: ./static_ens/
ocn_filename: ocn.%mem%.nc
ice_filename: ice.%mem%.nc
remap_filename: ./INPUT/MOM.res.nc
state variables: [cicen, hicen, hsnon, socn, tocn, uocn, vocn, ssh, hocn, mld, layer_depth]
pattern: '%mem%'
nmembers: ${CLIM_ENS_SIZE}
Expand Down
12 changes: 0 additions & 12 deletions parm/soca/berror/saber_block_identity.yaml

This file was deleted.

12 changes: 5 additions & 7 deletions parm/soca/berror/saber_blocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ components:
- linear variable change name: BkgErrSOCA
read_from_file: 3
basename: ./static_ens/
ocn_filename: 'ocn.orig_ens_stddev.incr.{{ATM_WINDOW_BEGIN}}.nc'
ice_filename: 'ice.orig_ens_stddev.incr.{{ATM_WINDOW_BEGIN}}.nc'
#remap_filename: ./INPUT/MOM.res.nc
ocn_filename: 'ocn.bkgerr_stddev.incr.{{ATM_WINDOW_BEGIN}}.nc'
ice_filename: 'ice.bkgerr_stddev.incr.{{ATM_WINDOW_BEGIN}}.nc'
date: '{{ATM_WINDOW_MIDDLE}}'
t_min: 0.1
t_max: 10.0
Expand All @@ -45,8 +44,7 @@ components:
standard deviation: true

- linear variable change name: BalanceSOCA
ksshts:
nlayers: 10

weight:
value: 1.0
- covariance:
Expand All @@ -56,8 +54,8 @@ components:
read_from_file: 1
date: '{{ATM_WINDOW_MIDDLE}}'
basename: ./static_ens/
ocn_filename: 'ocn.pert.steric.%mem%.{{ATM_WINDOW_BEGIN}}.nc'
ice_filename: 'ice.pert.ens.%mem%.{{ATM_WINDOW_BEGIN}}.PT0S.nc'
ocn_filename: 'ocn.pert.steric.%mem%.nc'
ice_filename: 'ice.%mem%.nc'
state variables: [tocn, socn, ssh, uocn, vocn, cicen, hicen, hsnon]
pattern: '%mem%'
nmembers: ${CLIM_ENS_SIZE}
Expand Down
92 changes: 92 additions & 0 deletions parm/soca/berror/soca_ensb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
geometry:
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, cicen, hicen, hsnon]

set increment variables to zero: [ssh]

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

soca increments:
number of increments: ${CLIM_ENS_SIZE}
pattern: '%mem%'
template:
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./static_ens/
ocn_filename: 'ocn.%mem%.nc'
ice_filename: 'ice.%mem%.nc'
read_from_file: 3

steric height:
linear variable changes:
- linear variable change name: BalanceSOCA # Only the steric balance is applied

ssh output:
unbalanced:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: ssh_unbal_stddev
type: incr

steric:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: ssh_steric_stddev
type: incr

total:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: ssh_total_stddev
type: incr

explained variance:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: steric_explained_variance
type: incr

recentering error:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: ssh_recentering_error
type: incr

background error output:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: bkgerr_stddev
type: incr

linear variable change:
linear variable changes:
# - linear variable change name: BkgErrFILT
# ocean_depth_min: 500 # zero where ocean is shallower than 500m
# rescale_bkgerr: 1.0 # rescale perturbation
# efold_z: 1500.0 # Apply exponential decay
- linear variable change name: BalanceSOCA

trajectory:
state variables: [tocn, socn, uocn, vocn, ssh, hocn, layer_depth, mld, cicen, hicen, hsnon]
date: '{{ATM_WINDOW_BEGIN}}'
basename: ./INPUT/
ocn_filename: MOM.res.nc
ice_filename: cice.res.nc
read_from_file: 1

output increment:
datadir: ./static_ens
date: '{{ATM_WINDOW_BEGIN}}'
exp: trash
type: incr
output file: 'ocn.pert.steric.%mem%.nc'
pattern: '%mem%'
2 changes: 1 addition & 1 deletion parm/soca/variational/3dvarfgat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ variational:
mom6_input_nml: mom_input.nml
fields metadata: ./fields_metadata.yaml
ninner: !ENV ${SOCA_NINNER}
gradient norm reduction: 1e-10
gradient norm reduction: 1e-7
diagnostics:
departures: ombg

Expand Down
38 changes: 2 additions & 36 deletions scripts/exgdas_global_marine_analysis_bmat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,14 @@ fi
# 3 - Copy h from deterministic to unbalanced perturbations
# 4 - Compute moments of converted ensemble perturbations

# Compute ensemble moments
# Process static ensemble
clean_yaml soca_clim_ens_moments.yaml
$APRUN_OCNANAL $JEDI_BIN/soca_ensmeanandvariance.x soca_clim_ens_moments.yaml
$APRUN_OCNANAL $JEDI_BIN/gdas_ens_handler.x soca_ensb.yaml
export err=$?; err_chk
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
export err=$?; err_chk
if [ $err -gt 0 ]; then
exit $err
fi

# Vertical filtering of the 3D perturbations and recompute the steric height perturbation
clean_yaml 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
fi


################################################################################
# Correlation and Localization operators
shopt -s nullglob
Expand Down Expand Up @@ -224,14 +198,6 @@ if [ $err -gt 0 ]; then
exit $err
fi

################################################################################
# Create ensemble of perturbations for the cycle

# Use ensemble recenter with "zerocenter"

# Apply inverse balance to perturbations, use deterministic background as trajectory


################################################################################
set +x
if [ $VERBOSE = "YES" ]; then
Expand Down
43 changes: 22 additions & 21 deletions scripts/exgdas_global_marine_analysis_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,33 @@ def list_all_files(dir_in, dir_out, wc='*', fh_list=[]):
post_file_list.append([os.path.join(anl_dir, 'inc.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ocninc.nc')])

# Copy of the diagonal of the background error for the cycle
post_file_list.append([os.path.join(anl_dir, 'static_ens', f'ocn.orig_ens_stddev.incr.{bdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ocn.bkgerr_stddev.nc')])
post_file_list.append([os.path.join(anl_dir, 'static_ens', f'ice.orig_ens_stddev.incr.{bdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ice.bkgerr_stddev.nc')])

# Copy the ice and ocean increments
post_file_list.append([os.path.join(anl_dir, 'Data', f'ocn.3dvarfgat_pseudo.incr.{mdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ocn.incr.nc')])
post_file_list.append([os.path.join(anl_dir, 'Data', f'ice.3dvarfgat_pseudo.incr.{mdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ice.incr.nc')])
domains = ['ocn', 'ice']
guillaumevernieres marked this conversation as resolved.
Show resolved Hide resolved
for domain in domains:
# Copy of the diagonal of the background error for the cycle
post_file_list.append([os.path.join(anl_dir, 'static_ens', f'{domain}.bkgerr_stddev.incr.{bdate}.nc'),
guillaumevernieres marked this conversation as resolved.
Show resolved Hide resolved
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.{domain}.bkgerr_stddev.nc')])

# Copy the recentering error
post_file_list.append([os.path.join(anl_dir, 'static_ens', f'{domain}.ssh_recentering_error.incr.{bdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.{domain}.recentering_error.nc')])

# Copy the ice and ocean increments
post_file_list.append([os.path.join(anl_dir, 'Data', f'{domain}.3dvarfgat_pseudo.incr.{mdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.{domain}.incr.nc')])

# Copy the analysis at the start of the window
post_file_list.append([os.path.join(anl_dir, 'Data', f'{domain}.3dvarfgat_pseudo.an.{mdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.{domain}ana.nc')])

# Copy of the ssh diagnostics
for string in ['ssh_steric_stddev', 'ssh_unbal_stddev', 'ssh_total_stddev', 'steric_explained_variance']:
post_file_list.append([os.path.join(anl_dir, 'static_ens', f'ocn.{string}.incr.{bdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ocn.{string}.nc')])

# Copy DA grid (computed for the start of the window)
post_file_list.append([os.path.join(anl_dir, 'soca_gridspec.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{bcyc}z.ocngrid.nc')])

# Copy the analysis at the start of the window
post_file_list.append([os.path.join(anl_dir, 'Data', f'ocn.3dvarfgat_pseudo.an.{mdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.ocnana.nc')])
post_file_list.append([os.path.join(anl_dir, 'Data', f'ice.3dvarfgat_pseudo.an.{mdate}.nc'),
os.path.join(com_ocean_analysis, f'{RUN}.t{cyc}z.iceana.nc')])

# Copy the CICE analysis restart
cdateice = pdy + '.' + cyc + '0000'
post_file_list.append([os.path.join(anl_dir, 'Data', f'{cdateice}.cice_model.res.nc'),
Expand All @@ -97,10 +102,6 @@ def list_all_files(dir_in, dir_out, wc='*', fh_list=[]):
fh_list = list_all_files(os.path.join(anl_dir, 'diags'),
os.path.join(com_ocean_analysis, 'diags'))

# localization and correlation operators
fh_list = list_all_files(os.path.join(anl_dir, 'bump'),
os.path.join(com_ocean_analysis, 'bump'), fh_list=fh_list)

# yaml configurations
fh_list = list_all_files(os.path.join(anl_dir),
os.path.join(com_ocean_analysis, 'yaml'), wc='*.yaml', fh_list=fh_list)
Expand Down
47 changes: 4 additions & 43 deletions scripts/exgdas_global_marine_analysis_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,56 +339,17 @@ def find_clim_ens(input_date):
gridgen_yaml_dst = os.path.abspath(os.path.join(stage_cfg['stage_dir'], 'gridgen.yaml'))
FileHandler({'copy': [[gridgen_yaml_src, gridgen_yaml_dst]]}).sync()


################################################################################
# generate YAML file for parametric diag of B

logging.info(f"---------------- generate parametric_stddev_b.yaml")
berr_yaml = os.path.join(anl_dir, 'parametric_stddev_b.yaml')
berr_yaml_template = os.path.join(gdas_home,
'parm',
'soca',
'berror',
'parametric_stddev_b.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)

################################################################################
# generate YAMLS file for diag of clim. ens. B
# generate the YAML file for the post processing of the clim. ens. B
berror_yaml_dir = os.path.join(gdas_home, 'parm', 'soca', 'berror')

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')
logging.info(f"---------------- generate soca_ensb.yaml")
berr_yaml = os.path.join(anl_dir, 'soca_ensb.yaml')
berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_ensb.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_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")
berr_yaml = os.path.join(anl_dir, 'soca_clim_ens_perts.yaml')
berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_clim_ens_perts.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_apply_steric.yaml")
berr_yaml = os.path.join(anl_dir, 'soca_apply_steric.yaml')
berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_apply_steric.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_ensweights.yaml")
berr_yaml = os.path.join(anl_dir, 'soca_ensweights.yaml')
berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_ensweights.yaml')
Expand Down
Loading
Loading