From 3a3b7a2133cbda22bb8dff560150811ed28b60fb Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 28 Mar 2017 09:50:04 +0200 Subject: [PATCH] TEST: use external soil file in Sail --- .../Radiometry/Simulation/test/CMakeLists.txt | 24 ++++++++++++++ .../Simulation/test/otbSailReflHTest.cxx | 32 ++++++++++++++----- .../Simulation/test/otbSoilDBTest.cxx | 1 + 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Modules/Radiometry/Simulation/test/CMakeLists.txt b/Modules/Radiometry/Simulation/test/CMakeLists.txt index cdb2450feb..f0c480ea75 100644 --- a/Modules/Radiometry/Simulation/test/CMakeLists.txt +++ b/Modules/Radiometry/Simulation/test/CMakeLists.txt @@ -338,3 +338,27 @@ otb_add_test(NAME siTvSoilDataParseFile COMMAND otbSimulationTestDriver otbSoilD 133 6.0800000e-001 ) + +otb_add_test(NAME siTvSailReflHSoilTest COMMAND otbSimulationTestDriver + --compare-ascii ${EPSILON_3} ${BASELINE_FILES}/Simulation/siTvSailReflHTest.txt + ${TEMP}/siTvSailReflHTest.txt + otbSailReflHTest + 30.0 #cab + 10.0 #car + 0.0 #CBrown + 0.015 #Cw + 0.009 #Cm + 1.2 #N + 2 #LAI + 50 #Angl + 1 #PSoil + 70 #Skyl + 0.2 #HSpot + 30 #TTS + 0 #TTO + 0 #PSI + ${TEMP}/siTvSailReflSoilHTest.txt + ${INPUTDATA}/Radiometry/Soils/sols_avignon_1990.txt + 20 # soil index + 1000 #wlfactor + ) diff --git a/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx b/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx index dfd6c31c38..96a92e65e4 100644 --- a/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx +++ b/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx @@ -29,11 +29,11 @@ int otbSailReflHTest(int argc, char * argv[]) { - if(argc != 16) - { - std::cout<<"Wrong number of arguments !"<<std::endl; - return EXIT_FAILURE; - } + if(argc < 16 || argc > 19) + { + std::cout<<"Wrong number of arguments !"<<std::endl; + return EXIT_FAILURE; + } double Cab=static_cast<double>(atof(argv[1])); double Car=static_cast<double>(atof(argv[2])); @@ -50,6 +50,17 @@ int otbSailReflHTest(int argc, char * argv[]) double TTO=static_cast<double>(atof(argv[13])); double PSI=static_cast<double>(atof(argv[14])); char * OutputName = argv[15]; + std::string SoilFileName{}; + size_t SoilIndex{0}; + double WlFactor{1000}; + bool UseSoilFile = false; + if(argc == 19) + { + UseSoilFile = true; + SoilFileName = argv[16]; + SoilIndex = static_cast<size_t>(atoi(argv[17])); + WlFactor = static_cast<double>(atof(argv[18])); + } typedef otb::ProspectModel ProspectType; @@ -81,13 +92,18 @@ int otbSailReflHTest(int argc, char * argv[]) sail->SetPSI(PSI); sail->SetReflectance(prospect->GetReflectance()); sail->SetTransmittance(prospect->GetTransmittance()); + if(UseSoilFile) + { + std::cout << "Using soil file " << SoilFileName << '\n'; + sail->UseExternalSoilFile(SoilFileName, SoilIndex, WlFactor); + } sail->Update(); std::ofstream outputFile(OutputName, std::ios::out); for(unsigned int i=0; i<sail->GetHemisphericalReflectance()->Size(); ++i) - { - outputFile<<sail->GetHemisphericalReflectance()->GetResponse()[i].second<<std::endl; - } + { + outputFile<<sail->GetHemisphericalReflectance()->GetResponse()[i].second<<std::endl; + } return EXIT_SUCCESS; diff --git a/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx index 84dc753eca..c412965dfc 100644 --- a/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx +++ b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx @@ -69,3 +69,4 @@ int otbSoilDataBaseParseFile(int argc, char * argv[]) return EXIT_SUCCESS; } + -- GitLab