| 1 |
/* |
| 2 |
* (C) Copyright 2013 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 |
#pragma once |
| 12 |
|
| 13 |
#include <array> |
| 14 |
#include <string> |
| 15 |
|
| 16 |
#include "atlas/grid/detail/spacing/Spacing.h" |
| 17 |
|
| 18 |
namespace atlas { |
| 19 |
namespace grid { |
| 20 |
namespace spacing { |
| 21 |
|
| 22 |
|
| 23 |
// clang-format off |
| 24 |
|
| 25 |
/// @brief Custom spacing in interval |
| 26 |
/// |
| 27 |
/// There are N points, by default in the open interval (90, -90). The interval is used to |
| 28 |
/// determine if a grid's domain contains poles. |
| 29 |
/// |
| 30 |
/// Using the constructor CustomSpacing( N, x[], {min,max} ) we can create |
| 31 |
/// |
| 32 |
/// CustomSpacing( 4, {75,25,-25,-75} ) --> { 75 , 25 , -25, -75 } |
| 33 |
/// CustomSpacing( 4, {75,25,-25,-75}, {-90,90} ) --> { 75 , 25 , -25, -75 } |
| 34 |
/// |
| 35 |
/// The optional argument {min,max} serves as purpose to indicate that the points |
| 36 |
/// lie in the open interval (min,max). If not specified, the default values are taken |
| 37 |
/// to be the North and South pole's latitudes. |
| 38 |
/// |
| 39 |
/// Configuration parameters can be passed as well with following keys: |
| 40 |
/// |
| 41 |
/// {"N":4, "values":[75,25,-25,75] } --> { 75 , 25 , -25 , -75 } |
| 42 |
/// {"N":4, "values":[75,25,-25,75], "interval":[-90,90] } --> { 75 , 25 , -25 , -75 } |
| 43 |
|
| 44 |
// clang-format on |
| 45 |
|
| 46 |
class CustomSpacing : public Spacing { |
| 47 |
private: |
| 48 |
using Interval = std::array<double, 2>; |
| 49 |
static constexpr double North() { return 90.; } |
| 50 |
static constexpr double South() { return -90.; } |
| 51 |
|
| 52 |
public: |
| 53 |
// constructor |
| 54 |
CustomSpacing(const eckit::Parametrisation& p); |
| 55 |
|
| 56 |
CustomSpacing(long N, const double x[], const Interval& = {North(), South()}); |
| 57 |
|
| 58 |
// class name |
| 59 |
static std::string static_type() { return "custom"; } |
| 60 |
virtual std::string type() const { return static_type(); } |
| 61 |
|
| 62 |
virtual Spec spec() const; |
| 63 |
}; |
| 64 |
|
| 65 |
} // namespace spacing |
| 66 |
} // namespace grid |
| 67 |
} // namespace atlas |