ReFRACtor
forward_model_spectral_grid.cc
Go to the documentation of this file.
2 #include "linear_interpolate.h"
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 #ifdef HAVE_LUA
8 #include "register_lua.h"
11 #endif
12 
13 //-----------------------------------------------------------------------
15 //-----------------------------------------------------------------------
16 
18  {
19  range_check(Spec_index, 0, number_spectrometer());
20 
21  std::vector<int> plist = pixel_list(Spec_index);
22  if (plist.size() > 0) {
23  return spectral_window->apply(inst->pixel_spectral_domain(Spec_index), Spec_index);
24  } else {
25  return SpectralDomain(blitz::Array<double, 1>(0));
26  }
27  }
28 
29 //-----------------------------------------------------------------------
31 //-----------------------------------------------------------------------
32 
34  {
35  range_check(Spec_index, 0, number_spectrometer());
36 
37  std::vector<int> plist = pixel_list(Spec_index);
38  if (plist.size() > 0) {
39  return spectrum_sampling->spectral_domain(Spec_index, low_resolution_grid(Spec_index), inst->ils_half_width(Spec_index));
40  } else {
41  return SpectralDomain(blitz::Array<double, 1>(0));
42  }
43  }
44 
45 //-----------------------------------------------------------------------
47 //-----------------------------------------------------------------------
48 
50  {
51  range_check(Spec_index, 0, number_spectrometer());
52 
53  std::vector<int> plist = pixel_list(Spec_index);
54  if (plist.size() > 0) {
55  return spectrum_sampling->spectral_domain_interpolated(Spec_index, low_resolution_grid(Spec_index), inst->ils_half_width(Spec_index));
56  } else {
57  return SpectralDomain(blitz::Array<double, 1>(0));
58  }
59  }
60 
61 //-----------------------------------------------------------------------
63 //-----------------------------------------------------------------------
64  const std::vector<int> ForwardModelSpectralGrid::pixel_list(int Spec_index) const
65  {
66  range_check(Spec_index, 0, number_spectrometer());
67  return spectral_window->grid_indexes(inst->pixel_spectral_domain(Spec_index), Spec_index);
68  }
69 
70 //-----------------------------------------------------------------------
73 //-----------------------------------------------------------------------
75 (const Spectrum& Spec_in, int Spec_index) const
76 {
77  range_check(Spec_index, 0, number_spectrometer());
78  if(!spectrum_sampling->need_interpolation(Spec_index))
79  return Spec_in;
80  Range ra(Range::all());
81  SpectralDomain hgrid_inter = high_resolution_interpolated_grid(Spec_index);
82  ArrayAd<double, 1> res(hgrid_inter.data().rows(),
83  Spec_in.spectral_range().data_ad().number_variable());
84  Array<double, 1> spec_in_dom = Spec_in.spectral_domain().data();
85  Array<double, 1> ispec_dom =
86  hgrid_inter.convert_wave(Spec_in.spectral_domain().units());
88  interp(spec_in_dom.begin(),
89  spec_in_dom.end(),
90  Spec_in.spectral_range().data().begin(),
92  for(int i = 0; i< ispec_dom.rows(); ++i)
93  res.value()(i) = interp(ispec_dom(i));
94  if(res.number_variable() > 0) {
95  std::vector<Array<double, 1> > yvec;
96  for(int i = 0; i< spec_in_dom.rows(); ++i)
97  yvec.push_back(Spec_in.spectral_range().data_ad().jacobian()(i, ra));
99  jacinterp(spec_in_dom.begin(), spec_in_dom.end(),
100  yvec.begin(),
101  LinearInterpolate<double, Array<double, 1> >::OUT_OF_RANGE_ERROR);
102  for(int i = 0; i< ispec_dom.rows(); ++i)
103  res.jacobian()(i,ra) = jacinterp(ispec_dom(i));
104  }
105  return Spectrum(hgrid_inter.clone(),
106  SpectralRange(res, Spec_in.spectral_range().units()));
107 }
#define range_check(V, Min, Max)
Range check.
Definition: fp_exception.h:140
const SpectralDomain high_resolution_grid(int Spec_index) const
The high resolution grid, possibly nonuniform.
const SpectralDomain high_resolution_interpolated_grid(int Spec_index) const
The high resolution grid, interpolated to be uniform.
const std::vector< int > pixel_list(int Spec_index) const
Pixel indexes to use for low resolution grid.
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
const SpectralDomain clone() const
Clones object into a new copy.
This is the Forward Model spectral grid.
Spectrum interpolate_spectrum(const Spectrum &Spec_in, int Spec_index) const
Interpolate a spectrum to the high_resolution_interpolated_grid() sampling.
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
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
Apply value function to a blitz array.
const Unit & units() const
Units of data.
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
Definition: spectrum.h:18
blitz::Array< double, 1 > convert_wave(const Unit &Units) const
Return data as the supplied the units.
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.
const Unit units() const
Units that go with data()
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
#define REGISTER_LUA_END()
Definition: register_lua.h:134
const SpectralDomain & spectral_domain() const
Spectral domain (i.e., wavenumber or wavelength).
Definition: spectrum.h:32
const SpectralDomain low_resolution_grid(int Spec_index) const
The low resolution grid.
const blitz::Array< double, 1 > & data() const
Underlying data.
const blitz::Array< double, 1 > & data() const
Return data.
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