UFO
ProfileVerticalAveraging.h
Go to the documentation of this file.
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 #ifndef UFO_PROFILE_PROFILEVERTICALAVERAGING_H_
9 #define UFO_PROFILE_PROFILEVERTICALAVERAGING_H_
10 
11 #include <vector>
12 
13 namespace ufo {
14  namespace ProfileAveraging {
16  }
17 
18  /// \brief Profile vertical averaging onto model levels.
19  ///
20  /// This routine averages the observed values in a profile onto model levels.
21  /// The vertical positions of observations are referred to as reported levels.
22  ///
23  /// Firstly, all valid reported level values are interpolated onto the adjacent model level
24  /// boundaries. If there are no reported level values adjacent to a model level then the
25  /// model level value is set to missing.
26  ///
27  /// If the parameter \p method is set to 'Interpolation' then no further action is taken;
28  /// otherwise, averaging onto the midpoint of the model layer is performed as follows.
29  ///
30  /// If a model layer contains no reported levels then the mean of the values at the
31  /// upper and lower model layer bounds is taken as the average value.
32  /// If the model layer contains at least one reported level then the weighted mean of the
33  /// values at the model layer boundaries and the reported levels is calculated.
34  /// The distance between adjacent levels (including the model layer boundaries)
35  /// is used as the weight in each case.
36  /// If either of the model boundary values is missing then the layer is referred to as a
37  /// partial layer. In this case a minimum fraction of distance between the upper and lower
38  /// model levels must have been included in the weighted mean, otherwise the mean is
39  /// set to the missing value.
40  /// The minimum fraction is governed by the parameter \p DZFrac.
41  ///
42  /// The vector \p BigGap contains the thresholds for defining the distance between
43  /// reported level coordinates as a 'big gap'.
44  /// Interpolation to model levels is not performed for reported levels separted by a big gap.
45  ///
46  /// The vectors \p coordMin and \p coordMax, which are the coordinates of the highest and lowest
47  /// valid values used in the weighted mean calculation, can optionally be recorded.
48  /// These values are used in (e.g.) atmospheric profile temperature averaging.
49  ///
50  /// \param[in] flagsIn: flags on input data.
51  /// \param[in] valuesIn: reported-level values.
52  /// \param[in] coordIn: reported-level coordinates.
53  /// \param[in] bigGap: maximum gap to be filled in.
54  /// \param[in] coordOut: model layer boundaries.
55  /// \param[in] DZFrac: minimum fraction for partially filled layers to be used.
56  /// \param[in] method: interpolate to model layer boundaries or average over model layers?
57  /// \param[out] flagsOut: flags on output data.
58  /// \param[out] valuesOut: output data (averaged or interpolated).
59  /// \param[out] numGaps: number of large gaps in profile.
60  /// \param[out] coordMax: maximum coordinate of the values used in the model layer average.
61  /// \param[out] coordMin: minimum coordinate of the values used in the model layer average.
62  void calculateVerticalAverage(const std::vector <int> &flagsIn,
63  const std::vector <float> &valuesIn,
64  const std::vector <float> &coordIn,
65  const std::vector <float> &bigGap,
66  const std::vector <float> &coordOut,
67  float DZFrac,
69  std::vector <int> &flagsOut,
70  std::vector <float> &valuesOut,
71  int &numGaps,
72  std::vector <float> *coordMax = nullptr,
73  std::vector <float> *coordMin = nullptr);
74 } // namespace ufo
75 
76 #endif // UFO_PROFILE_PROFILEVERTICALAVERAGING_H_
Definition: RunCRTM.h:27
void calculateVerticalAverage(const std::vector< int > &flagsIn, const std::vector< float > &valuesIn, const std::vector< float > &coordIn, const std::vector< float > &bigGap, const std::vector< float > &coordOut, float DZFrac, ProfileAveraging::Method method, std::vector< int > &flagsOut, std::vector< float > &valuesOut, int &numGaps, std::vector< float > *coordMax, std::vector< float > *coordMin)
Profile vertical averaging onto model levels.