OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
DbAlgLand.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * NAME: DbAlgLand.cpp
4  *
5  * DESCRIPTION: Object class that provides data structures and processes that
6  * compute processings for a given DbAlgLand object class.
7  *
8  * Created on: October 13, 2018
9  * Author: Sam Anderson, DB
10  *
11  * Modified:
12  *
13  *******************************************************************************/
14 
15 #include <boost/math/interpolators/barycentric_rational.hpp>
16 #include <fstream>
17 
18 #include <DDAlgorithm.h>
19 #include <DDProcess.h>
20 #include <DDOptions.h>
21 #include "deepblue/DbLutNetcdf.h"
22 #include "deepblue/DbMask.h"
23 #include "deepblue/DbAlgorithm.h"
24 
25 using namespace std;
26 
27 extern"C" {
28 void deepblue_initialize_( char* config_file, char* nc4_file,
29  int* lines, int* pixels, float* lat, float* lon,
30  int* year, int* month, int* day);
31 void deepblue_cleanup_();
32 void find_v_viirs_( float* realbuf, float* tmpvg, float* outbuf, int* flags,
33  float* elev, int* ls_flag, float* windsp, float* wv);
34 };
35 
36 /**************************************************************************
37  * NAME: DbAlgLand()
38  *
39  * DESCRIPTION: Class Constructor
40  *
41  *************************************************************************/
42 
44 {
45 }
46 
47 /**************************************************************************
48  * NAME: ~DbAlgLand()
49  *
50  * DESCRIPTION: Class Destructor
51  *
52  *************************************************************************/
53 
55 {
57 
58  delete msr_lut_;
59  delete vsr_lut_;
60  delete scl_lut_;
61  delete sp_lut_;
62  delete mt_lut_;
63  delete gz_lut_;
64 
65  delete cm_;
66  delete smoke_;
67  delete ha_smoke_;
68  delete pyrocb_;
69 }
70 
71 /**************************************************************************
72  * NAME: initialize()
73  *
74  * DESCRIPTION: Virtual function initializes data and object classes for
75  * processing operations.
76  *
77  *************************************************************************/
78 
79 int DbAlgLand::initialize( map<string, ddata*> imap )
80 {
81  int status = DTDB_SUCCESS;
82 
84  if (status != DTDB_SUCCESS) {
85  std::cerr << "DbAlgLand:: Base class initialization failure" << std::endl;
86  return status;
87  }
88  status = initialize_LUT_data( imap );
89 // Compute various arrays, including dstar, ndvi, sca, etc.
90 
91 // calculate values needed in table interpolation
92  for (int j = 0; j < 7; j++) {
93  for (int k = j; k <= j + 3; k++) {
94  float xdenom = 1.0;
95  for (int i = j; i <= j + 3; i++) {
96  if (i != k) xdenom = xdenom*(xzlog[k] - xzlog[i]);
97  }
98  densol_[j][k-j] = xdenom;
99  }
100  }
101  for (int j = 0; j < 5; j++) {
102  for (int k = j; k <= j + 3; k++) {
103  float xdenom = 1.0;
104  for (int i = j; i <= j + 3; i++) {
105  if (i != k) xdenom = xdenom*(xlog[k] - xlog[i]);
106  }
107  denscn_[j][k-j] = xdenom;
108  }
109  }
110 
111  cm_ = new DbCloudMaskLand(this);
112  smoke_ = new DbSmokeMask(this);
113  pyrocb_ = new DbPyrocbMask(this);
114  ha_smoke_ = new DbHighAltSmokeMask(this);
115 
116  return status;
117 }
118 
119 int DbAlgLand::initialize_LUT_data( map<string, ddata*> imap )
120 {
121  int status = DTDB_SUCCESS;
122 
124  string config_file = static_cast<ddstr*>(imap["config_file"])->str;
125  int num_lines = static_cast<ddval<int>*>(imap["num_lines"])->val;
126  int num_pixels = static_cast<ddval<int>*>(imap["num_pixels"])->val;
127  int start_year = static_cast<ddval<int>*>(imap["start_year"])->val;
128  int start_month = static_cast<ddval<int>*>(imap["start_month"])->val;
129  int start_day = static_cast<ddval<int>*>(imap["start_day"])->val;
130  int season = static_cast<ddval<int>*>(imap["season"])->val;
131  ddma<float,2>* plat = static_cast<ddma<float,2>*>(imap["latitude"]);
132  ddma<float,2>* plon = static_cast<ddma<float,2>*>(imap["longitude"]);
133 
134  char nc4_file[255] = "";
135  string nc4_str = get_option(INPUT_NC4_LUT);
136  if (nc4_str.empty()) {
137  nc4_str = get_option(INPUT_DB_NC4_LUT);
138  }
139  nc4_str.copy(nc4_file, nc4_str.length());
140  char cfile[255] = "";
141  config_file.copy(cfile, config_file.length());
142 
143 // Load LUTs
144  deepblue_initialize_( cfile, nc4_file, &num_lines,
145  &num_pixels, &plat->pts[0][0], &plon->pts[0][0],
146  &start_year, &start_month, &start_day );
147 
148  DbLutNetcdf* lutgen = new DbLutNetcdf();
149  msr_lut_ = new dbModisSurfReflLimited;
150  status = lutgen->read_modis_surf_refl_lut(msr_lut_, &ler_start_[0],
151  &ler_edge_[0], season, dateline_);
152  vsr_lut_ = new dbViirsSurfReflLimited;
153  status = lutgen->read_viirs_surf_refl_lut(vsr_lut_, &ler_start_[0],
154  &ler_edge_[0], season, dateline_);
155  scl_lut_ = new dbSurfCoeffLimited();
156  status = lutgen->read_surf_coeff_lut(scl_lut_, &ler_start_[0],
157  &ler_edge_[0], season, dateline_);
158  sp_lut_ = new dbSurfacePressureLUT();
159  status = lutgen->read_surface_pressure_lut(sp_lut_);
160  mt_lut_ = new dbTablesLUT();
161  status = lutgen->read_tables_lut(mt_lut_);
162  gz_lut_ = new dbGeozoneLUT();
163  status = lutgen->read_geozone_lut(gz_lut_);
164  delete lutgen;
165 
166  return status;
167 }
168 
169 /**************************************************************************
170  * NAME: compute()
171  *
172  *************************************************************************/
173 
174 map<string, ddata*> DbAlgLand::process(vector<size_t> start, vector<size_t> count,
175  map<string, ddata*> imap)
176 {
177  get_inputs(start, count, imap);
178 
179  l2_flags_ += (unsigned int) flags::LAND;
180 
181  size_t iy = start[0];
182  size_t ix = start[1];
183 
184  float realbuf[26];
185  float ob[21];
186  float tmpvg[7];
187  int flags[4];
188  int ls_flag;
189  float cl_flag = DFILL_FLOAT;
190 
191  set_fill_out();
192  for (size_t i=0; i<21; i++) {
193  ob[i] = DFILL_FLOAT;
194  }
195  mask_cm_ = DFILL_SHORT;
196  short snow_1 = DFILL_SHORT;
197  short snow_2 = DFILL_SHORT;
198 
199 // -- Skip pixels with invalid angles
200  if ((solz_ > 84.0) || (solz_ < 0.0) || (senz_ < 0.0) || (senz_ > 90.0) ||
201  (raa_ < 0.0) || (raa_ > 180.0) || (ws_ < 0.0) || (ws_ > 99.0)) {
202 // std::cerr << "DbAlgOcean:: Invalid angles at "<< iy << ":" << ix << std::endl;
203  return set_fills();
204  }
205 // -- Skip pixels with invalid reflectances
206  if ((rfl_[(int)rhot_band::W490] < 0) || (rfl_[(int)rhot_band::W550] < 0) ||
207  (rfl_[(int)rhot_band::W670] < 0) || (rfl_[(int)rhot_band::W865] < 0)) {
208 // std::cerr << "DbAlgOcean:: Invalid reflectances at "<< iy << ":" << ix << std::endl;
209  l2_flags_ += (unsigned int) flags::BOWTIEDEL;
210  return set_fills();
211  }
212 
213  compute_glint_angle(glint_angle_);
214  compute_scatter_angle(scatter_angle_);
215 
216  compute_dstar( iy, ix );
217  if (sr670_<=DFILL_TEST) {
218  return set_fills();
219  }
220 
221  cm_->compute_1( iy, ix, mask_cm_, snow_1, snow_2 );
222 
223 // at this point convert from VIIRS to IOF units
224  double cossza = cos(solz_*DEGtoRAD);
225  for ( int i=0; i<NTWL; i++) {
226  if (rfl_[i] > DFILL_TEST) {
227  rfl_[i] *= (cossza/M_PI);
228  }
229  for (size_t il=0; il<=2; il++) {
230  for (size_t ip=0; ip<=2; ip++) {
231  if (rfla_[i][il][ip] > DFILL_TEST) {
232  rfla_[i][il][ip] *= (cossza/M_PI);
233  }
234  }
235  }
236  }
237  NC_[NC412] = rfl_[(int)rhot_band::W410];
238  NC_[NC488] = rfl_[(int)rhot_band::W490];
239  NC_[NC670] = rfl_[(int)rhot_band::W670];
240 
241  if (bgascorrect_) {
242  compute_gas_correction();
243  for (int ib = 0; ib < NTWL; ib++) {
244  rfl_[ib] *= gasc_[ib];
245  }
246  }
247 
248  compute_sr( iy, ix );
249  if (sr412_<=DFILL_TEST || sr488_<=DFILL_TEST || sr670_<=DFILL_TEST) {
250  return set_fills();
251  }
252  compute_ler( iy, ix );
253  if (ler412_<=DFILL_TEST || ler488_<=DFILL_TEST || ler670_<=DFILL_TEST) {
254  return set_fills();
255  }
256 
257  cm_->compute_2( iy, ix, mask_cm_, snow_2 );
258 
259  smoke_->compute( iy, ix, mask_smoke_ );
260  pyrocb_->compute( iy, ix, mask_pyrocb_ );
261  ha_smoke_->compute( iy, ix, mask_ha_smoke_ );
262 
263  if (mask_smoke_ == 1 || mask_pyrocb_ == 1 || mask_ha_smoke_ == 1) {
264  mask_cm_ = 0;
265  }
266 
267  if (cloud_mask_ == DFILL_UBYTE) {
268  cloud_mask_ = mask_cm_;
269  } else {
270  mask_cm_ = cloud_mask_;
271  }
272  if (!bcloudmask_) {
273  mask_cm_ = 0;
274  }
275  if (bcloudmask_ && cloud_mask_) {
276  l2_flags_ += (unsigned int) flags::CLDICE;
277  return set_fills();
278  }
279 
280  if (mask_cm_ == 0 && rfl_[(int)rhot_band::W410] > 0) {
281 
282  tmpvg[0] = rfl_[(int)rhot_band::W670];
283  tmpvg[1] = rfl_[(int)rhot_band::W490];
284  tmpvg[2] = rfl_[(int)rhot_band::W410];
285  tmpvg[3] = rfl_[(int)rhot_band::W2250];
286  tmpvg[4] = rfl_[(int)rhot_band::W865];
287  tmpvg[5] = rfl_[(int)rhot_band::W1240];
288  tmpvg[6] = rfl_[(int)rhot_band::W2250];
289 
290  realbuf[0] = lat_;
291  realbuf[1] = lon_;
292  realbuf[2] = solz_;
293  realbuf[3] = senz_;
294  realbuf[4] = raa_;
295  realbuf[5] = ler670_;
296  realbuf[6] = NC_[NC670]; //no
297  realbuf[7] = rfl_[(int)rhot_band::W490]; //new
298  realbuf[8] = NC_[NC488]; //no
299  realbuf[9] = rfl_[(int)rhot_band::W410]; //new
300  realbuf[10] = NC_[NC412]; //no
301  realbuf[11] = rfl_[(int)rhot_band::W2250]; //old
302  realbuf[12] = DFILL_FLOAT;
303  realbuf[13] = ndvi_;
304  realbuf[14] = rfl_[(int)rhot_band::W12000];
305  realbuf[15] = dstar_;
306  realbuf[16] = cl_flag;
307  realbuf[17] = qdf412_;
308  realbuf[18] = qdf488_;
309  realbuf[19] = qdf670_;
310  realbuf[20] = ps_/1013.25;
311  realbuf[21] = ler412_;
312  realbuf[22] = ler488_;
313  realbuf[23] = DFILL_FLOAT;
314  realbuf[24] = DFILL_FLOAT;
315  realbuf[25] = DFILL_FLOAT;
316 
317  find_v_viirs_( &realbuf[0], &tmpvg[0], &ob[0], &flags[0],
318  &height_, &ls_flag, &ws_, &pwv_);
319  }
320 
321  mask_cm_ = (mask_cm_ >= 0) ? mask_cm_ : DFILL_SHORT;
322 
323  float aotmax = (mask_cm_==0) ? 30.0 : 5.0;
324  lOut_.aot[OL412] = (ob[0] > 0.0 && ob[0] <= aotmax) ? ob[0] : DFILL_FLOAT;
325  lOut_.aot[OL488] = (ob[1] > 0.0 && ob[1] <= aotmax) ? ob[1] : DFILL_FLOAT;
326  lOut_.aot[OL670] = (ob[2] > 0.0 && ob[2] <= aotmax) ? ob[2] : DFILL_FLOAT;
327  lOut_.ssa[OL412] = (ob[3] > 0.0 && ob[3] <= aotmax) ? ob[3] : DFILL_FLOAT;
328  lOut_.ssa[OL488] = (ob[4] > 0.0 && ob[4] <= aotmax) ? ob[4] : DFILL_FLOAT;
329  lOut_.ssa[OL670] = (ob[5] > 0.0 && ob[5] <= aotmax) ? ob[5] : DFILL_FLOAT;
330  lOut_.aot550 = (ob[6] > DFILL_TEST) ? ob[6] : DFILL_FLOAT;
331  lOut_.ae = (ob[7] > DFILL_TEST) ? ob[7] : DFILL_FLOAT;
332  lOut_.sr[OL412] = (ob[8] > 0.0) ? ob[8]/100.0 : DFILL_FLOAT;
333  lOut_.sr[OL488] = (ob[10] > 0.0) ? ob[10]/100.0 : DFILL_FLOAT;
334  lOut_.sr[OL670] = (ob[11] > 0.0) ? ob[11]/100.0 : DFILL_FLOAT;
335  lOut_.sfc_type = (ob[14] > DFILL_TEST) ? ob[14] : DFILL_SHORT;
336  lOut_.alg_flag = (ob[17] > DFILL_TEST) ? ob[17] : DFILL_SHORT;
337  lOut_.ndvi = (ndvi_ > DFILL_TEST) ? ndvi_ : DFILL_FLOAT;
338  lOut_.aerosol_type = 8;
339 
340  if (lOut_.aot550 > DFILL_TEST) {
341  lOut_.aerosol_type = 5; // mixed, default
342  }
343  if (lOut_.ae > 1.2 && lOut_.aot550 > 0.4) {
344  lOut_.aerosol_type = 4; // non-smoke fine mode
345  }
346  if (mask_smoke_ == 1 && lOut_.aot550 > DFILL_TEST) {
347  lOut_.aerosol_type = 1; // smoke
348  }
349  if (mask_ha_smoke_ == 1 && lOut_.aot550 > DFILL_TEST) {
350  lOut_.aerosol_type = 2; // high altitude smoke
351  }
352  if (mask_pyrocb_ == 1 && lOut_.aot550 > DFILL_TEST) {
353  lOut_.aerosol_type = 3; // pyrocumulonimbus clouds
354  }
355  if (lOut_.aot550 > DFILL_TEST && lOut_.aot550 < 0.2) {
356  lOut_.aerosol_type = 6; // background
357  }
358  if (dstar_ > 1.1 && lOut_.aot550 > DFILL_TEST) {
359  lOut_.aerosol_type = 0; // dust
360  }
361  if (lOut_.ae < 0.1 && ob[20] < 0.78 && lOut_.aot550 > 0.4) {
362  lOut_.aerosol_type = 0; // dust
363  }
364 /*
365  if (lOut_.ae < 0.5 && gzone > 0 && gzone < 12 && lOut_.aot550 > 0.2) {
366  lOut_.aerosol_type = 0; // dust
367  }
368 */
369 
370 // write to generic outputs
371 
372  qual_flag_ = (lOut_.aot550 < DFILL_TEST) ? 0 : 3;
373  aerosol_type_ = lOut_.aerosol_type;
374  error_flag_ = lOut_.alg_flag;
375 
376  scatter_ang_ = scatter_angle_;
377  glint_ang_ = glint_angle_;
378  sse_ = DFILL_FLOAT;
379  fmf_ = DFILL_FLOAT;
380  aot_550_ = lOut_.aot550;
381  ae1_ = lOut_.ae;
382  ae2_ = DFILL_FLOAT;
383  ndv_ = lOut_.ndvi;
384  chlor_ = DFILL_FLOAT;
385  for ( int ib=0; ib<NOWL+1; ib++ ) {
386  aot_[ib] = DFILL_FLOAT;
387  }
388  aot_[(size_t)aot_band::W410] = lOut_.aot[(size_t)srf_band::W410];
389  aot_[(size_t)aot_band::W490] = lOut_.aot[(size_t)srf_band::W490];
390  aot_[(size_t)aot_band::W550] = lOut_.aot550;
391  aot_[(size_t)aot_band::W670] = lOut_.aot[(size_t)srf_band::W670];
392  for ( int ib=0; ib<NLWL; ib++ ) {
393  sr_[ib] = lOut_.sr[ib];
394  ssa_[ib] = lOut_.ssa[ib];;
395  }
396  sr_[(size_t)srf_band::W2250] = DFILL_FLOAT;
397  ssa_[(size_t)srf_band::W2250] = DFILL_FLOAT;
398  for (int ib = 0; ib < DB_RFL_BANDS; ib++) {
399  rfl_[ib] *= (M_PI/cossza);
400  }
401 
402  size_t cgood = 0;
403  vector<float> tba, yba;
404  if (aot_[(size_t)aot_band::W410]>0.0) {
405  tba.push_back(410.0);
406  yba.push_back(aot_[(size_t)aot_band::W410]);
407  cgood++;
408  }
409  if (aot_[(size_t)aot_band::W490]>0.0) {
410  tba.push_back(490.0);
411  yba.push_back(aot_[(size_t)aot_band::W490]);
412  cgood++;
413  }
414  if (aot_[(size_t)aot_band::W550]>0.0) {
415  tba.push_back(550.0);
416  yba.push_back(aot_[(size_t)aot_band::W550]);
417  cgood++;
418  }
419  if (aot_[(size_t)aot_band::W670]>0.0) {
420  tba.push_back(670.0);
421  yba.push_back(aot_[(size_t)aot_band::W670]);
422  cgood++;
423  }
424  if (cgood >= 3) {
425  using boost::math::barycentric_rational;
426  barycentric_rational<float> interp(move(tba), move(yba), 2);
427  if (aot_[(size_t)aot_band::W670] < 0) {
428  aot_[(size_t)aot_band::W670] = interp(670.0);
429  }
430  aot_[(size_t)aot_band::W865] = interp(865.0);
431  aot_[(size_t)aot_band::W1240] = interp(1240.0);
432  aot_[(size_t)aot_band::W1610] = interp(1610.0);
433  aot_[(size_t)aot_band::W2250] = interp(2250.0);
434  }
435  return set_outputs();
436 }
437 
438 /**************************************************************************
439 * NAME: compute_dstar()
440 *
441 * DESCRIPTION: Compute D* and LER670 required for initial cloud filter
442 *
443 *************************************************************************/
444 
445 int DbAlgLand::compute_dstar( const size_t iy, const size_t ix )
446 {
447  int status = DTDB_SUCCESS;
448 
449  if (lat_ < DFILL_TEST || lon_ < DFILL_TEST) {
450  return status;
451  }
452  float psi = acos( cos(solz_*DEGtoRAD)*cos(senz_*DEGtoRAD) -
453  sin(solz_*DEGtoRAD)*sin(senz_*DEGtoRAD) *
454  cos(raa_*DEGtoRAD) );
455  sca_ = 180.0 - psi / DEGtoRAD;
456  gla_ = psi / DEGtoRAD;
457  amf_ = 1.0/cos(solz_*DEGtoRAD) + 1.0/cos(senz_*DEGtoRAD);
458  if (rfl_[(int)rhot_band::W865] > DFILL_TEST
459  && rfl_[(int)rhot_band::W670] > DFILL_TEST) {
460  ndvi_ = (rfl_[(int)rhot_band::W865] - rfl_[(int)rhot_band::W670])
461  / (rfl_[(int)rhot_band::W865] + rfl_[(int)rhot_band::W670]);
462  } else {
463  ndvi_ = DFILL_FLOAT;
464  }
465  btd8_ = rfl_[(int)rhot_band::W8550] - rfl_[(int)rhot_band::W11000];
466  btd11_ = rfl_[(int)rhot_band::W11000] -rfl_[(int)rhot_band::W12000];
467 //calculate D* parameter. Skip bad/cloudy pixels
468  float A = -0.05;
469  float B = 10.0;
470  float ratio = (btd11_ - A) / (btd8_ - B);
471  dstar_ = (ratio >= 5.0) ? DFILL_FLOAT : exp(ratio);
472 
473  if (rfl_[(int)rhot_band::W670] <= 0.0 ||
474  rfl_[(int)rhot_band::W490] <= 0.0 ||
475  rfl_[(int)rhot_band::W410] <= 0.0) {
476  sr670_ = DFILL_FLOAT;
477  return status;
478  }
479  int ilat = floor((lat_ + 90.0)*10.0);
480  if (ilat >= 1800) ilat = 1800-1;
481  if (ilat < 0) ilat = 0;
482  int ilon = floor((lon_ + 180.0)*10.0);
483  if (ilon >= 3600) ilon = 3600-1;
484  if (ilon < 0) ilon = 0;
485  int sx;
486  if (dateline_ == 0 || ilon > ler_start_[0]) {
487  sx = ilon - ler_start_[0];
488  } else {
489  sx = ilon + dateline_;
490  }
491  int sy = ilat - ler_start_[1];
492  int nidx;
493  if (ndvi_ < NDVI1_CUTOFF) {
494  nidx = 0;
495  } else if (ndvi_ < NDVI2_CUTOFF) {
496  nidx = 1;
497  } else {
498  nidx = 2;
499  }
500  float c670[4], sr670;
501  if (raa_ < 90.0) {
502  for (int i = 0; i < 4; i++) {
503  c670[i] = scl_lut_->SC650_FWD_L[nidx][i][sy][sx];
504  }
505  sr670 = vsr_lut_->SR670_ALL_L[sy][sx]/100.0;
506  } else {
507  for (int i = 0; i < 4; i++) {
508  c670[i] = scl_lut_->SC650_ALL_L[nidx][i][sy][sx];
509  }
510  sr670 = vsr_lut_->SR670_ALL_L[sy][sx]/100.0;
511  }
512  float sfref670 = DFILL_FLOAT;
513  if (c670[0]>0 || c670[1]>0 || c670[2]>0 || c670[3]>0) {
514  sfref670 =
515  (c670[0] + sca_*(c670[1] + sca_*(c670[2] + sca_*c670[3])))/100.0;
516  }
517  sfref670 = (sfref670 < 0.0) ? sr670 : sfref670;
518  sr670_ = sfref670;
519 
520  return status;
521 }
522 
523 /**************************************************************************
524 * NAME: compute_sr()
525 *
526 * DESCRIPTION: Retrieve and compute Lambertian Equivalent Radiance
527 *
528 *************************************************************************/
529 
530 int DbAlgLand::compute_sr( const size_t iy, const size_t ix ) {
531 
532  int status = DTDB_SUCCESS;
533 
534  if (lat_ <= DFILL_TEST || lon_ <= DFILL_TEST) {
535  return status;
536  }
537 
538  if (rfl_[(int)rhot_band::W670] <= 0.0 ||
539  rfl_[(int)rhot_band::W490] <= 0.0 ||
540  rfl_[(int)rhot_band::W410] <= 0.0) {
541  sr412_ = DFILL_FLOAT;
542  sr488_ = DFILL_FLOAT;
543  sr670_ = DFILL_FLOAT;
544  return status;
545  }
546  if (rfl_[(int)rhot_band::W865] > DFILL_TEST
547  && rfl_[(int)rhot_band::W670] > DFILL_TEST) {
548  ndvi_ = (rfl_[(int)rhot_band::W865] - rfl_[(int)rhot_band::W670])
549  / (rfl_[(int)rhot_band::W865] + rfl_[(int)rhot_band::W670]);
550  } else {
551  ndvi_ = DFILL_FLOAT;
552  }
553  int ilat = floor((lat_ + 90.0)*10.0);
554  if (ilat >= 1800) ilat = 1800-1;
555  if (ilat < 0) ilat = 0;
556  int ilon = floor((lon_ + 180.0)*10.0);
557  if (ilon >= 3600) ilon = 3600-1;
558  if (ilon < 0) ilon = 0;
559  int sx;
560  if (dateline_ == 0 || ilon > ler_start_[0]) {
561  sx = ilon - ler_start_[0];
562  } else {
563  sx = ilon + dateline_;
564  }
565  int sy = ilat - ler_start_[1];
566  int nidx;
567  if (ndvi_ < NDVI1_CUTOFF) {
568  nidx = 0;
569  } else if (ndvi_ < NDVI2_CUTOFF) {
570  nidx = 1;
571  } else {
572  nidx = 2;
573  }
574  float c412[4], sr412;
575  float c488[4], sr488;
576  float c670[4], sr670;
577  sr412 = vsr_lut_->SR412_ALL_L[sy][sx];
578  sr488 = vsr_lut_->SR488_ALL_L[sy][sx];
579  sr670 = vsr_lut_->SR670_ALL_L[sy][sx];
580  if (sr412<=DFILL_TEST || sr488<=DFILL_TEST || sr670<=DFILL_TEST) {
581  sr412_ = DFILL_FLOAT;
582  sr488_ = DFILL_FLOAT;
583  sr670_ = DFILL_FLOAT;
584  return status;
585  } else {
586  sr412 /= 100.0;
587  sr488 /= 100.0;
588  sr670 /= 100.0;
589  }
590  if (raa_ < 90.0) {
591  for (int i = 0; i < 4; i++) {
592  c412[i] = scl_lut_->SC412_FWD_L[nidx][i][sy][sx];
593  c488[i] = scl_lut_->SC470_FWD_L[nidx][i][sy][sx];
594  c670[i] = scl_lut_->SC650_FWD_L[nidx][i][sy][sx];
595  }
596  } else {
597  for (int i = 0; i < 4; i++) {
598  c412[i] = scl_lut_->SC412_ALL_L[nidx][i][sy][sx];
599  c488[i] = scl_lut_->SC470_ALL_L[nidx][i][sy][sx];
600  c670[i] = scl_lut_->SC650_ALL_L[nidx][i][sy][sx];
601  }
602  }
603  float sfref412 = DFILL_FLOAT;
604  float sfref488 = DFILL_FLOAT;
605  float sfref670 = DFILL_FLOAT;
606  if (c412[0]>0 || c412[1]>0 || c412[2]>0 || c412[3]>0) {
607  sfref412 =
608  (c412[0] + sca_*(c412[1] + sca_*(c412[2] + sca_*c412[3])))/100.0;
609  }
610  if (c488[0]>0 || c488[1]>0 || c488[2]>0 || c488[3]>0) {
611  sfref488 =
612  (c488[0] + sca_*(c488[1] + sca_*(c488[2] + sca_*c488[3])))/100.0;
613  }
614  if (c670[0]>0 || c670[1]>0 || c670[2]>0 || c670[3]>0) {
615  sfref670 =
616  (c670[0] + sca_*(c670[1] + sca_*(c670[2] + sca_*c670[3])))/100.0;
617  }
618  sfref412 = (sfref412 < 0.0) ? sr412 : sfref412;
619  sfref488 = (sfref488 < 0.0) ? sr488 : sfref488;
620  sfref670 = (sfref670 < 0.0) ? sr670 : sfref670;
621  sr412_ = sfref412;
622  sr488_ = sfref488;
623  sr670_ = sfref670;
624 
625  return status;
626 }
627 
628 /**************************************************************************
629 *NAME: compute_ler()
630  *
631 *DESCRIPTION: Retrieve and compute Lambertian Equivalent Radiance
632  *
633  *************************************************************************/
634 
635 int DbAlgLand::compute_ler( const size_t iy, const size_t ix )
636 {
637  int status = DTDB_SUCCESS;
638 
639  if (rfl_[(int)rhot_band::W670] <= 0.0 ||
640  rfl_[(int)rhot_band::W490] <= 0.0 ||
641  rfl_[(int)rhot_band::W410] <= 0.0) {
642  ler412_ = DFILL_FLOAT;
643  ler488_ = DFILL_FLOAT;
644  ler670_ = DFILL_FLOAT;
645  qdf412_ = DFILL_FLOAT;
646  qdf488_ = DFILL_FLOAT;
647  qdf670_ = DFILL_FLOAT;
648  return status;
649  }
650 
651  int ilat = floor((lat_ + 90.0)*10.0);
652  if (ilat >= 1800) ilat = 1800-1;
653  if (ilat < 0) ilat = 0;
654  int ilon = floor((lon_ + 180.0)*10.0);
655  if (ilon >= 3600) ilon = 3600-1;
656  if (ilon < 0) ilon = 0;
657  ilat = floor((90.0 - lat_)*12.0);
658  if (ilat >= 2160) ilat = 2160-1;
659  if (ilat < 0) ilat = 0;
660  ilon = floor((lon_ + 180.0)*12.0);
661  if (ilon >= 4320) ilon = 4320-1;
662  if (ilon < 0) ilon = 0;
663 
664  float tmp0, tmp1;
665  compute_pressure(height_, tmp0, pteran_, tmp1);
666  double convrt = 0.005729577951;
667  ilat = 1;
668  if (abs(lat_) > 15.)
669  ilat = 2;
670  if (abs(lat_) > 60.)
671  ilat = 3;
672 // unpack thir cloud top pressure, terrain height, surface
673 // category, percent cloudiness and snow thickness
674 // compute phase factor terms,lagrange coeffs. and index offset
675 // for solar and satellite zenith angle interpolations
676  float xtemp1 = solz_ / (convrt*10000.);
677  float xtemp2 = sin(xtemp1);
678  xtemp1 = cos(xtemp1);
679  float xzlog1 = 0.0;
680  if (xtemp1 > 0.)
681  xzlog1 = log(1.0/xtemp1);
682 // raa variables
683  float ztemp1 = raa_/(convrt*10000.0);
684  cphi_ = cos(ztemp1);
685  cphir_ = cos(ztemp1*2.0);
686 // theta variables
687  float ytemp1 = senz_/(convrt*10000.0);
688  float ytemp2 = sin(ytemp1);
689  ytemp1 = cos(ytemp1);
690  float xlog1 = 0.0;
691  if (ytemp1 > 0.)
692  xlog1 = log(1.0/ytemp1);
693 // phase factors
694  phs_ = -0.375*xtemp1*xtemp2*ytemp2;
695  phsr_ = 2.0*phs_/(3.0*ytemp1*xtemp1*xtemp1);
696 // set up index offset value for theta,theta0
697  int indsol = 0;
698  for (int i = 0; i < 10; i++) {
699  indsol = i;
700  if (xzlog[i] >= xzlog1) break;
701  }
702  indsol = indsol - 2;
703 // check for range
704  if (indsol < 0) indsol = 0;
705  if (indsol >= 7) indsol = 7-1;
706 // theta
707  int indscn = 0;
708  for (int i = 0; i < 8; i++) {
709  indscn = i;
710  if (xlog[i] >= xlog1) break;
711  }
712  indscn = indscn - 2;
713 // check range
714  if (indscn < 0) indscn = 0;
715  if (indscn >= 5) indscn = 5-1;
716 // compute lagrange coeffs for solar zenith angle
717  float indmax = indsol + 3;
718  int j = 0;
719  float xnom = 1.0;
720  float cthet0[4];
721  for (int k = indsol; k <= indmax; k++) {
722  xnom = 1.0;
723  for (int i = indsol; i <= indmax; i++) {
724  if (i != k) {
725  xnom = (xzlog1 - xzlog[i])*xnom;
726  }
727  }
728  cthet0[j] = xnom / densol_[indsol][j];
729  j++;
730  }
731 // compute lagrange coeffs. for theta interp
732  indmax = indscn + 3;
733  j = 0;
734  float ctheta[4];
735  for (int k = indscn; k <= indmax; k++) {
736  xnom = 1.0;
737  for (int i = indscn; i <= indmax; i++) {
738  if (i != k) {
739  xnom = (xlog1 - xlog[i])*xnom;
740  }
741  }
742  ctheta[j] = xnom / denscn_[indscn][j];
743  j++;
744  }
745 // compute offset into tables for theta0, theta block
746  int iofset = indsol*8 + indscn;
747 // store products of coeffs
748  int l = 0;
749  for (int i = 0; i < 4; i++) {
750  for (int k = 0; k < 4; k++) {
751  cofs_[l] = ctheta[k]*cthet0[i];
752  l++;
753  }
754  }
755  float sfref412 = sr412_;
756  float sfref488 = sr488_;
757  float sfref670 = sr670_;
758  float clref = 0.80;
759  float grref = sfref670;
760  float qgc670 = 0.0;
761  float qcc670 = 0.0;
762  float qdif670 = 0.0;
763  float qgc670x = 0.0;
764  float qcc670x = 0.0;
765  float qgc412 = 0.0;
766  float qcc412 = 0.0;
767  float qdif412 = 0.0;
768  float qgc412x = 0.0;
769  float qcc412x = 0.0;
770  float qgc488 = 0.0;
771  float qcc488 = 0.0;
772  float qdif488 = 0.0;
773  float qgc488x = 0.0;
774  float qcc488x = 0.0;
775 // int ip670_1[2] = { 0, 80 };
776 // int ip670_2[2] = { 0, 1 };
777  int ipt_1[2] = { 0, 10400 };
778  int ipt_2[2] = { 0, 130 };
779  int lamtb1[5] = { 0, 2080, 4160, 6240, 8320 };
780  int lamtb2[5] = { 0, 26, 52, 78, 104 };
781  float ez670[2], t670[2], sb670[2];
782  float ez412[2], t412[2], sb412[2];
783  float ez488[2], t488[2], sb488[2];
784 // set terrain and cloud weighting fractions
785  float pwtlo = (pteran_ - .4) / .6;
786  float pwthi = (pcloud_ - .4) / .6;
787 // convert 670, 412, and 488 nm channel n values to albedos
788  float alb670 = NC_[NC670];
789  float alb412 = NC_[NC412];
790  float alb488 = NC_[NC488];
791  float qsh670 = DFILL_FLOAT;
792  float qsh412 = DFILL_FLOAT;
793  float qsh488 = DFILL_FLOAT;
794  float qsl670 = DFILL_FLOAT;
795  float qsl412 = DFILL_FLOAT;
796  float qsl488 = DFILL_FLOAT;
797 // calculate Rayleigh correction
798  for (int ip = 0; ip < 2; ip++) {
799 // compute table indices for 670 channel
800  int i670_1 = ipt_1[ip] + lamtb1[3] + iofset;
801  int i670_2 = ipt_2[ip] + lamtb2[3];
802 // compute table indices for 412 channel
803  int i412_1 = ipt_1[ip] + lamtb1[0] + iofset;
804  int i412_2 = ipt_2[ip] + lamtb2[0];
805 // compute table indices for 488 channel
806  int i488_1 = ipt_1[ip] + lamtb1[2] + iofset;
807  int i488_2 = ipt_2[ip] + lamtb2[2];
808 // perform interpolations
809 // for 670
810  interx(i670_1, i670_2, rhot_band::W670, ez670[ip], t670[ip], sb670[ip]);
811 // for 412
812  interx(i412_1, i412_2, rhot_band::W410, ez412[ip], t412[ip], sb412[ip]);
813 // for 488
814  interx(i488_1, i488_2, rhot_band::W490, ez488[ip], t488[ip], sb488[ip]);
815 // determine calculated q values
816 // 670 --
817  qgc670 = ez670[ip] + grref*t670[ip] / (1 - grref*sb670[ip]);
818  qcc670 = ez670[ip] + clref*t670[ip] / (1 - clref*sb670[ip]);
819 // 412 --
820  qgc412 = ez412[ip] + sfref412*t412[ip] / (1 - sfref412*sb412[ip]);
821  qcc412 = ez412[ip] + clref*t412[ip] / (1 - clref*sb412[ip]);
822 // 488 --
823  qgc488 = ez488[ip] + sfref488*t488[ip] / (1 - sfref488*sb488[ip]);
824  qcc488 = ez488[ip] + clref*t488[ip] / (1 - clref*sb488[ip]);
825  if (ip == 0) {
826 // for ip = 0 (p = 1 atm) save q values
827 // and denominator used in ref calculation
828  qsl670 = qgc670;
829  qsh670 = qcc670;
830  qsl412 = qgc412;
831  qsh412 = qcc412;
832  qsl488 = qgc488;
833  qsh488 = qcc488;
834  } else {
835 // for ip = 2 (p = 0.4 atm) interpolate
836 // 0.4 and 1 atm q values to obtain final q values
837  qgc670 = pwtlo*qsl670 + qgc670*(1. - pwtlo);
838  qcc670 = pwthi*qsh670 + qcc670*(1. - pwthi);
839  qdif670 = qsl670 - qgc670;
840 // 412 --
841  qgc412 = pwtlo*qsl412 + qgc412*(1. - pwtlo);
842  qcc412 = pwthi*qsh412 + qcc412*(1. - pwthi);
843  qdif412 = qsl412 - qgc412;
844 // 488 --
845  qgc488 = pwtlo*qsl488 + qgc488*(1. - pwtlo);
846  qcc488 = pwthi*qsh488 + qcc488*(1. - pwthi);
847  qdif488 = qsl488 - qgc488;
848  }
849  }
850 // Calculate reflectivity
851  float rh670 = DFILL_FLOAT;
852  float rh412 = DFILL_FLOAT;
853  float rh488 = DFILL_FLOAT;
854  float rl670 = DFILL_FLOAT;
855  float rl412 = DFILL_FLOAT;
856  float rl488 = DFILL_FLOAT;
857  float cl670 = DFILL_FLOAT;
858  float cl412 = DFILL_FLOAT;
859  float cl488 = DFILL_FLOAT;
860  float r670_10 = 0.0;
861  float r412_10 = 0.0;
862  float r488_10 = 0.0;
863  float r670_04 = 0.0;
864  float r412_04 = 0.0;
865  float r488_04 = 0.0;
866  float d670 = 0.0;
867  float d412 = 0.0;
868  float d488 = 0.0;
869  float grr = 0.02;
870 
871  for (int ip = 0; ip < 2; ip++) {
872 // compute table indices for 670 channel
873  int i670_1 = ipt_1[ip] + lamtb1[3] + iofset;
874  int i670_2 = ipt_2[ip] + lamtb2[3] ;
875 // compute table indices for 412 channel
876  int i412_1 = ipt_1[ip] + lamtb1[0] + iofset;
877  int i412_2 = ipt_2[ip] + lamtb2[0];
878 // compute table indices for 488 channel
879  int i488_1 = ipt_1[ip] + lamtb1[2] + iofset;
880  int i488_2 = ipt_2[ip] + lamtb2[2];
881 // perform interpolations
882  interx(i670_1, i670_2, rhot_band::W670, ez670[ip], t670[ip], sb670[ip]);
883  interx(i412_1, i412_2, rhot_band::W410, ez412[ip], t412[ip], sb412[ip]);
884  interx(i488_1, i488_2, rhot_band::W490, ez488[ip], t488[ip], sb488[ip]);
885 // determine calculated q values
886  qgc670x = ez670[ip] + grr*t670[ip] / (1 - grr*sb670[ip]);
887  qcc670x = ez670[ip] + clref*t670[ip] / (1 - clref*sb670[ip]);
888  qgc412x = ez412[ip] + grr*t412[ip] / (1 - grr*sb412[ip]);
889  qcc412x = ez412[ip] + clref*t412[ip] / (1 - clref*sb412[ip]);
890  qgc488x = ez488[ip] + grr*t488[ip] / (1 - grr*sb488[ip]);
891  qcc488x = ez488[ip] + clref*t488[ip] / (1 - clref*sb488[ip]);
892 
893  if (ip == 0) {
894 // for ip = 1 (p = 1 atm) save q values
895 // and denominator used in ref calculation
896  qsl670 = qgc670x;
897  qsh670 = qcc670x;
898  qsl412 = qgc412x;
899  qsh412 = qcc412x;
900  qsl488 = qgc488x;
901  qsh488 = qcc488x;
902  d670 = alb670 - ez670[ip];
903  d412 = alb412 - ez412[ip];
904  d488 = alb488 - ez488[ip];
905 // calculate reflectivity using version 6 method
906  if (d670 != 0.) {
907  r670_10 = 1. / (t670[ip] / d670 + sb670[ip]);
908  r412_10 = 1. / (t412[ip] / d412 + sb412[ip]);
909  r488_10 = 1. / (t488[ip] / d488 + sb488[ip]);
910  } else {
911  r670_10 = 0.0;
912  r412_10 = 0.0;
913  r488_10 = 0.0;
914  }
915  } else {
916 // for ip = 2 (p = 0.4 atm) interpolate
917 // 0.4 and 1 atm q values to obtain
918 // final q values
919  float pwtlo_base = 1.0;
920  qgc670x = pwtlo_base*qsl670
921  + qgc670x*(1. - pwtlo_base);
922  qcc670x = pwthi*qsh670 + qcc670x*(1. - pwthi);
923 // 412 --
924  qgc412x = pwtlo_base*qsl412
925  + qgc412x*(1. - pwtlo_base);
926  qcc412x = pwthi*qsh412 + qcc412x*(1. - pwthi);
927 // 488 --
928  qgc488x = pwtlo_base*qsl488
929  + qgc488x*(1. - pwtlo_base);
930  qcc488x = pwthi*qsh488 + qcc488x*(1. - pwthi);
931 // determine denominator used in Version 6
932 // ref calculation and calculate Version 6
933 // reflectivity
934  d670 = alb670 - ez670[ip];
935  d412 = alb412 - ez412[ip];
936  d488 = alb488 - ez488[ip];
937  if (d670 != 0.) {
938  r670_04 = 1. / (t670[ip] / d670 + sb670[ip]);
939  rl670 = pwtlo_base*r670_10 +
940  (1. - pwtlo_base)*r670_04;
941  rh670 = pwthi*r670_10 + (1. - pwthi)*r670_04;
942 // 412 --
943  r412_04 = 1. / (t412[ip] / d412 + sb412[ip]);
944  rl412 = pwtlo_base*r412_10 +
945  (1. - pwtlo_base)*r412_04;
946  rh412 = pwthi*r412_10 + (1. - pwthi)*r412_04;
947 // 488 --
948  r488_04 = 1. / (t488[ip] / d488 + sb488[ip]);
949  rl488 = pwtlo_base*r488_10 +
950  (1. - pwtlo_base)*r488_04;
951  rh488 = pwthi*r488_10 + (1. - pwthi)*r488_04;
952  } else {
953  rl670 = r670_10;
954  rh670 = r670_10;
955 // 412 --
956  rl412 = r412_10;
957  rh412 = r412_10;
958 // 488 --
959  rl488 = r488_10;
960  rh488 = r488_10;
961  }
962  }
963  }
964 // Calculate cloud fraction
965  isnow_ = 0;
966  int partial = 1;
967  if (qcc670x - qgc670x != 0.0) {
968  cl670 = (alb670 - qgc670x) / (qcc670x - qgc670x);
969  cl412 = (alb412 - qgc412x) / (qcc412x - qgc412x);
970  cl488 = (alb488 - qgc488x) / (qcc488x - qgc488x);
971  } else {
972  cl670 = 0.0;
973  }
974  if (partial == 0) {
975  cl670 = -1.0;
976  } else {
977 // if snow/ice probability > 50% recalculate cl670, grref
978 // and, if necessary, clref.
979  if (isnow_ >= 5) {
980  algflg_ = 10;
981  if (cl670 > 0.0 && cl670 < 1.0) {
982  cl670 = cl670 / 2.0;
983  alb670 = (alb670 - cl670*qcc670x) / (1. - cl670);
984  for (int ip = 0; ip < 2; ip++) {
985  d670 = alb670 - ez670[ip];
986  if (ip == 0) {
987  if (d670 != 0.0) {
988  r670_10 = 1. / (t670[ip] / d670 + sb670[ip]);
989  } else {
990  r670_10 = 0.0;
991  }
992  } else {
993  if (d670 != 0.) {
994  r670_04 = 1.0 / (t670[ip] / d670 + sb670[ip]);
995  grref = pwtlo*r670_10 +
996  (1. - pwtlo)*r670_04;
997  } else {
998  grref = r670_10;
999  }
1000  }
1001  }
1002  } else if (cl670 >= 1.0) {
1003  cl670 = 0.5;
1004  grref = r670_10*pwtlo + r670_04*(1. - pwtlo);
1005  clref = r670_10*pwthi + r670_04*(1. - pwthi);
1006  } else {
1007  cl670 = 0.0;
1008  grref = r670_10*pwtlo + r670_04*(1. - pwtlo);
1009  }
1010  } else {
1011  algflg_ = 0;
1012  }
1013  }
1014 // calculate reflectivity
1015 // use partial cloud algorithm if 0 < cl670 < 1
1016 // otherwise use Version 6 calculation
1017  float ler412 = 0;
1018  float ler488 = 0;
1019  float ler670 = 0;
1020  if (cl670 < 0.0) {
1021  ler412 = rl412;
1022  ler488 = rl488;
1023  ler670 = rl670;
1024  } else if (cl670 > 1.0) {
1025  ler412 = rh412;
1026  ler488 = rh488;
1027  ler670 = rh670;
1028  } else {
1029  ler412 = grr + cl412*(clref - grr);
1030  ler488 = grr + cl488*(clref - grr);
1031  ler670 = grr + cl670*(clref - grr);
1032  }
1033 
1034  ler412_ = ler412*100;
1035  ler488_ = ler488*100;
1036  ler670_ = ler670*100;
1037  qdf412_ = qdif412;
1038  qdf488_ = qdif488;
1039  qdf670_ = qdif670;
1040 
1041  return status;
1042 }
1043 
1044 /**************************************************************************
1045  * NAME: compute_stdv()
1046  *
1047  * DESCRIPTION: Compute spatial standard deviation.
1048  *
1049  *************************************************************************/
1050 
1052 
1053  int status = DTDB_SUCCESS;
1054  return status;
1055 }
1056 
1057 /**************************************************************************
1058 * NAME: intero()
1059 *
1060 * DESCRIPTION: Calculates intensity terms used in computation of
1061 * reflectivity for non 670 nm channels.
1062 * Performs table interpolation for theta and theta0.
1063 * Uses precomputed lagrangian coefs.
1064 * Calculates izero (intensity term arising from atmospheric
1065 * scattering; also calculates transmittance for reflected
1066 * radiation).
1067  *
1068  *************************************************************************/
1069 int DbAlgLand::interx(int i1, int i2, rhot_band w, float& ozero, float& otr,
1070  float& osb) {
1071 
1072  int status = DTDB_SUCCESS;
1073 
1074  float inot = 0.0;
1075  float zone = 0.0;
1076  float ztwo = 0.0;
1077  float tran = 0.0;
1078  int m = 0;
1079  for (int i = 0; i < 4; i++) {
1080  int l = i1 + 8*i;
1081  for (int k = 0; k < 4; k++) {
1082  inot = inot + mt_lut_->LOGI0[l]*cofs_[m];
1083  zone = zone + mt_lut_->Z1I0[l]*cofs_[m];
1084  ztwo = ztwo + mt_lut_->Z2I0[l]*cofs_[m];
1085  tran = tran + mt_lut_->TI0[l]*cofs_[m];
1086  m++;
1087  l++;
1088  }
1089  }
1090 // convert table values into i1, i2, t, and i0
1091  inot = pow(10.0,inot);
1092  float ione = zone*phs_*inot;
1093  float itwo = ztwo*phsr_*phs_*inot;
1094  tran = tran*inot;
1095 // compute ezero, t, and sbar
1096  ozero = inot + ione*cphi_ + itwo*cphir_;
1097  otr = tran;
1098  osb = mt_lut_->SB[i2];
1099 
1100  return status;
1101 }
1102 
1103 /**************************************************************************
1104  * NAME: int DbAlgLand::set_fill_out()
1105  *
1106  * DESCRIPTION: Set output fill values.
1107  *
1108  *************************************************************************/
1109 
1111 {
1112  int status = DTDB_SUCCESS;
1113 
1114  for (int iw=0; iw<NLWL; iw++) {
1115  lOut_.aot[iw] = DFILL_FLOAT;
1116  lOut_.ssa[iw] = DFILL_FLOAT;
1117  lOut_.sr[iw] = DFILL_FLOAT;
1118  }
1119  lOut_.aot550 = DFILL_FLOAT;
1120  lOut_.ae = DFILL_FLOAT;
1121  lOut_.sfc_type = DFILL_SHORT;
1122  lOut_.alg_flag = DFILL_SHORT;
1123  lOut_.ndvi = DFILL_FLOAT;
1124  lOut_.aerosol_type = 8;
1125  mask_cm_ = DFILL_SHORT;
1126 
1127  return status;
1128 }
1129 
1130 
void interp(double *ephemPtr, int startLoc, double *inTime, int numCoefs, int numCom, int numSets, int velFlag, double *posvel)
int initialize_LUT_data(map< string, ddata * > imap)
int j
Definition: decode_rs.h:73
int32_t day
int status
Definition: l1_czcs_hdf.c:32
constexpr unsigned char DFILL_UBYTE
Definition: DDataset.hpp:28
constexpr float DFILL_TEST
Definition: DDataset.hpp:26
const string INPUT_NC4_LUT
Definition: DDOptions.cpp:118
boost::multi_array< T, ndim > pts
Definition: DDataset.hpp:324
int compute_sr(const size_t iy, const size_t ix)
Definition: DbAlgLand.cpp:530
@ BOWTIEDEL
@ NC412
Definition: DbAlgorithm.h:31
string get_option(const string &name)
Definition: DDOptions.cpp:211
int read_tables_lut(dbTablesLUT *lut)
float * lat
@ OL670
Definition: DbAlgorithm.h:40
real, dimension(4) ctheta
int compute_ler(const size_t iy, const size_t ix)
Definition: DbAlgLand.cpp:635
void deepblue_initialize_(char *config_file, char *nc4_file, int *lines, int *pixels, float *lat, float *lon, int *year, int *month, int *day)
int read_modis_surf_refl_lut(dbModisSurfReflLimited *lut, int *start, int *edge, int &season, int &dateline)
#define DB_RFL_BANDS
Definition: DDOptions.h:48
int compute_dstar(const size_t iy, const size_t ix)
Definition: DbAlgLand.cpp:445
int compute_stdv()
Definition: DbAlgLand.cpp:1051
real, dimension(10) xzlog
map< string, ddata * > process(vector< size_t > start, vector< size_t > count, map< string, ddata * > imap)
Definition: DbAlgLand.cpp:174
void deepblue_cleanup_()
int read_surf_coeff_lut(dbSurfCoeffLimited *lut, int *start, int *edge, int &season, int &dateline)
int initialize_LUT_data()
int read_surface_pressure_lut(dbSurfacePressureLUT *lut)
int initialize(map< string, ddata * > imap)
Definition: DbAlgLand.cpp:79
const string INPUT_DB_NC4_LUT
Definition: DDOptions.cpp:120
int set_fill_out()
Definition: DbAlgLand.cpp:1110
int read_viirs_surf_refl_lut(dbViirsSurfReflLimited *lut, int *start, int *edge, int &season, int &dateline)
#define M_PI
Definition: pml_iop.h:15
int interx(int i1, int i2, rhot_band w, float &ezero, float &tr, float &sb)
Definition: DbAlgLand.cpp:1069
real, dimension(8) xlog
constexpr float DFILL_FLOAT
Definition: DDataset.hpp:25
@ OL412
Definition: DbAlgorithm.h:38
rhot_band
Definition: DDProcess.h:34
const char * str
Definition: l1c_msi.cpp:35
flags
Definition: DDAlgorithm.h:22
real, dimension(26) realbuf
int read_geozone_lut(dbGeozoneLUT *lut)
@ NC670
Definition: DbAlgorithm.h:33
float * lon
virtual int initialize(map< string, ddata * > imap)
Definition: DbAlgorithm.cpp:89
def set_outputs(output_keys)
Definition: utils.py:164
void find_v_viirs_(float *realbuf, float *tmpvg, float *outbuf, int *flags, float *elev, int *ls_flag, float *windsp, float *wv)
real, dimension(4) cthet0
@ NC488
Definition: DbAlgorithm.h:32
@ OL488
Definition: DbAlgorithm.h:39
#define abs(a)
Definition: misc.h:90
int i
Definition: decode_rs.h:71
msiBandIdx val
Definition: l1c_msi.cpp:34
int k
Definition: decode_rs.h:73
constexpr short DFILL_SHORT
Definition: DDataset.hpp:27
int count
Definition: decode_rs.h:79