14 : real_fm(Real_forward_model), statev(Sv), perturb(Perturbation)
23 return real_fm->radiance(Spec_index, Skip_jacobian);
26 Array<double, 1> initial_sv( statev->state() );
29 Logger::info() <<
"Finite Difference FM: Unperturbed radiances\n";
34 statev->state_with_derivative().number_variable());
35 res.
value() =
rad.spectral_range().data();
38 if( initial_sv.extent(firstDim) != perturb.extent(firstDim) ) {
40 err <<
"Statevector size does not match size of perturbation array, can not do FD jacobian calculations";
45 Array<double, 1> current_sv(initial_sv.extent(firstDim));
46 for(
int sv_idx = 0; sv_idx < initial_sv.extent(firstDim); sv_idx++) {
47 Logger::info() <<
"Finite Difference FM: Perturbation of state vector element #" << sv_idx+1 <<
"\n";
48 if( perturb(sv_idx) > 0.0 ) {
50 current_sv = initial_sv;
51 current_sv(sv_idx) += perturb(sv_idx);
54 statev->update_state(current_sv);
57 res.jacobian()(Range::all(), sv_idx) =
58 (real_fm->radiance(Spec_index,
true).spectral_range().data() -
59 rad.spectral_range().data()) / perturb(sv_idx);;
64 res.jacobian()(Range::all(), sv_idx) = 0.0;
69 statev->update_state(initial_sv);
This is the base of the exception hierarchy for Full Physics code.
Apply value function to a blitz array.
const blitz::Array< T, D > & value() const
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
virtual Spectrum radiance(int Spec_index, bool Skip_jacobian=false) const
Spectrum for the given spectral band.
We have a number of different spectrums that appear in different parts of the code.
FdForwardModel(const boost::shared_ptr< ForwardModel > &Real_Forward_model, const boost::shared_ptr< StateVector > &Sv, const blitz::Array< double, 1 > &Perturbation)
Constructor.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
This gets the perturbation to use with a finite difference Jacobian.
const Unit rad("rad", 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0)