Skip to content
Snippets Groups Projects
Commit a80a5264 authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

Correction sur 6S et correction atmospherique

parent 5b783777
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@ PURPOSE. See the above copyright notices for more information.
namespace otb
{
/*********************** FilterFunctionValues **************************/
const FilterFunctionValues::WavelenghtSpectralBandType FilterFunctionValues::m_StepOfWavelenghtSpectralBandValues = 2.5;
FilterFunctionValues
::FilterFunctionValues()
{
......@@ -30,57 +29,6 @@ namespace otb
m_FilterFunctionValues.empty();
}
/** Check the correpondance between the vector value size and the interval number between min and max.*/
/** return true if the vector step is not at 2.5 and the vector has been changed. */
/*
bool
FilterFunctionValues
:: SetParameters(const WavelenghtSpectralBandType L_min, const WavelenghtSpectralBandType L_max, const WavelenghtSpectralBandType step, const ValuesVectorType & vect)
{
m_MinSpectralValue = L_min;
m_UserStep = step;
bool hasChangedVector = false;
if(m_UserStep != m_StepOfWavelenghtSpectralBandValues)
{
ValuesVectorType values(1, vect[0]);
unsigned int i = 1;
unsigned int j = 1;
double invStep = 1/m_UserStep;
// Stop the interpolation at the max spectral value.
while(m_MinSpectralValue+i*m_StepOfWavelenghtSpectralBandValues <= L_max )
{
// Search the User interval that surround the StepOfWavelenghtSpectralBandValues current value.
while(j*m_UserStep <= i*m_StepOfWavelenghtSpectralBandValues)
{
j++;
}
double valueTemp;
valueTemp = static_cast<double>(vect[j-1])
+ ((static_cast<double>(vect[j])-static_cast<double>(vect[j-1]))*invStep)
*(i*static_cast<double>(m_StepOfWavelenghtSpectralBandValues)-static_cast<double>(m_UserStep)*(j-1));
values.push_back(static_cast<WavelenghtSpectralBandType>(valueTemp));
i++;
}
if (m_MinSpectralValue+(i-1)*m_StepOfWavelenghtSpectralBandValues != L_max)
{
values.push_back(0);
}
m_FilterFunctionValues = values;
m_MaxSpectralValue = m_MinSpectralValue + i*m_StepOfWavelenghtSpectralBandValues;
}
else
{
m_MaxSpectralValue = L_max;
m_FilterFunctionValues = vect;
hasChangedVector = true;
}
return hasChangedVector;
}
*/
/**PrintSelf method */
void
FilterFunctionValues
......@@ -95,7 +43,11 @@ namespace otb
{
os << indent << m_FilterFunctionValues[i] <<std::endl;
}
os << indent << "6S Step between each wavelenght spectral band values: " << m_StepOfWavelenghtSpectralBandValues << std::endl;
os << indent << "Filter function Vector Values 6S: " << std::endl;
for (unsigned int i=0; i<m_FilterFunctionValues6S.size(); i++)
{
os << indent << m_FilterFunctionValues6S[i] <<std::endl;
}
}
......
......@@ -83,9 +83,6 @@ namespace otb
/** Get the 6S imposed step : 2.5nm. */
itkGetConstMacro(StepOfWavelenghtSpectralBandValues, WavelenghtSpectralBandType);
/** Set paramaters and check value step. If it's not 0.0025µm (cf. 6S), interpolate needed values.*/
// bool SetParameters(const WavelenghtSpectralBandType L_min, const WavelenghtSpectralBandType L_max, const WavelenghtSpectralBandType step, const ValuesVectorType & vect);
protected:
/** Constructor */
......
......@@ -38,7 +38,7 @@ SIXSTraits::ComputeAtmosphericParameters(
const double OzoneAmount, /** The Ozone amount (Stratospheric ozone layer content) */
const AerosolModelType & AerosolModel, /** The Aerosol model */
const double AerosolOptical, /** The Aerosol optical (radiative impact of aerosol for the reference wavelenght 550-nm) */
WavelenghtSpectralType& WavelenghtSpectralBand, /** Wavelenght for the spectral band definition */
WavelenghtSpectralType* WavelenghtSpectralBand, /** Wavelenght for the spectral band definition */
/** Note : The Max wavelenght spectral band value must be updated ! */
double & AtmosphericReflectance, /** Atmospheric reflectance */
double & AtmosphericSphericalAlbedo, /** atmospheric spherical albedo */
......@@ -83,14 +83,14 @@ SIXSTraits::ComputeAtmosphericParameters(
// 6S official tab size Wavelenght Spectral
const unsigned int S_6S_SIZE=1501;
// Generate WavelenghtSpectralBand in 6S compatible buffer s[1501]
otb_6s_integer iinf = static_cast<otb_6s_integer>((WavelenghtSpectralBand.GetMinSpectralValue() - (double).25) / SIXSStepOfWavelenghtSpectralBandValues + (double)1.5);
otb_6s_integer isup = static_cast<otb_6s_integer>((WavelenghtSpectralBand.GetMaxSpectralValue() - (double).25) / SIXSStepOfWavelenghtSpectralBandValues + (double)1.5);
otb_6s_integer iinf = static_cast<otb_6s_integer>((WavelenghtSpectralBand->GetMinSpectralValue() - (double).25) / SIXSStepOfWavelenghtSpectralBandValues + (double)1.5);
otb_6s_integer isup = static_cast<otb_6s_integer>((WavelenghtSpectralBand->GetMaxSpectralValue() - (double).25) / SIXSStepOfWavelenghtSpectralBandValues + (double)1.5);
otb_6s_integer cpt=iinf-1;
otb_6s_real * s(NULL);
s = new otb_6s_real[S_6S_SIZE];
memset( s, 0, S_6S_SIZE*sizeof(otb_6s_real) );
const ValuesVectorType & FilterFunctionValues6S = WavelenghtSpectralBand.GetFilterFunctionValues6S();
const ValuesVectorType & FilterFunctionValues6S = WavelenghtSpectralBand->GetFilterFunctionValues6S();
// Set the values of FilterFunctionValues6S in s between [iinf-1;isup]
for(unsigned int i=0 ; cpt<isup ; i++)
{
......@@ -135,13 +135,13 @@ SIXSTraits::ComputeAtmosphericParameters(
void
SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S(
const double SIXSStepOfWavelenghtSpectralBandValues,
WavelenghtSpectralType& WavelenghtSpectralBand
WavelenghtSpectralType* WavelenghtSpectralBand
)
{
const double L_min = static_cast<double>(WavelenghtSpectralBand.GetMinSpectralValue());
const double L_max = static_cast<double>(WavelenghtSpectralBand.GetMaxSpectralValue());
const double L_userStep = static_cast<double>(WavelenghtSpectralBand.GetUserStep());
const ValuesVectorType & FilterFunctionValues = WavelenghtSpectralBand.GetFilterFunctionValues();
const double L_min = static_cast<double>(WavelenghtSpectralBand->GetMinSpectralValue());
const double L_max = static_cast<double>(WavelenghtSpectralBand->GetMaxSpectralValue());
const double L_userStep = static_cast<double>(WavelenghtSpectralBand->GetUserStep());
const ValuesVectorType & FilterFunctionValues = WavelenghtSpectralBand->GetFilterFunctionValues();
unsigned int i = 1;
unsigned int j = 1;
const double invStep = static_cast<double>(1./L_userStep);
......@@ -169,6 +169,7 @@ SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S(
values.push_back(static_cast<WavelenghtSpectralBandType>(valueTemp));
i++;
value = i*SIXSStepOfWavelenghtSpectralBandValues;
}
if (L_min+(i-1)*SIXSStepOfWavelenghtSpectralBandValues != L_max)
......@@ -176,15 +177,15 @@ SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S(
values.push_back(0);
}
// Store this values
WavelenghtSpectralBand.SetFilterFunctionValues6S(values);
WavelenghtSpectralBand->SetFilterFunctionValues6S(values);
// Store the new Max MaxSpectralValue
WavelenghtSpectralBand.SetMaxSpectralValue(static_cast<WavelenghtSpectralBandType>(L_min + i*SIXSStepOfWavelenghtSpectralBandValues));
WavelenghtSpectralBand->SetMaxSpectralValue(static_cast<WavelenghtSpectralBandType>(L_min + i*SIXSStepOfWavelenghtSpectralBandValues));
}
else
{
// Init with copy of FilterFunctionValues input vector values
WavelenghtSpectralBand.SetFilterFunctionValues6S(FilterFunctionValues);
WavelenghtSpectralBand->SetFilterFunctionValues6S(FilterFunctionValues);
}
}
......
......@@ -56,7 +56,7 @@ public:
const double OzoneAmount, /** The Ozone amount (Stratospheric ozone layer content) */
const AerosolModelType & AerosolModel, /** The Aerosol model */
const double AerosolOptical, /** The Aerosol optical (radiative impact of aerosol for the reference wavelenght 550-nm) */
WavelenghtSpectralType& WavelenghtSpectralBand, /** Wavelenght for the spectral band definition */
WavelenghtSpectralType* WavelenghtSpectralBand, /** Wavelenght for the spectral band definition */
/** Note : The Max wavelenght spectral band value must be updated ! */
double & AtmosphericReflectance, /** Atmospheric reflectance */
double & AtmosphericSphericalAlbedo, /** atmospheric spherical albedo */
......@@ -64,10 +64,13 @@ public:
double & DownwardTransmittance, /** downward transmittance */
double & UpwardTransmittance /** upward transmittance */
);
/** Generate WavelenghtSpectralBand if the step is not the official 6S step value */
/** Check the correpondance between the vector value size and the interval number between min and max.
* If the vector step is not at 0.0025, the new values are computed.
* The utput vector values is store in the m_FilterFunctionValues6S of WavelenghtSpectralBand
. */
static void ComputeWavelenghtSpectralBandValuesFor6S(
const double SIXSStepOfWavelenghtSpectralBandValues,
WavelenghtSpectralType& WavelenghtSpectralBand
WavelenghtSpectralType* WavelenghtSpectralBand
);
};
......
......@@ -327,10 +327,10 @@ ADD_TEST(raTvFilterFunctionValuesTest ${RADIOMETRY_TESTS}
${TEMP}/raTvFilterFunctionValuesTest.txt
otbFilterFunctionValuesTest
${TEMP}/raTvFilterFunctionValuesTest.txt
5 # lambda min
17 # lambda max
3 # user step
2 5 3 9 8 # vectorlambda max
0.5 # lambda min
0.7 # lambda max
0.05 # user step
0.2 0.5 0.3 0.9 # vectorlambda max
)
......
......@@ -29,6 +29,7 @@ int otbFilterFunctionValuesTest(int argc, char * argv[])
try
{
char * outname = argv[1];
const double SIXSStepOfWavelenghtSpectralBandValues(0.0025);
typedef otb::FilterFunctionValues FilterFunctionValuesType;
// Instantiating object
......@@ -40,14 +41,16 @@ int otbFilterFunctionValuesTest(int argc, char * argv[])
vect.push_back(atof(argv[i]));
}
// bool bumbo = object->SetParameters(atof(argv[2]), atof(argv[3]), atof(argv[4]), vect);
const double SIXSStepOfWavelenghtSpectralBandValues(0.0025);
/*
otb::SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S(
,
WavelenghtSpectralType& WavelenghtSpectralBand
);
*/
object->SetMinSpectralValue(atof(argv[2]));
object->SetMaxSpectralValue(atof(argv[3]));
object->SetUserStep(atof(argv[4]));
object->SetFilterFunctionValues(vect);
// Call interpolate
otb::SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S(
SIXSStepOfWavelenghtSpectralBandValues,
object);
// Writing output file
std::ofstream file;
......@@ -60,9 +63,9 @@ int otbFilterFunctionValuesTest(int argc, char * argv[])
}
file<<std::endl;
file<<"Output vector :"<<std::endl;
for (unsigned int i=0; i<object->GetFilterFunctionValues().size(); i++)
for (unsigned int i=0; i<object->GetFilterFunctionValues6S().size(); i++)
{
file<< object->GetFilterFunctionValues()[i] <<std::endl;
file<< object->GetFilterFunctionValues6S()[i] <<std::endl;
}
file<<std::endl;
file<<"L_min :"<<object->GetMinSpectralValue()<<std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment