Request for Changes-100: Add external soil file to Sail model
Contents
Status
- Author: Jordi Inglada
- Submitted on 12.07.2017
- Vote : +1 from Julien, Manuel and Guillaume
- Proposed target release: 6.2
- Link to a public git branch : https://git.orfeo-toolbox.org/otb.git/shortlog/refs/heads/prosail-evolutions
- Merged : https://git.orfeo-toolbox.org/otb.git/commit/de9c2717283253bb0618c2426a63712ef7409b93
Summary
Add the possibility for Sail model to use an external file with soil reflectances.
Rationale
The Sail model simulates canopy reflectance and needs soil reflectance values to be combined with the simulated vegetation values. The current version uses the combination of two soil reflectances (wet and dry soils) stored in the DataSpecP5B class.
The goal of this RFC is to give the possibility of using any soil spectra provided in a file.
Implementation details
Classes
The class otb::SoilDataBase is added to be responsible for the parsing of the file and providing the reflectances as a function of the wavelength. The soil file follows the same format as the RSR files: a CSV using spaces as separators; the first column is wavelength and the following 1 to N columns give the reflectance of the N soil spectra in the file. The method
double GetReflectance(size_t SoilIndex, WavelenghtType wl) const;
is used to access the reflectance of a particular soil spectrum for a given wavelength. The data is stored as a vector of std::unordered_map:
using SoilData = std::unordered_map<WavelenghtType, double>; using SoilDataVector = std::vector<SoilData>;
The otb::SailModel class is modified to accept a SoilDataBase:
diff --git a/Modules/Radiometry/Simulation/include/otbSailModel.h b/Modules/Radiometry/Simulation/include/otbSailModel.h index 288d0d7030..089b3cf1cd 100644 --- a/Modules/Radiometry/Simulation/include/otbSailModel.h +++ b/Modules/Radiometry/Simulation/include/otbSailModel.h @@ -103,6 +106,9 @@ class OTBSimulation_EXPORT SailModel : public SimulationStep2Base /** Get the computed fcover */ itkGetMacro(FCoverView, double); + /** Use an external soil DB */ + void UseExternalSoilDB(std::shared_ptr<SoilDataBase> SoilDB, size_t SoilIndex); + /** GenerateData */ void GenerateData() ITK_OVERRIDE; @@ -152,6 +158,9 @@ class OTBSimulation_EXPORT SailModel : public SimulationStep2Base double m_TTO; //observer zenith angle double m_PSI; //azimuth double m_FCoverView; //fCover in the viewing direction + bool m_UseSoilFile; //use a soil file instead of DataSpecP5B + size_t m_SoilIndex; //which soil in the soil file + std::shared_ptr<SoilDataBase> m_SoilDataBase; }; }// end namespace otb diff --git a/Modules/Radiometry/Simulation/src/otbSailModel.cxx b/Modules/Radiometry/Simulation/src/otbSailModel.cxx index 15e262fee7..1049da6833 100644 --- a/Modules/Radiometry/Simulation/src/otbSailModel.cxx +++ b/Modules/Radiometry/Simulation/src/otbSailModel.cxx @@ -34,7 +34,7 @@ namespace otb /** Constructor */ SailModel ::SailModel() : m_LAI(2), m_Angl(50), m_PSoil(1), m_Skyl(70), m_HSpot(0.2), - m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0) + m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0), m_UseSoilFile(false) { this->ProcessObject::SetNumberOfRequiredInputs(2); this->ProcessObject::SetNumberOfRequiredOutputs(4); @@ -319,7 +319,14 @@ SailModel // Soil Reflectance Properties //rsoil1 = dry soil //rsoil2 = wet soil + if(!m_UseSoilFile) + { rsoil0 = m_PSoil*Rsoil1+(1-m_PSoil)*Rsoil2; + } + else + { + rsoil0 = m_SoilDataBase->GetReflectance(m_SoilIndex, lambda)*m_PSoil; + } // Here rho and tau come in sigb = ddb*rho+ddf*tau; @@ -711,4 +718,12 @@ SailModel Superclass::PrintSelf(os, indent); } + +void SailModel::UseExternalSoilDB(std::shared_ptr<SoilDataBase> SoilDB, + size_t SoilIndex) +{ + m_UseSoilFile = true; + m_SoilIndex = SoilIndex; + m_SoilDataBase = SoilDB; +} } // end namespace otb
Tests
Modified tests:
Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx
New tests:
Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx
Documentation
No modification of the documentation yet.