Skip to content
Snippets Groups Projects
Commit 92e4b699 authored by Mickael Savinaud's avatar Mickael Savinaud
Browse files

ENH: use external function to compute earth-sun distance from OTB-atmo project

parent a44d8b8a
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
#ifndef __otbImageToReflectanceImageFilter_h
#define __otbImageToReflectanceImageFilter_h
#include "otbVarSol.h"
#include "otbUnaryImageFunctorWithVectorImageFilter.h"
#include "otbImageToLuminanceImageFilter.h"
#include "otbLuminanceToReflectanceImageFilter.h"
......@@ -315,12 +316,8 @@ protected:
{
if (m_Day * m_Month != 0 && m_Day < 32 && m_Month < 13)
{
otb_6s_doublereal dsol = 0.;
otb_6s_integer day = static_cast<otb_6s_integer>(m_Day);
otb_6s_integer month = static_cast<otb_6s_integer>(m_Month);
//int cr(0);
otb_6s_varsol_(&day, &month, &dsol);
coefTemp = vcl_cos(m_ZenithalSolarAngle * CONST_PI_180) * static_cast<double>(dsol);
double dsol = VarSol::GetVarSol(m_Day, m_Month);
coefTemp = vcl_cos(m_ZenithalSolarAngle * CONST_PI_180) * dsol;
}
else
{
......
......@@ -22,7 +22,7 @@
#ifndef __otbLuminanceToReflectanceImageFilter_h
#define __otbLuminanceToReflectanceImageFilter_h
#include "otb_6S.h"
#include "otbVarSol.h"
#include "otbUnaryImageFunctorWithVectorImageFilter.h"
#include "otbVectorImage.h"
#include "otbMath.h"
......@@ -297,12 +297,8 @@ protected:
{
if (m_Day * m_Month != 0 && m_Day < 32 && m_Month < 13)
{
otb_6s_doublereal dsol = 0.;
otb_6s_integer day = static_cast<otb_6s_integer>(m_Day);
otb_6s_integer month = static_cast<otb_6s_integer>(m_Month);
//int cr(0);
otb_6s_varsol_(&day, &month, &dsol);
coefTemp = vcl_cos(m_ZenithalSolarAngle * CONST_PI_180) * static_cast<double>(dsol);
double dsol = VarSol::GetVarSol(m_Day, m_Month);
coefTemp = vcl_cos(m_ZenithalSolarAngle * CONST_PI_180) * dsol;
}
else
{
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbVarSol_h
#define __otbVarSol_h
#include "otbMath.h"
namespace otb
{
/** \class VarSol
* \brief VarSol operations.
*
* Call VarSol main function
*
* [1] Vermote, E., Tanré, D., Deuze, J., Herman, M., Morcette, J., 1997.
* Second simulation of the satellite signal in the solar spectrum, 6S: An overview.
* IEEE Transactions on Geoscience and Remote Sensing 35
* \ingroup Radiometry
*
*/
class ITK_EXPORT VarSol
{
public:
/** Call the varSol function*/
static double GetVarSol(const int day, const int month)
{
/* System generated locals */
double d__1;
/* Builtin functions */
//double acos(double), cos(double);
/* Local variables */
int j;
double pi, om;
/* calculation of the variability of the solar constant during the year. */
/* day is the number of the day in the month */
if (month <= 2)
j = (month - 1) * 31 + day;
else if (month > 8)
j = (month - 1) * 31 - (month - 2) / 2 - 2 + day;
else
j = (month - 1) * 31 - (month - 1) / 2 - 2 + day;
pi = acos(0.) * 2.;
om = (double) (j - 4) * .9856 * pi / 180.;
/* Computing 2nd power */
d__1 = 1. - cos(om) * .01673;
return 1. / (d__1 * d__1);
}
};
} //end namespace otb
#endif
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