ReFRACtor
model_measure.h
Go to the documentation of this file.
1 #ifndef MODEL_MEASURE_H
2 #define MODEL_MEASURE_H
3 #include <model_state.h>
4 
5 
6 namespace FullPhysics {
7 
8 //-----------------------------------------------------------------------
44 //-----------------------------------------------------------------------
45 
46 class ModelMeasure : public ModelState {
47 
48 public:
49 
50 
51 //-----------------------------------------------------------------------
60 //-----------------------------------------------------------------------
61 
62  ModelMeasure(const blitz::Array<double, 1>& measurement,
63  const blitz::Array<double, 1>& measurement_error_cov)
64  { set_measurement(measurement, measurement_error_cov); }
65 
66 
67 //-----------------------------------------------------------------------
69 //-----------------------------------------------------------------------
70 
72 
73 
74  virtual ~ModelMeasure() {}
75 
76 
77 //-----------------------------------------------------------------------
86 //-----------------------------------------------------------------------
87 
88  void set_measurement(const blitz::Array<double, 1>& measurement,
89  const blitz::Array<double, 1>& measurement_error_cov);
90 
91 
92 //-----------------------------------------------------------------------
110 //-----------------------------------------------------------------------
111 
112  virtual void model_eval() = 0;
113 
114 
115 //-----------------------------------------------------------------------
126 //-----------------------------------------------------------------------
127 
128  virtual blitz::Array<double, 1> model()
129  { model_eval(); return M.copy(); }
130 
131 
132 //-----------------------------------------------------------------------
145 //-----------------------------------------------------------------------
146 
147  virtual blitz::Array<double, 1> model_x(const blitz::Array<double, 1>& x)
148  { parameters(x); return model(); }
149 
150 
151 //-----------------------------------------------------------------------
170 //-----------------------------------------------------------------------
171 
172  virtual void jacobian_eval() = 0;
173 
174 
175 //-----------------------------------------------------------------------
188 //-----------------------------------------------------------------------
189 
190  virtual blitz::Array<double, 2> jacobian()
191  { jacobian_eval(); return K.copy(); }
192 
193 
194 //-----------------------------------------------------------------------
209 //-----------------------------------------------------------------------
210 
211  virtual blitz::Array<double, 2> jacobian_x(const blitz::Array<double, 1>& x)
212  { parameters(x); return jacobian(); }
213 
214 
215 //-----------------------------------------------------------------------
231 //-----------------------------------------------------------------------
232 
233  virtual void model_jacobian_eval()
234  { jacobian_eval(); model_eval(); }
235 
236 
237 //-----------------------------------------------------------------------
249 //-----------------------------------------------------------------------
250 
251  virtual void model_jacobian(
252  blitz::Array<double, 1>& m, blitz::Array<double, 2>& k)
253  { model_jacobian_eval(); m.reference(M.copy()); k.reference(K.copy()); }
254 
255 
256 //-----------------------------------------------------------------------
270 //-----------------------------------------------------------------------
271 
272  virtual void model_jacobian_x(const blitz::Array<double, 1>& x,
273  blitz::Array<double, 1>& m, blitz::Array<double, 2>& k)
274  { parameters(x); model_jacobian(m,k); }
275 
276 
277 //-----------------------------------------------------------------------
281 //-----------------------------------------------------------------------
282 
283  virtual blitz::Array<double, 1> measurement() const
284  { return msrmnt.copy(); }
285 
286 
287 //-----------------------------------------------------------------------
292 //-----------------------------------------------------------------------
293 
294  virtual blitz::Array<double, 1> measurement_error_cov() const
295  { return Se.copy(); }
296 
297 
298 //-----------------------------------------------------------------------
310 //-----------------------------------------------------------------------
311 
312  virtual int measurement_size() const
313  { return msrmnt.rows(); }
314 
315 
316 //-----------------------------------------------------------------------
327 //-----------------------------------------------------------------------
328 
329  virtual void assert_model_correct(const blitz::Array<double, 1>& m) const;
330 
331 
332 //-----------------------------------------------------------------------
343 //-----------------------------------------------------------------------
344 
345  virtual void assert_jacobian_correct(const blitz::Array<double, 2>& k) const;
346 
347 
348 //-----------------------------------------------------------------------
354 //-----------------------------------------------------------------------
355 
356  bool model_computed() const
357  { return (M.size() > 0); }
358 
359 
360 //-----------------------------------------------------------------------
365 //-----------------------------------------------------------------------
366 
367  bool jacobean_computed() const
368  { return (K.size() > 0); }
369 
370 
371 //-----------------------------------------------------------------------
373 //-----------------------------------------------------------------------
374 
375  virtual void print(std::ostream& Os) const
376  { Os << "ModelMeasure"; }
377 
378 
379 
380 
381 //-----------------------------------------------------------------------
382 //-----------------------------------------------------------------------
383 // The following public methods are for convenience.
384 //-----------------------------------------------------------------------
385 //-----------------------------------------------------------------------
386 
387 
388 //-----------------------------------------------------------------------
408 //-----------------------------------------------------------------------
409 
410  virtual blitz::Array<double, 1> model_measure_diff()
411  { return blitz::Array<double, 1>(model() - measurement()); }
412 
413 
414 //-----------------------------------------------------------------------
449 //-----------------------------------------------------------------------
450 
451  virtual blitz::Array<double, 1> uncert_weighted_model_measure_diff()
452  { return blitz::Array<double, 1>(model_measure_diff()/Se_chol); }
453 
454 
455 //-----------------------------------------------------------------------
484 //-----------------------------------------------------------------------
485 
486  virtual blitz::Array<double, 2> uncert_weighted_jacobian();
487 
488 
489 //-----------------------------------------------------------------------
505 //-----------------------------------------------------------------------
506 
507  virtual blitz::Array<double, 2> uncert_weighted_jac_inner_product();
508 
509 
510 protected:
511 
512  blitz::Array<double, 1> msrmnt;
513  blitz::Array<double, 1> Se;
514 
515  // For convenience
516  blitz::Array<double, 1> Se_chol;
517 
518 };
519 }
520 #endif
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, 1 > model_measure_diff()
Returns model and measurement difference (model - measurement)
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...
ModelMeasure()
Default Constructor.
Definition: model_measure.h:71
blitz::Array< double, 1 > Se
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...
bool jacobean_computed() const
A boolean function to check whether or not the Jacobean of the model is computed. ...
The state for a parametrized mathematical model (a vector function) and its Jacobian.
Definition: model_state.h:36
virtual blitz::Array< double, 1 > parameters() const
Returns the current parameters.
virtual blitz::Array< double, 1 > uncert_weighted_model_measure_diff()
Returns model and measurement difference weighted by the inverse of the Cholesky decomposition of the...
virtual blitz::Array< double, 1 > model()
Evaluates and returns the model at the currently set parameter values.
virtual blitz::Array< double, 2 > jacobian()
Evaluates and returns the Jacobian of the model at the currently set parameter values.
virtual blitz::Array< double, 2 > uncert_weighted_jacobian()
Returns the model Jacobian weighted by the inverse of the Cholesky decomposition of the error covaria...
virtual void model_eval()=0
Evaluates the model at the currently set parameter values.
virtual void model_jacobian(blitz::Array< double, 1 > &m, blitz::Array< double, 2 > &k)
Evaluates model and its Jacobian together.
virtual int measurement_size() const
Returns the size of the measurement data vector.
bool model_computed() const
A boolean function to check whether or not the model is computed.
The base class for models and measurements.
Definition: model_measure.h:46
virtual blitz::Array< double, 2 > jacobian_x(const blitz::Array< double, 1 > &x)
The model Jacobian with parameters.
virtual blitz::Array< double, 1 > measurement_error_cov() const
Returns the measurement error covariance (implemented as a diagonal matrix).
virtual void model_jacobian_x(const blitz::Array< double, 1 > &x, blitz::Array< double, 1 > &m, blitz::Array< double, 2 > &k)
Model and its Jacobian with parameters.
virtual blitz::Array< double, 1 > measurement() const
Returns the measured data, to which the model is fit.
const Unit m("m", 1.0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
virtual void jacobian_eval()=0
Evaluates the Jacobian of the model at the currently set parameter values.
virtual void print(std::ostream &Os) const
Prints description of object.
blitz::Array< double, 1 > Se_chol
blitz::Array< double, 2 > K
Definition: model_state.h:99
blitz::Array< double, 1 > M
Definition: model_state.h:98
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.
virtual void model_jacobian_eval()
Evaluates the model and its Jacobian at the currently set parameter values.
blitz::Array< double, 1 > msrmnt
virtual blitz::Array< double, 1 > model_x(const blitz::Array< double, 1 > &x)
The model function with parameters.
ModelMeasure(const blitz::Array< double, 1 > &measurement, const blitz::Array< double, 1 > &measurement_error_cov)
Constructor.
Definition: model_measure.h:62

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