metkitlib 1.16.0.9__cp312-cp312-manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metkitlib/__init__.py +3 -0
- metkitlib/bin/bufr-sanity-check +0 -0
- metkitlib/bin/compare-mars-requests.py +265 -0
- metkitlib/bin/mars-archive-script +0 -0
- metkitlib/bin/parse-mars-request +0 -0
- metkitlib/include/metkit/api/metkit_c.h +255 -0
- metkitlib/include/metkit/codes/BUFRDecoder.h +47 -0
- metkitlib/include/metkit/codes/BufrContent.h +43 -0
- metkitlib/include/metkit/codes/CodesContent.h +67 -0
- metkitlib/include/metkit/codes/CodesHandleDeleter.h +41 -0
- metkitlib/include/metkit/codes/CodesSplitter.h +40 -0
- metkitlib/include/metkit/codes/GRIBDecoder.h +42 -0
- metkitlib/include/metkit/codes/GribAccessor.h +75 -0
- metkitlib/include/metkit/codes/GribHandle.h +121 -0
- metkitlib/include/metkit/codes/GribIterator.h +48 -0
- metkitlib/include/metkit/codes/LibEccodes.h +38 -0
- metkitlib/include/metkit/codes/MallocCodesContent.h +46 -0
- metkitlib/include/metkit/codes/api/CodesAPI.h +365 -0
- metkitlib/include/metkit/codes/api/CodesTypes.h +93 -0
- metkitlib/include/metkit/codes/api/GeoIterator.h +104 -0
- metkitlib/include/metkit/codes/api/KeyIterator.h +187 -0
- metkitlib/include/metkit/config/LibMetkit.h +56 -0
- metkitlib/include/metkit/fields/FieldIndex.h +58 -0
- metkitlib/include/metkit/fields/FieldIndexList.h +40 -0
- metkitlib/include/metkit/fields/SimpleFieldIndex.h +41 -0
- metkitlib/include/metkit/hypercube/HyperCube.h +105 -0
- metkitlib/include/metkit/hypercube/HyperCubePayloaded.h +88 -0
- metkitlib/include/metkit/mars/BaseProtocol.h +95 -0
- metkitlib/include/metkit/mars/ClientTask.h +206 -0
- metkitlib/include/metkit/mars/DHSProtocol.h +106 -0
- metkitlib/include/metkit/mars/MarsExpandContext.h +42 -0
- metkitlib/include/metkit/mars/MarsExpansion.h +83 -0
- metkitlib/include/metkit/mars/MarsExpension.h +28 -0
- metkitlib/include/metkit/mars/MarsHandle.h +83 -0
- metkitlib/include/metkit/mars/MarsLanguage.h +106 -0
- metkitlib/include/metkit/mars/MarsLocation.h +100 -0
- metkitlib/include/metkit/mars/MarsParsedRequest.h +44 -0
- metkitlib/include/metkit/mars/MarsParser.h +70 -0
- metkitlib/include/metkit/mars/MarsRequest.h +198 -0
- metkitlib/include/metkit/mars/MarsRequestHandle.h +79 -0
- metkitlib/include/metkit/mars/Matcher.h +88 -0
- metkitlib/include/metkit/mars/Param.b +43 -0
- metkitlib/include/metkit/mars/Param.h +84 -0
- metkitlib/include/metkit/mars/ParamID.h +306 -0
- metkitlib/include/metkit/mars/Parameter.h +87 -0
- metkitlib/include/metkit/mars/Quantile.h +73 -0
- metkitlib/include/metkit/mars/RequestEnvironment.h +58 -0
- metkitlib/include/metkit/mars/StepRange.b +43 -0
- metkitlib/include/metkit/mars/StepRange.h +164 -0
- metkitlib/include/metkit/mars/StepRangeNormalise.h +95 -0
- metkitlib/include/metkit/mars/Type.h +265 -0
- metkitlib/include/metkit/mars/TypeAny.h +39 -0
- metkitlib/include/metkit/mars/TypeDate.h +42 -0
- metkitlib/include/metkit/mars/TypeEnum.h +67 -0
- metkitlib/include/metkit/mars/TypeExpver.h +40 -0
- metkitlib/include/metkit/mars/TypeFloat.h +41 -0
- metkitlib/include/metkit/mars/TypeInteger.h +55 -0
- metkitlib/include/metkit/mars/TypeLowercase.h +38 -0
- metkitlib/include/metkit/mars/TypeMixed.h +47 -0
- metkitlib/include/metkit/mars/TypeParam.h +45 -0
- metkitlib/include/metkit/mars/TypeRange.h +41 -0
- metkitlib/include/metkit/mars/TypeRegex.h +49 -0
- metkitlib/include/metkit/mars/TypeTime.h +44 -0
- metkitlib/include/metkit/mars/TypeToByList.h +137 -0
- metkitlib/include/metkit/mars/TypeToByListQuantile.h +41 -0
- metkitlib/include/metkit/mars/TypesFactory.h +92 -0
- metkitlib/include/metkit/metkit_config.h +26 -0
- metkitlib/include/metkit/metkit_ecbuild_config.h +72 -0
- metkitlib/include/metkit/metkit_version.h +30 -0
- metkitlib/include/metkit/pointdb/DataSource.h +91 -0
- metkitlib/include/metkit/pointdb/FieldIndexer.h +128 -0
- metkitlib/include/metkit/pointdb/GribDataSource.h +47 -0
- metkitlib/include/metkit/pointdb/GribFieldInfo.h +76 -0
- metkitlib/include/metkit/pointdb/GribHandleDataSource.h +58 -0
- metkitlib/include/metkit/pointdb/PointIndex.h +121 -0
- metkitlib/include/metkit/pointdb/bits.h +1834 -0
- metkitlib/include/metkit/pointdb/masks.h +22 -0
- metkitlib/include/metkit/tool/MetkitTool.h +79 -0
- metkitlib/lib64/cmake/metkit/metkit-config-version.cmake +43 -0
- metkitlib/lib64/cmake/metkit/metkit-config.cmake +112 -0
- metkitlib/lib64/cmake/metkit/metkit-import.cmake +14 -0
- metkitlib/lib64/cmake/metkit/metkit-targets-relwithdebinfo.cmake +46 -0
- metkitlib/lib64/cmake/metkit/metkit-targets.cmake +116 -0
- metkitlib/lib64/libmetkit.so +0 -0
- metkitlib/lib64/pkgconfig/metkit.pc +33 -0
- metkitlib/share/metkit/axis.yaml +63 -0
- metkitlib/share/metkit/bufr-subtypes.yaml +140 -0
- metkitlib/share/metkit/chemids.yaml +209 -0
- metkitlib/share/metkit/language.yaml +1707 -0
- metkitlib/share/metkit/modifiers.yaml +341 -0
- metkitlib/share/metkit/obstype.yaml +182 -0
- metkitlib/share/metkit/odb/marsrequest.yaml +9 -0
- metkitlib/share/metkit/param-matching.yaml +16 -0
- metkitlib/share/metkit/paramids.yaml +24034 -0
- metkitlib/share/metkit/params-static.yaml +212 -0
- metkitlib/share/metkit/params.yaml +9833 -0
- metkitlib/share/metkit/reportype.yaml +525 -0
- metkitlib/share/metkit/shortname-context.yaml +192 -0
- metkitlib-1.16.0.9.dist-info/METADATA +75 -0
- metkitlib-1.16.0.9.dist-info/RECORD +104 -0
- metkitlib-1.16.0.9.dist-info/WHEEL +5 -0
- metkitlib-1.16.0.9.dist-info/licenses/AUTHORS +12 -0
- metkitlib-1.16.0.9.dist-info/licenses/LICENSE +190 -0
- metkitlib-1.16.0.9.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (C) Copyright 1996- ECMWF.
|
|
3
|
+
*
|
|
4
|
+
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
5
|
+
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* In applying this licence, ECMWF does not waive the privileges and immunities
|
|
7
|
+
* granted to it by virtue of its status as an intergovernmental organisation nor
|
|
8
|
+
* does it submit to any jurisdiction.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// File Param.h
|
|
12
|
+
// Baudouin Raoult - ECMWF Dec 97
|
|
13
|
+
|
|
14
|
+
#ifndef metkit_Param_H
|
|
15
|
+
#define metkit_Param_H
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
#include "eckit/persist/Bless.h"
|
|
20
|
+
|
|
21
|
+
namespace eckit {
|
|
22
|
+
class DumpLoad;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
namespace metkit {
|
|
26
|
+
|
|
27
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
class Param {
|
|
30
|
+
public:
|
|
31
|
+
|
|
32
|
+
Param() : table_(-1), value_(-1) {}
|
|
33
|
+
|
|
34
|
+
Param(const std::string&);
|
|
35
|
+
|
|
36
|
+
Param(long table, long value) : table_(table), value_(value) {}
|
|
37
|
+
|
|
38
|
+
#include "metkit/mars/Param.b"
|
|
39
|
+
|
|
40
|
+
~Param() {}
|
|
41
|
+
|
|
42
|
+
operator std::string() const;
|
|
43
|
+
|
|
44
|
+
bool operator==(const Param& other) const { return value_ == other.value_ && table_ == other.table_; }
|
|
45
|
+
|
|
46
|
+
bool operator!=(const Param& other) const { return value_ != other.value_ || table_ != other.table_; }
|
|
47
|
+
|
|
48
|
+
bool operator<(const Param& other) const {
|
|
49
|
+
return (value_ == other.value_) ? (table_ < other.table_) : (value_ < other.value_);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
bool operator>(const Param& other) const {
|
|
53
|
+
return (value_ == other.value_) ? (table_ > other.table_) : (value_ > other.value_);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
long table() const { return table_; }
|
|
57
|
+
long value() const { return value_; }
|
|
58
|
+
long grib1value() const { return value_ % 1000; }
|
|
59
|
+
|
|
60
|
+
long paramId() const;
|
|
61
|
+
|
|
62
|
+
void dump(eckit::DumpLoad&) const;
|
|
63
|
+
void load(eckit::DumpLoad&);
|
|
64
|
+
|
|
65
|
+
protected:
|
|
66
|
+
|
|
67
|
+
void print(std::ostream& s) const;
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
|
|
71
|
+
long table_;
|
|
72
|
+
long value_;
|
|
73
|
+
|
|
74
|
+
friend std::ostream& operator<<(std::ostream& s, const Param& p) {
|
|
75
|
+
p.print(s);
|
|
76
|
+
return s;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
} // namespace metkit
|
|
83
|
+
|
|
84
|
+
#endif
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (C) Copyright 1996- ECMWF.
|
|
3
|
+
*
|
|
4
|
+
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
5
|
+
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* In applying this licence, ECMWF does not waive the privileges and immunities
|
|
7
|
+
* granted to it by virtue of its status as an intergovernmental organisation nor
|
|
8
|
+
* does it submit to any jurisdiction.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/// @author Baudouin Raoult
|
|
12
|
+
/// @author Tiago Quintino
|
|
13
|
+
/// @author Simon Smart
|
|
14
|
+
|
|
15
|
+
/// @date Febuary 2019
|
|
16
|
+
|
|
17
|
+
#ifndef metkit_ParamID_H
|
|
18
|
+
#define metkit_ParamID_H
|
|
19
|
+
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
#include "eckit/config/Resource.h"
|
|
26
|
+
#include "eckit/filesystem/PathName.h"
|
|
27
|
+
#include "eckit/log/Log.h"
|
|
28
|
+
#include "eckit/runtime/Metrics.h"
|
|
29
|
+
#include "eckit/types/Types.h"
|
|
30
|
+
|
|
31
|
+
#include "metkit/config/LibMetkit.h"
|
|
32
|
+
#include "metkit/mars/Param.h"
|
|
33
|
+
|
|
34
|
+
namespace metkit {
|
|
35
|
+
|
|
36
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
class ParamID {
|
|
39
|
+
|
|
40
|
+
public: // types
|
|
41
|
+
|
|
42
|
+
struct WindFamily {
|
|
43
|
+
Param u_;
|
|
44
|
+
Param v_;
|
|
45
|
+
Param vo_;
|
|
46
|
+
Param d_;
|
|
47
|
+
|
|
48
|
+
WindFamily(const std::string& u, const std::string& v, const std::string& vo, const std::string& d) :
|
|
49
|
+
u_(u), v_(v), vo_(vo), d_(d) {}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
public: // methods
|
|
53
|
+
|
|
54
|
+
template <typename REQUEST_T, typename AXIS_T>
|
|
55
|
+
static void normalise(const REQUEST_T& r, std::vector<Param>& req, const AXIS_T& axis, bool& windConversion,
|
|
56
|
+
bool fullTableDropping = ParamID::fullTableDropping());
|
|
57
|
+
|
|
58
|
+
static const std::vector<WindFamily>& getWindFamilies();
|
|
59
|
+
static const std::vector<size_t>& getDropTables();
|
|
60
|
+
static bool fullTableDropping();
|
|
61
|
+
static const std::set<std::string>& getMlParamsSingleLevel();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
inline long replaceTable(size_t table, long paramid) {
|
|
67
|
+
return (table * 1000 + paramid % 1000);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
template <typename REQUEST_T, typename AXIS_T>
|
|
71
|
+
void ParamID::normalise(const REQUEST_T& request, std::vector<Param>& req, const AXIS_T& axis, bool& windConversion,
|
|
72
|
+
bool fullTableDropping) {
|
|
73
|
+
|
|
74
|
+
static const bool useGRIBParamID = eckit::Resource<bool>("useGRIBParamID", false);
|
|
75
|
+
|
|
76
|
+
const std::vector<WindFamily>& windFamilies(getWindFamilies());
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if (useGRIBParamID) {
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
std::set<Param> inAxis;
|
|
83
|
+
for (typename AXIS_T::const_iterator j = axis.begin(); j != axis.end(); ++j) {
|
|
84
|
+
inAxis.insert((*j));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
std::vector<Param> newreq;
|
|
88
|
+
newreq.reserve(req.size());
|
|
89
|
+
|
|
90
|
+
for (std::vector<Param>::const_iterator k = req.begin(); k != req.end(); ++k) {
|
|
91
|
+
const Param& p = (*k);
|
|
92
|
+
|
|
93
|
+
Param alt;
|
|
94
|
+
|
|
95
|
+
if (p.table()) {
|
|
96
|
+
alt = Param(0, (p.table() == 128 ? 0 : p.table()) * 1000 + p.value()); // No '.' version
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
size_t t = p.value() / 1000;
|
|
100
|
+
size_t v = p.value() % 1000;
|
|
101
|
+
alt = Param(t == 0 ? 128 : t, v); // '.' version
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (inAxis.find(p) != inAxis.end()) {
|
|
105
|
+
newreq.push_back(p);
|
|
106
|
+
}
|
|
107
|
+
else if (inAxis.find(alt) != inAxis.end()) {
|
|
108
|
+
newreq.push_back(alt);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
newreq.push_back(p);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
LOG_DEBUG_LIB(LibMetkit) << "useGRIBParamID p=" << p << ", alt=" << alt << ", choice=" << newreq.back()
|
|
115
|
+
<< std::endl;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
req = newreq;
|
|
120
|
+
|
|
121
|
+
for (eckit::Ordinal w = 0; w < windFamilies.size(); w++) {
|
|
122
|
+
|
|
123
|
+
const Param windU(windFamilies[w].u_);
|
|
124
|
+
const Param windV(windFamilies[w].v_);
|
|
125
|
+
const Param windVO(windFamilies[w].vo_);
|
|
126
|
+
const Param windD(windFamilies[w].d_);
|
|
127
|
+
|
|
128
|
+
bool wantU = false;
|
|
129
|
+
bool wantV = false;
|
|
130
|
+
bool wantVO = false;
|
|
131
|
+
bool wantD = false;
|
|
132
|
+
|
|
133
|
+
// Check if wind is requested
|
|
134
|
+
for (eckit::Ordinal i = 0; i < req.size(); i++) {
|
|
135
|
+
if (req[i] == windU)
|
|
136
|
+
wantU = true;
|
|
137
|
+
if (req[i] == windV)
|
|
138
|
+
wantV = true;
|
|
139
|
+
if (req[i] == windVO)
|
|
140
|
+
wantVO = true;
|
|
141
|
+
if (req[i] == windD)
|
|
142
|
+
wantD = true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Check if we have got it, axis should be sorted
|
|
146
|
+
bool gotU = false;
|
|
147
|
+
bool gotV = false;
|
|
148
|
+
|
|
149
|
+
if (wantU)
|
|
150
|
+
gotU = std::binary_search(axis.begin(), axis.end(), windU);
|
|
151
|
+
|
|
152
|
+
if (wantV)
|
|
153
|
+
gotV = std::binary_search(axis.begin(), axis.end(), windV);
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
if ((wantU && !gotU) || (wantV && !gotV)) {
|
|
157
|
+
// Push VO and D if needed
|
|
158
|
+
if (!wantVO)
|
|
159
|
+
req.push_back(windVO);
|
|
160
|
+
if (!wantD)
|
|
161
|
+
req.push_back(windD);
|
|
162
|
+
|
|
163
|
+
LOG_DEBUG_LIB(LibMetkit) << "U/V conversion requested U=" << windU << ", V=" << windV
|
|
164
|
+
<< ", VO=" << windVO << ", D=" << windD << std::endl;
|
|
165
|
+
windConversion = true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
|
|
171
|
+
std::vector<std::pair<Param, Param> > tableDropped;
|
|
172
|
+
|
|
173
|
+
std::set<Param> inAxis;
|
|
174
|
+
std::map<long, Param> inAxisParamID;
|
|
175
|
+
std::set<Param> wind;
|
|
176
|
+
|
|
177
|
+
for (typename AXIS_T::const_iterator j = axis.begin(); j != axis.end(); ++j) {
|
|
178
|
+
inAxis.emplace(*j);
|
|
179
|
+
inAxisParamID[j->paramId()] = *j;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
std::vector<Param> newreq;
|
|
183
|
+
newreq.reserve(req.size());
|
|
184
|
+
|
|
185
|
+
for (auto r : req) {
|
|
186
|
+
if (inAxis.find(r) != inAxis.end()) { // Perfect match - look no further
|
|
187
|
+
newreq.push_back(r);
|
|
188
|
+
}
|
|
189
|
+
else { // r is normalised to ParamID
|
|
190
|
+
long paramid = r.paramId();
|
|
191
|
+
auto ap = inAxisParamID.find(paramid);
|
|
192
|
+
if (ap != inAxisParamID.end()) { // ParamID representation matching - look no further
|
|
193
|
+
newreq.push_back(ap->second);
|
|
194
|
+
}
|
|
195
|
+
else { // Special case for U/V - exact match
|
|
196
|
+
bool ok = false;
|
|
197
|
+
for (eckit::Ordinal w = 0; w < windFamilies.size(); w++) {
|
|
198
|
+
if ((paramid == windFamilies[w].u_.paramId() || paramid == windFamilies[w].u_.grib1value() ||
|
|
199
|
+
paramid == windFamilies[w].v_.paramId() || paramid == windFamilies[w].v_.grib1value()) &&
|
|
200
|
+
inAxis.find(windFamilies[w].vo_) != inAxis.end() &&
|
|
201
|
+
inAxis.find(windFamilies[w].d_) != inAxis.end()) {
|
|
202
|
+
|
|
203
|
+
if (paramid == windFamilies[w].u_.paramId() || paramid == windFamilies[w].u_.grib1value())
|
|
204
|
+
newreq.push_back(windFamilies[w].u_);
|
|
205
|
+
else
|
|
206
|
+
newreq.push_back(windFamilies[w].v_);
|
|
207
|
+
|
|
208
|
+
wind.emplace(windFamilies[w].vo_);
|
|
209
|
+
wind.emplace(windFamilies[w].d_);
|
|
210
|
+
windConversion = true;
|
|
211
|
+
|
|
212
|
+
ok = true;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (!ok && r.table() == 0 &&
|
|
217
|
+
paramid < 1000) { // Partial match (only it table has not been specified by user)
|
|
218
|
+
const std::vector<size_t>& dropTables = ParamID::getDropTables();
|
|
219
|
+
for (auto t : dropTables) {
|
|
220
|
+
auto ap = inAxisParamID.find(replaceTable(t, paramid));
|
|
221
|
+
if (ap != inAxisParamID.end()) { // ParamID representation matching - look no further
|
|
222
|
+
newreq.push_back(ap->second);
|
|
223
|
+
ok = true;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (!ok) { // Special case for U/V - partial match
|
|
229
|
+
for (eckit::Ordinal w = 0; !ok && w < windFamilies.size(); w++) {
|
|
230
|
+
if (paramid == windFamilies[w].u_.paramId() ||
|
|
231
|
+
paramid == windFamilies[w].v_.paramId()) {
|
|
232
|
+
for (auto t : dropTables) {
|
|
233
|
+
auto vo = inAxisParamID.find(replaceTable(t, windFamilies[w].vo_.paramId()));
|
|
234
|
+
auto d = inAxisParamID.find(replaceTable(t, windFamilies[w].d_.paramId()));
|
|
235
|
+
|
|
236
|
+
if (vo != inAxisParamID.end() && d != inAxisParamID.end()) {
|
|
237
|
+
bool grib1 = vo->second.table() > 0;
|
|
238
|
+
if (paramid == windFamilies[w].u_.paramId())
|
|
239
|
+
newreq.push_back(grib1 ? Param(t, paramid)
|
|
240
|
+
: Param(0, replaceTable(t, paramid)));
|
|
241
|
+
else
|
|
242
|
+
newreq.push_back(grib1 ? Param(t, paramid)
|
|
243
|
+
: Param(0, replaceTable(t, paramid)));
|
|
244
|
+
|
|
245
|
+
wind.emplace(vo->second);
|
|
246
|
+
wind.emplace(d->second);
|
|
247
|
+
windConversion = true;
|
|
248
|
+
|
|
249
|
+
ok = true;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (ok)
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (fullTableDropping &&
|
|
259
|
+
!ok) { // Backward compatibility - Partial match (drop completely table information)
|
|
260
|
+
for (auto ap : inAxisParamID) {
|
|
261
|
+
if (ap.first % 1000 == paramid % 1000) {
|
|
262
|
+
newreq.push_back(ap.second);
|
|
263
|
+
ok = true;
|
|
264
|
+
tableDropped.push_back(std::make_pair(r, ap.second));
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
req = newreq;
|
|
274
|
+
|
|
275
|
+
for (auto w : wind) {
|
|
276
|
+
bool exist = false;
|
|
277
|
+
for (eckit::Ordinal i = 0; i < req.size(); i++)
|
|
278
|
+
if (req[i] == w) {
|
|
279
|
+
exist = true;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
if (!exist) {
|
|
283
|
+
req.push_back(w);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (tableDropped.size() > 0) {
|
|
287
|
+
eckit::MetricsPrefix prefix("paramid_normalisation");
|
|
288
|
+
{
|
|
289
|
+
std::ostringstream oss;
|
|
290
|
+
oss << request;
|
|
291
|
+
eckit::Metrics::set("user_request", oss.str());
|
|
292
|
+
}
|
|
293
|
+
{
|
|
294
|
+
std::ostringstream oss;
|
|
295
|
+
oss << tableDropped;
|
|
296
|
+
eckit::Metrics::set("params", oss.str());
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
303
|
+
|
|
304
|
+
} // namespace metkit
|
|
305
|
+
|
|
306
|
+
#endif
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (C) Copyright 1996- ECMWF.
|
|
3
|
+
*
|
|
4
|
+
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
5
|
+
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* In applying this licence, ECMWF does not waive the privileges and immunities
|
|
7
|
+
* granted to it by virtue of its status as an intergovernmental organisation nor
|
|
8
|
+
* does it submit to any jurisdiction.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/// @author Manuel Fuentes
|
|
12
|
+
/// @author Baudouin Raoult
|
|
13
|
+
/// @author Tiago Quintino
|
|
14
|
+
|
|
15
|
+
/// @date Sep 96
|
|
16
|
+
|
|
17
|
+
#ifndef metkit_Parameter_H
|
|
18
|
+
#define metkit_Parameter_H
|
|
19
|
+
|
|
20
|
+
#include "eckit/types/Date.h"
|
|
21
|
+
#include "eckit/types/Double.h"
|
|
22
|
+
#include "eckit/types/Time.h"
|
|
23
|
+
#include "eckit/utils/Translator.h"
|
|
24
|
+
#include "eckit/value/Value.h"
|
|
25
|
+
|
|
26
|
+
namespace eckit {
|
|
27
|
+
class JSON;
|
|
28
|
+
class MD5;
|
|
29
|
+
} // namespace eckit
|
|
30
|
+
|
|
31
|
+
namespace metkit {
|
|
32
|
+
namespace mars {
|
|
33
|
+
|
|
34
|
+
class Type;
|
|
35
|
+
class MarsRequest;
|
|
36
|
+
|
|
37
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Parameter {
|
|
41
|
+
public: // methods
|
|
42
|
+
|
|
43
|
+
Parameter();
|
|
44
|
+
~Parameter();
|
|
45
|
+
|
|
46
|
+
Parameter(const std::vector<std::string>& values, Type* = 0);
|
|
47
|
+
Parameter(const Parameter&);
|
|
48
|
+
|
|
49
|
+
Parameter& operator=(const Parameter&);
|
|
50
|
+
bool operator<(const Parameter&) const;
|
|
51
|
+
|
|
52
|
+
const std::vector<std::string>& values() const { return values_; }
|
|
53
|
+
void values(const std::vector<std::string>& values);
|
|
54
|
+
|
|
55
|
+
bool filter(const std::vector<std::string>& filter);
|
|
56
|
+
bool filter(const std::string& keyword, const std::vector<std::string>& filter);
|
|
57
|
+
bool matches(const std::vector<std::string>& matches) const;
|
|
58
|
+
|
|
59
|
+
void merge(const Parameter& p);
|
|
60
|
+
|
|
61
|
+
Type& type() const { return *type_; }
|
|
62
|
+
const std::string& name() const;
|
|
63
|
+
|
|
64
|
+
size_t count() const;
|
|
65
|
+
|
|
66
|
+
private: // methods
|
|
67
|
+
|
|
68
|
+
void print(std::ostream&) const;
|
|
69
|
+
|
|
70
|
+
friend std::ostream& operator<<(std::ostream& s, const Parameter& p) {
|
|
71
|
+
p.print(s);
|
|
72
|
+
return s;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private: // members
|
|
76
|
+
|
|
77
|
+
Type* type_;
|
|
78
|
+
std::vector<std::string> values_;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
} // namespace mars
|
|
85
|
+
} // namespace metkit
|
|
86
|
+
|
|
87
|
+
#endif
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (C) Copyright 1996- ECMWF.
|
|
3
|
+
*
|
|
4
|
+
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
5
|
+
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* In applying this licence, ECMWF does not waive the privileges and immunities
|
|
7
|
+
* granted to it by virtue of its status as an intergovernmental organisation nor
|
|
8
|
+
* does it submit to any jurisdiction.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/// @file Quantile.h
|
|
12
|
+
/// @author Emanuele Danovaro
|
|
13
|
+
/// @date February 2022
|
|
14
|
+
|
|
15
|
+
#pragma once
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
namespace metkit {
|
|
20
|
+
|
|
21
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
class Quantile {
|
|
24
|
+
public:
|
|
25
|
+
|
|
26
|
+
Quantile(const std::string& value);
|
|
27
|
+
Quantile(long num, long den);
|
|
28
|
+
|
|
29
|
+
long num() const { return num_; }
|
|
30
|
+
long den() const { return den_; }
|
|
31
|
+
|
|
32
|
+
operator std::string();
|
|
33
|
+
|
|
34
|
+
Quantile& operator+=(const long& rhs);
|
|
35
|
+
Quantile& operator-=(const long& rhs);
|
|
36
|
+
|
|
37
|
+
protected:
|
|
38
|
+
|
|
39
|
+
void print(std::ostream& s) const;
|
|
40
|
+
|
|
41
|
+
private:
|
|
42
|
+
|
|
43
|
+
void check() const;
|
|
44
|
+
|
|
45
|
+
friend std::ostream& operator<<(std::ostream& s, const Quantile& q) {
|
|
46
|
+
q.print(s);
|
|
47
|
+
return s;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private:
|
|
51
|
+
|
|
52
|
+
long num_;
|
|
53
|
+
long den_;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
bool operator==(const Quantile& lhs, const Quantile& rhs);
|
|
57
|
+
inline bool operator!=(const Quantile& lhs, const Quantile& rhs) {
|
|
58
|
+
return !(rhs == lhs);
|
|
59
|
+
}
|
|
60
|
+
bool operator<(const Quantile& lhs, const Quantile& rhs);
|
|
61
|
+
inline bool operator>(const Quantile& lhs, const Quantile& rhs) {
|
|
62
|
+
return rhs < lhs;
|
|
63
|
+
}
|
|
64
|
+
inline bool operator<=(const Quantile& lhs, const Quantile& rhs) {
|
|
65
|
+
return !(lhs > rhs);
|
|
66
|
+
}
|
|
67
|
+
inline bool operator>=(const Quantile& lhs, const Quantile& rhs) {
|
|
68
|
+
return !(lhs < rhs);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
} // namespace metkit
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (C) Copyright 1996- ECMWF.
|
|
3
|
+
*
|
|
4
|
+
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
5
|
+
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* In applying this licence, ECMWF does not waive the privileges and immunities
|
|
7
|
+
* granted to it by virtue of its status as an intergovernmental organisation
|
|
8
|
+
* nor does it submit to any jurisdiction.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/// @author Baudouin Raoult
|
|
12
|
+
/// @author Tiago Quintino
|
|
13
|
+
#pragma once
|
|
14
|
+
|
|
15
|
+
#include <map>
|
|
16
|
+
#include <mutex>
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
#include "metkit/mars/MarsRequest.h"
|
|
21
|
+
|
|
22
|
+
namespace metkit::mars {
|
|
23
|
+
|
|
24
|
+
/// Encapsulates the environment to be sent to the mars-server.
|
|
25
|
+
/// This uses a mars request with 'environ' as the verb and each environment
|
|
26
|
+
/// variable is treated as keyword with its respective value.
|
|
27
|
+
class RequestEnvironment {
|
|
28
|
+
public:
|
|
29
|
+
|
|
30
|
+
RequestEnvironment(const RequestEnvironment& other);
|
|
31
|
+
|
|
32
|
+
/// Create the actual "mars-request"
|
|
33
|
+
/// @return the request
|
|
34
|
+
const MarsRequest& request() const { return *env_; }
|
|
35
|
+
|
|
36
|
+
/// @brief Initialize the RequestEnvironment with a map of KEYWORD:VALUE(s).
|
|
37
|
+
/// @param env, map of KEYWORD:VALUE (or KEYWORD:VALUE1/VALUE2/.../VALUEn) to add to the environment.
|
|
38
|
+
static void initialize(const std::map<std::string, std::string>& env);
|
|
39
|
+
|
|
40
|
+
/// @brief Update the RequestEnvironment with a map of KEYWORD:VALUE(s).
|
|
41
|
+
/// @param env, map of KEYWORD:VALUE (or KEYWORD:VALUE1/VALUE2/.../VALUEn) to add to the environment.
|
|
42
|
+
void update(const std::map<std::string, std::string>& env);
|
|
43
|
+
|
|
44
|
+
/// Access instance of RequestEnvironment
|
|
45
|
+
/// @return RequestEnvironment
|
|
46
|
+
static const RequestEnvironment& instance();
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
|
|
50
|
+
RequestEnvironment() = default;
|
|
51
|
+
|
|
52
|
+
static RequestEnvironment& inst();
|
|
53
|
+
|
|
54
|
+
std::optional<MarsRequest> env_ = std::nullopt;
|
|
55
|
+
std::recursive_mutex init_;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace metkit::mars
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
StepRange(eckit::Bless& b):
|
|
3
|
+
from_(b(&from_)),
|
|
4
|
+
to_(b(&to_))
|
|
5
|
+
{
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
StepRange(eckit::Evolve b):
|
|
9
|
+
from_(b("StepRange","from_")),
|
|
10
|
+
to_(b("StepRange","to_"))
|
|
11
|
+
{
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static const char* specName() { return "StepRange"; }
|
|
15
|
+
static void isa(TypeInfo* t) { eckit::Isa::add(t,specName()); }
|
|
16
|
+
static eckit::Isa* isa() { return eckit::Isa::get(specName()); }
|
|
17
|
+
|
|
18
|
+
static void schema(eckit::Schema& s)
|
|
19
|
+
{
|
|
20
|
+
s.start(specName(),sizeof(StepRange));
|
|
21
|
+
s.member("from_",member_size(StepRange,from_),member_offset(StepRange,from_),"double");
|
|
22
|
+
s.member("to_",member_size(StepRange,to_),member_offset(StepRange,to_),"double");
|
|
23
|
+
s.end(specName());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
void describe(std::ostream& s,int depth = 0) const {
|
|
28
|
+
eckit::_startClass(s,depth,specName());
|
|
29
|
+
eckit::_describe(s,depth+1,"from_",from_);
|
|
30
|
+
eckit::_describe(s,depth+1,"to_",to_);
|
|
31
|
+
eckit::_endClass(s,depth,specName());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
void _export(eckit::Exporter& h) const {
|
|
37
|
+
eckit::_startClass(h,"StepRange");
|
|
38
|
+
eckit::_export(h,"from_",from_);
|
|
39
|
+
eckit::_export(h,"to_",to_);
|
|
40
|
+
eckit::_endClass(h,"StepRange");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|