CARMA C++
Atmosphere.h
Go to the documentation of this file.
1 // $Id: Atmosphere.h,v 1.2 2014/06/04 17:09:38 mpound Exp $
13 #include "carma/services/Units.h"
14 #include "carma/services/Angle.h"
18 
19 #ifndef CARMA_SERVICES_ATMOSPHERE_H
20 #define CARMA_SERVICES_ATMOSPHERE_H
21 namespace carma {
22  namespace services {
46  class Atmosphere {
47  public:
48 
49  //------------------------------------------------------
50  // PUBLIC STATIC CONSTANTS
51  //------------------------------------------------------
52 
53 
59  static const double DEFAULT_ATM_PRESSURE = 780.0;
60 
64  static const double STANDARD_ATM_PRESSURE = 1013.25;
65 
71  static const double MIN_ATM_PRESSURE = 680; // 0.9*DEFAULT for CARMA
72 
78  static const double MAX_ATM_PRESSURE = 1115.0; //1.1atm at sealevel
79 
84  //"room temperature"
85  static const double DEFAULT_AIR_TEMP = 300.0; //80 Fahrenheit
86 
92  //??need reasonable limits
93  static const double MIN_AIR_TEMP = 242.0; // -25 Fahrenheit
94 
100  //??need reasonable limits
101  static const double MAX_AIR_TEMP = 316.5; // 110 Fahrenheit
102 
107  //??need reasonable limits
108  static const double DEFAULT_RH = 25.0;
109 
115  //??need reasonable limits
116  static const double MIN_RH = 5.0;
117 
123  static const double MAX_RH = 100.0;
124 
129  // This is the dewpoint for the DEFAULT_AIRTEMP (300K)
130  // and DEFAULT_RH (50%)
131  // carma/environment/Test/tAtmosphere RH=50 Ta=26.85
132  // 25% = 277.388
133  // carma/environment/Test/tAtmosphere RH=25 Ta=26.85
134  // 50% = 288.761;
135  static const double DEFAULT_DEW_POINT = 278.388;
136 
142  //For MIN_AIRTEMP, MIN_RH
143  static const double MIN_DEW_POINT = 221.9;
144 
154  //dewpoint at 100% RH is the airtemp
155  //value is initialized with the storage declaration in the .cc file
156  static const double MAX_DEW_POINT;
157 
164  static const double MIN_ELEVATION = 0.0174533; // radians
165 
169  static const double DEFAULT_WIND_SPEED = 0.0;
170 
176  static const double MIN_WIND_SPEED = 0.0;
177 
183  static const double MAX_WIND_SPEED = 200.0;
184 
185  typedef enum dewPointMethodEnum {
186  CLAUSIUS_CLAPEYRON,
187  MAGNUS_TETENS,
188  HOFFMAN_WELCH
189  } dewPointMethodType ;
190 
191  //------------------------------------------------------
192  // PUBLIC METHODS
193  //------------------------------------------------------
194 
196  Atmosphere();
197 
199  virtual ~Atmosphere();
200 
214  double computeSaturatedPressure(double airTemp) const;
215 
225  double waterColumn(double airTemp, double relHumid) const;
226 
238  double waterPartialPressure(double airTemp, double relHumid) const;
239 
251  double waterVaporDensity(double airTemp, double relHumid) const;
252 
253 
286  double computeDewPoint(double airTemp,
287  double relHumid,
288  dewPointMethodType method = CLAUSIUS_CLAPEYRON ) const;
289 
290 
306  double computeHumidity(double airTemp,
307  double dewTemp,
308  dewPointMethodType method = CLAUSIUS_CLAPEYRON ) const;
309 
328  double computeZenithRefractivity(double airTemp,
329  double atmPressure,
330  double relHumid,
331  double frequency) const;
332 
356  double computeRefractionCorrection(double airTemp,
357  double atmPressure,
358  double relHumid,
359  double elevation,
360  double frequency,
361  double altitude) const;
374  double ulichRefractionCorrection(double airTemp,
375  double atmPressure,
376  double relHumid,
377  double elevation,
378  double frequency) const;
420  double computePathlength(double airTemp,
421  double atmPressure,
422  double relHumid,
423  double elevation,
424  double frequency,
425  double altitude = 0.0) const;
426 
427 
447  double computeHorizonPathlength(double airTemp,
448  double atmPressure,
449  double relHumid,
450  double frequency) const;
451 
463  static double safeAirTemperature(double airTemp);
464 
471  static bool isSafeAirTemperature(double airTemp);
472 
494 
505 
517 
522 
535  static double safeAtmPressure(double atmPressure);
536 
544  static bool isSafeAtmPressure(double atmPressure);
545 
559  carma::services::Pressure atmPressure );
566  static bool isSafeAtmPressure( carma::services::Pressure atmPressure );
567 
577  carma::services::Pressure lastSafeAtmPressure( double atmPressure );
578 
589  carma::services::Pressure atmPressure );
590 
595 
606  static double safeRelativeHumidity(double relHumid);
607 
613  static bool isSafeRelativeHumidity(double relHumid);
614 
624  double lastSafeRelativeHumidity( double relHumid );
625 
629  double lastSafeRelativeHumidity( ) const;
630 
645  static double safeDewPoint(double dewPoint);
646 
653  static bool isSafeDewPoint(double dewPoint);
654 
667  carma::services::Temperature dewPoint );
668 
675  static bool isSafeDewPoint( carma::services::Temperature dewPoint );
676 
698  services::Temperature airTemp,
699  double relHumid,
700  dewPointMethodType method = CLAUSIUS_CLAPEYRON,
701  double consistencyPercent = 10.0 );
702 
713 
724  carma::services::Temperature dewPoint );
725 
730 
737  static double safeElevation(double elevation);
738 
744  static bool isSafeElevation(double elevation);
745 
754  carma::services::Angle elevation );
760  static bool isSafeElevation( carma::services::Angle elevation );
761 
775  carma::services::Velocity windSpeed );
776 
777  /*
778  * @return true is wind speed
779  * is within reasonable bounds for the CARMA site.
780  * @see #safeWindSpeed(services::Velocity windSpeed)
781  */
782  static bool isSafeWindSpeed( carma::services::Velocity windSpeed );
783 
795  static double safeWindSpeed(double windSpeed);
796 
797  /*
798  * @return true is wind speed
799  * is within reasonable bounds for the CARMA site.
800  * @see #safeWindSpeed(double windSpeed)
801  */
802  static bool isSafeWindSpeed( double windSpeed );
803 
804  private:
805  //------------------------------------------------------
806  // PRIVATE STATIC CONSTANTS
807  //------------------------------------------------------
812  static const double CC_A = 6.105; // leading coeff.
813  static const double CC_B = 25.22; // T coeff.
814  static const double CC_C = 5.31; // ln(T) coeff.
815 
822  static const double AWIPS_C1 = 0.0091379024;
823  static const double AWIPS_C2 = 6106.396;
824  static const double AWIPS_C3 = 223.1986;
825  static const double AWIPS_C4 = 0.0182758048;
826  static const double AWIPS_C15 = 26.66082;
827 
828 
832  static const double MT_A = 17.27;
833  static const double MT_B = 237.7;
834 
839  static const double HW_A = 1.598E9;
840  static const double HW_B = 5370;
841 
848  static const double SW_DRY_AIR = 77.6;
849 
854  static const double BW_DRY_AIR = 77.6;
855 
865  static const double SW_INDUCED_DIPOLE = 0.128;
869  static const double BW_INDUCED_DIPOLE = 5.6;
870 
880  static const double SW_PERM_DIPOLE = 3.776E3;
884  static const double BW_PERM_DIPOLE = 3.75E3;
885 
892  static const double REFRAC_COEFF_A = -2.8354E-5;
893 
900  static const double REFRAC_COEFF_B = 5.4012E-7;
901 
909  static const double MIN_REFRAC_FREQ = 50.0; //50 GHz
910 
932  // Equations 13. (radio)
933  static const double A1_RAD_1 = 0.5753868; // constant
934  static const double A1_RAD_P = 0.5291E-4; // * P
935  static const double A1_RAD_PPW = -0.2819E-4; // * Pwater
936  static const double A1_RAD_PPWSQ = -0.9381E-6; // * Pwater^2
937  static const double A1_RAD_T = -0.5958E-3; // * T
938  static const double A1_RAD_TSQ = 0.2657E-5; // * T^2
939 
940  static const double A2_RAD_1 = 1.301211; // constant
941  static const double A2_RAD_P = 0.2003E-4; // * P
942  static const double A2_RAD_PPW = -0.7285E-4; // * Pwater
943  static const double A2_RAD_PPWSQ = 0.2579E-5; // * Pwater^2
944  static const double A2_RAD_T = -0.2595E-2; // * T
945  static const double A2_RAD_TSQ = 0.8509E-5; // * T^2
946 
947  // Equations 17. (optical)
948  static const double A1_OPT_1 = 0.5787089; // constant
949  static const double A1_OPT_P = 0.5609E-4; // * P
950  static const double A1_OPT_T = -0.6229E-3; // * T
951  static const double A1_OPT_TSQ = 0.2824E-5; // * T^2
952  static const double A1_OPT_PPW = 0.5177E-3; // * Pwater
953  static const double A1_OPT_PPWSQ = 0.2900E-6; // * Pwater^2
954  static const double A1_OPT_WAVE = -0.1644E-1; // * lambda
955  static const double A1_OPT_WAVESQ = 0.4910E-1; // * lambda^2
956 
957  static const double A2_OPT_1 = 1.302474; // constant
958  static const double A2_OPT_P = 0.2142E-4; // * P
959  static const double A2_OPT_T = 0.1287E-2; // * Pwater
960  static const double A2_OPT_TSQ = 0.6500E-6; // * Pwater^2
961  static const double A2_OPT_PPW = -0.2623E-2; // * T
962  static const double A2_OPT_PPWSQ = 0.8776E-5; // * T^2
963  static const double A2_OPT_WAVE = -0.6298E-2; // * lambda
964  static const double A2_OPT_WAVESQ = 0.1890E-1; // * lambda^2
965 
966  // Zero point offsets used by Mangum (2001)
967  // Same as Yan (1996) except temperature has been converted
968  // to Kelvin. These are all to be ADDED to the measured
969  // values.
970  //
971  // pressure offset, mbar
972  static const double P_OFFSET = -1013.25;
973  // temperature offset, K
974  static const double T_OFFSET = -258.15;
975  // wavelength offset, micron
976  static const double WAVE_OFFSET = -0.5320;
977 
978  // coefficients for normalized effective zenith
979  // Yan equation 12, Mangum equations 24 and 27.
980  // R = 8314.14 J/(kmol K) = kg/(m^2 s^2 kmol K)
981  // M = 28.970 kg/kmol
982  // g = 9.7840 m/s^2 (in vertical column of air at tropopause)
983  // R/(M*g) = 29.33895 meters
984  // From units:
985  // You have: 1 K*gasconstant/(28.970 kg kmol^-1*9.7840 m s^-2)
986  // You want:
987  // Definition: 29.333895 m
988  static const double RMG = 29.333895;
989 
990  // some constants used in the mapping function
991  // see computeMappingFunction(...)
992  static const double MAP1 = 13.24969;
993  static const double MAP2 = 173.4233;
994 
995  //------------------------------------------------------
996  // PRIVATE NON-STATIC NON-CONSTANT DATA
997  //------------------------------------------------------
998  carma::services::Temperature lastSafeAirTemperature_;
999  carma::services::Pressure lastSafeAtmPressure_;
1000  carma::services::Temperature lastSafeDewPoint_;
1001  double lastSafeRelativeHumidity_;
1002 
1003  //------------------------------------------------------
1004  // STRUCTS USED BY THIS CLASS
1005  //------------------------------------------------------
1006 
1011  typedef struct {
1016  double ir;
1017 
1022  double dry;
1023 
1028  double wet;
1029 
1034  double opacity;
1035 
1036  } scaleHeightType;
1037 
1042  static const scaleHeightType scaleHeight;
1043 
1047  const carma::services::Units units;
1048 
1049  //------------------------------------------------------
1050  // PRIVATE METHODS
1051  //------------------------------------------------------
1059  double freqDependence(double frequency);
1060 
1077  double computeMappingFunction(
1078  double airTemp,
1079  double atmPressure,
1080  double relHumid,
1081  double elevation,
1082  double frequency,
1083  double altitude) const;
1084 
1085  /*
1086  * This is to test against the Ulich (1981)
1087  * mapping function from NRAO.
1088  * @param elevation The <em>in vacuo</em>
1089  * (uncorrected) elevation in radians
1090  */
1091  double ulichMappingFunction(double elevation) const;
1092 
1093  /*
1094  * Calculates the normalized effective zenith parameter, I,
1095  * which is used in calculating the refraction mapping function.
1096  * This calculates I<sup>2</sup>csc(elevation).
1097  * @param elevation The <em>in vacuo</em>
1098  * (uncorrected) elevation in radians
1099  * @param airTemp The ambient air temperature in Kelvin
1100  * @param the altitude (station height) of the antenna above
1101  * the array reference plane, meters.
1102  * @return the normalized effective zenith parameter (unitless).
1103  * @see Mangum (2001) equation 27
1104  */
1105  double normalizedEffectiveZenith(double airTemp,
1106  double elevation,
1107  double altitude) const;
1108 
1114  bool isOptical(double frequency) const;
1115 
1125  double a1Radio(double p0, double t0, double ppw) const;
1126 
1136  double a2Radio(double p0, double t0, double ppw) const;
1137 
1147  double a1Optical(double p0, double t0, double ppw, double w0) const;
1148 
1158  double a2Optical(double p0, double t0, double ppw, double w0) const;
1159 
1160  };
1161 
1162  }
1163 }
1164 #endif //CARMA_SERVICES_ATMOSPHERE_H
1165 
static bool isSafeElevation(double elevation)
double computeRefractionCorrection(double airTemp, double atmPressure, double relHumid, double elevation, double frequency, double altitude) const
Compute the refraction pointing correction, given the in vacuo elevation and weather parameters...
static const double DEFAULT_ATM_PRESSURE
Default atmospheric pressure, in millibars For when weather station measurement unavailable.
Definition: Atmosphere.h:59
carma::services::Temperature lastSafeDewPoint() const
static const double MIN_AIR_TEMP
Minimum believable air temperature, in Kelvin If weather station gives value below this...
Definition: Atmosphere.h:93
static const double MAX_RH
Maximum believable relative humidity, in percent If weather station gives value above this...
Definition: Atmosphere.h:123
static const double MIN_ATM_PRESSURE
Minimum believable atmospheric pressure, in millibars.
Definition: Atmosphere.h:71
carma::services::Temperature lastSafeAirTemperature() const
double waterVaporDensity(double airTemp, double relHumid) const
The water vapor density is derived from the relative humidity and saturated pressure, and is the amount of water in the atmosphere.
double computeHumidity(double airTemp, double dewTemp, dewPointMethodType method=CLAUSIUS_CLAPEYRON) const
The relative humidity is computed from the ambient and dew point temperatures.
static const double MAX_ATM_PRESSURE
Maximum believable atmospheric pressure, in millibars If weather station gives value above this...
Definition: Atmosphere.h:78
double computeZenithRefractivity(double airTemp, double atmPressure, double relHumid, double frequency) const
The refractivity, N_O, at zenith.
Representation of Pressure.
This class is used to calculate a variety of quantities related to the earth&#39;s atmosphere, such as refractivity, saturated pressure, and pathlength (refractivity integrated through the atmosphere).
Definition: Atmosphere.h:46
static const double MIN_RH
Minimum believable relative humidity, in percent If weather station gives value below this...
Definition: Atmosphere.h:116
static const double STANDARD_ATM_PRESSURE
US standard 1 atm of pressure.
Definition: Atmosphere.h:64
static const double MIN_WIND_SPEED
Minimum wind speed, in mph If weather station gives value below this, there is probably something wro...
Definition: Atmosphere.h:176
Representation of an angle, return values are always modulo 2PI radians.
static double safeElevation(double elevation)
static const double MIN_ELEVATION
The minimum elevation at which pathlength will be directly calculated, in radians.
Definition: Atmosphere.h:164
double computeHorizonPathlength(double airTemp, double atmPressure, double relHumid, double frequency) const
Calculate the maximum possible pathlength, toward the horizon.
static double safeRelativeHumidity(double relHumid)
This method is meant to check that a given relative humidity is within reasonable bounds for the CARM...
static const double DEFAULT_DEW_POINT
Default dew point, in Kelvin For when weather station measurement unavailable.
Definition: Atmosphere.h:135
bool isConsistentDewPoint(services::Temperature dewPoint, services::Temperature airTemp, double relHumid, dewPointMethodType method=CLAUSIUS_CLAPEYRON, double consistencyPercent=10.0)
Check that a given dewPoint value is consistent with its paired ambient air temperature and relative ...
The Velocity class can represent an velocity in any units.
Definition: Velocity.h:42
static const double DEFAULT_RH
Default relative humidity, in percent For when weather station measurement unavailable.
Definition: Atmosphere.h:108
double waterColumn(double airTemp, double relHumid) const
The water column is derived from the water vapor density and an assumed scaleheight for the wet atmos...
Atmosphere()
no-arg constructor
double waterPartialPressure(double airTemp, double relHumid) const
Compute the partial pressure of water given the ambient air temperature and relative humidity...
The Temperature class represents a temperature in any unit.
Definition: Temperature.h:39
static carma::services::Velocity safeWindSpeed(carma::services::Velocity windSpeed)
This method is meant to check that a given wind speed is within reasonable bounds for the CARMA site...
The Pressure class can represent any pressure in any units.
Definition: Pressure.h:38
static double safeDewPoint(double dewPoint)
This method is meant to check that a given dew point temperature is within reasonable bounds for the ...
carma/services/Temperature.h Representation of Temperature
static const double DEFAULT_AIR_TEMP
Default air temperature, in Kelvin For when weather station measurement unavailable.
Definition: Atmosphere.h:85
The Angle class can represent any angle in any units.
Definition: Angle.h:38
virtual ~Atmosphere()
destructor
static double safeAtmPressure(double atmPressure)
This method is meant to check that a given atmospheric pressure is within reasonable bounds for the C...
double computePathlength(double airTemp, double atmPressure, double relHumid, double elevation, double frequency, double altitude=0.0) const
static double safeAirTemperature(double airTemp)
This method is meant to check that a given air temperature is within reasonable bounds for the CARMA ...
static bool isSafeAtmPressure(double atmPressure)
static const double MAX_DEW_POINT
Maximum believable dew point, in Kelvin If weather station gives value above this, there is probably something wrong, so fall back to default.
Definition: Atmosphere.h:156
static const double MIN_DEW_POINT
Minimum believable dew point, in Kelvin If weather station gives value below this, there is probably something wrong, so fall back to default.
Definition: Atmosphere.h:143
static bool isSafeAirTemperature(double airTemp)
double computeSaturatedPressure(double airTemp) const
The surface saturated water vapor pressure is used in the calculation of the refractivity.
Representation of Velocity in any units.
static const double MAX_AIR_TEMP
Maximum believable air temperature, in Kelvin If weather station gives value above this...
Definition: Atmosphere.h:101
double lastSafeRelativeHumidity() const
static bool isSafeDewPoint(double dewPoint)
double ulichRefractionCorrection(double airTemp, double atmPressure, double relHumid, double elevation, double frequency) const
This is to test against the Ulich (1981) radio refraction formulation NOTE: RADIO ONLY...
static const double DEFAULT_WIND_SPEED
Default wind speed, in mph.
Definition: Atmosphere.h:169
carma::services::Pressure lastSafeAtmPressure() const
static const double MAX_WIND_SPEED
Maximum reasonable wind speed, in mph If weather station gives value above this, there is probably so...
Definition: Atmosphere.h:183
double computeDewPoint(double airTemp, double relHumid, dewPointMethodType method=CLAUSIUS_CLAPEYRON) const
The dewpoint temperature defines the temperature to which a parcel of air would need to be cooled at ...
static bool isSafeRelativeHumidity(double relHumid)
This class is based on the GNU units library.
Definition: Units.h:46