Commit b1185773 authored by Esquis Benjamin's avatar Esquis Benjamin
Browse files

Merge branch 'develop' into 180-update-documentation

parents eda13433 a37b0543
......@@ -142,6 +142,7 @@ tv-centos7:
- time rclone copy s3_otb:maja-data/TV/LANDSAT8 data/TV/LANDSAT8
- time rclone copy s3_otb:maja-data/TV/VENUS data/TV/VENUS
- time rclone copy s3_otb:maja-data/TV/VENUS_MUSCATE data/TV/VENUS_MUSCATE
- time rclone copy s3_otb:maja-data/TV/START_MAJA data/TV/START_MAJA
- CI/run_tv.sh tv_content.txt
artifacts:
expire_in: 20 days
......
/*
* Copyright (C) 2020 Centre National d'Etudes Spatiales (CNES)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/************************************************************************************************************
* *
* ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *
* o *
* o *
* o *
* o *
* o ooooooo ooooooo o o oo *
* o o o o o o o o o o *
* o o o o o o o o o o *
* o o o o o o o o o o *
* o o o oooo o o o o o o *
* o o o o o o o o o *
* o o o o o o o o o o *
* oo oooooooo o o o oooooo o oooo *
* o *
* o *
* o o *
* o o oooo o o oooo *
* o o o o o o *
* o o ooo o o ooo *
* o o o o o *
* ooooo oooo o ooooo oooo *
* o *
* *
************************************************************************************************************
* *
* Author: CS Systemes d'Information (France) *
* *
************************************************************************************************************
* HISTORIQUE *
* *
* VERSION : 5-1-0 : FA : LAIG-FA-MAC-145739-CS : 27 juin 2016 : Audit code - Supp de la macro ITK_EXPORT *
* VERSION : 4-0-0 : DM : LAIG-DM-MAC-517-CNES : 11 février 2014 : Améliorations algorithmiques (Spec v2.1) *
* *
* FIN-HISTORIQUE *
* *
* $Id: DirectionalCorrectionLUTCompute.h 2406 2011-01-19 15:38:23Z tfeuvrie $
* *
************************************************************************************************************/
#ifndef __DirectionalCorrectionLUTCompute_h
#define __DirectionalCorrectionLUTCompute_h
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "otbMath.h"
#include "vnsMacro.h"
#include "vnsVectorLookUpTable.h"
namespace vns
{
/** \class DirectionalCorrectionLUTCompute
*
* \author CS Systemes d'Information
*
* \sa Object
*
* \ingroup L2
*
*/
class DirectionalCorrectionLUTCompute : public itk::Object
{
public:
/** Standard class typedefs. */
typedef DirectionalCorrectionLUTCompute Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef VNSLUT3DType LUTType;
typedef typename LUTType::ConstPointer ReducedLutConstPointerType;
typedef typename LUTType::Pointer ReducedLutPointerType;
typedef typename LUTType::PixelType ReducedLutPixelType;
typedef typename LUTType::PointType ReducedLutPointType;
typedef typename ReducedLutPointType::ValueType ReducedLutPointValueType;
typedef std::vector<double> DoubleVectType;
/** Type macro */
itkNewMacro(Self);
/** Creation through object factory macro */
itkTypeMacro(DirectionalCorrectionLUTCompute, Object );
/** Set the Solar Zenith value. */
vnsSetMacro(SolarZenith, double)
/** Get the Solar Zenith value. */
vnsGetConstMacro(SolarZenith, double)
/** Set the Solar Azimuth value. */
vnsSetMacro(SolarAzimuth, double)
/** Get the Solar Azimuth value. */
vnsGetConstMacro(SolarAzimuth, double)
/** Set the Reference Solar Zenith value. */
vnsSetMacro(RefZenith, double)
/** Get the Reference Solar Zenith value. */
vnsGetConstMacro(RefZenith, double)
/** Set the Reference Solar Azimuth value. */
vnsSetMacro(RefAzimuth, double)
/** Get the Reference Solar Azimuh value. */
vnsGetConstMacro(RefAzimuth, double)
/** Set the LUT image */
itkSetObjectMacro(LUT, LUTType)
/** Set/Get the Viewing Zenith angles values */
vnsSetMacro(MeanViewingZenithAngles, DoubleVectType)
vnsGetConstMacro(MeanViewingZenithAngles, DoubleVectType)
/** Set/Get the Viewing Azimuth angles values */
vnsSetMacro(MeanViewingAzimuthAngles, DoubleVectType)
vnsGetConstMacro(MeanViewingAzimuthAngles, DoubleVectType)
/** Get the Directional correction coefficients */
vnsGetConstMacro(CorrCoefs, DoubleVectType)
void ComputeDirectionalCoeffs();
protected:
/** Constructor */
DirectionalCorrectionLUTCompute();
/** Destructor */
virtual ~DirectionalCorrectionLUTCompute();
/** PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
DirectionalCorrectionLUTCompute(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/** Solar Zenith value */
double m_SolarZenith;
/** Solar Azimuth value */
double m_SolarAzimuth;
/** Ref Solar Zenith value */
double m_RefZenith;
/** Ref Solar Azimtuh value */
double m_RefAzimuth;
/** Surface reflectance LUT */
ReducedLutPointerType m_LUT;
/** Viewing Zenith angles */
DoubleVectType m_MeanViewingZenithAngles;
/** Viewing Azimuth angles */
DoubleVectType m_MeanViewingAzimuthAngles;
/** Directional correction coefficients */
DoubleVectType m_CorrCoefs;
};
} // End namespace vns
#ifndef VNS_MANUAL_INSTANTIATION
#include "vnsDirectionalCorrectionLUTCompute.txx"
#endif
#endif /* __vnsDirectionalCorrectionLUTCompute_h */
/*
* Copyright (C) 2020 Centre National d'Etudes Spatiales (CNES)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/************************************************************************************************************
* *
* ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *
* o *
* o *
* o *
* o *
* o ooooooo ooooooo o o oo *
* o o o o o o o o o o *
* o o o o o o o o o o *
* o o o o o o o o o o *
* o o o oooo o o o o o o *
* o o o o o o o o o *
* o o o o o o o o o o *
* oo oooooooo o o o oooooo o oooo *
* o *
* o *
* o o *
* o o oooo o o oooo *
* o o o o o o *
* o o ooo o o ooo *
* o o o o o *
* ooooo oooo o ooooo oooo *
* o *
* *
************************************************************************************************************
* *
* Author: CS Systemes d'Information (France) *
* *
************************************************************************************************************/
#ifndef __vnsDirectionalCorrectionLUTCompute_txx
#define __vnsDirectionalCorrectionLUTCompute_txx
#include "vnsDirectionalCorrectionLUTCompute.h"
#include "vnsLoggers.h"
namespace vns
{
// Constructor
DirectionalCorrectionLUTCompute::DirectionalCorrectionLUTCompute() :
m_SolarZenith(0.), m_SolarAzimuth(0.), m_RefZenith(0.), m_RefAzimuth(0.)
{
}
// Destructor
DirectionalCorrectionLUTCompute::~DirectionalCorrectionLUTCompute()
{
}
// Get sunglint distance
void
DirectionalCorrectionLUTCompute::ComputeDirectionalCoeffs()
{
// Check LUT availability
if (m_LUT.IsNull() == true)
{
vnsExceptionBusinessMacro("Waiting for a LUT, but no one specified. Please set one.");
}
// Get the number of band
const unsigned int numberOfBand(m_MeanViewingZenithAngles.size());
//Lut ExtractPoint
ReducedLutPointType point;
ReducedLutPointType pointRef;
pointRef.Fill(0);
point[0] = m_SolarZenith;
point[1] = m_RefZenith;
point[2] = m_RefAzimuth;
pointRef[0] = m_SolarZenith;
ReducedLutPixelType interpRefValue = m_LUT->InterpolateValue(pointRef);
// Band loop
for (unsigned int i = 0; i < numberOfBand; i++)
{
point[1] = m_MeanViewingZenithAngles[i];
// Get the relative azimuth angle
double deltaPhi = m_SolarAzimuth - m_MeanViewingAzimuthAngles[i];
if (deltaPhi < 0.)
{
deltaPhi = -deltaPhi;
}
if (deltaPhi > 180.)
{
deltaPhi = 360 - deltaPhi;
}
point[2] = deltaPhi;
ReducedLutPixelType interpValue = m_LUT->InterpolateValue(point);
const float l_dirNorm = interpRefValue[i] / interpValue[i];
// Set directional correction coefficients
m_CorrCoefs.push_back(l_dirNorm) ;
}
}
// PrintSelf method
void
DirectionalCorrectionLUTCompute::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << "Solar Zenith value: " << m_SolarZenith << std::endl;
os << "Solar Azimuth value: " << m_SolarAzimuth << std::endl;
os << "Ref Zenith value: " << m_RefZenith << std::endl;
os << "Ref Azimuth value: " << m_RefAzimuth << std::endl;
}
} // End namespace vns
#endif /* __vnsDirectionalCorrectionLUTCompute_txx */
......@@ -58,9 +58,21 @@
#include "otbWrapperApplicationFactory.h"
#include "vnsDirectionalCorrectionCompute.h"
#include "vnsUtilities.h"
#include "vnsLookUpTableFileReader.h"
#include "vnsSimpleLutXMLFileHandler.h"
#include "vnsSimpleLutXMLContainer.h"
#include "vnsDirectionalCorrectionLUTCompute.h"
namespace vns
{
enum
{
roy,
lut
};
namespace Wrapper
{
......@@ -83,6 +95,20 @@ public:
/** Some convenient typedefs. */
//Directional correction compute
typedef DirectionalCorrectionCompute DirectionalCorrectionComputeType;
//Reduced output lut typedef
typedef VNSLUT3DType LutType;
typedef typename LutType::ConstPointer ReducedLutConstPointer;
typedef typename LutType::Pointer ReducedLutPointer;
//LookupTable Reader
typedef LookUpTableFileReader<LutType> LookUpTableReaderType;
typedef typename LookUpTableReaderType::Pointer LookUpTableReaderPointer;
typedef typename LutType::ParameterValuesType ParameterValuesType;
typedef DirectionalCorrectionLUTCompute DirectionalCorrectionLUTComputeFilterType;
typedef DirectionalCorrectionLUTComputeFilterType::Pointer DirectionalCorrectionLUTComputeFilterPointerType;
private:
void DoInit()
{
......@@ -97,8 +123,6 @@ private:
AddDocTag("Statistics");
AddParameter(ParameterType_StringList, "coeffsr", "CoeffsR");
AddParameter(ParameterType_StringList, "coeffsv", "CoeffsV");
AddParameter(ParameterType_Group, "solar","Solar angles");
AddParameter(ParameterType_Float, "solar.zenith","Solar zenith");
AddParameter(ParameterType_Float, "solar.azimuth","Solar azimuth");
......@@ -111,6 +135,20 @@ private:
AddParameter(ParameterType_String, "coeffs", "correction coeffs");
SetParameterRole("coeffs", Role_Output);
//Choose the mode
AddParameter(ParameterType_Choice,"model", "directional correction option");
AddChoice("model.roy", "ROY Model");
AddChoice("model.lut", "LUT Model");
AddParameter(ParameterType_Group,"roy", "roy model");
MandatoryOff("roy");
AddParameter(ParameterType_StringList, "roy.coeffsr","CoeffsR");
AddParameter(ParameterType_StringList, "roy.coeffsv","CoeffsV");
AddParameter(ParameterType_Group,"lut", "lut model");
MandatoryOff("lut");
AddParameter(ParameterType_String, "lut.filename","LUT filename");
AddRAMParameter("ram");
SetDefaultParameterInt("ram",2048);
......@@ -118,18 +156,11 @@ private:
void DoUpdateParameters()
{
}
void DoExecute()
{
//Get Params
//Correction coeff
Utilities::ListOfDoubles m_CoefsR = Utilities::StringListAsDouble(
this->GetParameterStringList("coeffsr"));
Utilities::ListOfDoubles m_CoefsV= Utilities::StringListAsDouble(
this->GetParameterStringList("coeffsv"));
double m_SolarZenith = GetParameterFloat("solar.zenith");
double m_SolarAzimuth = GetParameterFloat("solar.azimuth");
Utilities::ListOfDoubles m_MeanViewingZenithAngles = Utilities::StringListAsDouble(
......@@ -139,22 +170,130 @@ private:
double m_RefZenith = GetParameterFloat("refzenith");
double m_RefAzimuth = GetParameterFloat("refazimuth");
const unsigned int nb_MeanViewingAngles = m_MeanViewingZenithAngles.size();
//Verify consitency of input
if (m_CoefsR.size() != m_MeanViewingZenithAngles.size()){
vnsExceptionAlgorithmsProcessingMacro("Internal error: the number of CoefR '"<<m_CoefsR.size()<<
"' is different than the ViewingAnglesZenithPerBand'"<<m_MeanViewingZenithAngles.size()<<"'!")
}
if (m_CoefsV.size() != m_MeanViewingZenithAngles.size()){
vnsExceptionAlgorithmsProcessingMacro("Internal error: the number of CoefV '"<<m_CoefsV.size()<<
"' is different than the ViewingAnglesZenithPerBand'"<<m_MeanViewingZenithAngles.size()<<"'!")
//Choose model
Utilities::DirCorrModelEnumType l_DirCorrOption;
// Get mell
switch ( GetParameterInt("model") )
{
case roy:
l_DirCorrOption = Utilities::ROY;
break;
case lut:
l_DirCorrOption = Utilities::LUT;
break;
}
//Compute the directional correction coeffs
Utilities::ListOfDoubles coefs = DirectionalCorrectionComputeType::ComputeCorrectionCoeffs(m_SolarZenith,m_SolarAzimuth,
Utilities::ListOfDoubles coefs ;
if (l_DirCorrOption == Utilities::ROY)
{
vnsLogDebugMacro("Directional Correction model : ROY");
if ((!IsParameterEnabled("roy.coeffsr")) || (!IsParameterEnabled("roy.coeffsv")))
{
vnsExceptionDataMacro("roy.coeffsr and roy.coeffsv parameter must be set in cas of ROY model!!!");
}
//Correction coeff
Utilities::ListOfDoubles m_CoefsR = Utilities::StringListAsDouble(this->GetParameterStringList("roy.coeffsr"));
Utilities::ListOfDoubles m_CoefsV= Utilities::StringListAsDouble(this->GetParameterStringList("roy.coeffsv"));
//Verify consitency of input
if (m_CoefsR.size() != m_MeanViewingZenithAngles.size()){
vnsExceptionAlgorithmsProcessingMacro("Internal error: the number of CoefR '"<<m_CoefsR.size()<<
"' is different than the ViewingAnglesZenithPerBand'"<<m_MeanViewingZenithAngles.size()<<"'!")
}
if (m_CoefsV.size() != m_MeanViewingZenithAngles.size()){
vnsExceptionAlgorithmsProcessingMacro("Internal error: the number of CoefV '"<<m_CoefsV.size()<<
"' is different than the ViewingAnglesZenithPerBand'"<<m_MeanViewingZenithAngles.size()<<"'!")
}
//Compute the ROY directional correction coeffs
coefs = DirectionalCorrectionComputeType::ComputeCorrectionCoeffs(m_SolarZenith,m_SolarAzimuth,
m_RefZenith,m_RefAzimuth,m_MeanViewingZenithAngles, m_MeanViewingAzimuthAngles, m_CoefsR,m_CoefsV);
for (unsigned int bandNum = 0; bandNum < nb_MeanViewingAngles; bandNum++)
{
}
else //l_DirCorrOption == Utilities::LUT
{
vnsLogDebugMacro("Directional Correction model : LUT");
// Init filters
m_DirectionalCorrectionLUTComputeFilter = DirectionalCorrectionLUTComputeFilterType::New();
if (!IsParameterEnabled("lut.filename"))
{
vnsExceptionDataMacro("Missing LUT : lut.filename parameter must be set in cas of LUT model!!!");
}
const std::string m_strLutFileName = GetParameterString("lut.filename");
vnsLogDebugMacro("lut filemane : " << m_strLutFileName) ;
//Read the xml lut description file
SimpleLutXMLFileHandler::Pointer l_LUTXMLHandler = vns::SimpleLutXMLFileHandler::New();
// Load the XML file and check with the schema
l_LUTXMLHandler->LoadFile(m_strLutFileName);
const vns::SimpleLutXMLContainer& l_lutxml = l_LUTXMLHandler->GetLutContainer();
// Init LUT filters
LookUpTableReaderPointer l_lookUpTableReader = LookUpTableReaderType::New();
// Get the number of file that matches with the number of band
const std::vector<std::string>& l_GIP_DIRCOR_ListOfFilenames = l_lutxml.GetListOfPackaged_DBL_Files();
const unsigned int fileNumber = l_GIP_DIRCOR_ListOfFilenames.size();
for (unsigned int file = 0; file < fileNumber; file++)
{
// Set the filename of each band
l_lookUpTableReader->AddBandFilename(l_GIP_DIRCOR_ListOfFilenames[file]);
}
// Read informations from the GIPP file
const std::vector<double>& l_GIP_DIRCOR_SolarZenithalAngleIndexes = l_lutxml.GetSolar_Zenith_Angle_Indexes();
const std::vector<double>& l_GIP_DIRCOR_ViewZenithalAngleIndexes = l_lutxml.GetView_Zenith_Angle_Indexes();
const std::vector<double>& l_GIP_DIRCOR_RelativeAzimuthAngleIndexes = l_lutxml.GetRelative_Azimuth_Angle_Indexes();
/* parameters are added one by one to the LUT */
ParameterValuesType l_GIP_DIRCORParam1;
l_GIP_DIRCORParam1.ParameterName = "Solar_Zenith_Angle_Indexes";
l_GIP_DIRCORParam1.ParameterValues = l_GIP_DIRCOR_SolarZenithalAngleIndexes;
l_lookUpTableReader->AddParameterValues(l_GIP_DIRCORParam1);
ParameterValuesType l_GIP_DIRCORParam2;
l_GIP_DIRCORParam2.ParameterName = "View_Zenith_Angle_Indexes";
l_GIP_DIRCORParam2.ParameterValues = l_GIP_DIRCOR_ViewZenithalAngleIndexes;
l_lookUpTableReader->AddParameterValues(l_GIP_DIRCORParam2);
ParameterValuesType l_GIP_DIRCORParam3;
l_GIP_DIRCORParam3.ParameterName = "Relative_Azimuth_Angle_Indexes";
l_GIP_DIRCORParam3.ParameterValues = l_GIP_DIRCOR_RelativeAzimuthAngleIndexes;
l_lookUpTableReader->AddParameterValues(l_GIP_DIRCORParam3);
//Generate Lut
l_lookUpTableReader->GenerateLUT();
//Useful typedef for LUT
typedef LutType::PointType LUTPointType;
typedef LutType::Pointer LUTPointer;
//Get the lut pointer
LUTPointer l_LutInPtr = l_lookUpTableReader->GetLUT();
m_DirectionalCorrectionLUTComputeFilter->SetSolarZenith(m_SolarZenith);
m_DirectionalCorrectionLUTComputeFilter->SetSolarAzimuth(m_SolarAzimuth);
m_DirectionalCorrectionLUTComputeFilter->SetRefZenith(m_RefZenith);
m_DirectionalCorrectionLUTComputeFilter->SetRefAzimuth(m_RefAzimuth);
m_DirectionalCorrectionLUTComputeFilter->SetLUT(l_LutInPtr);
m_DirectionalCorrectionLUTComputeFilter->SetMeanViewingZenithAngles(m_MeanViewingZenithAngles);
m_DirectionalCorrectionLUTComputeFilter->SetMeanViewingAzimuthAngles(m_MeanViewingAzimuthAngles);
// Compute the directional correction coeffs
m_DirectionalCorrectionLUTComputeFilter->ComputeDirectionalCoeffs();
// Get the directional correction coeffs
coefs = m_DirectionalCorrectionLUTComputeFilter->GetCorrCoefs();
}
for (unsigned int bandNum = 0; bandNum < nb_MeanViewingAngles; bandNum++)
{
vnsLogDebugMacro("Direction Correction Coeff band "<<bandNum<<" = "<<std::setprecision(20)<<coefs.at(bandNum));
}
}
std::string l_String("");
if (coefs.size() > 0)
......@@ -168,13 +307,15 @@ private:
std::ostringstream oss;
oss << coefs[coefs.size() - 1];
l_String = l_String + oss.str().c_str();
}
SetParameterString("coeffs",l_String);
}
}
private:
DirectionalCorrectionLUTComputeFilterPointerType m_DirectionalCorrectionLUTComputeFilter;
/** Filters declaration */
};
......
......@@ -59,7 +59,6 @@
#include "otbWrapperApplicationFactory.h"
#include "vnsSimpleLutXMLFileHandler.h"
#include "vnsVectorLookUpTableExtractor.h"
#include "vnsDirectionalCorrectionCompute.h"