UFO
ModelHeightCalculator.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020, 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 #include "oops/util/CompareNVectors.h"
9 #include "oops/util/Logger.h"
10 #include "oops/util/missingValues.h"
11 #include "oops/util/PropertiesOfNVectors.h"
12 
14 
15 namespace ufo {
17  const float orogGeoVaLs,
18  std::vector <float> &zRhoGeoVaLs,
19  std::vector <float> &zThetaGeoVaLs)
20  {
21  const std::vector <float> &etaThetaGeoVaLs = options.etaTheta;
22  const std::vector <float> &etaRhoGeoVaLs = options.etaRho;
23 
24  if (!oops::allVectorsSameNonZeroSize(etaThetaGeoVaLs,
25  etaRhoGeoVaLs))
26  {
27  oops::Log::warning() << "At least one vector is the wrong size. "
28  << "Model height calculation will not be performed." << std::endl;
29  oops::Log::warning() << "Vector sizes: "
30  << oops::listOfVectorSizes(etaThetaGeoVaLs,
31  etaRhoGeoVaLs)
32  << std::endl;
33  return;
34  }
35 
36  const float missingValueFloat = util::missingValue(missingValueFloat);
37  const float zModelTop = options.zModelTop;
38  const int firstConstantRhoLevel = options.firstConstantRhoLevel;
39  const size_t NumModLevels = etaThetaGeoVaLs.size();
40 
41  zRhoGeoVaLs.assign(NumModLevels + 1, missingValueFloat);
42  zThetaGeoVaLs.assign(NumModLevels, missingValueFloat);
43 
44  // Calculate heights of rho and theta levels using terrain-following height coordinate.
45  for (int jlev = 0; jlev < NumModLevels; ++jlev) {
46  zRhoGeoVaLs[jlev] = etaRhoGeoVaLs[jlev] * zModelTop;
47  zThetaGeoVaLs[jlev] = etaThetaGeoVaLs[jlev] * zModelTop;
48  }
49  // Calculate height of extra rho level.
50  zRhoGeoVaLs[NumModLevels] =
51  zThetaGeoVaLs[NumModLevels - 1] * 2.0 - zRhoGeoVaLs[NumModLevels - 1];
52  // Quadratic method used to account for local orography.
53  for (int k = 0; k < firstConstantRhoLevel; ++k) {
54  zRhoGeoVaLs[k] += orogGeoVaLs *
55  std::pow(1.0 - etaRhoGeoVaLs[k] / etaRhoGeoVaLs[firstConstantRhoLevel], 2.0);
56  zThetaGeoVaLs[k] += orogGeoVaLs *
57  std::pow(1.0 - etaThetaGeoVaLs[k] / etaRhoGeoVaLs[firstConstantRhoLevel], 2.0);
58  }
59  }
60 } // namespace ufo
Options related to GeoVaLs used in the profile QC code.
oops::Parameter< float > zModelTop
Height of the upper boundary of the highest model layer.
oops::Parameter< std::vector< float > > etaTheta
Values of terrain-following height coordinate (eta) on theta levels.
oops::Parameter< int > firstConstantRhoLevel
oops::Parameter< std::vector< float > > etaRho
Value of terrain-following height coordinate (eta) on rho levels.
Definition: RunCRTM.h:27
void CalculateModelHeight(const ModelParameters &options, const float orogGeoVaLs, std::vector< float > &zRhoGeoVaLs, std::vector< float > &zThetaGeoVaLs)
Calculate model heights on rho and theta levels. The calculation uses the terrain-following height co...