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
Program: ORFEO Toolbox
Language: C++
Language: C++
Date: $Date$
Date: $Date$
Version: $Revision$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
=========================================================================*/
#ifndef __otbSatelliteRSR_h
#ifndef __otbSatelliteRSR_h
#define __otbSatelliteRSR_h
#define __otbSatelliteRSR_h
#include
"itkDataObject.h"
#include
"itkDataObject.h"
#include
<itkObjectFactory.h>
#include
<itkObjectFactory.h>
#include
<vector>
#include
<vector>
...
@@ -31,122 +30,129 @@
...
@@ -31,122 +30,129 @@
namespace
otb
namespace
otb
{
{
/** \class SatelliteRSR
/** \class SatelliteRSR
* \brief This class represents a hierarchy of vector data.
* \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).
* This class contains an std::vector of spectral response, class otb::SpectralResponse (one for each band of the satellite).
*
*
*
*
* The two templates indicate:
* The two templates indicate:
* - the precision of the wavelength (X) (by default: double)
* - the precision of the wavelength (X) (by default: double)
* - the precision of the gain associated to the wavelength (Y) (by default: double)
* - the precision of the gain associated to the wavelength (Y) (by default: double)
* \sa SpectralResponse
* \sa SpectralResponse
* \sa itk::DataObject
* \sa itk::DataObject
*/
*/
template
<
class
TPrecision
=
double
,
class
TValuePrecision
=
double
>
template
<
class
TPrecision
=
double
,
class
TValuePrecision
=
double
>
class
SatelliteRSR
:
public
itk
::
DataObject
class
SatelliteRSR
:
public
itk
::
DataObject
{
{
public:
public:
/** Standard class typedefs */
/** Standard class typedefs */
typedef
SatelliteRSR
Self
;
typedef
SatelliteRSR
Self
;
typedef
itk
::
DataObject
Superclass
;
typedef
itk
::
DataObject
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macros */
/** Standard macros */
itkNewMacro
(
Self
);
itkNewMacro
(
Self
)
itkTypeMacro
(
SatelliteRSR
,
DataObject
);
;
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 */
/** Set the number of band of the satellite from an ASCII file
itkGetConstMacro
(
NbBands
,
unsigned
int
);
* Need to parse first all the file to determine the number of columns */
itkSetMacro
(
NbBands
,
unsigned
int
);
itkGetConstMacro
(
NbBands
,
unsigned
int
)
;
itkSetMacro
(
NbBands
,
unsigned
int
)
itkSetMacro
(
SortBands
,
bool
);
;
/** Template parameters typedef */
itkSetMacro
(
SortBands
,
bool
)
typedef
TPrecision
PrecisionType
;
;
typedef
TValuePrecision
ValuePrecisionType
;
/** Template parameters typedef */
typedef
SpectralResponse
<
TPrecision
,
TValuePrecision
>
SpectralResponseType
;
typedef
TPrecision
PrecisionType
;
typedef
typename
SpectralResponseType
::
Pointer
SpectralResponsePointerType
;
typedef
TValuePrecision
ValuePrecisionType
;
typedef
std
::
vector
<
SpectralResponsePointerType
>
RSRVectorType
;
typedef
typename
SpectralResponseType
::
VectorPairType
VectorPairType
;
typedef
SpectralResponse
<
TPrecision
,
TValuePrecision
>
SpectralResponseType
;
typedef
typename
SpectralResponseType
::
Pointer
SpectralResponsePointerType
;
/** Clear the vector data */
typedef
std
::
vector
<
SpectralResponsePointerType
>
RSRVectorType
;
virtual
bool
Clear
();
typedef
typename
SpectralResponseType
::
VectorPairType
VectorPairType
;
/** Return the number of element in the vector (nb bands) */
/** Clear the vector data */
virtual
int
Size
()
const
;
virtual
bool
Clear
();
/** Fill from a ASCII file (spectral gauge)*/
/** Return the number of element in the vector (nb bands) */
void
Load
(
const
std
::
string
&
filename
,
ValuePrecisionType
coefNormalization
=
1.0
);
virtual
int
Size
()
const
;
/** Fill from user defined criteria (sampling band from lambdaMin to lambdaMax with Bandwidth width) */
/** Fill from a ASCII file (spectral gauge)*/
void
Load
(
PrecisionType
lambdaMin
,
PrecisionType
lambdaMax
,
PrecisionType
sampling
,
ValuePrecisionType
coefNormalization
=
1.0
);
void
Load
(
const
std
::
string
&
filename
,
ValuePrecisionType
coefNormalization
=
1.0
);
/** Fill from user defined criteria (sampling band from lambdaMin to lambdaMax with Bandwidth width) */
/** Compare RSR response (order bands from high to low frequency)*/
void
Load
(
PrecisionType
lambdaMin
,
PrecisionType
lambdaMax
,
PrecisionType
sampling
,
struct
sort_band
{
ValuePrecisionType
coefNormalization
=
1.0
);
bool
operator
()
(
SpectralResponsePointerType
a
,
SpectralResponsePointerType
b
)
{
/** Compare RSR response (order bands from high to low frequency)*/
PrecisionType
aFirstNotNull
;
struct
sort_band
PrecisionType
bFirstNotNull
;
{
bool
operator
()(
SpectralResponsePointerType
a
,
SpectralResponsePointerType
b
)
typename
VectorPairType
::
const_iterator
it
=
a
->
GetResponse
().
begin
();
{
PrecisionType
aFirstNotNull
;
while
((
*
it
).
second
==
0
)
PrecisionType
bFirstNotNull
;
{
++
it
;
typename
VectorPairType
::
const_iterator
it
=
a
->
GetResponse
().
begin
();
}
aFirstNotNull
=
(
*
it
).
first
;
while
((
*
it
).
second
==
0
)
{
typename
VectorPairType
::
const_iterator
it2
=
b
->
GetResponse
().
begin
();
++
it
;
}
while
((
*
it2
).
second
==
0
)
aFirstNotNull
=
(
*
it
).
first
;
{
++
it2
;
typename
VectorPairType
::
const_iterator
it2
=
b
->
GetResponse
().
begin
();
}
bFirstNotNull
=
(
*
it2
).
first
;
while
((
*
it2
).
second
==
0
)
{
return
aFirstNotNull
<
bFirstNotNull
;
++
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
);
* \param PrecisionType
* \param Band
/** PrintSelf method */
* \return The interpolate value of the SR for the numBand (band num 0 to band num (m_NbBands-1)).
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
*/
inline
ValuePrecisionType
operator
()(
const
PrecisionType
&
lambda
,
const
unsigned
int
numBand
);
/** get vector of RSR */
RSRVectorType
&
GetRSR
()
/** PrintSelf method */
{
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
return
m_RSR
;
}
/** get vector of RSR */
RSRVectorType
&
GetRSR
()
protected
:
{
/** Constructor */
return
m_RSR
;
SatelliteRSR
();
}
/** Constructor from a ASCII file */
//SatelliteRSR( const std::string & filename );
protected
:
/** Destructor */
/** Constructor */
virtual
~
SatelliteRSR
()
{};
SatelliteRSR
();
/** Constructor from a ASCII file */
//SatelliteRSR( const std::string & filename );
/** Destructor */
virtual
~
SatelliteRSR
()
{
}
;
bool
m_SortBands
;
bool
m_SortBands
;
private
:
private
:
SatelliteRSR
(
const
Self
&
);
//purposely not implemented
SatelliteRSR
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
/** Vector of SpectralResponse */
/** Vector of SpectralResponse */
RSRVectorType
m_RSR
;
RSRVectorType
m_RSR
;
/** Number of bands*/
/** Number of bands*/
unsigned
int
m_NbBands
;
unsigned
int
m_NbBands
;
};
};
}
// end namespace otb
}
// end namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/Simulation/otbSatelliteRSR.txx
+
91
−
106
View file @
e94da76a
/*=========================================================================
/*=========================================================================
Program: ORFEO Toolbox
Program: ORFEO Toolbox
Language: C++
Language: C++
Date: $Date$
Date: $Date$
Version: $Revision$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
=========================================================================*/
#ifndef __otbSatelliteRSR_txx
#ifndef __otbSatelliteRSR_txx
#define __otbSatelliteRSR_txx
#define __otbSatelliteRSR_txx
#include "otbSatelliteRSR.h"
#include "otbSatelliteRSR.h"
namespace otb
namespace otb
{
{
template <class TPrecision, class TValuePrecision>
template<class TPrecision, class TValuePrecision>
SatelliteRSR<TPrecision, TValuePrecision>
SatelliteRSR<TPrecision, TValuePrecision>::SatelliteRSR()
::SatelliteRSR()
{
{
//m_RSR = VectorType::New();
//m_RSR = VectorType::New();
m_SortBands = true;
m_SortBands = true;
}
}
template<class TPrecision, class TValuePrecision>
template <class TPrecision, class TValuePrecision>
void SatelliteRSR<TPrecision, TValuePrecision>::Load(const std::string & filename, ValuePrecisionType coefNormalization)
void
SatelliteRSR<TPrecision, TValuePrecision>
::Load(const std::string & filename, ValuePrecisionType coefNormalization)
{
{
//Parse 6S file Reduce spectral response
//Parse 6S file Reduce spectral response
//Begin by getting the number of band of the satellite
//Begin by getting the number of band of the satellite
//unsigned int nbBands= this->SetNbBands ( filename );
//unsigned int nbBands= this->SetNbBands ( filename );
std::ifstream fin(filename.c_str());
std::ifstream fin(filename.c_str());
if (
fin.fail()
)
if (fin.fail())
{
{
itkExceptionMacro(<<"Error opening file" << filename);
itkExceptionMacro(<<"Error opening file" << filename);
}
}
// For each band
// For each band
for (unsigned int i
=
0; i < m_NbBands; ++i)
for (unsigned int i
=
0; i < m_NbBands; ++i)
{
{
//Create a SpectralResponse for the band i
//Create a SpectralResponse for the band i
SpectralResponsePointerType RSRBand = SpectralResponseType::New();
SpectralResponsePointerType RSRBand = SpectralResponseType::New();
m_RSR.push_back
(RSRBand);
m_RSR.push_back(RSRBand);
}
}
PrecisionType currentLambda;
PrecisionType currentLambda;
PrecisionType zenithalAngle;
PrecisionType zenithalAngle;
while(!
fin.eof()
)
while
(!fin.eof())
{
{
//Parse the 6S.txt file
//Parse the 6S.txt file
fin >> currentLambda;
fin >> currentLambda;
fin >> zenithalAngle;
fin >> zenithalAngle;
//for each band add a pair of values (wavelength and % response)
//for each band add a pair of values (wavelength and % response)
for (unsigned int i
=
0; i < m_NbBands; ++i)
for (unsigned int i
=
0; i < m_NbBands; ++i)
{
{
std::pair
<TPrecision, TValuePrecision
> currentPair;
std::pair<TPrecision, TValuePrecision> currentPair;
currentPair.first = currentLambda;
currentPair.first = currentLambda;
fin >> currentPair.second;
fin >> currentPair.second;
currentPair.second = currentPair.second / coefNormalization;
currentPair.second = currentPair.second / coefNormalization;
//Include only non null value //TODO
//Include only non null value //TODO
m_RSR[i]->GetResponse().push_back(currentPair);
m_RSR[i]->GetResponse().push_back(currentPair);
}
}
}
}
fin.close();
fin.close();
if(m_SortBands)
if
(m_SortBands)
{
{
//Sort the vector of SpectralResponse (band order by minimum wavelength first not null response
//Sort the vector of SpectralResponse (band order by minimum wavelength first not null response
std::sort(m_RSR.begin(), m_RSR.end(), sort_band());
std::sort(m_RSR.begin(), m_RSR.end(), sort_band());
}
}
}
}
template <class TPrecision, class TValuePrecision>
template<class TPrecision, class TValuePrecision>
void
void SatelliteRSR<TPrecision, TValuePrecision>::Load(PrecisionType lambdaMin, PrecisionType lambdaMax,
SatelliteRSR<TPrecision, TValuePrecision>
PrecisionType sampling, ValuePrecisionType coefNormalization)
::Load(PrecisionType lambdaMin, PrecisionType lambdaMax , PrecisionType sampling, ValuePrecisionType coefNormalization )
{
{
m_NbBands = 1;
m_NbBands = 1;
const double wavelengthPrecision = 0.0025; //in um
const double wavelengthPrecision = 0.0025; //in um
...
@@ -117,59 +111,50 @@ SatelliteRSR<TPrecision, TValuePrecision>
...
@@ -117,59 +111,50 @@ SatelliteRSR<TPrecision, TValuePrecision>
}
}
template<class TPrecision, class TValuePrecision>
template <class TPrecision, class TValuePrecision>
bool SatelliteRSR<TPrecision, TValuePrecision>::Clear()
bool
SatelliteRSR<TPrecision, TValuePrecision>
::Clear()
{
{
m_RSR.clear();
m_RSR.clear();
return true;
return true;
}
}
template <class TPrecision, class TValuePrecision>
template<class TPrecision, class TValuePrecision>
int
int SatelliteRSR<TPrecision, TValuePrecision>::Size() const
SatelliteRSR<TPrecision, TValuePrecision>
::Size() const
{
{
return m_RSR.size();
return m_RSR.size();
}
}
template<class TPrecision, class TValuePrecision>
template <class TPrecision, class TValuePrecision>
inline typename SatelliteRSR<TPrecision, TValuePrecision>::ValuePrecisionType SatelliteRSR<TPrecision, TValuePrecision>::operator()(
inline typename SatelliteRSR<TPrecision, TValuePrecision>::ValuePrecisionType
const PrecisionType & lambda,
SatelliteRSR<TPrecision, TValuePrecision>
const unsigned int numBand)
::operator()(const PrecisionType & lambda, const unsigned int numBand)
{
{
//Get the response of the band number numBand at the wavelenght lambda
//Get the response of the band number numBand at the wavelenght lambda
if (
numBand >= m_NbBands
)
if (numBand >= m_NbBands)
{
{
itkExceptionMacro(<<"There is no band num " << numBand<< " in the RSR vector!(Size of the current RSR vector is " << m_NbBands <<")");
itkExceptionMacro(<<"There is no band num " << numBand<< " in the RSR vector!(Size of the current RSR vector is " << m_NbBands <<")");
}
}
else
else
{
{
return (*(m_RSR[numBand]))(lambda);
return (*(m_RSR[numBand]))(lambda);
}
}
}
}
template<class TPrecision, class TValuePrecision>
template <class TPrecision, class TValuePrecision>
void SatelliteRSR<TPrecision, TValuePrecision>::PrintSelf(std::ostream& os, itk::Indent indent) const
void
SatelliteRSR<TPrecision, TValuePrecision>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
{
Superclass::PrintSelf(os, indent);
Superclass::PrintSelf(os, indent);
os<<std::endl;
os
<<
std::endl;
//typename VectorPairType::iterator it = m_RSR.begin();
//typename VectorPairType::iterator it = m_RSR.begin();
//it = m_RSR.at(0);
//it = m_RSR.at(0);
for(typename RSRVectorType::const_iterator it = m_RSR.begin(); it != m_RSR.end(); ++it)
for
(typename RSRVectorType::const_iterator it = m_RSR.begin(); it != m_RSR.end(); ++it)
{
{
os << indent << "Band Number " << it - m_RSR.begin() << std::endl;
os << indent << "Band Number " << it - m_RSR.begin() << std::endl;
(*it)->PrintSelf
(os, indent);
(*it)->PrintSelf(os, indent);
os << std::endl;
os << std::endl;
}
}
}
}
} // end namespace otb
} // 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