ReFRACtor
ils_gaussian.h
Go to the documentation of this file.
1 #ifndef ILS_GAUSSIAN_H
2 #define ILS_GAUSSIAN_H
3 #include "ils_function.h"
4 
5 namespace FullPhysics {
6 /****************************************************************/
9 class IlsGaussian : public IlsFunction {
10 public:
11 //-----------------------------------------------------------------------
13 //-----------------------------------------------------------------------
14  IlsGaussian(double a, const std::string& Band_name,
15  const std::string& Hdf_band_name)
16  : band_name_(Band_name), hdf_band_name_(Hdf_band_name)
17  { gamma = a / sqrt(2); }
18  virtual ~IlsGaussian() {}
19 
20  virtual void ils
21  (const AutoDerivative<double>& wn_center,
22  const blitz::Array<double, 1>& wn, ArrayAd<double, 1>& res) const;
23  virtual void print(std::ostream& os) const {os << "IlsGaussian";}
24  virtual std::string band_name() const { return band_name_; }
25  virtual std::string hdf_band_name() const {return hdf_band_name_;}
26 private:
27  double gamma;
28  std::string band_name_, hdf_band_name_;
29 };
30 }
31 
32 //-----------------------------------------------------------------------
33 // For reference, here are the other functions that use to be in the
34 // old Fortran code. We can easily implement and test these, but there
35 // doesn't seem to be much point until we actually need them:
36 //
37 /*
38 void ils_coefs(double wn_center, Array<double,1> wn,
39  const Array<double,1>& para, int ils_function,
40  Array<double,1>& ils_out)
41 {
42  int wn_length = wn.rows();
43  int num_para = para.rows();
44  Range allwn(0,wn_length-1);
45 
46  // constants
47 
48  const double sqrt_log_2 = 0.83255461115769769;
49  const double sqrt_PI = 1.7724538509055159;
50 
51  // local variables
52 
53  Array<double,1> thres(3);
54  double a;
55  double c;
56  double d;
57  double Peak;
58  double s;
59  double Cbkg;
60  double Cs;
61  double t;
62 
63  Array<double,1> x(wn_length);
64  double b;
65  Array<double,1> L1(wn_length);
66  Array<double,1> L2(wn_length);
67  double gamma;
68  int i;
69 
70  // init
71 
72  wn.reindexSelf(TinyVector<int,1>(0)); // reindex local version only
73 
74  // generate the ILS per the selected model and parameters
75 
76  switch (ils_function) {
77  case KEY_ILS_LORENTZ:
78  x(allwn) = wn(allwn) - wn_center;
79  if (num_para > 1)
80  throw Exception("Error ! Number of ILS Parameters > 1");
81  a = para(0);
82  ils_out(allwn) = a / (x(allwn)*x(allwn) + a*a);
83  break;
84 
85  case KEY_ILS_SUM_LORENTZ:
86  // if only one parameter is given, then Lorentz6 will be used
87 
88  x(allwn) = wn(allwn) - wn_center;
89  if (num_para == 1) {
90  a = para(0);
91  b = 1.0;
92  }
93  else if (num_para == 2) {
94  a = para(0);
95  b = para(1);
96  }
97  else throw Exception("Error ! Number of ILS Parameters > 2");
98 
99  L1(allwn) = (a/PI) / (x(allwn)*x(allwn) + a*a);
100  L2(allwn) = pow((6.0 * a / (x(allwn)*x(allwn) + 6.0*a*a)), 6.0) /
101  pow((PI / a), 6.0);
102  ils_out(allwn) = b * L2(allwn) + (1.0 - b) * L1(allwn);
103  break;
104 
105  case KEY_ILS_GAUSS:
106  x(allwn) = wn(allwn) - wn_center;
107  if (num_para > 1)
108  throw Exception("Error ! Number of ILS Parameters > 1");
109  a = para(0);
110 
111  gamma = a/(sqrt_log_2); // convert HWHM into e-length
112 
113  ils_out(allwn) = exp(-(x(allwn)/gamma)*(x(allwn)/gamma)) / (gamma*sqrt_PI);
114  break;
115 
116  case KEY_ILS_SIGMOID:
117  x(allwn) = wn(allwn) - wn_center;
118  Cbkg = 0.0;
119  Cs = 1.0;
120  if (num_para > 3)
121  throw Exception("Error ! Number of ILS Parameters > 3");
122  a = para(0);
123  b = para(1);
124  s = para(2);
125 
126  L1(allwn) = -a/2.0+b;
127  L2(allwn) = a/2.0+b;
128  ils_out(allwn) = Cs/(1.0+exp(-(x(allwn)-L1(allwn))/s)) -
129  Cs/(1.0+exp(-(x(allwn)-L2(allwn))/s))+Cbkg;
130  break;
131 
132  case KEY_ILS_SIGMOID_LORENTZ:
133  x(allwn) = wn(allwn) - wn_center;
134  Cbkg = 0.0;
135  Cs = 1.0;
136  if (num_para > 5)
137  throw Exception("Error ! Number of ILS Parameters > 5");
138  a = para(0); // FWHM Sigmoid
139  s = para(1); // slope
140  c = para(2); // FWHM Lorentz
141  d = para(3); // Lorentz Peak
142  t = para(4); // threshold (for GOSAT specs, .03, .006, .006)
143 
144  L1(0) = -a/2.0;
145  L2(0) = a/2.0;
146 
147  Peak = Cs/(1.0+exp(L1(0)/s)) - Cs/(1.0+exp(L2(0)/s));
148 
149  ils_out(allwn) = Cs/(1.0+exp(-(x(allwn)-L1(0))/s)) -
150  Cs/(1.0+exp(-(x(allwn)-L2(0))/s));
151 
152  for (i=0;i < wn_length;i++)
153  if (ils_out(i) < t*Peak)
154  ils_out(i) = (d*c*c/4.0) / (x(i)*x(i)+(c/2.0)*(c/2.0));
155  break;
156 
157  default:
158  throw Exception("Unknown ILS function selected");
159  }
160 }
161 */
162 
163 #endif
virtual std::string band_name() const
Descriptive name of the band.
Definition: ils_gaussian.h:24
IlsGaussian(double a, const std::string &Band_name, const std::string &Hdf_band_name)
Constructor.
Definition: ils_gaussian.h:14
This class models an Instrument Line Shape (ILS) function.
Definition: ils_function.h:17
virtual void print(std::ostream &os) const
Definition: ils_gaussian.h:23
This is an ILS function that is a Gaussian.
Definition: ils_gaussian.h:9
virtual std::string hdf_band_name() const
In general, the name used in HDF files for a particular band is similar but not identical to the more...
Definition: ils_gaussian.h:25
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
virtual void ils(const AutoDerivative< double > &wn_center, const blitz::Array< double, 1 > &wn, ArrayAd< double, 1 > &res) const
Return response function.
Definition: ils_gaussian.cc:6

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:08