ReFRACtor
spectral_bound.h
Go to the documentation of this file.
1 #ifndef SPECTRAL_BOUND_H
2 #define SPECTRAL_BOUND_H
3 #include "printable.h"
4 #include <vector>
5 #include "fp_exception.h"
6 #include "double_with_unit.h"
7 #include "array_with_unit.h"
8 
9 namespace FullPhysics {
10 /****************************************************************/
25 class SpectralBound : public Printable<SpectralBound> {
26 public:
27 //-----------------------------------------------------------------------
29 //-----------------------------------------------------------------------
30 
32 
33  SpectralBound(const std::vector<DoubleWithUnit>& Lower_bound,
34  const std::vector<DoubleWithUnit>& Upper_bound);
36  virtual ~SpectralBound() {}
37 
38 //-----------------------------------------------------------------------
40 //-----------------------------------------------------------------------
41 
42  int number_spectrometer() const { return (int) lower_b.size(); }
43 
44 //-----------------------------------------------------------------------
47 //-----------------------------------------------------------------------
48 
49  DoubleWithUnit center(int Spec_index, const Unit& U) const
50  {
51  return ((lower_bound(Spec_index) + upper_bound(Spec_index)) / 2.0).
52  convert_wave(U);
53  }
54 
55 //-----------------------------------------------------------------------
57 //-----------------------------------------------------------------------
58 
59  DoubleWithUnit lower_bound(int Spec_index) const
60  {
61  range_check(Spec_index, 0, number_spectrometer());
62  return lower_b[Spec_index];
63  }
64 
65 //-----------------------------------------------------------------------
68 //-----------------------------------------------------------------------
69 
70  DoubleWithUnit lower_bound(int Spec_index, const Unit& U) const
71  {
72  range_check(Spec_index, 0, number_spectrometer());
73  return DoubleWithUnit(std::min(upper_b[Spec_index].convert_wave(U).value,
74  lower_b[Spec_index].convert_wave(U).value),
75  U);
76  }
77 
78 //-----------------------------------------------------------------------
80 //-----------------------------------------------------------------------
81 
82  DoubleWithUnit upper_bound(int Spec_index) const
83  {
84  range_check(Spec_index, 0, number_spectrometer());
85  return upper_b[Spec_index];
86  }
87 
88 //-----------------------------------------------------------------------
91 //-----------------------------------------------------------------------
92 
93  DoubleWithUnit upper_bound(int Spec_index, const Unit& U) const
94  {
95  range_check(Spec_index, 0, number_spectrometer());
96  return DoubleWithUnit(std::max(upper_b[Spec_index].convert_wave(U).value,
97  lower_b[Spec_index].convert_wave(U).value),
98  U);
99  }
100 
101  int spectral_index(const DoubleWithUnit& W) const;
102  virtual void print(std::ostream& Os) const;
103 private:
104  std::vector<DoubleWithUnit> lower_b, upper_b;
105 };
106 }
107 #endif
#define range_check(V, Min, Max)
Range check.
Definition: fp_exception.h:140
SpectralBound()
Default constructor.
We frequently have a array of numbers with units associated with them.
DoubleWithUnit upper_bound(int Spec_index, const Unit &U) const
Upper bound but with a unit conversion first in case the conversion reverses ordering.
This is a Mixin for classes that can be printed.
Definition: printable.h:24
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.
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
DoubleWithUnit lower_bound(int Spec_index, const Unit &U) const
Lower bound but with a unit conversion first in case the conversion reverses ordering.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
int number_spectrometer() const
Number of spectrometers.
double value(const FullPhysics::AutoDerivative< double > &Ad)
DoubleWithUnit center(int Spec_index, const Unit &U) const
Center between lower_bound and upper_bound.
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