ReFRACtor
stacked_radiance_mixin.cc
Go to the documentation of this file.
2 
3 using namespace FullPhysics;
4 using namespace blitz;
5 
6 const boost::optional<Range> StackedRadianceMixin::stacked_pixel_range(int channel_index) const
7 {
8  range_check(channel_index, 0, num_channels());
9  int sind = 0;
10 
11  for(int i = 0; i < channel_index; ++i) {
12  sind += spectral_domain(i).data().rows();
13  }
14 
15  int nrow = spectral_domain(channel_index).data().rows();
16 
17  if(nrow > 0) {
18  return boost::optional<Range>(Range(sind, sind + nrow - 1));
19  } else {
20  return boost::optional<Range>();
21  }
22 }
23 
24 
26 {
27  std::vector<Spectrum> sall;
28  std::vector<Range> prall;
29 
30  for(int i = 0; i < num_channels(); ++i) {
31  boost::optional<Range> pr = stacked_pixel_range(i);
32 
33  if(pr) {
34  sall.push_back(radiance(i, skip_jacobian));
35  prall.push_back(*pr);
36  }
37  }
38 
39  if(sall.size() == 0) {
40  throw Exception("Measured radiance Spectrum empty, pixel ranges must be empty");
41  }
42 
43  int nrow = 0;
44  int nvar = 0;
45  bool have_uncertainty = true;
46  BOOST_FOREACH(const Spectrum & s, sall) {
47  nrow += s.spectral_domain().data().rows();
48  nvar = std::max(nvar, s.spectral_range().data_ad().number_variable());
49 
50  if(s.spectral_range().uncertainty().rows() == 0) {
51  have_uncertainty = false;
52  }
53  }
54  Unit ud, ur;
55 
56  if(sall.size() > 0) {
57  ud = sall[0].spectral_domain().units();
58  ur = sall[0].spectral_range().units();
59  }
60 
61  ArrayAd<double, 1> sr(nrow, nvar);
62  Array<double, 1> sd(nrow);
63  Array<double, 1> uncer;
64 
65  if(have_uncertainty) {
66  uncer.resize(nrow);
67  }
68 
69  for(int i = 0; i < (int) sall.size(); ++i) {
70  sd(prall[i]) = sall[i].spectral_domain().data() *
71  FullPhysics::conversion(sall[i].spectral_domain().units(), ud);
72  sr.value()(prall[i]) = sall[i].spectral_range().data() *
73  FullPhysics::conversion(sall[i].spectral_range().units(), ur);
74 
75  if(have_uncertainty)
76  uncer(prall[i]) = sall[i].spectral_range().uncertainty() *
77  FullPhysics::conversion(sall[i].spectral_range().units(), ur);
78 
79  if(nvar > 0)
80  sr.jacobian()(prall[i], Range::all()) =
81  sall[i].spectral_range().data_ad().jacobian() *
82  FullPhysics::conversion(sall[i].spectral_range().units(), ur);
83  }
84 
85  return Spectrum(SpectralDomain(sd, ud), SpectralRange(sr, ur, uncer));
86 }
#define range_check(V, Min, Max)
Range check.
Definition: fp_exception.h:140
const Unit s("s", 1.0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0)
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
double conversion(const Unit &Dunit_from, const Unit &Dunit_to)
Return conversion factor to go from one unit to another.
Definition: unit.cc:180
const Unit sr("sr", 1.0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
const SpectralRange & spectral_range() const
Spectral range (e.g, radiance values)
Definition: spectrum.h:39
const blitz::Array< T, D+1 > jacobian() const
Definition: array_ad.h:307
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 blitz::Array< double, 1 > & uncertainty() const
Uncertainty.
virtual const boost::optional< blitz::Range > stacked_pixel_range(int channel_index) const
The range of indicies that corresponds to a particular band in the stacked radiances.
int number_variable() const
Definition: array_ad.h:376
We have a number of different spectrums that appear in different parts of the code.
const ArrayAd< double, 1 > & data_ad() const
Underlying data, possibly with a Jacobian.
virtual Spectrum radiance_all(bool skip_jacobian=false) const
Radiance data all stacked together as one long spectrum (so band 0, followed by band 1...
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
const SpectralDomain & spectral_domain() const
Spectral domain (i.e., wavenumber or wavelength).
Definition: spectrum.h:32
const blitz::Array< double, 1 > & data() const
Return data.

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