ReFRACtor
radiative_transfer_fixed_stokes_coefficient.cc
Go to the documentation of this file.
2 #include "fp_exception.h"
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 static const char* stoke_names[] = {"I", "Q", "U", "V"};
8 static const int max_num_stokes = 4;
9 
10 // See base class for description.
12 (const SpectralDomain& Spec_domain, int Spec_index, bool Skip_jacobian) const
13 {
14  firstIndex i1; secondIndex i2; thirdIndex i3;
15  range_check(Spec_index, 0, number_spectrometer());
17  if(Skip_jacobian)
18  stk.reference(ArrayAd<double, 2>(stokes(Spec_domain, Spec_index)));
19  else
20  stk.reference(stokes_and_jacobian(Spec_domain, Spec_index));
21 
22  // Send out update to Observers with spectrum index and stokes
23  // values in case these need to be recorded, wraps them
24  // as Spectrum for convenience and to package up any info needed
25  // Only does this if any observers are registered
26  if (olist.size() > 0) {
27  std::vector<boost::shared_ptr<NamedSpectrum> > stoke_spectrums;
28  for(int stokes_idx = 0; stokes_idx < min(stk.value().cols(), max_num_stokes); stokes_idx++) {
29  Array<double, 1> stoke_val(stk.value()(Range::all(), stokes_idx));
30  Array<double, 2> stoke_jac(stk.jacobian()(Range::all(), stokes_idx, Range::all()));
31  SpectralRange stoke_range(ArrayAd<double, 1>(stoke_val, stoke_jac), units::inv_sr);
32  boost::shared_ptr<NamedSpectrum> stoke_ptr(new NamedSpectrum(Spec_domain, stoke_range, "stokes_" + std::string(stoke_names[stokes_idx]), Spec_index));
33  stoke_spectrums.push_back(stoke_ptr);
34  }
35  const_cast<RadiativeTransferFixedStokesCoefficient *>(this)->notify_update_do(stoke_spectrums);
36  }
37 
38  ArrayAd<double, 1> res(stk.rows(), stk.number_variable());
39  Array<double, 1> stokes_coef_sub(stokes_coef->stokes_coefficient().value()(Spec_index, Range(0, number_stokes() - 1)));
40  res.value() = sum(stk.value()(i1, i2) * stokes_coef_sub(i2), i2);
41  if(!res.is_constant()) {
42  if(!stokes_coef->stokes_coefficient().is_constant()) {
43  Array<double, 2> stokes_coef_jac_sub(stokes_coef->stokes_coefficient().jacobian()(Spec_index, Range(0, number_stokes() - 1), Range::all()));
44  res.jacobian() =
45  sum(stk.jacobian()(i1, i3, i2) * stokes_coef_sub(i3), i3) +
46  sum(stk.value()(i1, i3) * stokes_coef_jac_sub(i3, i2), i3);
47  } else
48  res.jacobian() =
49  sum(stk.jacobian()(i1, i3, i2) * stokes_coef_sub(i3), i3);
50  } else if(!stokes_coef->stokes_coefficient().is_constant()) {
51  Array<double, 2> stokes_coef_jac_sub(stokes_coef->stokes_coefficient().jacobian()(Spec_index, Range(0, number_stokes() - 1), Range::all()));
52  res.jacobian() =
53  sum(stk.value()(i1, i3) * stokes_coef_jac_sub(i3, i2), i3);
54  }
55  return Spectrum(Spec_domain, SpectralRange(res, units::inv_sr));
56 }
57 
58 
#define range_check(V, Min, Max)
Range check.
Definition: fp_exception.h:140
virtual Spectrum reflectance(const SpectralDomain &Spec_domain, int Spec_index, bool Skip_jacobian=false) const
Calculate reflectance for the given set of wavenumbers/wavelengths.
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
const blitz::Array< T, D+1 > jacobian() const
Definition: array_ad.h:307
Adds name and spec index fields to a Spectrum.
Apply value function to a blitz array.
const blitz::Array< T, D > & value() const
Definition: array_ad.h:306
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
Definition: spectrum.h:18
const Unit inv_sr("sr^-1", pow(sr, -1))
int number_variable() const
Definition: array_ad.h:376
We have a number of different spectrums that appear in different parts of the code.
void reference(const ArrayAd< T, D > &V)
Definition: array_ad.h:372
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
For GOSAT and OCO, we have a set of stokes coefficients to go from Stokes vector to radiation...
int rows() const
Definition: array_ad.h:368

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:10