RefractionModel.h
1 #ifndef _ANITA_REFRACTION_MODEL_HH
2 #define _ANITA_REFRACTION_MODEL_HH
3 
4 #include <vector>
5 #include "AntarcticAtmosphere.h"
6 #include <map>
7 #include "Rtypes.h"
8 #include "TMutex.h"
9 
10 class Adu5Pat;
11 class AntarcticCoord;
12 class TGraph;
13 namespace Refraction
14 {
15 
18  class Model
19  {
20 
21  public:
22 
23  virtual ~Model() { ; }
24  /* Returns the elevation correction based on the source and payload position. This is the true elevation of the source
25  * with respect to the apparent (true - apparent).
26  * Because I'm using the positive theta going down convention, this should be positive (the real theta is lower than the apparent).
27  * */
28  virtual double getElevationCorrection(const Adu5Pat * pat, const AntarcticCoord * source, double * correction_at_source = 0, double dth = 0.01) const = 0;
29 
30 
31  };
32 
33 
34 
35  /* A model that only depends on elevation, payload height and estimated source height */
37  {
38  public:
39  virtual ~PositionIndependentModel() { ; }
40  /* Returns the elevation correction based on theta (positive down) , source height above MSL and payload height above MSL
41  *
42  * */
43  virtual double getElevationCorrection(double theta, double hSource, double hPayload, double * correction_at_source = 0) const = 0;
44 
45  // TGraph * makeGraph(double hSource, double hPayload, double minEl = 0);
46 
47  /* Implemented in terms of the other prototpe */
48  virtual double getElevationCorrection(const Adu5Pat * pat, const AntarcticCoord * source, double * correction_at_source = 0, double dth = 0.01) const ;
49  };
50 
51 
54  {
55 
56  public:
57  virtual ~PGFit() { ; }
58 
59  virtual double getElevationCorrection(double el, double hSource, double hPayload, double * correction_at_source = 0)const ;
60  };
61 
62 
63 
64 
67  {
68  public:
70  {
71  m = atm;
72  step_size = 10;
73  }
74 
75  struct Setup
76 
77  {
78  Setup() : start_alt(0) , end_alt(40e3), thrown_payload_angle(1), save_path(true), R_c(6399593.6258), surface_alt(0) {;}
79  double start_alt;
80  double end_alt;
81  double thrown_payload_angle;
82  bool save_path;
83  double R_c;
84  double surface_alt;
85  };
86 
87  struct Result
88  {
89  double apparent_source_angle;
90  double actual_source_angle;
91  double actual_payload_angle;
92  double actual_distance;
93  double surface_distance;
94  double ray_distance;
95  double ray_time;
96  bool reflected;
97  double reflection_angle;
98  double reflect_xy[2];
99  double x,y,r;
100  double last_dx;
101  double last_dy;
102  double full_dx;
103  double full_dy;
104 
105  };
106 
107  int raytrace(const Setup * setup, Result * result);
108 
109  double step_size;
110 
111  int nSteps() const { return (int) last_path_x.size(); }
112  const double * lastY() const { return &last_path_y[0]; }
113  const double * lastX() const { return &last_path_x[0]; }
114 
115  //this is the grammage from the end of the path to the beginning
116  const double * lastGrammage() const { return &last_path_X[0]; }
117  const double * lastS() const { return &last_path_s[0]; }
118  const double * lastT() const { return &last_path_t[0]; }
119  double lastMinAlt() const;
120 
121  TGraph * makeXYGraph(TGraph * g = 0) const;
122  TGraph * makeXTGraph(TGraph * g = 0) const;
123  TGraph * makeSTGraph(TGraph * g = 0) const;
124  TGraph * makeRTGraph(TGraph * g = 0) const;
125  TGraph * makePhiAltGraph(TGraph * g = 0) const;
126 
127  private:
129  std::vector<double> last_path_x;
130  std::vector<double> last_path_t;
131  std::vector<double> last_path_s;
132  std::vector<double> last_path_y;
133  std::vector<double> last_path_X;
134  double last_R_c;
135  };
136 
145  {
146  public:
147 
148  SphRay(const AntarcticAtmosphere::AtmosphericModel * a = &AntarcticAtmosphere::ITURefractivity() , double step_size = 10, bool cache_similar = true)
149  : atm(a), step(step_size), use_cache(cache_similar)
150  {
151  adjustLatitude(-90,0);
152  }
153  void adjustLatitude(double lat, double bearing);
154  void changeAtmosphere(const AntarcticAtmosphere::AtmosphericModel * a) { atm = a; }
155  virtual double getElevationCorrection(double el, double hSource, double hPayload, double * correction_at_source = 0) const ;
156  virtual ~SphRay() {; }
157 
158  private:
160  double step;
161  bool use_cache;
162  mutable TMutex cache_lock;
163  double R_c;
164  mutable std::map<UInt_t, std::pair<double,double> > cache;
165 
166  ClassDef(SphRay,1);
167  };
168 
169 
170 
171 
172 }
173 
174 #endif
Adu5Pat – The ADU5 Position and Attitude Data.
Definition: Adu5Pat.h:26