15 const std::string&>())
25 const std::vector<int>& Pixel_list,
29 for (
int i = 0; i < (int) Pixel_list.size(); i++) {
30 grid_ad(i) = Pixel_grid.
data_ad()(Pixel_list[i]);
37 Array<double, 1> meas_conv_data(Pixel_list.size());
38 for(
int i = 0; i < (int) Pixel_list.size(); i++)
39 meas_conv_data(i) = measured_radiance.data()(Pixel_list[i]) * conv_factor;
43 Array<double, 2> problem_mat;
45 problem_mat.resize(Pixel_list.size(), 3);
47 problem_mat.resize(Pixel_list.size(), 2);
49 double band_ref_conv = band_ref.convert_wave(grid_sd.units()).
value;
50 Array<double, 1> wrefd( grid_sd.data() - band_ref_conv );
52 Range all = Range::all();
58 problem_mat(all, 0) = Radiance.
data();
59 problem_mat(all, 1) = Radiance.
data() * wrefd;
61 problem_mat(all,2) = 1.0;
67 scaling_coeff(all) = scale_offset(Range(0,1));
69 offset = scale_offset(2);
73 std::ofstream debug_out((
"radiance_scaling_linear_fit_debug_" + band_name +
".txt").c_str());
74 debug_out <<
"# scale_offset: " << std::endl << scale_offset << std::endl;
76 debug_out <<
"# inst_corr conv_factor = " << conv_factor << std::endl
77 <<
"# measured_radiance: " << measured_radiance.units().name() << std::endl
78 << measured_radiance.data() << std::endl
79 <<
"# ---" << std::endl
80 <<
"# measured_radiance converted = " << meas_conv.units().name() << std::endl
81 << meas_conv.data() << std::endl
82 <<
"# ---" << std::endl
83 <<
"# Radiance: " << Radiance.
units().
name() << std::endl
84 << Radiance.
data() << std::endl
85 <<
"# ---" << std::endl
86 <<
"# wrefd: " << std::endl
87 << wrefd << std::endl;
91 apply_scaling(grid_sd, Radiance);
102 Os <<
"RadianceScalingLinearFit:" << std::endl;
105 opad <<
"Use offset: " << (do_offset ?
"True" :
"False") << std::endl;
virtual void print(std::ostream &Os) const
virtual void print(std::ostream &Os) const
virtual void apply_correction(const SpectralDomain &Pixel_grid, const std::vector< int > &Pixel_list, SpectralRange &Radiance) const
Apply correction to radiance values, in place.
This is a filtering stream that adds a pad to the front of every line written out.
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
const ArrayAd< double, 1 > & data_ad() const
Underlying data, possibly with a Jacobian.
virtual boost::shared_ptr< InstrumentCorrection > clone() const
Clone an InstrumentCorrection object.
double conversion(const Unit &Dunit_from, const Unit &Dunit_to)
Return conversion factor to go from one unit to another.
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Apply value function to a blitz array.
blitz::Array< double, 1 > solve_least_squares_qr(const blitz::Array< double, 2 > &A, const blitz::Array< double, 1 > &B)
This finds the least squares solution to the overdetermined system A x = b where the matrix A has mor...
const Unit & units() const
Units of data.
Implements a fitted radiance scaling correction where the correction is determined by a linear fit of...
We frequently have a double with units associated with it.
int number_variable() const
We have a number of different spectrums that appear in different parts of the code.
const Unit units() const
Units that go with data()
Contains classes to abstract away details in various Spurr Radiative Transfer software.
#define REGISTER_LUA_END()
const std::string & name() const
Name of unit. May be an empty string if a name wasn't assigned.
double value(const FullPhysics::AutoDerivative< double > &Ad)
const blitz::Array< double, 1 > & data() const
Underlying data.
This class models an Instrument correction.