ReFRACtor
connor_cost_function.h
Go to the documentation of this file.
1 #ifndef CONNOR_COST_FUNCTION
2 #define CONNOR_COST_FUNCTION
3 #include "cost_function.h"
4 #include "state_vector.h"
5 #include "forward_model.h"
6 #include "observation.h"
7 #include <boost/shared_ptr.hpp>
8 
9 namespace FullPhysics {
11 public:
15  const boost::shared_ptr<Observation>& inst_meas)
16  : statev(Sv), forward_model(fm), meas(inst_meas)
17  {
18  }
19  virtual ~ConnorCostFunction() {}
20  virtual void cost_function(const blitz::Array<double, 1>& X,
21  blitz::Array<double, 1>& Residual,
22  blitz::Array<double, 1>& Se,
23  blitz::Array<double, 2>& Jacobian) const
24  {
25  using namespace blitz;
26  statev->update_state(X);
27  SpectralRange rad_meas = meas->radiance_all().spectral_range();
28  Spectrum rad_spec = forward_model->radiance_all();
29 
30  SpectralRange rad_mod = rad_spec.spectral_range().convert(rad_meas.units());
31  Se.resize(rad_meas.data().rows());
32  Residual.resize(rad_meas.data().rows());
33 
34  if(rad_meas.uncertainty().rows() == 0)
35  throw Exception("Radiance uncertainty is empty in ConnorCostFunction");
36 
37  Se = sqr(rad_meas.uncertainty());
38  Residual = rad_mod.data() - rad_meas.data();
39  Jacobian.reference(rad_mod.data_ad().jacobian());
40  }
41  virtual void print(std::ostream& Os) const
42  {
43  Os << "ConnorCostFunction";
44  }
45 private:
47  boost::shared_ptr<ForwardModel> forward_model;
49 };
50 }
51 #endif
virtual void print(std::ostream &Os) const
Print description of object.
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
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
ConnorCostFunction(const boost::shared_ptr< StateVector > &Sv, const boost::shared_ptr< ForwardModel > &fm, const boost::shared_ptr< Observation > &inst_meas)
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
const blitz::Array< double, 1 > & uncertainty() const
Uncertainty.
virtual void cost_function(const blitz::Array< double, 1 > &X, blitz::Array< double, 1 > &Residual, blitz::Array< double, 1 > &Se, blitz::Array< double, 2 > &Jacobian) const
For the given value of X, calculate the residuals and jacobians.
This class calculates a cost function, along with a jacobian.
Definition: cost_function.h:10
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.
double sqr(double x)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
SpectralRange convert(const Unit &R) const
Convert to given units.
const blitz::Array< double, 1 > & data() const
Underlying data.

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