25 using namespace AtmosphereNS;
42 float ai[12][5] = { { -129.86987635, -13.912578027, 1.137905219, -4.5501979957e-4, 0.01128292},
43 { -140.02703037, -32.154019677, 1.3324218584, -3.4759783013e-4, 0.01128292},
44 { -140.79368856, -36.408818366, 1.4042651261, -2.4583883619e-4, 0.01128292},
45 { -133.89496569, -47.089899137, 0.83278306486, -2.1054367331e-4, 0.01128292},
46 { -152.40981237, -12.095554799, 0.85136995339, -4.5928490669e-5, 0.01128292},
47 { -187.01662033, -25.280960312, 0.89432403304, 3.47276315e-5 , 0.01128292},
48 { -136.34855518, -20.914318979, 0.87280369409, 3.732759787e-5 , 0.01128292},
49 { -139.77721439, -25.948986634, 0.70618984827, -9.6699826826e-6, 0.01128292},
50 { -158.54644384, -95.110327312, 0.76408408672, -1.5130518952e-4, 0.01128292},
51 { -150.1396913, -58.140415154, 0.87315735073, -3.6221952628e-4, 0.01128292},
52 { -194.83705256, -68.148895317, 0.91697530761, -5.9280159541e-4, 0.01128292},
53 { -152.92783842, -37.51920314, 1.5800882678, -5.9051575509e-4, 0.01128292}
56 float bi[12][5] = { {1170.0778448, 1310.6961298, 1490.6966654, 503.61356785, 1.},
57 {1177.9948918, 1226.5793800, 1544.3942757, 529.86754375, 1.},
58 {1177.4425334, 1189.0214700, 1556.0070888, 539.33390781, 1.},
59 {1174.1385323, 1215.7355043, 1425.6918596, 503.93169671, 1.},
60 {1190.3622315, 1265.7764387, 1437.9375049, 524.79662686, 1.},
61 {1227.6177212, 1178.8761669, 1445.4602411, 535.28753109, 1.},
62 {1182.9054740, 1213.2533581, 1413.9801198, 547.58686206, 1.},
63 {1184.5463072, 1205.4324091, 1366.0574680, 542.40761127, 1.},
64 {1200.3725926, 1165.8522743, 1373.2445748, 521.58648708, 1.},
65 {1189.9866918, 1193.1675932, 1422.7442647, 490.3837468, 1.},
66 {1231.0108397, 1164.4301252, 1412.7462127, 460.92737873, 1.},
67 {1190.2311741, 1189.4576063, 1575.7147090, 484.1030213, 1.}
70 float ci[12][5] = { {971950.03798, 682326.92144, 615751.05849, 795110.76, 1.e9},
71 {990841.49847, 746882.89502, 608546.43122, 787929.8796, 1.e9},
72 {984028.35984, 766300.21844, 604631.06014, 782862.57672, 1.e9},
73 {967164.95864, 768155.10252, 621852.25389, 785601.62044, 1.e9},
74 {985619.00774, 681017.97599, 617989.22267, 776008.70875, 1.e9},
75 {1012299.9934, 732521.03651, 614783.70338, 771077.62332, 1.e9},
76 {947431.21788, 710893.29507, 619412.05748, 769605.79586, 1.e9},
77 {953640.44565, 723050.32076, 629158.20120, 772372.2386, 1.e9},
78 {986103.78389, 881190.80912, 628689.50007, 781005.59304, 1.e9},
79 {990579.96621, 800597.35355, 623333.46715, 793328.53093, 1.e9},
80 {1042817.5709, 832823.86466, 624149.14260, 805671.77828, 1.e9},
81 {997989.25368, 766606.85869, 599559.45014, 802421.45312, 1.e9}
84 float hi[12][5] = { {0., 1070000., 1460000., 3660000., 10000000. },
85 {0., 980000., 1430000., 3550000., 10000000. },
86 {0., 900000., 1450000., 3500000., 10000000. },
87 {0., 990000., 1210000., 3800000., 10000000. },
88 {0., 950000., 1500000., 3750000., 10000000. },
89 {0., 750000., 1450000., 3700000., 10000000. },
90 {0., 890000., 1400000., 3700000., 10000000. },
91 {0., 880000., 1280000., 3830000., 10000000. },
92 {0., 690000., 1100000., 3820000., 10000000. },
93 {0., 900000., 1200000., 3800000., 10000000. },
94 {0., 700000., 1200000., 3810000., 10000000. },
95 {0., 870000., 1450000., 3480000., 10000000. }
99 float ai_gdas[12][5] = {
100 { -136.72575606000001 , -31.63664304400000 , 1.88902340350000 , 0.00039201867984 , 0.01128000000000 },
101 { -137.25655861999999 , -31.79397889600000 , 2.06162275470000 , 0.00041243062289 , 0.01128000000000 },
102 { -132.36885161999999 , -29.07704662900000 , 2.09050150900000 , 0.00043534337925 , 0.01128000000000 },
103 { -129.99304119999999 , -21.84724843800000 , 1.52111364840000 , 0.00039559055121 , 0.01128000000000 },
104 { -125.11468467000000 , -14.59123562100000 , 0.93641128677000 , 0.00032475590985 , 0.01128000000000 },
105 { -126.17178851000000 , -7.72898528110000 , 0.81676828638000 , 0.00031947676891 , 0.01128000000000 },
106 { -126.17216789000000 , -8.61825375140000 , 0.74177836911000 , 0.00029350702097 , 0.01128000000000 },
107 { -123.27936204000000 , -10.05149304100000 , 0.84187346153000 , 0.00032422546759 , 0.01128000000000 },
108 { -126.94494665000001 , -9.55565369810000 , 0.74939405052000 , 0.00029823116961 , 0.01128000000000 },
109 { -133.13151124999999 , -13.97320926500000 , 0.83782634310000 , 0.00031117421760 , 0.01128000000000 },
110 { -134.72208165000001 , -18.17238290800000 , 1.11598068450000 , 0.00035217025515 , 0.01128000000000 },
111 { -135.40825208999999 , -22.83040902600000 , 1.42234534930000 , 0.00037512921774 , 0.01128000000000 }
114 float bi_gdas[12][5] = {
115 { 1174.82983340000010 , 1204.82334530000003 , 1637.77035830000000 , 735.96095022999998 , 1.00000000000000 },
116 { 1176.09075650000000 , 1197.89511040000002 , 1646.46169549999991 , 755.18728656999997 , 1.00000000000000 },
117 { 1172.62277840000002 , 1215.39646769999990 , 1617.00992820000010 , 769.51991638000004 , 1.00000000000000 },
118 { 1172.32918780000000 , 1250.29227740000010 , 1542.62484130000007 , 713.10082850000003 , 1.00000000000000 },
119 { 1169.95113020000008 , 1277.67684880000002 , 1493.53037810000001 , 617.96607470000004 , 1.00000000000000 },
120 { 1171.09162760000004 , 1295.35164340000006 , 1455.30093439999996 , 595.11713507000002 , 1.00000000000000 },
121 { 1172.73406879999993 , 1258.91800790000002 , 1450.05371409999998 , 583.07727714999999 , 1.00000000000000 },
122 { 1169.76303600000006 , 1251.02198079999994 , 1436.64993720000007 , 627.42169844000000 , 1.00000000000000 },
123 { 1174.86764530000005 , 1251.55885289999992 , 1440.82575489999999 , 606.31473165000000 , 1.00000000000000 },
124 { 1176.98334730000010 , 1244.23453100000006 , 1464.01208550000001 , 622.11207419000004 , 1.00000000000000 },
125 { 1175.77379719999999 , 1238.95385039999996 , 1505.16143659999989 , 670.64752105000002 , 1.00000000000000 },
126 { 1174.64497099999994 , 1227.27536830000008 , 1585.71305619999998 , 691.23389637000002 , 1.00000000000000 }
129 float ci_gdas[12][5] = {
130 { 982815.95247999997810 , 754029.87759000004735 , 594416.83822000003420 , 733974.36971999995876 , 1000000000.00000000000000 },
131 { 981369.61250000004657 , 756657.65382999996655 , 592969.89671000000089 , 731345.88332000002265 , 1000000000.00000000000000 },
132 { 972654.05630000005476 , 742769.21710000000894 , 595342.19851000001654 , 728921.61953999998514 , 1000000000.00000000000000 },
133 { 962396.55209999997169 , 711452.06672999996226 , 603480.61835000000428 , 735460.83741000003647 , 1000000000.00000000000000 },
134 { 947742.88769000000320 , 685089.57509000005666 , 609640.01931999996305 , 747555.95525999995880 , 1000000000.00000000000000 },
135 { 940102.98841999995057 , 661697.57542999996804 , 612702.06319999997504 , 749976.26832000003196 , 1000000000.00000000000000 },
136 { 934649.58886000001803 , 672975.82513000001200 , 614888.52457999996841 , 752631.28535999997985 , 1000000000.00000000000000 },
137 { 931569.97624999994878 , 678861.75135999999475 , 617363.34490999998525 , 746739.16140999994241 , 1000000000.00000000000000 },
138 { 936953.91919000004418 , 678906.60516000003554 , 618132.60560999996960 , 750154.67709000001196 , 1000000000.00000000000000 },
139 { 954151.40399999998044 , 692708.89815999998245 , 615439.43935999996029 , 747969.08132999995723 , 1000000000.00000000000000 },
140 { 964877.07765999995172 , 706199.57501999998931 , 610242.24563999997918 , 741412.74548000004143 , 1000000000.00000000000000 },
141 { 973884.44360999995843 , 723759.74682000000030 , 600308.13983000000007 , 738390.20524999999907 , 1000000000.00000000000000 }
144 float hi_gdas[12][5] = {
145 { 0.00000000000000 , 940000.00000000000000 , 1530000.00000000000000 , 3160000.00000000000000 , 10000000.00000000000000 },
146 { 0.00000000000000 , 919999.99999999988358 , 1540000.00000000000000 , 3100000.00000000000000 , 10000000.00000000000000 },
147 { 0.00000000000000 , 960000.00000000000000 , 1520000.00000000000000 , 3070000.00000000000000 , 10000000.00000000000000 },
148 { 0.00000000000000 , 1000000.00000000000000 , 1490000.00000000000000 , 3260000.00000000000000 , 10000000.00000000000000 },
149 { 0.00000000000000 , 1019999.99999999988358 , 1510000.00000000000000 , 3590000.00000000000000 , 10000000.00000000000000 },
150 { 0.00000000000000 , 1010000.00000000000000 , 1600000.00000000000000 , 3670000.00000000046566 , 10000000.00000000000000 },
151 { 0.00000000000000 , 960000.00000000000000 , 1650000.00000000000000 , 3740000.00000000000000 , 10000000.00000000000000 },
152 { 0.00000000000000 , 960000.00000000000000 , 1590000.00000000000000 , 3629999.99999999953434 , 10000000.00000000000000 },
153 { 0.00000000000000 , 950000.00000000000000 , 1620000.00000000000000 , 3720000.00000000046566 , 10000000.00000000000000 },
154 { 0.00000000000000 , 950000.00000000000000 , 1550000.00000000000000 , 3650000.00000000000000 , 10000000.00000000000000 },
155 { 0.00000000000000 , 960000.00000000000000 , 1530000.00000000000000 , 3460000.00000000000000 , 10000000.00000000000000 },
156 { 0.00000000000000 , 960000.00000000000000 , 1560000.00000000000000 , 3329999.99999999953434 , 10000000.00000000000000 }
160 for (
int imonth = 0; imonth < 12; imonth++) {
161 for (
int i = 0; i < 5; i++) {
163 amonth[imonth].
ai[i] = ai_gdas[imonth][i];
164 amonth[imonth].
bi[i] = bi_gdas[imonth][i];
165 amonth[imonth].
ci[i] = ci_gdas[imonth][i];
166 amonth[imonth].
hi[i] = hi_gdas[imonth][i];
168 amonth[imonth].
ai[i] = ai[imonth][i];
169 amonth[imonth].
bi[i] = bi[imonth][i];
170 amonth[imonth].
ci[i] = ci[imonth][i];
171 amonth[imonth].
hi[i] = hi[imonth][i];
176 }
else if (
atmType ==
"seasonal") {
178 float ai[5][5] = { {0, 0, 0, 0, 0},
185 float bi[5][5] = { {0, 0, 0, 0, 0},
192 float ci[5][5] = { {0, 0, 0, 0, 0},
199 float hi[5][5] = { {0, 0, 0, 0, 0},
206 float ai_gdas[5][5] = { {0, 0, 0, 0, 0},
213 float bi_gdas[5][5] = { {0, 0, 0, 0, 0},
220 float ci_gdas[5][5] = { {0, 0, 0, 0, 0},
227 float hi_gdas[5][5] = { {0, 0, 0, 0, 0},
234 for (
int iseason = 0; iseason < 5; iseason++) {
235 for (
int i = 0; i < 5; i++) {
237 aseason[iseason].
ai[i] = ai_gdas[iseason][i];
238 aseason[iseason].
bi[i] = bi_gdas[iseason][i];
239 aseason[iseason].
ci[i] = ci_gdas[iseason][i];
240 aseason[iseason].
hi[i] = hi_gdas[iseason][i];
262 for (
int i = 0; i < 5; i++) {
272 for (
int imonth = 0; imonth < 12; imonth++) {
274 for (
int j = 0; j < 5; j++) {
287 printf(
"ERROR: I did not recognize the atmosphere %d \n",
acurrent.
atmflag);
301 for (
int i = 0; i < 5; i++) {
311 for (
int imonth = 0; imonth < 12; imonth++) {
313 for (
int j = 0; j < 5; j++) {
326 printf(
"ERROR: I did not recognize the atmosphere %d \n",
acurrent.
atmflag);
337 if (imonth < 1 || imonth > 12) {
338 printf(
"Wrong atmosphere \n");
341 for (
int i = 0; i < 5; i++) {
347 }
else if (
atmType ==
"seasonal") {
348 if (imonth < 1 || imonth > 5) {
349 printf(
"Wrong atmosphere \n");
352 for (
int i = 0; i < 5; i++) {
366 for (
int i = 0; i < 5; i++) {
377 fprintf(fp,
"---------------------\n");
379 fprintf(fp,
"---------------------\n");
381 fprintf(fp,
" ai bi ci hi \n");
382 for (
int i = 0; i < 5; i++)
396 if (vdepth < vdepth_min || vdepth > vdepth_max) {
399 else if (vdepth > vdepth_max) {
401 h = (vdepth_max - vdepth) / density;
407 for (
int k = 0; k < 4; k++) {
418 float vdepth = sdepth * cos(theta);
430 if (h >
h_max || h < h_min) {
439 for (
int k = 0; k < 4; k++) {
462 for (
int i = 1; i < 13; i++) {
479 const float X0 = 37.;
489 for (
int i = 1; i < 13; i++) {
505 if (h >
h_max || h < h_min) {
508 else if (h > h0) density = 0.;
512 for (
int k = 0; k < 4; k++) {
528 if (SlantDepth < 0.)
return 0.;
533 for (
int i = 1; i < 13; i++) {
535 mean +=
Get_DX_DL_i(r, psi, SlantDepth, theta, hground, UseDL, IsDiffusive);
541 else return Get_DX_DL_i(r, psi, SlantDepth, theta, hground, UseDL, IsDiffusive);
554 float dh = r * cos(psi) * sin(theta);
555 float h0 = hground + dh;
566 double rmax[3] = {(hmax - hground) / cos(theta), 0., 0.};
569 double rdet[3] = {r * tan(theta)* cos(psi), r * sin(psi), -r * cos(psi)};
571 double rdetmax[3] = { rmax[0] - rdet[0], rmax[1] - rdet[1], rmax[2] - rdet[2] };
574 double l =
sqrt(
pow(rdetmax[0], 2) +
pow(rdetmax[1], 2) +
pow(rdetmax[2], 2));
575 double calpha = rdetmax[0] / l;
577 if (calpha < 0.)
return -100.;
580 if (UseDL)
return l / 1000.;
583 double ctheta = calpha * cos(theta) + sin(theta) * cos(psi) *
sqrt(1. - calpha * calpha);
600 float costheta = cos(theta);
601 float sintheta = sin(theta);
602 float cosazi = cos(azi);
603 float sinazi = sin(azi);
606 double xr = x * cosazi + y * sinazi;
610 float dT = -(xr * sintheta + zr * costheta) /
c_cmperns;
621 if (SlantDepth < 0.)
return 0.;
626 for (
int i = 1; i < 13; i++) {
628 mean +=
GetTimePF_i(r, psi, SlantDepth, theta, hground);
634 else return GetTimePF_i(r, psi, SlantDepth, theta, hground);
655 float dh = r * cos(psi) * sin(theta);
656 float h1 = hground + dh;
657 float t0 = (h2 - h1) / cos(theta) /
c_cmperns;
667 if (SlantDepth < 0.)
return 0.;
672 for (
int i = 1; i < 13; i++) {
674 mean +=
GetTimeCF_i(r, psi, SlantDepth, theta, hground);
680 else return GetTimeCF_i(r, psi, SlantDepth, theta, hground);
697 double d = (h1 - hground) / cos(theta) - r * tan(theta) * cos(psi) ;
float GetTimePF_i(float r, float psi, float SlantDepth, float theta, float hground)
float VertDepthToHeight(float vdepth)
float GetTimeCF(float r, float psi, float SlantDepth, float theta, float hground)
float Get_DX_DL(float r, float psi, float SlantDepth, float theta, float hground, bool UseDL, bool IsDiffusive)
float GetDensity_i(float h)
float GetTimeCF_i(float r, float psi, float SlantDepth, float theta, float hground)
double pow(const double x, const unsigned int i)
void printCurrentAtmosphere(FILE *fp)
float HeightToVertDepth(float h)
float GetTimeCF_h(float r, float psi, float h1, float theta, float hground)
float GetDensity(float h)
void ClearCurrentAtmosphere()
float HeightToSlantDepth(float h, float theta)
Atmosphere(const bool UseGDAS=false, const std::string atmtype="monthly")
float Get_DX_DL_i(float r, float psi, float SlantDepth, float theta, float hground, bool UseDL, bool IsDiffusive)
float GetTimePF(float r, float psi, float SlantDepth, float theta, float hground)
float SlantDepthToHeight(float sdepth, float theta)
float GetDensityAboveGround(float hground, float theta, float nRad)
float GetTimePF_delay(float x, float y, float z, float theta, float azi)
float GetTimePF_h(float r, float psi, float hStart, float theta, float hground)
float GetDensityAboveGround_i(float hground, float theta, float nRad)
void SetCurrentAtmosphere(AtmModel theAtm)