MTP  1.0
 All Classes Files Functions Variables Macros Pages
retriever.cc
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <iostream>
4 #include <math.h>
5 #include "rcf_set.h"
6 #include "retriever.h"
7 
8 using namespace std;
9 
11  float ACAltKm)
12 {
13  float Temperature;
15  std::vector<float> PressureAlts;
16  RC_Set_4Retrieval BestWtdRCSet =
17  _Rcf_Set.getBestWeightedRCSet(ScanBTs, ACAltKm, 0.0);
18  for (int L = 0; L < NUM_RETR_LVLS; L++)
19  {
20  Temperature = BestWtdRCSet.FL_RCs.TAvgRl[L];
21  PressureAlts.push_back(BestWtdRCSet.FL_RCs.PAltRl[L]);
22  for (int j = 0; j < NUM_BRT_TEMPS; j++)
23  {
24  float BtDiff = (ScanBTs[j] - BestWtdRCSet.FL_RCs.MBTAvg[j]);
25  Temperature = Temperature + (BestWtdRCSet.FL_RCs.RC[L][j] * BtDiff);
26  }
27  ATP.Temperatures.push_back(Temperature);
28  }
29 
30  ATP.Altitudes = Pressure2Km(PressureAlts);
31 
32  // Any Temperature with Altitude <= 0 is not valid (nor is altitude)
33  for (int L = 0; L < NUM_RETR_LVLS; L++)
34  {
35  if (ATP.Altitudes[L] <= 0)
36  {
37  ATP.Altitudes[L] = NAN;
38  ATP.Temperatures[L] = NAN;
39  }
40  }
41  return ATP;
42 }
43 
44 /*
45  * MJ's rather elaborate way of converting from pressure altitude to km.
46  */
47 std::vector<float> Retriever::Pressure2Km(std::vector<float> Pressures)
48 {
49  std::vector<float> Altitudes;
50  float Altitude;
51 
52  for (std::vector<float>::iterator Pit = Pressures.begin();
53  Pit != Pressures.end(); ++Pit)
54  {
55  if (*Pit > 226.3206) // < 11km
56  {
57  Altitude = 44.3307692307692 *
58  (1.0 - pow((*Pit/1013.25),0.190263235151657));
59  } else if (*Pit > 54.7488) // < 20km
60  {
61  Altitude = 11.0 - (6.34161998393947*log(*Pit/226.3206));
62  } else if (*Pit > 8.680185) // < 32km
63  {
64  Altitude = 20.0 - (216.65 *
65  (1.0 - pow((*Pit/54.7488),-0.0292712699464088)));
66  } else if (*Pit > 1.109063) // < 47km
67  {
68  Altitude = 32.0 - (81.6607142857143 *
69  (1.0 - pow((*Pit/8.680185),-0.0819595474499447)));
70  } else if (*Pit > 0.6693885) // < 51km
71  {
72  Altitude = 47.0 - (7.92226839904554 * log(*Pit/1.109063));
73  } else if (*Pit > 0.03956419) // <71 km
74  {
75  Altitude = 51.0 + (96.6607142857143 *
76  (1.0 - pow((*Pit/0.6693885),(0.0819595474499447))));
77  } else if (*Pit > 1.45742511874549E-03) //<90 km
78  {
79  Altitude = 71.0 + (107.325 *
80  (1.0 - pow((*Pit/0.03956419),(5.85425338928176E-02))));
81  } else if (*Pit > 5.8654139565495E-04) // <95 km
82  {
83  Altitude = 84.852 - (5.47214624555127 * log(*Pit/0.003733834));
84  } else if (*Pit > 2.40645796828482E-04) // <100 km
85  {
86  Altitude = 95.0 - (140.597 *
87  (1.0 - pow((*Pit/5.8654139565495E-04),
88  (-3.92234986852218E-02))));
89  } else if (*Pit > 1.03251578598705E-04) // <105 km
90  {
91  Altitude = 100.0 - (71.20438 *
92  (1.0 - pow((*Pit/2.40645796828482E-04),
93  (-8.02032717123127E-02))));
94  } else if (*Pit > 4.81695302325482E-05) // <110 km
95  {
96  Altitude = 105.0 - (33.46154 *
97  (1.0 - pow((*Pit/1.03251578598705E-04),
98  (-0.18265269904593))));
99  } else
100  {
101  if (*Pit <= 0) *Pit=0.000001;
102  Altitude = 110.0 - (20.0 *
103  (1.0 - pow((*Pit/4.81695302325482E-05),
104  (-0.351255203356906))));
105  }
106 
107  Altitudes.push_back(Altitude);
108  }
109 
110  return Altitudes;
111 
112 }
float MBTAvg[NUM_BRT_TEMPS]
Model Brightness Temperature Averages.
Definition: rcf_structs.h:101
float TAvgRl[NUM_RETR_LVLS]
Average T at retrieval levels.
Definition: rcf_structs.h:103
#define NUM_BRT_TEMPS
Definition: mtp.h:18
This class encapsulates the whole set of RCFs for a project and provides a method for determining whi...
float RC[NUM_RETR_LVLS][NUM_BRT_TEMPS]
Retrieval Coefficients.
Definition: rcf_structs.h:106
AtmosphericTemperatureProfile Retrieve(std::vector< float >, float)
Definition: retriever.cc:10
RC_Set_1FL FL_RCs
Definition: rcf_structs.h:116
#define NUM_RETR_LVLS
number of retrieval levels per flight level in RCFs
Definition: mtp.h:17
std::vector< float > Temperatures
Definition: retriever.h:25
This class encapsulates the retrieval method which performs the inverse calculation of the radiative ...
std::vector< float > Altitudes
Definition: retriever.h:26
float PAltRl[NUM_RETR_LVLS]
Pressure at retrieval levels.
Definition: rcf_structs.h:102