source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/common/atmosphere/src/LinsleyAtmosphere.cc @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 8.1 KB
Line 
1// $Id: LinsleyAtmosphere.cc 2695 2006-05-27 19:09:42Z moreggia $
2// S. Moreggia created 27 October 2003
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: LinsleyAtmosphere                                                           *
8 *  Package: atmosphere                                                      *
9 *  Coordinator: S. Moreggia                                                 *
10 *                                                                           *
11 *****************************************************************************/
12
13//_____________________________________________________________________________
14//
15// LinsleyAtmosphere
16//
17// <extensive class description>
18//
19//   Config file parameters
20//   ======================
21//
22//   <parameter name>: <parameter description>
23//   -Valid options: <available options>
24//
25
26#include "LinsleyAtmosphere.hh"
27#include "LinsleyAtmosphereData.hh"
28#include <TH1F.h>
29#include <TROOT.h>
30#include <math.h>
31#include <TSpline.h>
32
33Atmosphere* LinsleyAtmosphere::fMe = NULL;
34
35using namespace sou;
36
37ClassImp(LinsleyAtmosphere)
38
39//___________________________________________________________________________________
40LinsleyAtmosphere::LinsleyAtmosphere(string type) : Atmosphere(), fData(0) {
41    //
42    // ctor
43    //
44    fType = type;
45    Msg(EsafMsg::Info) << "*** LinsleyAtmosphere ***"<< MsgDispatch;
46    Build();
47}
48
49//___________________________________________________________________________________
50LinsleyAtmosphere::~LinsleyAtmosphere() {
51    //
52    // dtor
53    //
54    SafeDelete(fData);
55}
56
57//___________________________________________________________________________________
58void LinsleyAtmosphere::CreateInstance() {
59    //
60    // Create the single atmosphere instance as being a LinsleyAtmosphere object
61    //
62    if(!Atmosphere::fChild) Atmosphere::fChild = new LinsleyAtmosphere("linsley");
63    else Atmosphere::fChild->Msg(EsafMsg::Warning) << "Trying to create two atmospheres !!"<< MsgDispatch;
64}
65
66//___________________________________________________________________________________
67void LinsleyAtmosphere::Build() {
68    //
69    // Build AtmosphereData object
70    //
71    if(!fData) fData = new LinsleyAtmosphereData();
72    if(!fData) Msg(EsafMsg::Panic) << "Pb of memory allocation in LinsleyAtmosphere" << MsgDispatch ; 
73   
74    if(fData->GetName() == "Uniform") fTOA = fData->Bottom(1); // tow layers only
75   
76    // interpolators initialization
77    /*
78    const Double_t* data = 0;
79    data =  fData->GetTemperatureTable();
80    TArrayD t_arr(100,data);
81    fTempInterpol = new TSpline3("fTempInterpol",0,100*km,t_arr.GetArray(),100);   
82   
83    data =  fData->GetAir_DensityTable();
84    TArrayD rho_arr(100,data);
85    fDensInterpol = new TSpline3("fDensInterpol",0,100*km,rho_arr.GetArray(),100);   
86   
87    data =  fData->GetPressureTable();
88    TArrayD press_arr(100,data);
89    fPressInterpol = new TSpline3("fPressInterpol",0,100*km,press_arr.GetArray(),100);   
90    */
91}
92
93//___________________________________________________________________________________
94Double_t LinsleyAtmosphere::Pressure(Double_t h) const {
95    //
96    // Pressure at a given altitude
97    //
98    if(h > fTOA)  return 0.;
99    return 0;//fPressInterpol->Eval(h);
100}
101
102//___________________________________________________________________________________
103Double_t LinsleyAtmosphere::Temperature(Double_t h) const {
104    //
105    // Temperature at a given altitude
106    //
107    if(h > fTOA)  return 0.;
108    return 0;//fTempInterpol->Eval(h);
109}
110
111//___________________________________________________________________________________
112Double_t LinsleyAtmosphere::AbsoluteHumidity(Double_t h) const {
113    //
114    // Absolute humidity at a given altitude (water vapor density)
115    //
116    return 0;
117}
118
119//___________________________________________________________________________________
120Double_t LinsleyAtmosphere::Air_Density(Double_t h) const {
121    //
122    // Air density at a given altitude
123    //
124    if(h > fTOA)  return 0.;
125       
126    return fData->DensityParametrization(h);   
127}
128
129//___________________________________________________________________________________
130Double_t LinsleyAtmosphere::O_Density(Double_t h) const {
131    //
132    // Oxigen density at a given altitude
133    //
134     if(h > fTOA )
135        return 0.;
136
137    // linear interpolation between table values
138    string val = "Odens";
139    string mod = "expon";
140    return 0;//Interpolate(val,mod,h);
141}
142
143//___________________________________________________________________________________
144Double_t LinsleyAtmosphere::O2_Density(Double_t h) const {
145    //
146    // Di-oxigen density at a given altitude
147    //
148   if(h > fTOA)
149        return 0.;
150
151   // linear interpolation between table values
152   string val = "O2dens";
153   string mod = "expon";
154   return 0;//Interpolate(val,mod,h);
155}
156
157//___________________________________________________________________________________
158Double_t LinsleyAtmosphere::O3_Density(Double_t h) const {
159    //
160    // Ozone density at a given altitude
161    //
162    if(h > fTOA)
163        return 0.;
164
165    // linear interpolation between table values
166    string val = "O3dens";
167    string mod = "linear";
168    return 0;//Interpolate(val,mod,h);
169}
170
171//___________________________________________________________________________________
172Double_t LinsleyAtmosphere::N2_Density(Double_t h) const {
173    //
174    // Di-nitrogen density at a given altitude
175    //
176    if(h > fTOA)
177        return 0.;
178
179    // linear interpolation between table values
180    string val = "N2dens";
181    string mod = "expon";
182    return 0;//Interpolate(val,mod,h);
183}
184
185//___________________________________________________________________________________
186Double_t LinsleyAtmosphere::Aerosols_Density(string& type,Double_t h) const {
187    //
188    // Aerosols density for a given type at a given altitude
189    //
190    return 0;
191}
192
193//___________________________________________________________________________________
194long double LinsleyAtmosphere::Index(Double_t h, Double_t wl) const {
195    //
196    // Index as fonction of altitude ONLY (formula drawn from Corsika)
197    //
198    return 1. + Index_Minus1(h,wl);
199}
200
201//___________________________________________________________________________________
202Double_t LinsleyAtmosphere::Index_Minus1(Double_t h, Double_t wl) const {
203    //
204    // returns (n-1)
205    //
206    return 0.000283*Air_Density(h)/Air_Density(0.);
207}
208
209//___________________________________________________________________________________
210double LinsleyAtmosphere::Interpolate(string& val,string& mod,double h) const {
211    //
212    // Calculate interpolation (from tables of parameter)
213    //
214    const double* data = 0;
215    if(val == "Odens")        data = fData->GetO_DensityTable();
216    else if(val == "O2dens")  data = fData->GetO2_DensityTable();
217    else if(val == "N2dens")  data = fData->GetN2_DensityTable();
218    else  Msg(EsafMsg::Panic) << "Wrong val argument in LinsleyAtmosphere::Interpolate"  << MsgDispatch ;
219   
220    if(h<0) return data[0];
221    int nb=100;
222    double step=1*km;
223    if(h > (nb-1)*step) return data[nb-1];
224 
225    double val1, val2;
226    double h1;
227    int i = 0;
228    i = Int_t(floor(h/step));
229    h1 = i * step;
230    val1 = data[i];
231    val2 = data[i+1];
232       
233    if(mod == "linear" || val1 == 0 || val2 == 0)  return (val2 - val1)*(h - h1)/step + val1;
234    else if(mod == "expon")                        return val1 * exp(-(h - h1) * log(val1/val2)/step);
235    else   Msg(EsafMsg::Panic) << "Wrong mod argument in LinsleyAtmosphere::Interpolate"  << MsgDispatch ;
236    return 0;
237}
238
239
240//_____________________________________________________________________________
241Double_t LinsleyAtmosphere::GetLatitude() const {
242    //
243    // used to identify the model
244    //
245   
246    return fData->GetLatitude();
247}
248
249//_____________________________________________________________________________
250Double_t LinsleyAtmosphere::GetLongitude() const {
251    //
252    // dummy
253    //
254   
255    return fData->GetLongitude();
256}
257
258//_____________________________________________________________________________
259Double_t LinsleyAtmosphere::GetDate() const {
260    //
261    // dummy
262    //
263   
264    return fData->GetDate();
265}
266
267
268
269
Note: See TracBrowser for help on using the repository browser.