Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Oct 31, 2024
1 parent 2d14328 commit 7da3b10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
33 changes: 20 additions & 13 deletions src/mir/key/style/ECMWFStyle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,13 @@ void ECMWFStyle::sh2grid(action::ActionPlan& plan) const {
bool vod2uv = option(user, "vod2uv", false);
bool uv2uv = option(user, "uv2uv", false) || uv_input; // where "MIR knowledge of winds" is hardcoded

if (vod2uv && uv_input) {
throw exception::UserError("ECMWFStyle: option 'vod2uv' is incompatible with input U/V");
if (vod2uv) {
if (uv2uv) {
throw exception::UserError("ECMWFStyle: option 'vod2uv' is incompatible with 'uv2uv'");
}
if (uv_input) {
throw exception::UserError("ECMWFStyle: option 'vod2uv' is incompatible with input U/V");
}
}

if (resol.resultIsSpectral()) {
Expand All @@ -281,29 +286,31 @@ void ECMWFStyle::sh2grid(action::ActionPlan& plan) const {
auto target = target_gridded_from_parametrisation(parametrisation_, false);
if (!target.empty()) {
if (resol.resultIsSpectral()) {

plan.add("transform." + std::string(vod2uv ? "sh-vod-to-uv-" : "sh-scalar-to-") + target);

if (uv2uv) {
plan.add("filter.adjust-winds-scale-cos-latitude");
}

if ((vod2uv || uv2uv) && rotation) {
plan.add("filter.adjust-winds-directions");
}
}
else {

resol.prepare(plan);

if (uv2uv) {
plan.add("filter.adjust-winds-scale-cos-latitude");
}

// if the intermediate grid is the same as the target grid, the interpolation to the
// intermediate grid is not followed by an additional interpolation
std::string grid;
if (rotation || !user.get("grid", grid) || grid != resol.gridname()) {
plan.add("interpolate.grid2" + target);
}
}

if (vod2uv || uv2uv) {
ASSERT(vod2uv != uv2uv);

if (uv2uv) {
plan.add("filter.adjust-winds-scale-cos-latitude");
}

if (rotation) {
if ((vod2uv || uv2uv) && rotation) {
plan.add("filter.adjust-winds-directions");
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/mir/repres/regular/Lambert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include "mir/repres/regular/Lambert.h"

#include <cmath>

#include "mir/param/MIRParametrisation.h"
#include "mir/util/Angles.h"
#include "mir/util/Exceptions.h"
Expand Down Expand Up @@ -88,8 +86,8 @@ void Lambert::fillGrib(grib_info& info) const {
info.grid.longitudeOfSouthernPoleInDegrees = longitudeOfSouthernPoleInDegrees_;
info.grid.uvRelativeToGrid = uvRelativeToGrid_ ? 1 : 0;

info.extra_set("DxInMetres", std::abs(x().step()));
info.extra_set("DyInMetres", std::abs(y().step()));
info.extra_set("DxInMetres", x().step());
info.extra_set("DyInMetres", y().step());
info.extra_set("Latin1InDegrees", reference[LLCOORDS::LAT]);
info.extra_set("Latin2InDegrees", reference[LLCOORDS::LAT]);
info.extra_set("LoVInDegrees", writeLonPositive_ ? util::normalise_longitude(reference[LLCOORDS::LON], 0)
Expand Down

0 comments on commit 7da3b10

Please sign in to comment.