ReFRACtor
sub_state_vector_observer.cc
Go to the documentation of this file.
2 
3 using namespace FullPhysics;
4 using namespace blitz;
5 
7 {
8  if(Sv.state().rows() < pstart + plen) {
9  std::stringstream err_msg;
10  err_msg << "StateVector is of size: "
11  << Sv.state().rows()
12  << " not the expected size: "
13  << (pstart + plen);
14  throw Exception(err_msg.str());
15  }
16 
17  if(pstart < 0) {
18  throw Exception("pstart < 0");
19  }
20 
21  sv_full.reference(Sv.state_with_derivative());
22  sv_cov_full.reference(Sv.state_covariance());
23 
24  if(plen > 0) {
25  blitz::Range rsub(pstart, pstart + plen - 1);
26  sv_sub.reference(sv_full(rsub));
27  sv_cov_sub.reference(Array<double, 2>(sv_cov_full(rsub, rsub)));
28  }
29 
30  // So that anything registered as a SubStateVector observer
31  // gets notified even if it doesn't contain any SV elements
32  update_sub_state(sv_sub, sv_cov_sub);
33 }
34 
36  blitz::Array<bool, 1>& Used) const
37 {
38  if(Used.rows() < pstart + plen) {
39  throw Exception("StateVector not the expected size");
40  }
41 
42  if(pstart < 0) {
43  throw Exception("pstart < 0");
44  }
45 
46  if(plen > 0) {
47  Array<bool, 1> used_sub(Used(blitz::Range(pstart, pstart + plen - 1)));
48  mark_used_sub(used_sub);
49  }
50 }
51 
53  blitz::Array<std::string, 1>& Sv_name) const
54 {
55  if(Sv_name.rows() < pstart + plen) {
56  throw Exception("StateVector not the expected size");
57  }
58 
59  if(pstart < 0) {
60  throw Exception("pstart < 0");
61  }
62 
63  if(plen > 0) {
64  Array<std::string, 1> sv_name_sub(Sv_name(blitz::Range(pstart,
65  pstart + plen - 1)));
66  state_vector_name_sub(sv_name_sub);
67  }
68 }
69 
70 //-----------------------------------------------------------------------
78 //-----------------------------------------------------------------------
79 
81 {
82  range_min_check(Plen, 0);
83  plen = Plen;
84 }
void state_vector_observer_initialize(int Plen)
Take the given number of state vector parameters.
const ArrayAd< double, 1 > & state_with_derivative() const
Return the state vector as state() does, but also make each value a AutoDerivative.
Definition: state_vector.h:45
const blitz::Array< double, 1 > & state() const
Current state vector.
Definition: state_vector.h:34
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
virtual void notify_update(const StateVector &Sv)
Called when the Observed object is updated.
const blitz::Array< double, 2 > & state_covariance() const
Current covariance of the state vector.
Definition: state_vector.h:53
Apply value function to a blitz array.
This handles informing a set of interested objects when the state vector has updated.
Definition: state_vector.h:16
virtual void mark_used(const StateVector &Sv, blitz::Array< bool, 1 > &Used) const
Mark elements that we are actively using (i.e., that aren&#39;t ignored).
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
#define range_min_check(V, Min)
Range check.
Definition: fp_exception.h:167
virtual void state_vector_name(const StateVector &Sv, blitz::Array< std::string, 1 > &Sv_name) const
Update any portion of the list of the state vector names that apply to this object.

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