ReFRACtor
max_a_posteriori_standard.cc
Go to the documentation of this file.
2 
3 using namespace FullPhysics;
4 using namespace blitz;
5 
6 #ifdef HAVE_LUA
7 #include "register_lua.h"
9 .def(luabind::constructor< const boost::shared_ptr<ForwardModel>&,
12  const Array<double, 1>,
13  const Array<double, 2> >())
15 #endif
16 
17 
18 
20  const boost::shared_ptr<Observation>& observation,
21  const boost::shared_ptr<StateVector>& state_vector,
22  const Array<double, 1> a_priori_params,
23  const Array<double, 2> a_priori_cov)
24  : ModelMeasure(
25  observation->radiance_all().spectral_range().data(),
26  Array<double, 1>(sqr(observation->radiance_all().spectral_range().uncertainty()))),
27  MaxAPosteriori(a_priori_params, a_priori_cov),
28  ModelMeasureStandard(forward_model, observation, state_vector)
29 {
30  if(Xa.rows() != sv->observer_claimed_size())
31  throw Exception("A priori state vector size and state vector size expected by the model are not equal. :( ");
32 }
33 
34 
35 // TEMPORARY
36 //
37 // Should go away after we end support for
38 // fixed pressure level grid.
39 // Not implemented efficiently.
40 #include <linear_algebra.h>
42 {
44  Array<bool, 1> used(sv->used_flag());
45  if(used.rows() != Sa_chol.rows())
46  throw Exception("Size of a-priori cov. matrix and the number of the elements of used-flag inconsistent! :( ");
47  if(!all(used)) {
48 // throw Exception("Handling vanishing parameters is not supported yet! :( ");
49  Sa_chol.reference(cholesky_decomposition(Sa));
50  for(int i=0; i<used.rows(); i++)
51  if(!used(i))
52  Sa_chol(i,Range::all()) = 0.0;
53  Sa_chol_inv.reference(generalized_inverse(Sa_chol,1e-20));
54  // Theoretically the selected columns of Sa_chol_inv should
55  // be zero; however, they may have very small nonzero values.
56  for(int i=0; i<used.rows(); i++)
57  if(!used(i))
58  Sa_chol_inv(Range::all(),i) = 0.0;
59  }
60 }
boost::shared_ptr< StateVector > sv
blitz::Array< double, 2 > Sa_chol_inv
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
blitz::Array< double, 2 > cholesky_decomposition(const blitz::Array< double, 2 > &A)
This calculates the Cholesky Decompostion of A so that A = L L^T.
MaxAPosterioriStandard(const boost::shared_ptr< ForwardModel > &fm, const boost::shared_ptr< Observation > &observation, const boost::shared_ptr< StateVector > &state_vector, const blitz::Array< double, 1 > a_priori_params, const blitz::Array< double, 2 > a_priori_cov)
Constructor.
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
blitz::Array< double, 2 > Sa
Apply value function to a blitz array.
blitz::Array< double, 1 > Xa
The base class for models and measurements.
Definition: model_measure.h:46
The base class for maximum a posteriori estimation.
blitz::Array< double, 2 > generalized_inverse(const blitz::Array< double, 2 > &A, double Rcond=std::numeric_limits< double >::epsilon())
This returns the generalized inverse of the given matrix.
double sqr(double x)
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
blitz::Array< double, 2 > Sa_chol

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