Debian Codegraph @

src/atlas/projection/detail/VariableResolutionProjection.h

raw
1 /**
2 * (C) Crown copyright 2021, Met Office
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 */
7
8 #pragma once
9
10 #include <array>
11
12 #include "atlas/domain.h"
13 #include "atlas/projection/detail/ProjectionImpl.h"
14 #include "atlas/util/NormaliseLongitude.h"
15
16
17 namespace atlas {
18 namespace projection {
19 namespace detail {
20
21
22 template <typename Rotation>
23 class VariableResolutionProjectionT final : public ProjectionImpl {
24 public:
25 ///<using Spec = ProjectionImpl::Spec;
26
27 ///< constructor uses parametrisation and point to stretch
28 VariableResolutionProjectionT(const eckit::Parametrisation& p);
29 VariableResolutionProjectionT();
30
31 ///< projection name
32 static std::string static_type() { return Rotation::typePrefix() + "variable_resolution"; }
33 std::string type() const override { return static_type(); }
34
35 // projection and inverse projection
36
37 void xy2lonlat(double crd[]) const override;
38 void lonlat2xy(double crd[]) const override;
39
40 ///< specification for stretching
41 Spec spec() const override;
42
43 std::string units() const override { return "degrees"; }
44
45 void hash(eckit::Hash&) const override;
46
47 ///< NOT for the moment
48 Jacobian jacobian(const PointLonLat&) const override;
49
50 bool strictlyRegional() const override { return true; } ///< Stretch projection cannot be used for global grids
51 RectangularLonLatDomain lonlatBoundingBox(const Domain& domain) const override {
52 return ProjectionImpl::lonlatBoundingBox(domain);
53 }
54
55 void checkvalue(const double&, const double&) const;
56 double general_stretch(const double, const bool, const int) const;
57 double general_stretch_inv(const double, const bool, const int) const;
58
59 protected:
60 double delta_outer; ///< resolution of the external regular grid (rim) it should be larger than the last stretch
61 double delta_inner; ///< /< resolution of the regional model (regular grid)
62 double var_ratio_; ///< power used for the stretching
63 double x_reg_start_; ///< xstart of the internal regional grid
64 double y_reg_start_; ///< ystart of the internal regional grid
65 double x_reg_end_; ///< xend of the internal regional grid
66 double y_reg_end_; ///< yend of the internal regional grid
67 double startx_; ///< original domain startx
68 double endx_; ///< original domain endx
69 double starty_; ///< original domain starty
70 double endy_; ///< original domain endy
71 double rim_widthx_; ///< xsize of the rim
72 double rim_widthy_; ///< ysize of the rim
73
74
75 //< variables derived from the configuration used for the projection
76 double deltax_all, deltay_all;
77 double add_xf_, add_yf_;
78 int nx_stretched, ny_stretched, nx_rim, ny_rim;
79 double check_x, check_y, check_st;
80 double lam_hires_size; ///< size regular grid x
81 double phi_hires_size; ///< size regular grid y
82 double lambda_start; ///< start grid x
83 double phi_start; ///< start grid y
84 std::array<double, 2> new_ratio_;
85
86 void setup(const eckit::Parametrisation& p);
87
88 private:
89 Rotation rotation_;
90 };
91
92 using VariableResolutionProjection = VariableResolutionProjectionT<NotRotated>;
93 using RotatedVariableResolutionProjection = VariableResolutionProjectionT<Rotated>;
94
95 } // namespace detail
96 } // namespace projection
97 } // namespace atlas