11 #include "position.hh" 12 #include "roughness.hh" 13 #include "Constants.h" 18 #include "Primaries.h" 21 #include "earthmodel.hh" 22 #include "icemodel.hh" 27 #include "healpix_base.h" 31 Roughness::Roughness(
Settings *settings1){
33 rough_dir_str = std::getenv(
"ICEMC_SRC_DIR");
36 H = Healpix_Base(order, RING);
39 roughscale_str =
"0p10";
40 roughnsims_str =
"1000000";
43 roughmaterial_str=
"firn";
47 roughmaterial_str=
"ice";
53 void Roughness::SetRoughScale(
double a){
54 std::ostringstream strs;
56 strs.setf( std::ios::fixed, std:: ios::floatfield );
58 roughscale_str = strs.str();
59 roughscale_str[1] =
'p';
61 if(roughscale_str==
"0p00")
67 std::string Roughness::incAngle_asString(
double T0){
69 sprintf(s_f,
"%.1f", T0);
70 std::string s = std::string() + s_f;
71 s.replace(s.find(
"."), 1,
"p");
78 static std::map<std::string, std::map<int, std::pair<double,double> > >lower_cache_polperp;
80 static std::map<std::string, std::map<int, std::pair<double,double> > >lower_cache_polparl;
83 void Roughness::InterpolatePowerValue(
double &tcoeff_perp_polperp,
double &tcoeff_parl_polperp,
double &tcoeff_perp_polparl,
double &tcoeff_parl_polparl,
double T0,
double T,
double A){
92 int pixel, thispixel_low;
95 double Tparl_polperp, Tperp_polperp;
96 double Tparl_polparl, Tperp_polparl;
100 std::string base_rough_file_str=
"";
102 std::string full_rough_file_lower;
103 std::string full_rough_file_upper;
105 std::vector<double> X, Yperp_polparl, Yparl_polparl, Yperp_polperp, Yparl_polperp;
107 tk::spline spl_parl_polparl, spl_perp_polparl, spl_parl_polperp, spl_perp_polperp;
112 for (
double i=0; i<90; i+=.1){
113 base_rough_file_str =
"/data/roughness_tables/"+roughmaterial_str+
"/"+roughscale_str+
"/combined_inc"+incAngle_asString((
double)i)+
"_nsims"+roughnsims_str+
"_hp"+Form(
"%i",H.Nside())+
"_beckmann.hpx";
114 full_rough_file_lower = rough_dir_str + base_rough_file_str;
116 T0_i = asin(NINDEX * sin(i*PI/180.))*180./PI;
119 ptg = pointing(T0_i*PI/180., A*PI/180.);
120 thispixel_low = H.ang2pix( ptg );
123 if (!lower_cache_polperp.count(full_rough_file_lower)){
125 ifs.open (full_rough_file_lower, std::ifstream::in);
131 std::map<int, std::pair<double,double> > this_lower_polperp;
132 std::map<int, std::pair<double,double> > this_lower_polparl;
133 std::getline(ifs, header);
135 ifs >> pixel >> pphi >> ptheta >> Tparl_polparl >> Tperp_polparl >> Tparl_polperp >> Tperp_polperp;
137 if (Tparl_polparl < 0) Tparl_polparl = 0;
138 if (Tperp_polparl < 0) Tperp_polparl = 0;
139 if (Tparl_polperp < 0) Tparl_polperp = 0;
140 if (Tperp_polperp < 0) Tperp_polperp = 0;
142 this_lower_polparl[pixel]=std::pair<double,double>(Tparl_polparl,Tperp_polparl);
143 this_lower_polperp[pixel]=std::pair<double,double>(Tparl_polperp,Tperp_polperp);
145 lower_cache_polparl[full_rough_file_lower] = this_lower_polparl;
146 lower_cache_polperp[full_rough_file_lower] = this_lower_polperp;
153 Yparl_polparl.push_back( lower_cache_polparl[full_rough_file_lower][thispixel_low].first );
154 Yperp_polparl.push_back( lower_cache_polparl[full_rough_file_lower][thispixel_low].second );
155 Yparl_polperp.push_back( lower_cache_polperp[full_rough_file_lower][thispixel_low].first );
156 Yperp_polperp.push_back( lower_cache_polperp[full_rough_file_lower][thispixel_low].second );
161 Yparl_polparl.push_back( 0. );
162 Yperp_polparl.push_back( 0. );
163 Yparl_polperp.push_back( 0. );
164 Yperp_polperp.push_back( 0. );
169 spl_parl_polparl.set_points(X,Yparl_polparl);
170 spl_perp_polparl.set_points(X,Yperp_polparl);
171 spl_parl_polperp.set_points(X,Yparl_polperp);
172 spl_perp_polperp.set_points(X,Yperp_polperp);
174 tcoeff_perp_polperp = spl_perp_polperp(T);
175 tcoeff_parl_polperp = spl_parl_polperp(T);
176 tcoeff_perp_polparl = spl_perp_polparl(T);
177 tcoeff_parl_polparl = spl_parl_polparl(T);
Reads in and stores input settings for the run.