ReFRACtor
solar_continuum_table.cc
Go to the documentation of this file.
2 #include "fp_exception.h"
3 #include "linear_algebra.h"
4 #include <boost/foreach.hpp>
5 
6 using namespace FullPhysics;
7 using namespace blitz;
8 
9 #ifdef HAVE_LUA
10 #include "register_lua.h"
11 
13 .def(luabind::constructor<const HdfFile&, const std::string&, bool>())
15 #endif
16 
17 //-----------------------------------------------------------------------
23 //-----------------------------------------------------------------------
24 
26 (const HdfFile& F, const std::string& Hdf_group,bool Convert_from_photon)
27 : convert_from_photon(Convert_from_photon),
28  hdf_file_name(F.file_name()),
29  hdf_group(Hdf_group)
30 {
32  (Hdf_group + "/wavenumber");
34  (Hdf_group + "/spectrum");
35  if(!srange.units.is_commensurate(Unit("ph / (s * m * m * micron)")))
36  throw Exception("Solar continuum spectrum units need to be commensurate with ph / (s * m * m * micron)");
37  if(sdom.value.rows() != srange.value.rows())
38  throw Exception("wavenumber and spectrum need to be the same size");
39  domain_unit = sdom.units;
40  range_unit = srange.units;
41  Array<double, 1> x = to_c_order(sdom.value);
42  Array<double, 1> y = to_c_order(srange.value);
44  (x.dataFirst(), x.dataFirst() + x.rows(), y.dataFirst());
45 }
46 
47 // See base class for description.
49  const SpectralDomain& spec_domain) const
50 {
51  Array<double, 1> wv = spec_domain.convert_wave(domain_unit);
52 
54  res.value.resize(wv.shape());
55  res.units = range_unit;
56  for(int i = 0; i < res.value.rows(); ++i)
57  res.value(i) = table(wv(i));
58 
59  // Convert from ph/s/m^2/micron to W/m^2/cm^-1 if requested
60  if(convert_from_photon)
61  res *= spec_domain.photon_to_radiance_factor();
62  return Spectrum(spec_domain, SpectralRange(res.value, res.units));
63 }
64 
65 void SolarContinuumTable::print(std::ostream& Os) const
66 {
67  Os << "SolarContinuumTable\n"
68  << " Hdf file name: " << hdf_file_name << "\n"
69  << " Hdf group: " << hdf_group << "\n"
70  << " Convert from photon: " << (convert_from_photon ? "true" : "false")
71  << "\n";
72 }
This class calculates the solar continuum spectrum.
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
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
blitz::Array< T, D > value
This class reads and writes a HDF5 file.
Definition: hdf_file.h:39
Apply value function to a blitz array.
virtual void print(std::ostream &Os) const
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
Definition: spectrum.h:18
SolarContinuumTable(const HdfFile &F, const std::string &Hdf_group, bool Convert_from_photon=true)
Constructor.
blitz::Array< double, 1 > convert_wave(const Unit &Units) const
Return data as the supplied the units.
const std::string & file_name() const
File name.
Definition: hdf_file.h:131
We have a number of different spectrums that appear in different parts of the code.
ArrayWithUnit< double, 1 > photon_to_radiance_factor() const
We may want to convert from photon number per second to radiance units.
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
#define REGISTER_LUA_END()
Definition: register_lua.h:134
ArrayWithUnit< T, D > read_field_with_unit(const std::string &Dataname) const
Read a given field, along with metadata describing the units.
Definition: hdf_file.h:575
This class calculates the solar continuum spectrum.
blitz::Array< T, D > to_c_order(const blitz::Array< T, D > &In)
Ensure that a given blitz::Array is contiguous, not reversed, and in C RowMajorArray format...
virtual Spectrum solar_continuum_spectrum(const SpectralDomain &spec_domain) const
This calculate the solar continuum spectrum.

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