ReFRACtor
ground_brdf_output.cc
Go to the documentation of this file.
1 #include "linear_interpolate.h"
2 #include "old_constant.h"
3 #include "ground_brdf_output.h"
4 
5 using namespace FullPhysics;
6 using namespace blitz;
7 
8 #ifdef HAVE_LUA
9 #include "register_lua.h"
10 
11 boost::shared_ptr<RegisterOutputBase> ground_brdf_output_create(const boost::shared_ptr<Ground>& ground, const boost::shared_ptr<Level1bSampleCoefficient>& l1b, const std::vector<std::string>& hdf_band_names)
12 {
14  (new GroundBrdfOutput(boost::dynamic_pointer_cast<GroundBrdf>(ground), boost::dynamic_pointer_cast<Level1bSampleCoefficient>(l1b), hdf_band_names));
15 }
16 
18 .def(luabind::constructor<const boost::shared_ptr<GroundBrdf>&, const boost::shared_ptr<Level1bSampleCoefficient>&, const std::vector<std::string>&>())
19 .scope
20 [
21  luabind::def("create", &ground_brdf_output_create)
22 ]
24 #endif
25 
26 
28 public:
29 
32  : brdf(Brdf), l1b(L1b) { }
33 
34  double weight_intercept(int spec_idx)
35  {
36  return brdf->weight_intercept(spec_idx).value();
37  }
38 
39  double weight_slope(int spec_idx)
40  {
41  return brdf->weight_slope(spec_idx).value();
42  }
43 
44  double rahman_factor(int spec_idx)
45  {
46  return brdf->rahman_factor(spec_idx).value();
47  }
48 
49  double hotspot_parameter(int spec_idx)
50  {
51  return brdf->hotspot_parameter(spec_idx).value();
52  }
53 
54  double asymmetry_parameter(int spec_idx)
55  {
56  return brdf->asymmetry_parameter(spec_idx).value();
57  }
58 
59  double anisotropy_parameter(int spec_idx)
60  {
61  return brdf->anisotropy_parameter(spec_idx).value();
62  }
63 
64  double breon_factor(int spec_idx)
65  {
66  return brdf->breon_factor(spec_idx).value();
67  }
68 
69  double uncert_value(int spec_idx, int coeff_idx)
70  {
71  Array<double, 2> cov = brdf->brdf_covariance(spec_idx);
72  if(cov.rows() > 0 and cov.cols() > 0) {
73  return (cov(coeff_idx, coeff_idx) < 0 ? 0.0 : sqrt(cov(coeff_idx, coeff_idx)));
74  } else {
75  return 0.0;
76  }
77  }
78 
79  double weight_intercept_uncert(int spec_idx)
80  {
81  return uncert_value(spec_idx, GroundBrdf::BRDF_WEIGHT_INTERCEPT_INDEX);
82  }
83 
84  double weight_slope_uncert(int spec_idx)
85  {
86  return uncert_value(spec_idx, GroundBrdf::BRDF_WEIGHT_SLOPE_INDEX);
87  }
88 
89  double rahman_factor_uncert(int spec_idx)
90  {
91  return uncert_value(spec_idx, GroundBrdf::RAHMAN_KERNEL_FACTOR_INDEX);
92  }
93 
94  double hotspot_parameter_uncert(int spec_idx)
95  {
96  return uncert_value(spec_idx, GroundBrdf::RAHMAN_OVERALL_AMPLITUDE_INDEX);
97  }
98 
99  double asymmetry_parameter_uncert(int spec_idx)
100  {
101  return uncert_value(spec_idx, GroundBrdf::RAHMAN_ASYMMETRY_FACTOR_INDEX);
102  }
103 
104  double anisotropy_parameter_uncert(int spec_idx)
105  {
106  return uncert_value(spec_idx, GroundBrdf::RAHMAN_GEOMETRIC_FACTOR_INDEX);
107  }
108 
109  double breon_factor_uncert(int spec_idx)
110  {
111  return uncert_value(spec_idx, GroundBrdf::BREON_KERNEL_FACTOR_INDEX);
112  }
113 
114  double reflectance_intercept(int spec_idx)
115  {
116  return weight_intercept(spec_idx) * kernel_amplitude(spec_idx);
117  }
118 
119  double reflectance_slope(int spec_idx)
120  {
121  return weight_slope(spec_idx) * kernel_amplitude(spec_idx);
122  }
123 
124  double reflectance_intercept_uncert(int spec_idx)
125  {
126  return weight_intercept_uncert(spec_idx) * kernel_amplitude(spec_idx);
127  }
128 
129  double reflectance_slope_uncert(int spec_idx)
130  {
131  return weight_slope_uncert(spec_idx) * kernel_amplitude(spec_idx);
132  }
133 
134  double kernel_amplitude(int spec_idx) const
135  {
136  Unit angle_unit("deg");
137  return brdf->kernel_value(spec_idx,
138  l1b->solar_zenith(spec_idx).convert(angle_unit).value,
139  l1b->sounding_zenith(spec_idx).convert(angle_unit).value,
140  l1b->relative_azimuth(spec_idx).convert(angle_unit).value);
141  }
142 private:
145 };
146 
148 {
149  boost::shared_ptr<GroundBrdf> brdf_freeze =
150  boost::dynamic_pointer_cast<GroundBrdf>(brdf->clone());
151  boost::shared_ptr<BrdfOutputHelper> helper(new BrdfOutputHelper(brdf_freeze, l1b));
152 
153  for(int spec_idx = 0; spec_idx < brdf->number_spectrometer(); spec_idx++) {
154  std::string band_name = hdf_band_names[spec_idx];
155 
156  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::weight_intercept, helper, spec_idx);
157  out->register_data_source("/RetrievalResults/brdf_weight_apriori_" + band_name, f); }
158 
159  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::weight_slope, helper, spec_idx);
160  out->register_data_source("/RetrievalResults/brdf_weight_slope_apriori_" + band_name, f); }
161 
162  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::reflectance_intercept, helper, spec_idx);
163  out->register_data_source("/RetrievalResults/brdf_reflectance_apriori_" + band_name, f); }
164 
165  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::reflectance_slope, helper, spec_idx);
166  out->register_data_source("/RetrievalResults/brdf_reflectance_slope_apriori_" + band_name, f); }
167 
168  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::rahman_factor, helper, spec_idx);
169  out->register_data_source("/RetrievalResults/brdf_rahman_factor_apriori_" + band_name, f); }
170 
171  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::hotspot_parameter, helper, spec_idx);
172  out->register_data_source("/RetrievalResults/brdf_hotspot_parameter_apriori_" + band_name, f); }
173 
174  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::asymmetry_parameter, helper, spec_idx);
175  out->register_data_source("/RetrievalResults/brdf_asymmetry_parameter_apriori_" + band_name, f); }
176 
177  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::anisotropy_parameter, helper, spec_idx);
178  out->register_data_source("/RetrievalResults/brdf_anisotropy_parameter_apriori_" + band_name, f); }
179 
180  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::breon_factor, helper, spec_idx);
181  out->register_data_source("/RetrievalResults/brdf_breon_factor_apriori_" + band_name, f); }
182  }
183 }
184 
186 {
188 
189  for(int spec_idx = 0; spec_idx < brdf->number_spectrometer(); spec_idx++) {
190  std::string band_name = hdf_band_names[spec_idx];
191 
192  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::weight_intercept, helper, spec_idx);
193  out->register_data_source("/RetrievalResults/brdf_weight_" + band_name, f); }
194 
195  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::weight_intercept_uncert, helper, spec_idx);
196  out->register_data_source("/RetrievalResults/brdf_weight_uncert_" + band_name, f); }
197 
198  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::weight_slope, helper, spec_idx);
199  out->register_data_source("/RetrievalResults/brdf_weight_slope_" + band_name, f); }
200 
201  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::weight_slope_uncert, helper, spec_idx);
202  out->register_data_source("/RetrievalResults/brdf_weight_slope_uncert_" + band_name, f); }
203 
204  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::reflectance_intercept, helper, spec_idx);
205  out->register_data_source("/RetrievalResults/brdf_reflectance_" + band_name, f); }
206 
207  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::reflectance_slope, helper, spec_idx);
208  out->register_data_source("/RetrievalResults/brdf_reflectance_slope_" + band_name, f); }
209 
210  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::reflectance_intercept_uncert, helper, spec_idx);
211  out->register_data_source("/RetrievalResults/brdf_reflectance_uncert_" + band_name, f); }
212 
213  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::reflectance_slope_uncert, helper, spec_idx);
214  out->register_data_source("/RetrievalResults/brdf_reflectance_slope_uncert_" + band_name, f); }
215 
216  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::rahman_factor, helper, spec_idx);
217  out->register_data_source("/RetrievalResults/brdf_rahman_factor_" + band_name, f); }
218 
219  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::rahman_factor_uncert, helper, spec_idx);
220  out->register_data_source("/RetrievalResults/brdf_rahman_factor_uncert_" + band_name, f); }
221 
222  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::hotspot_parameter, helper, spec_idx);
223  out->register_data_source("/RetrievalResults/brdf_hotspot_parameter_" + band_name, f); }
224 
225  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::hotspot_parameter_uncert, helper, spec_idx);
226  out->register_data_source("/RetrievalResults/brdf_hotspot_parameter_uncert_" + band_name, f); }
227 
228  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::asymmetry_parameter, helper, spec_idx);
229  out->register_data_source("/RetrievalResults/brdf_asymmetry_parameter_" + band_name, f); }
230 
231  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::asymmetry_parameter_uncert, helper, spec_idx);
232  out->register_data_source("/RetrievalResults/brdf_asymmetry_parameter_uncert_" + band_name, f); }
233 
234  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::anisotropy_parameter, helper, spec_idx);
235  out->register_data_source("/RetrievalResults/brdf_anisotropy_parameter_" + band_name, f); }
236 
237  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::anisotropy_parameter_uncert, helper, spec_idx);
238  out->register_data_source("/RetrievalResults/brdf_anisotropy_parameter_uncert_" + band_name, f); }
239 
240  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::breon_factor, helper, spec_idx);
241  out->register_data_source("/RetrievalResults/brdf_breon_factor_" + band_name, f); }
242 
243  { boost::function<double ()> f = boost::bind(&BrdfOutputHelper::breon_factor_uncert, helper, spec_idx);
244  out->register_data_source("/RetrievalResults/brdf_breon_factor_uncert_" + band_name, f); }
245  }
246 
247  surface_type = "BRDF " + brdf->breon_type();
248  out->register_data_source("/RetrievalResults/surface_type", surface_type.c_str());
249 
250 }
double reflectance_intercept(int spec_idx)
double weight_slope(int spec_idx)
double breon_factor(int spec_idx)
BrdfOutputHelper(const boost::shared_ptr< GroundBrdf > &Brdf, const boost::shared_ptr< Level1bSampleCoefficient > &L1b)
double rahman_factor_uncert(int spec_idx)
double hotspot_parameter_uncert(int spec_idx)
double weight_intercept(int spec_idx)
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
double weight_intercept_uncert(int spec_idx)
double reflectance_slope_uncert(int spec_idx)
double uncert_value(int spec_idx, int coeff_idx)
double kernel_amplitude(int spec_idx) const
Apply value function to a blitz array.
double weight_slope_uncert(int spec_idx)
virtual void register_output(const boost::shared_ptr< Output > &out) const
Register portions of class that will be written to output.
double anisotropy_parameter_uncert(int spec_idx)
As described in the Output class, we have a decentralized model of producing output for L2 Full Physi...
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
#define REGISTER_LUA_END()
Definition: register_lua.h:134
def(luabind::constructor< int >()) .def("rows"
double breon_factor_uncert(int spec_idx)
double reflectance_slope(int spec_idx)
double reflectance_intercept_uncert(int spec_idx)
double asymmetry_parameter_uncert(int spec_idx)
double asymmetry_parameter(int spec_idx)
virtual void register_output_apriori(const boost::shared_ptr< Output > &out) const
Register apriori portions of class.
This class implements the Breon + Rahman ground type.
Definition: ground_brdf.h:19
double anisotropy_parameter(int spec_idx)
double rahman_factor(int spec_idx)
This registers the portions of the GroundBrdf class that should be written as output.
double hotspot_parameter(int spec_idx)

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