Debian Codegraph @

src/atlas/util/function/SphericalHarmonic.h

raw
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 nor
8 * does it submit to any jurisdiction.
9 */
10
11
12 #pragma once
13
14 #include <functional>
15
16 namespace atlas {
17
18 namespace util {
19
20 namespace function {
21
22 /// \brief An analytic function that provides a spherical harmonic on a 2D sphere
23 ///
24 /// \param n Total wave number
25 /// \param m Zonal wave number
26 /// \param lon Longitude in degrees
27 /// \param lat Latitude in degrees
28 /// \return spherical harmonic
29 double spherical_harmonic(int n, int m, double lon, double lat);
30
31 /// \brief SphericalHarmonic operator that provides a spherical harmonic on a 2D sphere
32 class SphericalHarmonic {
33 public:
34 /// \brief Constructor
35 ///
36 /// \param n Total wave number
37 /// \param m Zonal wave number
38 /// \param caching When true, internally cache the results of Associated Legendre Polynomials
39 /// in a map. Warning: this is not thread-safe
40 SphericalHarmonic(int n, int m, bool caching = false);
41
42 /// \brief Evaluate the spherical harmonic function for given longitude and latitude
43 double operator()(double lon, double lat) const;
44
45 private:
46 std::function<double(double, double)> Y_;
47 };
48
49 } // namespace function
50
51 } // namespace util
52
53 } // namespace atlas