AerosolConcentration.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #include "AerosolConcentration.h"
  2. #include "AtmosModel.h"
  3. #include "common.h"
  4. /**********************************************************************c
  5. c aerosol model (concentration) c
  6. c ---------------------------- c
  7. c c
  8. c c
  9. c v if you have an estimate of the meteorological c
  10. c parameter: the visibility v, enter directly the c
  11. c value of v in km (the aerosol optical depth will c
  12. c be computed from a standard aerosol profile) c
  13. c c
  14. c v=0, taer55 if you have an estimate of aerosol optical depth , c
  15. c enter v=0 for the visibility and enter the aerosol c
  16. c optical depth at 550 c
  17. c c
  18. c v=-1 warning: if iaer=0, enter v=-1 c
  19. c c
  20. c**********************************************************************/
  21. void AerosolConcentration::parse(const long int _iaer, const AtmosModel& atms)
  22. {
  23. iaer = _iaer;
  24. taer55 = 0.f;
  25. cin >> v;
  26. cin.ignore(numeric_limits<int>::max(),'\n'); /* ignore comments */
  27. if(v == 0)
  28. {
  29. cin >> taer55;
  30. cin.ignore(numeric_limits<int>::max(),'\n'); /* ignore comments */
  31. v = (float)(exp(-log(taer55/2.7628f)/0.79902f));
  32. }
  33. else if(v > 0) oda550(v, atms);
  34. }
  35. void AerosolConcentration::oda550(const float v, const AtmosModel& atms)
  36. {
  37. /* aerosol optical depth at wl=550nm */
  38. /* vertical repartition of aerosol density for v=23km */
  39. /* ( in nbr of part/cm3 ) */
  40. static const float an23[34] = {
  41. 2.828e+03,1.244e+03,5.371e+02,2.256e+02,1.192e+02,
  42. 8.987e+01,6.337e+01,5.890e+01,6.069e+01,5.818e+01,
  43. 5.675e+01,5.317e+01,5.585e+01,5.156e+01,5.048e+01,
  44. 4.744e+01,4.511e+01,4.458e+01,4.314e+01,3.634e+01,
  45. 2.667e+01,1.933e+01,1.455e+01,1.113e+01,8.826e+00,
  46. 7.429e+00,2.238e+00,5.890e-01,1.550e-01,4.082e-02,
  47. 1.078e-02,5.550e-05,1.969e-08,0.000e+00
  48. };
  49. /* vertical repartition of aerosol density for v=5km */
  50. /* ( in nbr of part/cm3 ) */
  51. static const float an5[34] = {
  52. 1.378e+04,5.030e+03,1.844e+03,6.731e+02,2.453e+02,
  53. 8.987e+01,6.337e+01,5.890e+01,6.069e+01,5.818e+01,
  54. 5.675e+01,5.317e+01,5.585e+01,5.156e+01,5.048e+01,
  55. 4.744e+01,4.511e+01,4.458e+01,4.314e+01,3.634e+01,
  56. 2.667e+01,1.933e+01,1.455e+01,1.113e+01,8.826e+00,
  57. 7.429e+00,2.238e+00,5.890e-01,1.550e-01,4.082e-02,
  58. 1.078e-02,5.550e-05,1.969e-08,0.000e+00
  59. };
  60. taer55 = 0;
  61. if(fabs(v) <= 0) return;
  62. if(iaer == 0) return;
  63. for(int k = 0; k < 32; k++)
  64. {
  65. float dz = atms.z[k+1] - atms.z[k];
  66. float az = (115.f / 18.f) * (an5[k] - an23[k]);
  67. float az1 = (115.f / 18.f) * (an5[k+1] - an23[k+1]);
  68. float bz = (5.f * an5[k] / 18.f) - (23.f * an23[k] / 18.f);
  69. float bz1 = (5.f * an5[k+1] / 18.f) - (23.f * an23[k+1] / 18.f);
  70. float bnz = az / v - bz;
  71. float bnz1 = az1 / v - bz1;
  72. float ev = (float)(dz * exp((log(bnz) + log(bnz1)) / 2));
  73. taer55 += ev * sigma * 1.0e-03f;
  74. }
  75. }
  76. void AerosolConcentration::print()
  77. {
  78. /* --- aerosol model (concentration) ---- */
  79. Output::Begin();
  80. Output::End();
  81. if(iaer == 0) return;
  82. Output::Begin();
  83. Output::Repeat(10, ' ');
  84. Output::Print(" optical condition identity :");
  85. Output::End();
  86. if(fabs(v) <= xacc)
  87. {
  88. Output::Begin();
  89. Output::Repeat(15, ' ');
  90. Output::Print(" user def. opt. thick. at 550nm :");
  91. ostringstream s;
  92. s.setf(ios::fixed, ios::floatfield);
  93. s << setprecision(4);
  94. s << setw(11) << taer55 << ends;
  95. Output::Print(s.str());
  96. Output::End();
  97. }
  98. else
  99. {
  100. Output::Begin();
  101. Output::Repeat(15, ' ');
  102. Output::Print(" visibility :");
  103. ostringstream s1;
  104. s1.setf(ios::fixed, ios::floatfield);
  105. s1 << setprecision(2);
  106. s1 << setw(8) << v << ends;
  107. Output::Print(s1.str());
  108. Output::Print(" km opt. thick. 550nm :");
  109. ostringstream s2;
  110. s2.setf(ios::fixed, ios::floatfield);
  111. s2 << setprecision(4);
  112. s2 << setw(9) << taer55 << ends;
  113. Output::Print(s2.str());
  114. Output::End();
  115. }
  116. Output::Begin();
  117. Output::End();
  118. }
  119. AerosolConcentration AerosolConcentration::Parse(const long int iaer, const AtmosModel& atms)
  120. {
  121. AerosolConcentration aerocon;
  122. aerocon.parse(iaer, atms);
  123. return aerocon;
  124. }