Skip to content

Commit

Permalink
Merge branch 'release/1.19.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Jan 8, 2024
2 parents 80b88a3 + 549d7d8 commit 97cda0c
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 33 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.18.1
1.19.0
10 changes: 10 additions & 0 deletions etc/mir/classes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
_default:
compare: scalar

# TODO DGOV
count.density: {}

# amount of mass per unit volume (typical units: [kg m**-3])
density.mass: {}

Expand Down Expand Up @@ -60,6 +63,10 @@ vector-space.3d-vector-v:
vector-space.3d-vector-w:
vector-space: 3d-vector-w

# Vector in 3D Cartesian space, associated parameters
vector-space.3d-vector.associated:
vector-space: 3d-vector-u

# Geographic coordinate, latitude
vector-space.geographic-coordinate-latitude:
interpolation: fail
Expand Down Expand Up @@ -106,6 +113,9 @@ rate.energy-flux: {}
# rate of flow of mass per unit area (typical units: [kg m**-2 s**-1])
rate.mass-flux: {}

# TODO DGOV
rate.power: {}

# rate of flow of a volumetric quantity per unit area (typical units [m**3 m**-2 s**-1], [m s**-1])
rate.volume-flux: {}

Expand Down
124 changes: 114 additions & 10 deletions etc/mir/parameter-class.yaml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions src/mir/action/misc/ReferencePattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ void ReferencePattern::execute(context::Context& ctx) const {
double maxvalue = 0;

size_t first = 0;
size_t count = 0;
for (; first < values.size(); ++first) {
if (!hasMissing || values[first] != missingValue) {
minvalue = values[first];
maxvalue = values[first];
count++;
break;
}
}
Expand All @@ -83,7 +81,6 @@ void ReferencePattern::execute(context::Context& ctx) const {
if (!hasMissing || values[i] != missingValue) {
minvalue = std::min(minvalue, values[i]);
maxvalue = std::max(maxvalue, values[i]);
count++;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/mir/input/GribInput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ bool ConditionT<std::string>::eval(grib_handle* h) const {
}

if (err != 0) {
Log::debug() << "ConditionT<std::string>::eval("
<< ",key=" << key_ << ") failed " << err << std::endl;
Log::debug() << "ConditionT<std::string>::eval(" << ",key=" << key_ << ") failed " << err << std::endl;
GRIB_ERROR(err, key_);
}

Expand Down Expand Up @@ -678,8 +677,8 @@ data::MIRField GribInput::field() const {

// Ensure missingValue is unique, so values are not wrongly "missing"
long numberOfMissingValues = 0;
if (codes_get_long(grib_, "numberOfMissingValues", &numberOfMissingValues) == CODES_SUCCESS &&
numberOfMissingValues == 0) {
GRIB_GET(codes_get_long(grib_, "numberOfMissingValues", &numberOfMissingValues));
if (numberOfMissingValues == 0) {
grib_get_unique_missing_value(values, missingValue);
}

Expand Down Expand Up @@ -746,7 +745,8 @@ data::MIRField GribInput::field() const {
data::MIRField field(cache_, missingValuesPresent != 0, missingValue);

long scanningMode = 0;
if (codes_get_long(grib_, "scanningMode", &scanningMode) == CODES_SUCCESS && scanningMode != 0) {
GRIB_GET(codes_get_long(grib_, "scanningMode", &scanningMode));
if (scanningMode != 0) {
field.representation()->reorder(scanningMode, values);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mir/method/gridbox/GridBoxMethod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const char* GridBoxMethod::name() const {


int GridBoxMethod::version() const {
return 1;
return 2;
}


Expand Down
7 changes: 5 additions & 2 deletions src/mir/param/Rules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ void Rules::readConfigurationFiles() {
const eckit::ValueMap& klassConfig = config->second;

// paramId(s)
const eckit::ValueList& paramIds = i.second;
for (long paramId : paramIds) {
if (!i.second.isList()) {
continue;
}

for (long paramId : static_cast<const eckit::ValueList&>(i.second)) {
SimpleParametrisation& pidConfig = lookup(paramId);

std::string klasses;
Expand Down
5 changes: 3 additions & 2 deletions src/mir/repres/gauss/regular/RegularGG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ std::vector<util::GridBox> RegularGG::gridBoxes() const {
std::vector<util::GridBox> r;
r.reserve(Ni_ * Nj_);

for (size_t j = 0; j < Nj_; ++j) {
for (size_t j = k_; j < k_ + Nj_; ++j) {
Longitude lon1 = lon0;

for (size_t i = 0; i < Ni_; ++i) {
auto l = lon1;
lon1 = l + Longitude(inc * (i + half));
r.emplace_back(util::GridBox(latEdges[j], lonEdges[i], latEdges[j + 1], lonEdges[i + 1]));
r.emplace_back(std::min(bbox_.north().value(), latEdges[j]), lonEdges[i],
std::max(bbox_.south().value(), latEdges[j + 1]), lonEdges[i + 1]);
}

ASSERT(periodic ? lon0 == lon1.normalise(lon0) : lon0 < lon1.normalise(lon0));
Expand Down
4 changes: 2 additions & 2 deletions src/mir/util/Grib.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "mir/util/Exceptions.h"


inline bool grib_call(int e, const char* call, bool missingOK = false) {
inline bool grib_call(int e, const char* call, bool NOT_FOUND_IS_OK = false) {
if (static_cast<bool>(e)) {
if (missingOK && (e == CODES_NOT_FOUND)) {
if (NOT_FOUND_IS_OK && (e == CODES_NOT_FOUND)) {
return false;
}

Expand Down
19 changes: 15 additions & 4 deletions src/tools/mir-get-data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct MIRGetData : MIRTool {
options_.push_back(
new SimpleOption<size_t>("nclosest", "Number of points close to given latitude/longitude, default 1"));
options_.push_back(new SimpleOption<prec_t>("precision", "Output precision"));
options_.push_back(new SimpleOption<bool>("dryrun", "decode the field, no listing coordinates or values"));
}

int minimumPositionalArguments() const override { return 1; }
Expand Down Expand Up @@ -274,6 +275,10 @@ void MIRGetData::execute(const eckit::option::CmdArgs& args) {

const param::ConfigurationWrapper args_wrap(args);

bool dryrun = false;
args.get("dryrun", dryrun);


bool ecc = false;
args.get("diff-ecc", ecc);

Expand Down Expand Up @@ -321,6 +326,13 @@ void MIRGetData::execute(const eckit::option::CmdArgs& args) {

repres::RepresentationHandle rep(field.representation());

if (dryrun) {
ASSERT(rep->numberOfPoints() == values.size());
for (const std::unique_ptr<repres::Iterator> it(rep->iterator()); it->next();) {
}
continue;
}

if (!atlas && !ecc && (nclosest == 0)) {
for (const std::unique_ptr<repres::Iterator> it(rep->iterator()); it->next();) {
const Point2& P(**it);
Expand All @@ -341,10 +353,9 @@ void MIRGetData::execute(const eckit::option::CmdArgs& args) {
ASSERT(i < values.size());

constexpr double THOUSAND = 1000;
log << "- " << c++ << " -"
<< " index=" << i << " latitude=" << q[1] << " longitude=" << q[0]
<< " distance=" << util::Earth::distance(p, q) / THOUSAND << " (km)"
<< " value=" << values[i] << std::endl;
log << "- " << c++ << " -" << " index=" << i << " latitude=" << q[1] << " longitude=" << q[0]
<< " distance=" << util::Earth::distance(p, q) / THOUSAND << " (km)" << " value=" << values[i]
<< std::endl;
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/tools/mir-triangulate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ void MIRTriangulate::execute(const eckit::option::CmdArgs& args) {
eckit::JSON json(std::cout);
json.startList();

size_t count = 0;
while (!segments.empty()) {
Segment line = *segments.begin();
segments.erase(segments.begin());
Expand All @@ -410,8 +409,6 @@ void MIRTriangulate::execute(const eckit::option::CmdArgs& args) {
}

json << line;

count++;
}
json.endList();
}
Expand Down
12 changes: 12 additions & 0 deletions tests/assertions/MPY-400.001.core.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mars request: grid=f60,area=26.15/0/-26.15/360
MPY-400.grib1
# Mir tool options
--grid=1.5/1.5 --interpolation=grid-box-average
# grib_get assertions
gridType=regular_ll
Ni=240
Nj=35
latitudeOfFirstGridPointInDegrees=25.5
longitudeOfFirstGridPointInDegrees=0
latitudeOfLastGridPointInDegrees=-25.5
longitudeOfLastGridPointInDegrees=358.5
12 changes: 12 additions & 0 deletions tests/assertions/MPY-400.002.core.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mars request: grid=f60,area=26.15/0/-26.15/360
MPY-400.grib1
# Mir tool options
--grid=1.5/1.5 --interpolation=grid-box-average --area=25/-180/-25/180
# grib_get assertions
gridType=regular_ll
Ni=240
Nj=34
latitudeOfFirstGridPointInDegrees=24.5
longitudeOfFirstGridPointInDegrees=-180
latitudeOfLastGridPointInDegrees=-25
longitudeOfLastGridPointInDegrees=178.5
1 change: 1 addition & 0 deletions tests/assertions/MPY-400.grib1
Binary file added tests/data/MPY-400.grib1
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ if(mir_HAVE_ATLAS)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()

if(ENABLE_BUILD_TOOLS)
foreach(_t MIR-637.grib2)
ecbuild_add_test(
TARGET mir_tests_unit_grib_fail_decode_${_t}
COMMAND mir-get-data
ARGS --dryrun ${_t}
ENVIRONMENT ${_testEnvironment}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_tests_properties(mir_tests_unit_grib_fail_decode_${_t} PROPERTIES WILL_FAIL TRUE)
endforeach()
endif()

Binary file added tests/unit/MIR-637.grib2
Binary file not shown.

0 comments on commit 97cda0c

Please sign in to comment.