From 7da3b1071fa9c2cd163b591bd31fa0fc7f8b4b84 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Date: Sat, 26 Oct 2024 11:31:06 +0100 Subject: [PATCH] wip --- src/mir/key/style/ECMWFStyle.cc | 33 +++++++++++++++++++------------ src/mir/repres/regular/Lambert.cc | 6 ++---- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/mir/key/style/ECMWFStyle.cc b/src/mir/key/style/ECMWFStyle.cc index be9ae1b51..001d64e90 100644 --- a/src/mir/key/style/ECMWFStyle.cc +++ b/src/mir/key/style/ECMWFStyle.cc @@ -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()) { @@ -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"); } } diff --git a/src/mir/repres/regular/Lambert.cc b/src/mir/repres/regular/Lambert.cc index 94968a4ed..10527a044 100644 --- a/src/mir/repres/regular/Lambert.cc +++ b/src/mir/repres/regular/Lambert.cc @@ -12,8 +12,6 @@ #include "mir/repres/regular/Lambert.h" -#include - #include "mir/param/MIRParametrisation.h" #include "mir/util/Angles.h" #include "mir/util/Exceptions.h" @@ -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)