ReFRACtor
model_measure_standard.cc
Go to the documentation of this file.
2 
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 
9  const boost::shared_ptr<Observation>& observation,
10  const boost::shared_ptr<StateVector>& state_vector)
11  : fm(forward_model), obs(observation), sv(state_vector),
12  meas_units(obs->radiance_all().spectral_range().units())
13 {}
14 
15 
17 {
18  if(M.size() <= 0)
19  radiance_from_fm(true);
20 }
21 
22 
24 {
25  if(K.size() <= 0)
26  radiance_from_fm(false);
27 }
28 
29 
31 {
32  if((K.size() <= 0) or (M.size() <= 0))
33  radiance_from_fm(false);
34 }
35 
37 {
38  return sv->observer_claimed_size();
39 }
40 
41 
43 {
45  sv->update_state(X);
46 
47  // TEMPORARY
48  //
49  // There should be no need for this error check block.
50  // The problem is that with our current model code
51  // measurement may change.
52  //
53  Array<double, 1> temp_msrmnt(obs->radiance_all().spectral_range().data());
54  if(msrmnt.rows() != temp_msrmnt.rows())
55  throw Exception("Measurement has changed during the retrieval. :( ");
56  double msrmnt_L1_norm = sum(abs(msrmnt));
57  if(msrmnt_L1_norm <= 0.0)
58  throw Exception("Measurement has no signal (just 0). :( ");
59  if( sum(abs(temp_msrmnt-msrmnt))/msrmnt_L1_norm > 0.0000001 )
60  throw Exception("Measurement has changed during the retrieval. :( ");
61 
62  Spectrum rad_spec = fm->radiance_all(Skip_jacobian);
63  SpectralRange rad_mod = rad_spec.spectral_range().convert(meas_units);
64  M.reference(rad_mod.data_ad().value());
66  M.makeUnique();
67  if(!Skip_jacobian) {
68  K.reference(rad_mod.data_ad().jacobian());
70 
71  // TEMPORARY
72  //
73  // Should go away after we end support for
74  // fixed pressure level grid.
76 
77  K.makeUnique();
78  }
79 }
80 
81 
82 
83 
84 // TEMPORARY
85 //
86 // Should go away after we end support for
87 // fixed pressure level grid.
89 {
90  if(K.size() <= 0) return;
91 
92  // Even with fixed-pressure-level the following
93  // code block should not be necessary if the
94  // forward-model class is already setting to zero
95  // the columns of the Jacobian associated with
96  // the unused parameters (if any).
97  //
98  Array<bool, 1> used(sv->used_flag());
99  if(used.rows() != K.cols())
100  throw Exception("Columns of Jacobian and elements of used-flag not equal in numbers! :( ");
101  for(int i=0; i<used.rows(); i++)
102  if(!used(i)) K(Range::all(),i) = 0.0;
103 }
104 
105 
106 void ModelMeasureStandard::parameters(const blitz::Array<double, 1>& x)
107 {
108  // This check is needed because it is not obvious
109  // whether or not the Forward Model does caching.
110  //
111  if(!parameters_different(x)) return;
113  sv->update_state(x);
114 }
boost::shared_ptr< StateVector > sv
boost::shared_ptr< ForwardModel > fm
virtual void assert_parameter_set_correctly() const
Checks that the parameters are set correctly.
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...
blitz::Array< double, 1 > X
virtual blitz::Array< double, 1 > parameters() const
Returns the current parameters.
virtual void model_jacobian_eval()
Evaluates the model and its Jacobian at the currently set parameter values.
boost::shared_ptr< Observation > obs
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
Apply value function to a blitz array.
const blitz::Array< T, D > & value() const
Definition: array_ad.h:306
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
Definition: spectrum.h:18
We have a number of different spectrums that appear in different parts of the code.
void radiance_from_fm(bool Skip_jacobian=false)
const ArrayAd< double, 1 > & data_ad() const
Underlying data, possibly with a Jacobian.
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 blitz::Array< double, 1 > parameters() const
Just returns the current values of parameters.
virtual int expected_parameter_size() const
Returns the expected size of the parameters.
blitz::Array< double, 1 > msrmnt
virtual bool parameters_different(const blitz::Array< double, 1 > &x) const
Checks whether or not new input parameters are different from the current ones.
Definition: problem_state.cc:9
virtual void jacobian_eval()
Evaluates the Jacobian of the model at the currently set parameter values.
SpectralRange convert(const Unit &R) const
Convert to given units.
virtual void model_eval()
Evaluates the model at the currently set parameter values.

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