Orfeo ToolBox  4.2
Orfeo ToolBox is not a black box
otbAtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
19 #include "otbSIXSTraits.h"
20 
21 namespace otb
22 {
29 {
30  this->ProcessObject::SetNumberOfRequiredInputs(1);
31  this->ProcessObject::SetNumberOfRequiredOutputs(1);
32  // Create the output. We use static_cast<> here because we know the default
33  // output must be of type TOutputPointSet
35  = static_cast<AtmosphericRadiativeTermsType*>(this->MakeOutput(0).GetPointer());
36 
37  this->ProcessObject::SetNthOutput(0, output.GetPointer());
38 
39 }
43 AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms::DataObjectPointer
45 ::MakeOutput(unsigned int)
46 {
47  return static_cast<itk::DataObject*>(AtmosphericRadiativeTermsType::New().GetPointer());
48 }
49 
53 void
56 {
57  this->GraftNthOutput(0, graft);
58 }
59 
63 void
65 ::GraftNthOutput(unsigned int idx, itk::DataObject *graft)
66 {
67  if (idx >= this->GetNumberOfOutputs())
68  {
69  itkExceptionMacro(<< "Requested to graft output " << idx <<
70  " but this filter only has " << this->GetNumberOfOutputs() << " Outputs.");
71  }
72 
73  if (!graft)
74  {
75  itkExceptionMacro(<< "Requested to graft output that is a NULL pointer");
76  }
77 
78  itk::DataObject * output = this->GetOutput(idx);
79 
80  // Call Graft on the PointSet in order to copy meta-information, and containers.
81  output->Graft(graft);
82 }
83 
92 {
93  if (this->GetNumberOfOutputs() < 1)
94  {
95  return 0;
96  }
97  return static_cast<AtmosphericRadiativeTermsType *> (this->ProcessObject::GetOutput(0));
98 }
99 
105 ::GetOutput(unsigned int idx)
106 {
107  return static_cast<AtmosphericRadiativeTermsType*>
108  (this->itk::ProcessObject::GetOutput(idx));
109 }
110 
111 void
114 {
115  // A single input image
116  this->itk::ProcessObject::SetNthInput(0, const_cast<AtmosphericCorrectionParametersType*>(object));
117 }
118 
122 {
123  // If there is no input
124  if (this->GetNumberOfInputs() != 1)
125  {
126  // exit
127  return 0;
128  }
129  // else return the first input
130  return static_cast<AtmosphericCorrectionParametersType *>
131  (this->itk::ProcessObject::GetInput(0));
132 }
133 
134 void
137 {
138  itkExceptionMacro("This class is not compatible with the new radiometry"
139  " framework. It is kept in the sources for documentation purpose. Check"
140  " Example/Radiometry/AtmosphericCorrectionSequencement.cxx for details"
141  " on the new framework");
142 #if 0
143  AtmosphericCorrectionParametersPointer input = this->GetInput();
144  AtmosphericRadiativeTermsPointer output = this->GetOutput();
145 
146  output->GetValues().clear();
147  typedef AtmosphericCorrectionParameters::WavelengthSpectralBandVectorType WavelengthSpectralBandVectorType;
148  WavelengthSpectralBandVectorType WavelengthSpectralBandVector = input->GetWavelengthSpectralBand();
149  unsigned int NbBand = WavelengthSpectralBandVector->Size();
150 
151  double atmosphericReflectance(0.);
152  double atmosphericSphericalAlbedo(0.);
153  double totalGaseousTransmission(0.);
154  double downwardTransmittance(0.);
155  double upwardTransmittance(0.);
156  double upwardDiffuseTransmittance(0.);
157  double upwardDirectTransmittance(0.);
158  double upwardDiffuseTransmittanceForRayleigh(0.);
159  double upwardDiffuseTransmittanceForAerosol(0.);
160 
161  for (unsigned int i = 0; i < NbBand; ++i)
162  {
163  atmosphericReflectance = 0.;
164  atmosphericSphericalAlbedo = 0.;
165  totalGaseousTransmission = 0.;
166  downwardTransmittance = 0.;
167  upwardTransmittance = 0.;
168  upwardDiffuseTransmittance = 0.;
169  upwardDirectTransmittance = 0.;
170  upwardDiffuseTransmittanceForRayleigh = 0.;
171  upwardDiffuseTransmittanceForAerosol = 0.;
173  input->GetSolarZenithalAngle(),
174  input->GetSolarAzimutalAngle(),
175  input->GetViewingZenithalAngle(),
176  input->GetViewingAzimutalAngle(),
177  input->GetMonth(),
178  input->GetDay(),
179  input->GetAtmosphericPressure(),
180  input->GetWaterVaporAmount(),
181  input->GetOzoneAmount(),
182  input->GetAerosolModel(),
183  input->GetAerosolOptical(),
184  input->GetWavelengthSpectralBand()->GetNthElement(i),
186  atmosphericReflectance,
187  atmosphericSphericalAlbedo,
188  totalGaseousTransmission,
189  downwardTransmittance,
190  upwardTransmittance,
191  upwardDiffuseTransmittance,
192  upwardDirectTransmittance,
193  upwardDiffuseTransmittanceForRayleigh,
194  upwardDiffuseTransmittanceForAerosol
195  );
196 
197  output->SetIntrinsicAtmosphericReflectance(i, atmosphericReflectance);
198  output->SetSphericalAlbedo(i, atmosphericSphericalAlbedo);
199  output->SetTotalGaseousTransmission(i, totalGaseousTransmission);
200  output->SetDownwardTransmittance(i, downwardTransmittance);
201  output->SetUpwardTransmittance(i, upwardTransmittance);
202  output->SetUpwardDiffuseTransmittance(i, upwardDiffuseTransmittance);
203  output->SetUpwardDirectTransmittance(i, upwardDirectTransmittance);
204  output->SetUpwardDiffuseTransmittanceForRayleigh(i, upwardDiffuseTransmittanceForRayleigh);
205  output->SetUpwardDiffuseTransmittanceForAerosol(i, upwardDiffuseTransmittanceForAerosol);
206  output->SetWavelengthSpectralBand(i, input->GetWavelengthSpectralBand()->GetNthElement(i)->GetCenterSpectralValue());
207  }
208 #endif
209 }
210 
214 void
216 ::PrintSelf(std::ostream& os, itk::Indent indent) const
217 {
218  Superclass::PrintSelf(os, indent);
219 }
220 
221 } // end namespace otb
This class contains all atmospheric correction parameters.
ObjectType * GetPointer() const
This class is a vector of AtmosphericRadiativeTermsSingleChannel, it contains all atmospheric radiati...
static void ComputeAtmosphericParameters(const double SolarZenithalAngle, const double SolarAzimutalAngle, const double ViewingZenithalAngle, const double ViewingAzimutalAngle, const unsigned int Month, const unsigned int Day, const double AtmosphericPressure, const double WaterVaporAmount, const double OzoneAmount, const AerosolModelType &AerosolModel, const double AerosolOptical, WavelengthSpectralType *WavelengthSpectralBand, double &AtmosphericReflectance, double &AtmosphericSphericalAlbedo, double &TotalGaseousTransmission, double &DownwardTransmittance, double &UpwardTransmittance, double &UpwardDiffuseTransmittance, double &UpwardDirectTransmittance, double &UpwardDiffuseTransmittanceForRayleigh, double &UpwardDiffuseTransmittanceForAerosol)