ReFRACtor
model_measure.cc
Go to the documentation of this file.
1 #include "model_measure.h"
2 #include "fp_exception.h"
3 
4 
5 using namespace FullPhysics;
6 using namespace blitz;
7 
8 
9 void ModelMeasure::set_measurement( const blitz::Array<double, 1>& measurement,
10  const blitz::Array<double, 1>& measurement_error_cov )
11 {
12  if(measurement.rows() <= 0)
13  throw Exception("The size of measurement data array is zero.");
14  if(measurement_error_cov.rows() != measurement.rows() )
15  throw Exception("Measured data and the related diagonal error covariance matrix need to be the same size.");
16 
17  msrmnt.resize(measurement.shape());
18  msrmnt = measurement;
19 
20  Se.resize(measurement_error_cov.shape());
21  Se = measurement_error_cov;
22 
23  Se_chol.resize(Se.shape());
24  Se_chol = sqrt(Se);
25 }
26 
27 
28 void ModelMeasure::assert_model_correct(const blitz::Array<double, 1>& m) const
29 {
30  if( m.rows() != msrmnt.rows() )
31  throw Exception("Model data and measured data need to be the same size.");
32 }
33 
34 
35 void ModelMeasure::assert_jacobian_correct(const blitz::Array<double, 2>& k) const
36 {
37  if( k.rows() != msrmnt.rows() )
38  throw Exception("Model Jacobian and measurement error covariance matrix must have the same number of rows.");
39  if( k.cols() != expected_parameter_size() )
40  throw Exception("The number of model Jacobian columns must equal the number of parameters.");
41 }
42 
43 
44 
46 {
47  firstIndex i1; secondIndex i2;
48  Array<double, 2> result(measurement_size(), parameter_size());
49  result = jacobian()(i1, i2) / Se_chol(i1);
50  return result;
51 }
52 
53 
55 {
56  firstIndex i1; secondIndex i2; thirdIndex i3;
57  Array<double, 2> K(jacobian());
58  Array<double, 2> result(K.cols(), K.cols());
59  result = sum(K(i3,i1) / Se(i3) * K(i3, i2), i3);
60  return result;
61 }
void set_measurement(const blitz::Array< double, 1 > &measurement, const blitz::Array< double, 1 > &measurement_error_cov)
For setting measurement and the error covariance matrix.
Definition: model_measure.cc:9
virtual blitz::Array< double, 2 > uncert_weighted_jac_inner_product()
Returns the inner product of the matrix returned by the method uncert_weighted_jacobian() by itself...
virtual void assert_jacobian_correct(const blitz::Array< double, 2 > &k) const
Conditions that must be satisfied when a derived class computes the Jacobian of the model...
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
blitz::Array< T, 2 > jacobian(const blitz::Array< AutoDerivative< T >, 1 > &Ad)
Utility function to extract the Jacobian as a separate matrix from an array of AutoDerivative.
virtual blitz::Array< double, 2 > uncert_weighted_jacobian()
Returns the model Jacobian weighted by the inverse of the Cholesky decomposition of the error covaria...
Apply value function to a blitz array.
const Unit K("K", 1.0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
const Unit m("m", 1.0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
virtual void assert_model_correct(const blitz::Array< double, 1 > &m) const
Conditions that must be satisfied when a derived class computes the model.

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