ReFRACtor
spectral_bound.cc
Go to the documentation of this file.
1 #include "spectral_bound.h"
2 using namespace FullPhysics;
3 
4 #ifdef HAVE_LUA
5 #include "register_lua.h"
6 typedef DoubleWithUnit (SpectralBound::*bfunc)(int) const;
8 .def("number_spectrometer", &SpectralBound::number_spectrometer)
9 .def("lower_bound", ((bfunc) &SpectralBound::lower_bound))
10 .def("upper_bound", ((bfunc) &SpectralBound::upper_bound))
12 #endif
13 
14 //-----------------------------------------------------------------------
16 //-----------------------------------------------------------------------
17 
19 (const std::vector<DoubleWithUnit>& Lower_bound,
20  const std::vector<DoubleWithUnit>& Upper_bound
21  )
22 :lower_b(Lower_bound), upper_b(Upper_bound)
23 {
24  if(lower_b.size() != upper_b.size())
25  throw Exception("Lower bound and upper bound need to be the same size");
26  for(std::vector<DoubleWithUnit>::size_type i = 0;
27  i < lower_b.size(); ++i)
28  if(lower_b[i].value > upper_b[i].convert_wave(lower_b[i].units).value)
29  throw Exception("Lower bound needs to be less than upper bound");
30 }
31 
32 //-----------------------------------------------------------------------
34 //-----------------------------------------------------------------------
35 
37 {
38  if(Bound.cols() != 2)
39  throw Exception("Bound must have cols of 2");
40  for(int i = 0; i < Bound.rows(); ++i) {
41  if(Bound(i, 0).value > Bound(i, 1).value)
42  throw Exception("Lower bound needs to be less than upper bound");
43  lower_b.push_back(Bound(i, 0));
44  upper_b.push_back(Bound(i, 1));
45  }
46 }
47 
48 //-----------------------------------------------------------------------
51 //-----------------------------------------------------------------------
52 
54 {
55  for(int i = 0; i < number_spectrometer(); ++i)
56  if(W.value >= lower_bound(i, W.units).value &&
57  W.value < upper_bound(i, W.units).value)
58  return i;
59  return -1;
60 }
61 
62 void SpectralBound::print(std::ostream& Os) const
63 {
64  Os << "SpectralBound:\n"
65  << " Number spectrometer: " << number_spectrometer() << "\n";
66  for(int i = 0; i < number_spectrometer(); ++i)
67  Os << " [" << i << "]: (" << lower_b[i] << ", "
68  << upper_b[i] << ")\n";
69 }
SpectralBound()
Default constructor.
We frequently have a array of numbers with units associated with them.
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
blitz::Array< T, D > value
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
DoubleWithUnit lower_bound(int Spec_index) const
Lower bound of window slot.
int spectral_index(const DoubleWithUnit &W) const
Determine spectral index for given wavenumber/wavelength, or return -1 if it doesn&#39;t fit in any spect...
This gives the upper and lower bounds of the SpectralWindow.
We frequently have a double with units associated with it.
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
int number_spectrometer() const
Number of spectrometers.
double value(const FullPhysics::AutoDerivative< double > &Ad)
virtual void print(std::ostream &Os) const
const Unit W("W", J/s)
DoubleWithUnit upper_bound(int Spec_index) const
Upper bound of window slot.

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