icemc
 All Classes Namespaces Files Functions Variables Friends Macros Pages
icemodel.hh
Go to the documentation of this file.
1 #ifndef ICEMODEL_HH_
2 #define ICEMODEL_HH_
3 
4 #include <cmath>
5 #include <iostream>
6 #include <fstream>
7 #include <vector>
8 
9 #include "earthmodel.hh"
10 
11 class Balloon;
12 class Position;
13 class Vector;
14 class EarthModel;
15 class Settings;
16 class TRandom3;
17 class Interaction;
18 class Ray;
19 
20 //Constants relating to all ice models
21 const double FIRNDEPTH=-150.; // depth of the firn, in meters: currently a constant over all ice
22 using std::ofstream;
23 using std::vector;
24 using std::string;
25 
26 
27 
28 //Variables for conversion between BEDMAP polar stereographic coordinates and lat/lon. Conversion equations from ftp://164.214.2.65/pub/gig/tm8358.2/TM8358_2.pdf
29 const double scale_factor=0.97276901289; //scale factor at pole corresponding to 71 deg S latitude of true scale (used in BEDMAP)
30 const double ellipsoid_inv_f = 298.257223563; //of Earth
32 const double eccentricity = sqrt((1/ellipsoid_inv_f)*(2-(1/ellipsoid_inv_f)));
33 const double bedmap_a_bar = pow(eccentricity,2)/2 + 5*pow(eccentricity,4)/24 + pow(eccentricity,6)/12 + 13*pow(eccentricity,8)/360;
34 const double bedmap_b_bar = 7*pow(eccentricity,4)/48 + 29*pow(eccentricity,6)/240 + 811*pow(eccentricity,8)/11520;
35 const double bedmap_c_bar = 7*pow(eccentricity,6)/120 + 81*pow(eccentricity,8)/1120;
36 const double bedmap_d_bar = 4279*pow(eccentricity,8)/161280;
37 const double bedmap_c_0 = (2*EarthModel::R_EARTH / sqrt(1-pow(eccentricity,2))) * pow(( (1-eccentricity) / (1+eccentricity) ),eccentricity/2);
38 
39 
40 
42 class IceModel : public EarthModel {
43 
44 
45 
46 public:
47 
48  //BEDMAP data
49  double ice_thickness_array[1200][1000]; //thickness of the ice
50  double ground_elevation[1068][869]; //elevation above geoid at which ice starts
51  double water_depth[1200][1000]; //depth of water under ice
52 
53 
54 double bedmap_R; //varies with latitude, defined here for 71 deg S latitude
55 double bedmap_nu;
56 
57 
58 //Parameters of the BEDMAP ice model. (See http://www.antarctica.ac.uk/aedc/bedmap/download/)
59 int nCols_ice; //number of columns in data, set by header file (should be 1200)
60 int nRows_ice; //number of rows in data, set by header file (should be 1000)
61 int cellSize; //in meters, set by header file (should be 5000) - same for both files
72 int NODATA;
73 
74 
75  void IceENtoLonLat(int e,
76  int n,
77 
78  double& lon,
79  double& lat);
80  void GroundENtoLonLat(int e,
81  int n,
82 
83  double& lon,
84  double& lat);
85 
86  const static int NBNPOSITIONS_MAX=26000;
87  double volume_inhorizon[NBNPOSITIONS_MAX]; // volume of ice within horizon for each balloon phi position
88  IceModel(int model=0,int earth_mode=0,int WEIGHTABSORPTION_SETTING=1);
89  double IceThickness(double lon,double lat);
90  double IceThickness(const Position& pos) ;
91  double Surface(double lon,double lat) ;
92  double Surface(const Position& pos) ;
93  double SurfaceAboveGeoid(double lon,double lat);
94  double SurfaceAboveGeoid(const Position& pos) ;
95  double WaterDepth(double lon,double lat);
96  double WaterDepth(const Position& pos);
97  Position PickInteractionLocation(int ibnposition,int inu);
99  void GetMAXHORIZON(Balloon *bn1); // get upper limit on the horizon wrt the balloon.
100  int RossIceShelf(const Position &position);
101  int IceOnWater(const Position &postition);
102  int RossExcept(const Position &position);
103  int RonneIceShelf(const Position &position);
104  int WestLand(const Position &pos);
105  int AcceptableRfexit(const Vector &nsurf_rfexit,const Position &rfexit,const Vector &n_exit2rx);
106  double GetBalloonPositionWeight(int ibnpos);
107  int OutsideAntarctica(const Position &pos);
108  int OutsideAntarctica(double lat);
109  int WhereDoesItEnterIce(const Position &posnu,
110  const Vector &nnu,
111  double stepsize,
112  Position &r_enterice);
113 
114  int WhereDoesItExitIce(int inu,const Position &posnu,
115  const Vector &nnu,
116  double stepsize,
117  Position &r_enterice);
118  int WhereDoesItExitIceForward(const Position &posnu,
119  const Vector &nnu,
120  double stepsize,
121  Position &r_enterice);
122  void CreateHorizons(Settings *settings1,Balloon *bn1,double theta_bn,double phi_bn,double altitude_bn,ofstream &foutput);
123  Vector GetSurfaceNormal(const Position &r_out); //overloaded from EarthModel to include procedures for new ice models.
124  double GetN(double depth);
125  double GetN(const Position &pos);
126  double EffectiveAttenuationLength(Settings *settings1,const Position &pos, const int &whichray);
127 
128  void IceLonLattoEN(double lon,
129  double lat,
130 
131  int& e_coord,
132  int& n_coord);
133 
134  void FillArraysforTree(double lon_ground[1068][869],double lat_ground[1068][869],double lon_ice[1200][1000],double lat_ice[1200][1000],double lon_water[1200][1000],double lat_water[1200][1000]);
135  int PickUnbiased(int inu,Interaction *interaction1,IceModel *antarctica);
136 
137 
138 protected:
141 
142 
143  //Information on horizons - what ice the balloon can see at each position along its path.
144 
145 
146  double volume_inhorizon_average; // average volume of ice seen by balloon
147  vector<int> ilon_inhorizon[NBNPOSITIONS_MAX]; // indices in lon and lat for bins in horizon for NPHI balloon positions along 80 deg latitude line.
149  vector<int> easting_inhorizon[NBNPOSITIONS_MAX]; //indicies in easting and northing for bins in horizon for NPHI balloon positions along 80 deg latitude line.
151  double maxvol_inhorizon[NBNPOSITIONS_MAX]; // maximum volume of ice for a bin
152 
153  //BEDMAP utility methods
154  double Area(double latitude);
155 
156 void ENtoLonLat(int e_coord,
157  int n_coord,
158  double xLowerLeft,
159  double yLowerLeft,
160 
161  double& lon,
162  double& lat) ;
163 
164 
165 
166  void WaterENtoLonLat(int e,
167  int n,
168 
169  double& lon,
170  double& lat);
171  void LonLattoEN(double lon,
172  double lat,
173  double xLowerLeft,
174  double yLowerLeft,
175 
176  int& e_coord,
177  int& n_coord);
178 
179  void GroundLonLattoEN(double lon,
180  double lat,
181 
182  int& e_coord,
183  int& n_coord) ;
184  void WaterLonLattoEN(double lon,
185  double lat,
186 
187  int& e_coord,
188  int& n_coord) ;
189 
190  //BEDMAP data input methods
191  void ReadIceThickness();
192  void ReadGroundBed();
193  void ReadWaterDepth();
194 
195 private:
196  TRandom Rand3;
197 
198  const static int N_sheetup=2810;
199  double d_sheetup[N_sheetup], l_sheetup[N_sheetup];
200  const static int N_shelfup=420;
201  double d_shelfup[N_shelfup], l_shelfup[N_shelfup];
202  const static int N_westlandup=420;
203  double d_westlandup[N_westlandup],l_westlandup[N_westlandup];
204 
205  const static int N_sheetdown=2810;
206  double d_sheetdown[N_sheetup], l_sheetdown[N_sheetdown];
207  const static int N_shelfdown=420;
208  double d_shelfdown[N_shelfdown], l_shelfdown[N_shelfdown];
209  const static int N_westlanddown=420;
210  double d_westlanddown[N_westlanddown],l_westlanddown[N_westlanddown];
211 
212 
213 }; //class IceModel
214 // input files for Crust 2.0
215 const string crust20_in="data/outcr"; // Crust 2.0 data
216 const string crust20_out="altitudes.txt"; // output file for plotting
217 
218 #endif