General Purpose Geodetic Library
SgMeteoData.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <iostream>
24 #include <stdlib.h>
25 
26 
27 #include <SgMeteoData.h>
28 #include <SgLogger.h>
29 
30 
31 
32 /*=======================================================================================================
33 *
34 * METHODS:
35 *
36 *======================================================================================================*/
37 //
38 // static first:
39 double SgMeteoData::dewPt2Rho(double temperature, double dewPtTemperature)
40 {
41  const double a = 17.271; //pwxcb: 17.269
42  const double b = 237.7; //pwxcb: 237.3
43  // These values are taken by Ronnie from Wikipedia:
44  // "http://en.wikipedia.org/wiki/Dew_point"
45 
46  return exp(a*dewPtTemperature/(b + dewPtTemperature) - a*temperature/(b + temperature));
47 };
48 
49 
50 
51 //
52 double SgMeteoData::temperature(double height) const
53 {
54  double t(temperature_);
55  if (t<-70.0 || t>50.0 || isAttr(Attr_BAD_DATA) || isAttr(Attr_ARTIFICIAL_DATA))
56  {
57  //
58  // /mk5/libs/cutil/metfix.f:
59  // TEMP=293.15D0-(6.5D-3)*ALT-273.16D0
60  //
61  t = 293.15 - 6.5e-3*height - 273.16;
62  };
63 
64  return t;
65 };
66 
67 
68 
69 //
70 double SgMeteoData::pressure(double height) const
71 {
72  double p(pressure_);
73  if (p<600.0 || p>1100.0 || isAttr(Attr_BAD_DATA) || isAttr(Attr_ARTIFICIAL_DATA))
74  {
75  // p = 1013.0*exp(-0.03412476651981319179/(273.15 + 10.0)*height);
76  //
77  // /mk5/libs/cutil/metfix.f:
78  // X=1.D0-(6.5D-3)*ALT/293.15D0
79  // ATMPR=1013.25D0*(X**5.26D0)
80  //
81  p = 1013.25*pow(1.0 - 6.5e-3*height/293.15, 5.26);
82  };
83 
84  return p;
85 };
86 
87 
88 
89 //
90 double SgMeteoData::relativeHumidity(double /*height*/) const
91 {
92  double rho(relativeHumidity_);
93  if (rho<0.0 || rho>1.0 || isAttr(Attr_BAD_DATA) || isAttr(Attr_ARTIFICIAL_DATA))
94  rho = 0.5;
95 
96  return rho;
97 };
98 /*=====================================================================================================*/
99 //
100 // FRIENDS:
101 //
102 /*=====================================================================================================*/
103 //
104 
105 /*=====================================================================================================*/
106 //
107 // aux functions:
108 //
109 
110 /*=====================================================================================================*/
111 //
112 // constants:
113 //
114 
115 /*=====================================================================================================*/
bool isAttr(uint a) const
Definition: SgAttribute.h:226
double relativeHumidity_
Definition: SgMeteoData.h:158
double pressure(double height=0.0) const
Definition: SgMeteoData.cpp:70
double temperature_
Definition: SgMeteoData.h:156
double relativeHumidity(double height=0.0) const
Definition: SgMeteoData.cpp:90
double pressure_
Definition: SgMeteoData.h:157
double temperature(double height=0.0) const
Definition: SgMeteoData.cpp:52
static double dewPt2Rho(double temperature, double dewPtTemperature)
Definition: SgMeteoData.cpp:39
@ Attr_ARTIFICIAL_DATA
data are artificial (mean values or some model);
Definition: SgMeteoData.h:52
@ Attr_BAD_DATA
data readings are wrong;
Definition: SgMeteoData.h:51