Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
e94da76a
Commit
e94da76a
authored
13 years ago
by
Jonathan Guinet
Browse files
Options
Downloads
Patches
Plain Diff
STYLE: indent correction.
parent
2da33ef5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Simulation/otbSatelliteRSR.h
+127
-121
127 additions, 121 deletions
Code/Simulation/otbSatelliteRSR.h
Code/Simulation/otbSatelliteRSR.txx
+91
-106
91 additions, 106 deletions
Code/Simulation/otbSatelliteRSR.txx
with
218 additions
and
227 deletions
Code/Simulation/otbSatelliteRSR.h
+
127
−
121
View file @
e94da76a
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
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.
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 __otbSatelliteRSR_h
#define __otbSatelliteRSR_h
#include
"itkDataObject.h"
#include
<itkObjectFactory.h>
#include
<vector>
...
...
@@ -31,122 +30,129 @@
namespace
otb
{
/** \class SatelliteRSR
* \brief This class represents a hierarchy of vector data.
*
* This class contains an std::vector of spectral response, class otb::SpectralResponse (one for each band of the satellite).
*
*
* The two templates indicate:
* - the precision of the wavelength (X) (by default: double)
* - the precision of the gain associated to the wavelength (Y) (by default: double)
* \sa SpectralResponse
* \sa itk::DataObject
* \brief This class represents a hierarchy of vector data.
*
* This class contains an std::vector of spectral response, class otb::SpectralResponse (one for each band of the satellite).
*
*
* The two templates indicate:
* - the precision of the wavelength (X) (by default: double)
* - the precision of the gain associated to the wavelength (Y) (by default: double)
* \sa SpectralResponse
* \sa itk::DataObject
*/
template
<
class
TPrecision
=
double
,
class
TValuePrecision
=
double
>
class
SatelliteRSR
:
public
itk
::
DataObject
template
<
class
TPrecision
=
double
,
class
TValuePrecision
=
double
>
class
SatelliteRSR
:
public
itk
::
DataObject
{
public:
/** Standard class typedefs */
typedef
SatelliteRSR
Self
;
typedef
itk
::
DataObject
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macros */
itkNewMacro
(
Self
);
itkTypeMacro
(
SatelliteRSR
,
DataObject
);
/** Set the number of band of the satellite from an ASCII file
* Need to parse first all the file to determine the number of columns */
itkGetConstMacro
(
NbBands
,
unsigned
int
);
itkSetMacro
(
NbBands
,
unsigned
int
);
itkSetMacro
(
SortBands
,
bool
);
/** Template parameters typedef */
typedef
TPrecision
PrecisionType
;
typedef
TValuePrecision
ValuePrecisionType
;
typedef
SpectralResponse
<
TPrecision
,
TValuePrecision
>
SpectralResponseType
;
typedef
typename
SpectralResponseType
::
Pointer
SpectralResponsePointerType
;
typedef
std
::
vector
<
SpectralResponsePointerType
>
RSRVectorType
;
typedef
typename
SpectralResponseType
::
VectorPairType
VectorPairType
;
/** Clear the vector data */
virtual
bool
Clear
();
/** Return the number of element in the vector (nb bands) */
virtual
int
Size
()
const
;
/** Fill from a ASCII file (spectral gauge)*/
void
Load
(
const
std
::
string
&
filename
,
ValuePrecisionType
coefNormalization
=
1.0
);
/** Fill from user defined criteria (sampling band from lambdaMin to lambdaMax with Bandwidth width) */
void
Load
(
PrecisionType
lambdaMin
,
PrecisionType
lambdaMax
,
PrecisionType
sampling
,
ValuePrecisionType
coefNormalization
=
1.0
);
/** Compare RSR response (order bands from high to low frequency)*/
struct
sort_band
{
bool
operator
()
(
SpectralResponsePointerType
a
,
SpectralResponsePointerType
b
)
{
PrecisionType
aFirstNotNull
;
PrecisionType
bFirstNotNull
;
typename
VectorPairType
::
const_iterator
it
=
a
->
GetResponse
().
begin
();
while
((
*
it
).
second
==
0
)
{
++
it
;
}
aFirstNotNull
=
(
*
it
).
first
;
typename
VectorPairType
::
const_iterator
it2
=
b
->
GetResponse
().
begin
();
while
((
*
it2
).
second
==
0
)
{
++
it2
;
}
bFirstNotNull
=
(
*
it2
).
first
;
return
aFirstNotNull
<
bFirstNotNull
;
}
};
/**
* \param PrecisionType
* \param Band
* \return The interpolate value of the SR for the numBand (band num 0 to band num (m_NbBands-1)).
*/
inline
ValuePrecisionType
operator
()(
const
PrecisionType
&
lambda
,
const
unsigned
int
numBand
);
/** PrintSelf method */
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/** get vector of RSR */
RSRVectorType
&
GetRSR
()
{
return
m_RSR
;
}
protected
:
/** Constructor */
SatelliteRSR
();
/** Constructor from a ASCII file */
//SatelliteRSR( const std::string & filename );
/** Destructor */
virtual
~
SatelliteRSR
()
{};
public:
/** Standard class typedefs */
typedef
SatelliteRSR
Self
;
typedef
itk
::
DataObject
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macros */
itkNewMacro
(
Self
)
;
itkTypeMacro
(
SatelliteRSR
,
DataObject
)
;
/** Set the number of band of the satellite from an ASCII file
* Need to parse first all the file to determine the number of columns */
itkGetConstMacro
(
NbBands
,
unsigned
int
)
;
itkSetMacro
(
NbBands
,
unsigned
int
)
;
itkSetMacro
(
SortBands
,
bool
)
;
/** Template parameters typedef */
typedef
TPrecision
PrecisionType
;
typedef
TValuePrecision
ValuePrecisionType
;
typedef
SpectralResponse
<
TPrecision
,
TValuePrecision
>
SpectralResponseType
;
typedef
typename
SpectralResponseType
::
Pointer
SpectralResponsePointerType
;
typedef
std
::
vector
<
SpectralResponsePointerType
>
RSRVectorType
;
typedef
typename
SpectralResponseType
::
VectorPairType
VectorPairType
;
/** Clear the vector data */
virtual
bool
Clear
();
/** Return the number of element in the vector (nb bands) */
virtual
int
Size
()
const
;
/** Fill from a ASCII file (spectral gauge)*/
void
Load
(
const
std
::
string
&
filename
,
ValuePrecisionType
coefNormalization
=
1.0
);
/** Fill from user defined criteria (sampling band from lambdaMin to lambdaMax with Bandwidth width) */
void
Load
(
PrecisionType
lambdaMin
,
PrecisionType
lambdaMax
,
PrecisionType
sampling
,
ValuePrecisionType
coefNormalization
=
1.0
);
/** Compare RSR response (order bands from high to low frequency)*/
struct
sort_band
{
bool
operator
()(
SpectralResponsePointerType
a
,
SpectralResponsePointerType
b
)
{
PrecisionType
aFirstNotNull
;
PrecisionType
bFirstNotNull
;
typename
VectorPairType
::
const_iterator
it
=
a
->
GetResponse
().
begin
();
while
((
*
it
).
second
==
0
)
{
++
it
;
}
aFirstNotNull
=
(
*
it
).
first
;
typename
VectorPairType
::
const_iterator
it2
=
b
->
GetResponse
().
begin
();
while
((
*
it2
).
second
==
0
)
{
++
it2
;
}
bFirstNotNull
=
(
*
it2
).
first
;
return
aFirstNotNull
<
bFirstNotNull
;
}
};
/**
* \param PrecisionType
* \param Band
* \return The interpolate value of the SR for the numBand (band num 0 to band num (m_NbBands-1)).
*/
inline
ValuePrecisionType
operator
()(
const
PrecisionType
&
lambda
,
const
unsigned
int
numBand
);
/** PrintSelf method */
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/** get vector of RSR */
RSRVectorType
&
GetRSR
()
{
return
m_RSR
;
}
protected
:
/** Constructor */
SatelliteRSR
();
/** Constructor from a ASCII file */
//SatelliteRSR( const std::string & filename );
/** Destructor */
virtual
~
SatelliteRSR
()
{
}
;
bool
m_SortBands
;
private
:
SatelliteRSR
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
private
:
SatelliteRSR
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
/** Vector of SpectralResponse */
RSRVectorType
m_RSR
;
/** Number of bands*/
unsigned
int
m_NbBands
;
/** Vector of SpectralResponse */
RSRVectorType
m_RSR
;
/** Number of bands*/
unsigned
int
m_NbBands
;
};
}
// end namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/Simulation/otbSatelliteRSR.txx
+
91
−
106
View file @
e94da76a
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
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.
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 __otbSatelliteRSR_txx
#define __otbSatelliteRSR_txx
#include "otbSatelliteRSR.h"
namespace otb
{
template <class TPrecision, class TValuePrecision>
SatelliteRSR<TPrecision, TValuePrecision>
::SatelliteRSR()
template<class TPrecision, class TValuePrecision>
SatelliteRSR<TPrecision, TValuePrecision>::SatelliteRSR()
{
//m_RSR = VectorType::New();
//m_RSR = VectorType::New();
m_SortBands = true;
}
template <class TPrecision, class TValuePrecision>
void
SatelliteRSR<TPrecision, TValuePrecision>
::Load(const std::string & filename, ValuePrecisionType coefNormalization)
template<class TPrecision, class TValuePrecision>
void SatelliteRSR<TPrecision, TValuePrecision>::Load(const std::string & filename, ValuePrecisionType coefNormalization)
{
//Parse 6S file Reduce spectral response
//Begin by getting the number of band of the satellite
//unsigned int nbBands= this->SetNbBands ( filename );
std::ifstream fin(filename.c_str());
if (
fin.fail()
)
{
itkExceptionMacro(<<"Error opening file" << filename);
}
// For each band
for (unsigned int i
=
0; i < m_NbBands; ++i)
{
//Create a SpectralResponse for the band i
SpectralResponsePointerType RSRBand = SpectralResponseType::New();
m_RSR.push_back
(RSRBand);
}
PrecisionType currentLambda;
PrecisionType zenithalAngle;
while(!
fin.eof()
)
{
//Parse the 6S.txt file
fin >> currentLambda;
fin >> zenithalAngle;
//for each band add a pair of values (wavelength and % response)
for (unsigned int i
=
0; i < m_NbBands; ++i)
//Parse 6S file Reduce spectral response
//Begin by getting the number of band of the satellite
//unsigned int nbBands= this->SetNbBands ( filename );
std::ifstream fin(filename.c_str());
if (fin.fail())
{
itkExceptionMacro(<<"Error opening file" << filename);
}
// For each band
for (unsigned int i
=
0; i < m_NbBands; ++i)
{
//Create a SpectralResponse for the band i
SpectralResponsePointerType RSRBand = SpectralResponseType::New();
m_RSR.push_back(RSRBand);
}
PrecisionType currentLambda;
PrecisionType zenithalAngle;
while
(!fin.eof())
{
//Parse the 6S.txt file
fin >> currentLambda;
fin >> zenithalAngle;
//for each band add a pair of values (wavelength and % response)
for (unsigned int i
=
0; i < m_NbBands; ++i)
{
std::pair
<TPrecision, TValuePrecision
> currentPair;
currentPair.first = currentLambda;
fin >> currentPair.second;
currentPair.second = currentPair.second / coefNormalization;
//Include only non null value //TODO
m_RSR[i]->GetResponse().push_back(currentPair);
std::pair<TPrecision, TValuePrecision> currentPair;
currentPair.first = currentLambda;
fin >> currentPair.second;
currentPair.second = currentPair.second / coefNormalization;
//Include only non null value //TODO
m_RSR[i]->GetResponse().push_back(currentPair);
}
}
fin.close();
if(m_SortBands)
{
//Sort the vector of SpectralResponse (band order by minimum wavelength first not null response
std::sort(m_RSR.begin(), m_RSR.end(), sort_band());
}
}
fin.close();
if
(m_SortBands)
{
//Sort the vector of SpectralResponse (band order by minimum wavelength first not null response
std::sort(m_RSR.begin(), m_RSR.end(), sort_band());
}
}
template <class TPrecision, class TValuePrecision>
void
SatelliteRSR<TPrecision, TValuePrecision>
::Load(PrecisionType lambdaMin, PrecisionType lambdaMax , PrecisionType sampling, ValuePrecisionType coefNormalization )
template<class TPrecision, class TValuePrecision>
void SatelliteRSR<TPrecision, TValuePrecision>::Load(PrecisionType lambdaMin, PrecisionType lambdaMax,
PrecisionType sampling, ValuePrecisionType coefNormalization)
{
m_NbBands = 1;
const double wavelengthPrecision = 0.0025; //in um
...
...
@@ -117,59 +111,50 @@ SatelliteRSR<TPrecision, TValuePrecision>
}
template <class TPrecision, class TValuePrecision>
bool
SatelliteRSR<TPrecision, TValuePrecision>
::Clear()
template<class TPrecision, class TValuePrecision>
bool SatelliteRSR<TPrecision, TValuePrecision>::Clear()
{
m_RSR.clear();
return true;
m_RSR.clear();
return true;
}
template <class TPrecision, class TValuePrecision>
int
SatelliteRSR<TPrecision, TValuePrecision>
::Size() const
template<class TPrecision, class TValuePrecision>
int SatelliteRSR<TPrecision, TValuePrecision>::Size() const
{
return m_RSR.size();
return m_RSR.size();
}
template <class TPrecision, class TValuePrecision>
inline typename SatelliteRSR<TPrecision, TValuePrecision>::ValuePrecisionType
SatelliteRSR<TPrecision, TValuePrecision>
::operator()(const PrecisionType & lambda, const unsigned int numBand)
template<class TPrecision, class TValuePrecision>
inline typename SatelliteRSR<TPrecision, TValuePrecision>::ValuePrecisionType SatelliteRSR<TPrecision, TValuePrecision>::operator()(
const PrecisionType & lambda,
const unsigned int numBand)
{
//Get the response of the band number numBand at the wavelenght lambda
if (
numBand >= m_NbBands
)
{
itkExceptionMacro(<<"There is no band num " << numBand<< " in the RSR vector!(Size of the current RSR vector is " << m_NbBands <<")");
}
else
{
return (*(m_RSR[numBand]))(lambda);
}
//Get the response of the band number numBand at the wavelenght lambda
if (numBand >= m_NbBands)
{
itkExceptionMacro(<<"There is no band num " << numBand<< " in the RSR vector!(Size of the current RSR vector is " << m_NbBands <<")");
}
else
{
return (*(m_RSR[numBand]))(lambda);
}
}
template <class TPrecision, class TValuePrecision>
void
SatelliteRSR<TPrecision, TValuePrecision>
::PrintSelf(std::ostream& os, itk::Indent indent) const
template<class TPrecision, class TValuePrecision>
void SatelliteRSR<TPrecision, TValuePrecision>::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os<<std::endl;
//typename VectorPairType::iterator it = m_RSR.begin();
//it = m_RSR.at(0);
for(typename RSRVectorType::const_iterator it = m_RSR.begin(); it != m_RSR.end(); ++it)
{
os << indent << "Band Number " << it - m_RSR.begin() << std::endl;
(*it)->PrintSelf
(os, indent);
os << std::endl;
}
Superclass::PrintSelf(os, indent);
os
<<
std::endl;
//typename VectorPairType::iterator it = m_RSR.begin();
//it = m_RSR.at(0);
for
(typename RSRVectorType::const_iterator it = m_RSR.begin(); it != m_RSR.end(); ++it)
{
os << indent << "Band Number " << it - m_RSR.begin() << std::endl;
(*it)->PrintSelf(os, indent);
os << std::endl;
}
}
} // end namespace otb
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment