-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ foreach( _test | |
points | ||
polygon | ||
projection | ||
range | ||
search | ||
sphere | ||
types | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* (C) Copyright 1996- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation nor | ||
* does it submit to any jurisdiction. | ||
*/ | ||
|
||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include "eckit/geo/range/Gaussian.h" | ||
#include "eckit/geo/range/GlobalRegular.h" | ||
#include "eckit/geo/range/LocalRegular.h" | ||
#include "eckit/testing/Test.h" | ||
#include "eckit/types/FloatCompare.h" | ||
|
||
|
||
#define EXPECT_APPROX(a, b) EXPECT(::eckit::types::is_approximately_equal((a), (b), 1e-12)) | ||
|
||
|
||
int main(int argc, const char* argv[]) { | ||
using namespace eckit::geo::range; | ||
|
||
|
||
{ | ||
std::vector<double> ref{59.44440828916676, | ||
19.87571914744090, | ||
-19.87571914744090, | ||
-59.44440828916676}; | ||
|
||
auto global = Gaussian(2); | ||
EXPECT(global.size() == ref.size()); | ||
|
||
size_t i = 0; | ||
for (const auto& test : global.values()) { | ||
EXPECT_APPROX(test, ref[i++]); | ||
} | ||
|
||
auto cropped = Gaussian(2, 50., -50., 1e-3); | ||
EXPECT(cropped.size() == ref.size() - 2); | ||
|
||
i = 1; | ||
for (const auto& test : cropped.values()) { | ||
EXPECT_APPROX(test, ref[i++]); | ||
} | ||
|
||
EXPECT(Gaussian(2, 59.444, -59.444, 1e-3).size() == 4); | ||
EXPECT(Gaussian(2, 59.444, -59.444, 1e-6).size() == 2); | ||
EXPECT(Gaussian(2, 59.444, -59.445, 1e-6).size() == 3); | ||
|
||
auto single = Gaussian(2, -59.444, -59.444, 1e-3); | ||
EXPECT(single.size() == 1); | ||
|
||
EXPECT_APPROX(single.values().front(), ref.back()); | ||
} | ||
|
||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters