31 const double SolarZenithalAngle,
32 const double SolarAzimutalAngle,
33 const double ViewingZenithalAngle,
34 const double ViewingAzimutalAngle,
35 const unsigned int Month,
36 const unsigned int Day,
37 const double AtmosphericPressure,
38 const double WaterVaporAmount,
39 const double OzoneAmount,
41 const double AerosolOptical,
44 double& AtmosphericReflectance,
45 double& AtmosphericSphericalAlbedo,
46 double& TotalGaseousTransmission,
47 double& DownwardTransmittance,
48 double& UpwardTransmittance,
49 double& UpwardDiffuseTransmittance,
50 double& UpwardDirectTransmittance,
51 double& UpwardDiffuseTransmittanceForRayleigh,
52 double& UpwardDiffuseTransmittanceForAerosol
56 otb_6s_doublereal asol(static_cast<otb_6s_doublereal>(SolarZenithalAngle));
57 otb_6s_doublereal phi0(static_cast<otb_6s_doublereal>(SolarAzimutalAngle));
58 otb_6s_doublereal avis(static_cast<otb_6s_doublereal>(ViewingZenithalAngle));
59 otb_6s_doublereal phiv(static_cast<otb_6s_doublereal>(ViewingAzimutalAngle));
60 otb_6s_integer month(static_cast<otb_6s_integer>(Month));
61 otb_6s_integer jday(static_cast<otb_6s_integer>(Day));
62 otb_6s_doublereal pressure(static_cast<otb_6s_doublereal>(AtmosphericPressure));
63 otb_6s_doublereal uw(static_cast<otb_6s_doublereal>(WaterVaporAmount));
64 otb_6s_doublereal uo3(static_cast<otb_6s_doublereal>(OzoneAmount));
66 otb_6s_integer iaer(static_cast<otb_6s_integer>(AerosolModel));
67 otb_6s_doublereal taer55(static_cast<otb_6s_doublereal>(AerosolOptical));
70 AtmosphericReflectance = 0.;
71 AtmosphericSphericalAlbedo = 0.;
72 TotalGaseousTransmission = 0.;
73 DownwardTransmittance = 0.;
74 UpwardTransmittance = 0.;
75 UpwardDiffuseTransmittance = 0.;
76 UpwardDirectTransmittance = 0.;
77 UpwardDiffuseTransmittanceForRayleigh = 0.;
78 UpwardDiffuseTransmittanceForAerosol = 0.;
80 otb_6s_doublereal wlinf(0.), wlsup(0.);
81 otb_6s_doublereal otb_ratm__(0.), sast(0.), tgasm(0.), sdtott(0.), sutott(0.);
82 otb_6s_doublereal tdif_up(0.), tdir_up(0.), tdif_up_ray(0.), tdif_up_aer(0.);
85 const float SIXSStepOfWavelengthSpectralBandValues = .0025;
88 WavelengthSpectralBand
94 const otb_6s_integer S_6S_SIZE = 1501;
99 static_cast<otb_6s_integer
>((wlinf - (float) .25) / SIXSStepOfWavelengthSpectralBandValues + (float) 1.5);
100 otb_6s_integer cpt = iinf - 1;
101 otb_6s_doublereal * s(
NULL);
102 s =
new otb_6s_doublereal[S_6S_SIZE];
103 memset(s, 0, S_6S_SIZE *
sizeof(otb_6s_doublereal));
106 for (
unsigned int i = 0; i < FilterFunctionValues6S.size() && cpt < S_6S_SIZE; ++i)
108 s[cpt] = FilterFunctionValues6S[i];
114 otb_6s_ssssss_otb_main_function(&asol, &phi0, &avis, &phiv, &month, &jday,
115 &pressure, &uw, &uo3,
133 catch (std::bad_alloc& err)
135 itkGenericExceptionMacro(<<
"Exception bad_alloc in SIXSTraits class: " << (
char*) err.what());
139 itkGenericExceptionMacro(<<
"Unknown exception in SIXSTraits class (catch(...)");
143 AtmosphericReflectance =
static_cast<double>(otb_ratm__);
144 AtmosphericSphericalAlbedo =
static_cast<double>(sast);
145 TotalGaseousTransmission =
static_cast<double>(tgasm);
146 DownwardTransmittance =
static_cast<double>(sdtott);
147 UpwardTransmittance =
static_cast<double>(sutott);
148 UpwardDiffuseTransmittance =
static_cast<double>(tdif_up);
149 UpwardDirectTransmittance =
static_cast<double>(tdir_up);
150 UpwardDiffuseTransmittanceForRayleigh =
static_cast<double>(tdif_up_ray);
151 UpwardDiffuseTransmittanceForAerosol =
static_cast<double>(tdif_up_aer);
156 const double SIXSStepOfWavelengthSpectralBandValues,
160 const double epsilon(.000001);
163 const double L_userStep =
static_cast<double>(WavelengthSpectralBand->
GetUserStep());
167 const double invStep =
static_cast<double>(1. / L_userStep);
170 if (FilterFunctionValues.size() <= 1)
172 itkGenericExceptionMacro(<<
"The FilterFunctionValues vector must have more than 1 values !");
174 if (! (L_min + static_cast<double>(FilterFunctionValues.size() - 1) * L_userStep < (L_max + epsilon) ) )
176 itkGenericExceptionMacro(
177 <<
"The following condition: " << L_min <<
"+(" << FilterFunctionValues.size() <<
"-1)*" << L_userStep <<
178 " < (" << L_max <<
"+" << epsilon <<
") is not respected !" <<
"val1 " << L_min +
static_cast<double>(FilterFunctionValues.size() - 1) * L_userStep <<
" val2 " << L_max - epsilon);
182 if (vcl_abs(L_userStep - SIXSStepOfWavelengthSpectralBandValues) > epsilon)
187 value = SIXSStepOfWavelengthSpectralBandValues;
188 while (L_min + value <= L_max)
193 while (j * L_userStep < value)
199 if (j >= FilterFunctionValues.size())
201 itkGenericExceptionMacro(
202 <<
"Index " << j <<
" out of bound for FilterFunctionValues vector (size: " << FilterFunctionValues.size() <<
203 ")." <<
" and value is " << value <<
" and SIXSStepOfWavelengthSpectralBandValues is " << SIXSStepOfWavelengthSpectralBandValues<<
" and i is " << i);
207 valueTemp =
static_cast<double>(FilterFunctionValues[j - 1])
208 + ((static_cast<double>(FilterFunctionValues[j]) -
209 static_cast<double>(FilterFunctionValues[j - 1])) * invStep)
210 * (value - L_userStep * (j - 1));
211 values.push_back(static_cast<WavelengthSpectralBandType>(valueTemp));
214 value += SIXSStepOfWavelengthSpectralBandValues;
217 if (L_min + (i - 1) * SIXSStepOfWavelengthSpectralBandValues != L_max)
224 WavelengthSpectralBand->
SetMaxSpectralValue(static_cast<WavelengthSpectralBandType>(L_min + i *
225 SIXSStepOfWavelengthSpectralBandValues));
237 const double diffuseTransmittanceForAerosolScattering,
238 const double radiusInKilometers,
239 const double altitude,
240 const double cosineOfViewingAngle,
241 double& rayleighEstimation,
242 double& aerosolEstimation,
243 double& globalEstimation)
245 otb_6s_doublereal difr(static_cast<otb_6s_doublereal>(diffuseTransmittanceForRayleighScattering));
246 otb_6s_doublereal difa(static_cast<otb_6s_doublereal>(diffuseTransmittanceForAerosolScattering));
247 otb_6s_doublereal rad(static_cast<otb_6s_doublereal>(radiusInKilometers));
248 otb_6s_doublereal palt(static_cast<otb_6s_doublereal>(altitude));
249 otb_6s_doublereal xmuv(static_cast<otb_6s_doublereal>(cosineOfViewingAngle));
250 otb_6s_doublereal fra(0.), fae(0.), fr(0.);
251 otb_6s_enviro_(&difr, &difa, &rad, &palt, &xmuv, &fra, &fae, &fr);
252 rayleighEstimation =
static_cast<double>(fra);
253 aerosolEstimation =
static_cast<double>(fae);
254 globalEstimation =
static_cast<double>(fr);