Skip to content

Commit

Permalink
Updates to make global rescaling work.
Browse files Browse the repository at this point in the history
  • Loading branch information
andytangborn committed Oct 24, 2024
1 parent c8d41b1 commit 35eef0e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
22 changes: 18 additions & 4 deletions parm/aero/berror/aero_diagb.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,24 @@ variables:
- mass_fraction_of_sea_salt004_in_air

global rescale:
filetype: fms restart
dateapath: ./stddev
filename_trcr: rescale.fv_tracer.res.nc
filename_cplr: rescale.coupler.res
geometry:
fms initialization:
namelist filename: ./fv3jedi/fmsmpp.nml
field table filename: ./fv3jedi/field_table
akbk: ./fv3jedi/akbk.nc4
layout:
- {{ layout_x }}
- {{ layout_y }}
nxp: {{ npx_rescale }}
npy: {{ npy_rescale }}
npz: {{ npz_ges }}
field metadata override: ./fv3jedi/fv3jedi_fieldmetadata_restart.yaml
rescale stddev:
filetype: fms restart
skip coupler file: true
dateapath: ./stddev
filename_trcr: rescale.fv_tracer.res.nc
filename_cplr: rescale.coupler.res

number of halo points: {{ aero_diagb_n_halo }}
number of neighbors: {{ aero_diagb_n_neighbors }}
Expand Down
28 changes: 24 additions & 4 deletions utils/chem/chem_diagb.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,30 @@ namespace gdasapp {

// Rescale
if (fullConfig.has("global rescale")) {
fv3jedi::State global_rescale(geom, chemVars,cycleDate);
const eckit::LocalConfiguration GlobalRescaleConfig(fullConfig, "global rescale");
global_rescale.read(GlobalRescaleConfig);
const eckit::LocalConfiguration GlobalRescaleConfig(fullConfig, "global rescale");
// fv3jedi::State global_rescale(rescaleGeom, chemVars,cycleDate);
// fv3jedi::State global_rescale_interp(geom, chemVars, cycleDate);
const eckit::LocalConfiguration GlobalRescaleGeomConfig(GlobalRescaleConfig,"geometry");
const fv3jedi::Geometry GlobalRescaleGeom(GlobalRescaleGeomConfig, this-> getComm());
fv3jedi::Increment global_rescale(GlobalRescaleGeom, chemVars, cycleDate);
global_rescale.zero();
const eckit::LocalConfiguration GlobalRescaleStdConfig(GlobalRescaleConfig,"rescale stddev");
// Get the 'datapath' and 'filename_trcr' from the YAML configuration
std::string datapath, filename_trcr;
GlobalRescaleStdConfig.get("datapath", datapath);
GlobalRescaleStdConfig.get("filename_trcr", filename_trcr);

// Combine the path and filename to get the full file path
std::string fullPath = datapath + filename_trcr;

// Print out the full path to verify
std::cout << "Attempting to read the global rescale file from: " << fullPath << std::endl;

global_rescale.read(GlobalRescaleStdConfig);
// interpolate to background resolution
fv3jedi::Increment global_rescale_interp(geom, global_rescale);
atlas::FieldSet xrsFs;
global_rescale.toFieldSet(xrsFs);
global_rescale_interp.toFieldSet(xrsFs);
oops::Log::info() << "global rescaling coefficients:" << std::endl;
oops::Log::info() << xrsFs << std::endl;
util::multiplyFieldSets(bkgErrFs, xrsFs);
Expand Down Expand Up @@ -286,6 +305,7 @@ namespace gdasapp {
double rescale_staticb;
ClimBConfig.get("staticb rescaling factor", rescale_staticb);


// Combine diagb and climatological background errors
fv3jedi::Increment stddev_hybrid(geom, chemVars, cycleDate);
stddev_hybrid.zero();
Expand Down

0 comments on commit 35eef0e

Please sign in to comment.