Skip to content

Commit

Permalink
fixed steric error computation, added references
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumevernieres committed Sep 5, 2023
1 parent 840027a commit 176130e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
8 changes: 4 additions & 4 deletions parm/soca/berror/soca_ensb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ background error output:

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: 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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/exgdas_global_marine_analysis_bmat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fi
# 3 - Copy h from deterministic to unbalanced perturbations
# 4 - Compute moments of converted ensemble perturbations

# Process climatological ensemble
# Process static ensemble
clean_yaml soca_clim_ens_moments.yaml
$APRUN_OCNANAL $JEDI_BIN/gdas_ens_handler.x soca_ensb.yaml
export err=$?; err_chk
Expand Down
13 changes: 7 additions & 6 deletions utils/soca/gdas_ens_handler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <netcdf>

#include <filesystem>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -115,8 +113,8 @@ namespace gdasapp {

// Get the steric variable change configuration
eckit::LocalConfiguration stericVarChangeConfig;
fullConfig.get("steric variable change", stericVarChangeConfig);

fullConfig.get("steric height", stericVarChangeConfig);
oops::Log::info() << "steric config 0000: " << stericVarChangeConfig << std::endl;
// Initialize trajectories
const eckit::LocalConfiguration trajConfig(fullConfig, "trajectory");
soca::State cycleTraj(geom, trajConfig); // trajectory of the cycle
Expand All @@ -128,6 +126,9 @@ namespace gdasapp {
soca::Increment deterministicError(geom, postProcIncr.socaIncrVar_, postProcIncr.dt_);
deterministicError.diff(cycleTraj, meanTraj);
eckit::LocalConfiguration sshRecErrOutputConfig(fullConfig, "ssh output.recentering error");
deterministicError = postProcIncr.setToZero(deterministicError);
oops::Log::info() << "steric config : " << stericVarChangeConfig << std::endl;
postProcIncr.applyLinVarChange(deterministicError, stericVarChangeConfig, cycleTraj);
oops::Log::info() << "ensemble mean: " << meanTraj << std::endl;
oops::Log::info() << "deterministic: " << cycleTraj << std::endl;
oops::Log::info() << "error: " << deterministicError << std::endl;
Expand Down Expand Up @@ -159,7 +160,7 @@ namespace gdasapp {

// Compute the original steric height perturbation from T and S
eckit::LocalConfiguration stericConfig(fullConfig, "steric height");
incr = postProcIncr.applyLinVarChange(incr, stericConfig, meanTraj);
postProcIncr.applyLinVarChange(incr, stericConfig, meanTraj);
ssh_tmp = incr;
sshSteric.push_back(ssh_tmp);

Expand All @@ -179,7 +180,7 @@ namespace gdasapp {
// Filter ensemble member and recompute ssh, recentering around the cycle's trajectory
if ( fullConfig.has("linear variable change") ) {
eckit::LocalConfiguration lvcConfig(fullConfig, "linear variable change");
incr = postProcIncr.applyLinVarChange(incr, lvcConfig, cycleTraj);
postProcIncr.applyLinVarChange(incr, lvcConfig, cycleTraj);
}

// Save final perturbation, used in the offline EnVAR
Expand Down
4 changes: 1 addition & 3 deletions utils/soca/gdas_incr_handler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <netcdf>

#include <filesystem>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -65,7 +63,7 @@ namespace gdasapp {
if ( fullConfig.has("linear variable change") ) {
soca::State traj = postProcIncr.getTraj(fullConfig, geom);
eckit::LocalConfiguration lvcConfig(fullConfig, "linear variable change");
incrWithLayer = postProcIncr.applyLinVarChange(incrWithLayer, lvcConfig, traj);
postProcIncr.applyLinVarChange(incrWithLayer, lvcConfig, traj);
}

// Save final increment
Expand Down
16 changes: 8 additions & 8 deletions utils/soca/gdas_postprocincr.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PostProcIncr {
// Append layer thicknesses to increment
// TODO(guillaume): There's got to be a better way to append a variable.

soca::Increment appendLayer(soca::Increment socaIncr) {
soca::Increment appendLayer(soca::Increment& socaIncr) {
oops::Log::info() << "==========================================" << std::endl;
oops::Log::info() << "====== Append Layers" << std::endl;

Expand Down Expand Up @@ -129,7 +129,7 @@ class PostProcIncr {
// -----------------------------------------------------------------------------
// Set specified variables to 0

soca::Increment setToZero(soca::Increment socaIncr) {
soca::Increment setToZero(soca::Increment& socaIncr) {
oops::Log::info() << "==========================================" << std::endl;
if (!this->setToZero_) {
oops::Log::info() << "====== no variables to set to 0.0" << std::endl;
Expand Down Expand Up @@ -161,22 +161,22 @@ class PostProcIncr {
// -----------------------------------------------------------------------------
// Apply linear variable changes

soca::Increment applyLinVarChange(soca::Increment socaIncr,
const eckit::LocalConfiguration lvcConfig,
const soca::State xTraj) {
void applyLinVarChange(soca::Increment& socaIncr,
const eckit::LocalConfiguration& lvcConfig,
const soca::State& xTraj) {
oops::Log::info() << "==========================================" << std::endl;
oops::Log::info() << "====== applying specified change of variables" << std::endl;
soca::LinearVariableChange lvc(this->geom_, lvcConfig);
lvc.changeVarTraj(xTraj, socaIncrVar_);
lvc.changeVarTL(socaIncr, socaIncrVar_);

return socaIncr;
oops::Log::info() << "$%^#& in var change:" << socaIncr << std::endl;
//return socaIncr;
}

// -----------------------------------------------------------------------------
// Save increment

int save(soca::Increment socaIncr, int ensMem = 1) {
int save(soca::Increment& socaIncr, int ensMem = 1) {
oops::Log::info() << "==========================================" << std::endl;
oops::Log::info() << "-------------------- save increment: " << std::endl;
socaIncr.write(outputIncrConfig_);
Expand Down
2 changes: 0 additions & 2 deletions utils/soca/gdas_socahybridweights.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <netcdf>

#include <filesystem>
#include <iostream>
#include <string>
Expand Down

0 comments on commit 176130e

Please sign in to comment.