From 3ed816e6adf3b0ac1ac574471bbe5b820aaa8896 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Thu, 16 Sep 2010 14:26:20 +0800 Subject: [PATCH] TEST: add test on AtmosphericRadiativeTerms --- Testing/Code/Radiometry/CMakeLists.txt | 6 ++ .../otbAtmosphericRadiativeTermsTest.cxx | 94 +++++++++++++++++++ .../Code/Radiometry/otbRadiometryTests3.cxx | 1 + 3 files changed, 101 insertions(+) diff --git a/Testing/Code/Radiometry/CMakeLists.txt b/Testing/Code/Radiometry/CMakeLists.txt index dd12f31b52..ca69e7980d 100644 --- a/Testing/Code/Radiometry/CMakeLists.txt +++ b/Testing/Code/Radiometry/CMakeLists.txt @@ -528,6 +528,12 @@ ADD_TEST(raTuAtmosphericRadiativeTermsSingleChannelNew ${RADIOMETRY_TESTS3} otbAtmosphericRadiativeTermsSingleChannelNew ) +ADD_TEST(raTvAtmosphericRadiativeTermsTest ${RADIOMETRY_TESTS3} + --compare-ascii ${NOTOL} ${BASELINE_FILES}/raTvAtmosphericRadiativeTermsTest.txt + ${TEMP}/raTvAtmosphericRadiativeTermsTest.txt + otbAtmosphericRadiativeTermsTest + ${TEMP}/raTvAtmosphericRadiativeTermsTest.txt +) # ------- otb::ReflectanceToSurfaceReflectanceImageFilter ------------------------------ ADD_TEST(raTuReflectanceToSurfaceReflectanceImageFilterNew ${RADIOMETRY_TESTS3} diff --git a/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsTest.cxx b/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsTest.cxx index 9d25f71b71..05ffbda625 100644 --- a/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsTest.cxx +++ b/Testing/Code/Radiometry/otbAtmosphericRadiativeTermsTest.cxx @@ -19,6 +19,8 @@ #pragma warning ( disable : 4786 ) #endif +#include <fstream> + #include "itkExceptionObject.h" #include "otbAtmosphericRadiativeTerms.h" #include <cstdlib> @@ -40,6 +42,98 @@ int otbAtmosphericRadiativeTermsSingleChannelNew(int argc, char * argv[]) // Instantiating object AtmosphericRadiativeTermsType::Pointer object = AtmosphericRadiativeTermsType::New(); + std::cout << object << std::endl; return EXIT_SUCCESS; } +std::ostream& operator<<(std::ostream& os, const otb::AtmosphericRadiativeTerms::DataVectorType& values) +{ + os << "["; + if (values.size() > 0) + { + os << values[0]; + } + for (unsigned int i = 1; i < values.size(); ++i) + { + os << ", "; + os << values[i]; + } + os << "]\n"; + return os; +} + +int otbAtmosphericRadiativeTermsTest(int argc, char * argv[]) +{ + char * filename = argv[1]; + std::ofstream file; + file.open(filename); + + typedef otb::AtmosphericRadiativeTerms AtmosphericRadiativeTermsType; + + // Instantiating object + AtmosphericRadiativeTermsType::Pointer object = AtmosphericRadiativeTermsType::New(); + object->ValuesInitialization(3); + + // Set the values + AtmosphericRadiativeTermsType::DataVectorType values; + values.push_back(1.0); + values.push_back(2.0); + values.push_back(3.0); + + object->SetIntrinsicAtmosphericReflectances(values); + object->SetSphericalAlbedos(values); + object->SetTotalGaseousTransmissions(values); + object->SetDownwardTransmittances(values); + object->SetUpwardTransmittances(values); + object->SetUpwardDiffuseTransmittances(values); + object->SetUpwardDirectTransmittances(values); + object->SetUpwardDiffuseTransmittancesForRayleigh(values); + object->SetUpwardDiffuseTransmittancesForAerosol(values); + object->SetWavelengthSpectralBand(values); + + file << object << std::endl; + + file << "\n\n TESTING ACCESSOR OUT OF RANGE \n\n"; + object->SetSphericalAlbedo(3, 4.0); + object->SetTotalGaseousTransmission(5, 5.0); + object->SetDownwardTransmittance(6, 6.0); + object->SetUpwardTransmittance(7, 7.0); + object->SetUpwardDiffuseTransmittance(8, 8.0); + object->SetUpwardDirectTransmittance(9, 9.0); + object->SetUpwardDiffuseTransmittanceForRayleigh(10, 10.0); + object->SetUpwardDiffuseTransmittanceForAerosol(11, 11.0); + object->SetWavelengthSpectralBand(12, 12.0); + + file << object << std::endl; + + file << "\n\n TESTING ACCESSOR \n\n"; + file << object->GetIntrinsicAtmosphericReflectances() << std::endl; + file << object->GetSphericalAlbedos() << std::endl; + file << object->GetTotalGaseousTransmissions() << std::endl; + file << object->GetDownwardTransmittances() << std::endl; + file << object->GetUpwardTransmittances() << std::endl; + file << object->GetUpwardDiffuseTransmittances() << std::endl; + file << object->GetUpwardDirectTransmittances() << std::endl; + file << object->GetUpwardDiffuseTransmittancesForRayleigh() << std::endl; + file << object->GetUpwardDiffuseTransmittancesForAerosol() << std::endl; + file << object->GetWavelengthSpectralBand() << std::endl; + + file << "\n\n TESTING ACCESSOR WITH INDEX\n\n"; + file << object->GetIntrinsicAtmosphericReflectance(0) << std::endl; + file << object->GetSphericalAlbedo(5) << std::endl; + file << object->GetTotalGaseousTransmission(5) << std::endl; + file << object->GetDownwardTransmittance(5) << std::endl; + file << object->GetUpwardTransmittance(5) << std::endl; + file << object->GetUpwardDiffuseTransmittance(5) << std::endl; + file << object->GetUpwardDirectTransmittance(5) << std::endl; + file << object->GetUpwardDiffuseTransmittanceForRayleigh(5) << std::endl; + file << object->GetUpwardDiffuseTransmittanceForAerosol(5) << std::endl; + file << object->GetWavelengthSpectralBand(12) << std::endl; + file << std::endl; + file << object->GetValueByIndex(5) << std::endl; + + + file.close(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/Radiometry/otbRadiometryTests3.cxx b/Testing/Code/Radiometry/otbRadiometryTests3.cxx index 38563b8601..7ca32e0a74 100644 --- a/Testing/Code/Radiometry/otbRadiometryTests3.cxx +++ b/Testing/Code/Radiometry/otbRadiometryTests3.cxx @@ -34,6 +34,7 @@ void RegisterTests() REGISTER_TEST(otbSIXSTraitsComputeAtmosphericParametersTest); REGISTER_TEST(otbAtmosphericRadiativeTermsNew); REGISTER_TEST(otbAtmosphericRadiativeTermsSingleChannelNew); + REGISTER_TEST(otbAtmosphericRadiativeTermsTest); REGISTER_TEST(otbReflectanceToSurfaceReflectanceImageFilterNew); REGISTER_TEST(otbReflectanceToSurfaceReflectanceImageFilterTest); REGISTER_TEST(otbReflectanceToSurfaceReflectanceImageFilterTest2); -- GitLab