OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
DbLutNetcdf.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * NAME: DbLutNetcdf.cpp
3  *
4  * DESCRIPTION: Object class that generates a netCDF4 LUT for NASA Deep Blue
5  * aerosols algorithm
6  *
7  * Created on: April 25, 2017
8  * Author: Sam Anderson
9  *
10  *
11  ******************************************************************************/
12 
13 
14 #include "deepblue/DbLutNetcdf.h"
15 
16 #include <string>
17 #include <sstream>
18 #include <fstream>
19 #include <iostream>
20 #include <mfhdf.h>
21 
22 #include <libgen.h>
23 
24 #include <DDAlgorithm.h>
25 #include <DDOptions.h>
26 
27 const int chindx[8] = { 1,2,3,4,5,6,10,11 };
28 const int bindx[3] = { 1,3,8 };// DeepBlue targetted bands in MODIS
29 const std::string str_season[NUM_SEASONS] = {"winter", "spring", "summer", "fall"};
30 /**************************************************************************
31  * NAME: DbLutNetcdf()
32  *
33  * DESCRIPTION: Class Constructor
34  *
35  *************************************************************************/
36 
38 }
39 
40 /**************************************************************************
41  * NAME: ~DbLutNetcdf()
42  *
43  * DESCRIPTION: Class Destructor
44  *
45  *************************************************************************/
46 
48 }
49 
50 /**************************************************************************
51  * NAME: initialize()
52  *
53  * DESCRIPTION: Initializes data and object classes for granule
54  *
55  *************************************************************************/
56 
58  return DTDB_SUCCESS;
59 }
60 
61 
62 /**************************************************************************
63  * NAME: create_db_nc4_lut()
64  *
65  * DESCRIPTION: Create deep blue aerosol netCDF4 LUT.
66  *
67  *************************************************************************/
68 
70 
71  int status = DTDB_SUCCESS;
72  int istatus = DTDB_SUCCESS;
73  int num_good = 0;
74 
76  string filepath = path + "/VIIRS_DEEPBLUE_LUT_" + "version_source" + ".nc";
77 
78  NcFile* nc_output;
79 
80  try {
81  nc_output = new NcFile( filepath, NcFile::replace );
82  }
83  catch( NcException& e) {
84  e.what();
85  cerr << "DbLutNetcdf:: Failure creating netCDF4 LUT file: " + filepath + "." << endl;
86  return DTDB_FAIL;
87  }
88  nc_output->putAtt( "title", "VIIRS DEEP BLUE LUTs" );
89 
90  write_global_attributes( nc_output );
91 
92 // Read input files and create LUTs
93  cerr << "DbLutNetcdf:: Begin moving LUTs to NetCDF4 LUT file" << endl;
94 
95  dbOceanAerosolLUT* oa_fine = new dbOceanAerosolLUT;
96  istatus = read_ocean_aero_file( oa_fine, INPUT_AERO_OCEAN_FINE );
97  if ( istatus != DTDB_SUCCESS ) {
98  cerr << "DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
99  status = istatus;
100  }
101  istatus = write_ocean_aero_lut( nc_output, oa_fine, LUT_OCEAN_AEROSOL_FINE );
102  if ( istatus != DTDB_SUCCESS ) {
103  cerr << "DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
104  status = istatus;
105  }
106  delete oa_fine;
107  if (istatus == DTDB_SUCCESS) {
108  num_good++;
109  cerr << "DbLutNetcdf:: Created " + LUT_OCEAN_AEROSOL_FINE << endl;
110  }
111  dbOceanAerosolLUT* oa_dust = new dbOceanAerosolLUT;
112  istatus = read_ocean_aero_file( oa_dust, INPUT_AERO_OCEAN_DUST );
113  if ( istatus != DTDB_SUCCESS ) {
114  cerr << "DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
115  status = istatus;
116  }
117  istatus = write_ocean_aero_lut( nc_output, oa_dust, LUT_OCEAN_AEROSOL_DUST );
118  if ( istatus != DTDB_SUCCESS ) {
119  cerr << "DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
120  status = istatus;
121  }
122  delete oa_dust;
123  if (istatus == DTDB_SUCCESS) {
124  num_good++;
125  cerr << "DbLutNetcdf:: Created " + LUT_OCEAN_AEROSOL_DUST << endl;
126  }
127  dbOceanAerosolLUT* oa_mari = new dbOceanAerosolLUT;
128  istatus = read_ocean_aero_file( oa_mari, INPUT_AERO_OCEAN_MARI );
129  if ( istatus != DTDB_SUCCESS ) {
130  cerr << "DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
131  status = istatus;
132  }
133  istatus = write_ocean_aero_lut( nc_output, oa_mari, LUT_OCEAN_AEROSOL_MARI );
134  if ( istatus != DTDB_SUCCESS ) {
135  cerr << "DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
136  status = istatus;
137  }
138  delete oa_mari;
139  if (istatus == DTDB_SUCCESS) {
140  num_good++;
141  cerr << "DbLutNetcdf:: Created " + LUT_OCEAN_AEROSOL_MARI << endl;
142  }
143  dbOceanAerosolLUT* oa_mix = new dbOceanAerosolLUT;
144  istatus = read_ocean_aero_file( oa_mix, INPUT_AERO_OCEAN_MIX );
145  if ( istatus != DTDB_SUCCESS ) {
146  cerr << "DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
147  status = istatus;
148  }
149  istatus = write_ocean_aero_lut( nc_output, oa_mix, LUT_OCEAN_AEROSOL_MIX );
150  if ( istatus != DTDB_SUCCESS ) {
151  cerr << "DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
152  status = istatus;
153  }
154  delete oa_mix;
155  if (istatus == DTDB_SUCCESS) {
156  num_good++;
157  cerr << "DbLutNetcdf:: Created " + LUT_OCEAN_AEROSOL_MIX << endl;
158  }
159  dbLandAerosolLUT* la_lut = new dbLandAerosolLUT;
160  istatus = read_land_aero_file( la_lut, INPUT_AERO_LAND_FINE );
161  if ( istatus != DTDB_SUCCESS ) {
162  cerr << "DbLutNetcdf:: Failure reading Land Aerosol LUT file " << endl;
163  status = istatus;
164  }
165  istatus = write_land_aero_lut( nc_output, la_lut,
167  if ( istatus != DTDB_SUCCESS ) {
168  cerr << "DbLutNetcdf:: Failure writing Land Aerosol data to netCDF4 LUT file " << endl;
169  status = istatus;
170  }
171  delete la_lut;
172  if (istatus == DTDB_SUCCESS) {
173  num_good++;
174  cerr << "DbLutNetcdf:: Created " + LUT_LAND_AEROSOL_FINE << endl;
175  }
176  la_lut = new dbLandAerosolLUT;
177  istatus = read_land_aero_file( la_lut, INPUT_AERO_LAND_DUST );
178  if ( istatus != DTDB_SUCCESS ) {
179  cerr << "DbLutNetcdf:: Failure reading Land Aerosol LUT file " << endl;
180  status = istatus;
181  }
182  istatus = write_land_aero_lut( nc_output, la_lut,
184  if ( istatus != DTDB_SUCCESS ) {
185  cerr << "DbLutNetcdf:: Failure writing Land Aerosol data to netCDF4 LUT file " << endl;
186  status = istatus;
187  }
188  delete la_lut;
189  if (istatus == DTDB_SUCCESS) {
190  num_good++;
191  cerr << "DbLutNetcdf:: Created " + LUT_LAND_AEROSOL_DUST << endl;
192  }
193  dbBathymetryLUT* b_lut = new dbBathymetryLUT;
194  istatus = read_bathymetry_files( b_lut );
195  if ( istatus != DTDB_SUCCESS ) {
196  cerr << "DbLutNetcdf:: Failure reading bathymetry LUT file " << endl;
197  status = istatus;
198  }
199  istatus = write_bathymetry_lut( nc_output, b_lut );
200  if ( istatus != DTDB_SUCCESS ) {
201  cerr << "DbLutNetcdf:: Failure writing bathymetry data to netCDF4 LUT file " << endl;
202  status = istatus;
203  }
204  delete b_lut;
205  if (istatus == DTDB_SUCCESS) {
206  num_good++;
207  cerr << "DbLutNetcdf:: Created " + LUT_BATHYMETRY << endl;
208  }
209  dbChlLUT* c_lut = new dbChlLUT;
210  istatus = read_chl_files( c_lut );
211  if ( istatus != DTDB_SUCCESS ) {
212  cerr << "DbLutNetcdf:: Failure reading CHL LUT file " << endl;
213  status = istatus;
214  }
215  istatus = write_chl_lut( nc_output, c_lut );
216  if ( istatus != DTDB_SUCCESS ) {
217  cerr << "DbLutNetcdf:: Failure writing CHL data to netCDF4 LUT file " << endl;
218  status = istatus;
219  }
220  delete c_lut;
221  if (istatus == DTDB_SUCCESS) {
222  num_good++;
223  cerr << "DbLutNetcdf:: Created " + LUT_CHL << endl;
224  }
225  dbTablesLUT* t_lut = new dbTablesLUT;
226  istatus = read_tables_file( t_lut );
227  if ( istatus != DTDB_SUCCESS ) {
228  cerr << "DbLutNetcdf:: Failure reading LER tables file " << endl;
229  status = istatus;
230  }
231  istatus = write_tables_lut( nc_output, t_lut );
232  if ( istatus != DTDB_SUCCESS ) {
233  cerr << "DbLutNetcdf:: Failure writing LER tables to netCDF4 LUT file " << endl;
234  status = istatus;
235  }
236  delete t_lut;
237  if (istatus == DTDB_SUCCESS) {
238  num_good++;
239  cerr << "DbLutNetcdf:: Created " + LUT_LER_TABLES << endl;
240  }
241  dbLandcoverLUT* lc_lut = new dbLandcoverLUT;
242  istatus = read_landcover_files( lc_lut );
243  if ( istatus != DTDB_SUCCESS ) {
244  cerr << "DbLutNetcdf:: Failure reading Landcover LUT file " << endl;
245  status = istatus;
246  }
247  istatus = write_landcover_lut( nc_output, lc_lut );
248  if ( istatus != DTDB_SUCCESS ) {
249  cerr << "DbLutNetcdf:: Failure writing Landcover data to netCDF4 LUT file " << endl;
250  status = istatus;
251  }
252  delete lc_lut;
253  if (istatus == DTDB_SUCCESS) {
254  num_good++;
255  cerr << "DbLutNetcdf:: Created " + LUT_LANDCOVER << endl;
256  }
257  dbGeozoneLUT* gz_lut = new dbGeozoneLUT;
258  istatus = read_geozone_files( gz_lut );
259  if ( istatus != DTDB_SUCCESS ) {
260  cerr << "DbLutNetcdf:: Failure reading geozone LUT file " << endl;
261  status = istatus;
262  }
263  istatus = write_geozone_lut( nc_output, gz_lut );
264  if ( istatus != DTDB_SUCCESS ) {
265  cerr << "DbLutNetcdf:: Failure writing geozone data to netCDF4 LUT file " << endl;
266  status = istatus;
267  }
268  delete gz_lut;
269  if (istatus == DTDB_SUCCESS) {
270  num_good++;
271  cerr << "DbLutNetcdf:: Created " + LUT_GEOZONE << endl;
272  }
273  dbModisSurfReflLUT* msr_lut = new dbModisSurfReflLUT;
274  istatus = read_modis_surf_refl_files( msr_lut );
275  if ( istatus != DTDB_SUCCESS ) {
276  cerr << "DbLutNetcdf:: Failure reading surface reflectance LUT file " << endl;
277  status = istatus;
278  }
279  istatus = write_modis_surf_refl_lut( nc_output, msr_lut );
280  if ( istatus != DTDB_SUCCESS ) {
281  cerr << "DbLutNetcdf:: Failure writing surface reflectance data to netCDF4 LUT file " << endl;
282  status = istatus;
283  }
284  delete msr_lut;
285  if (istatus == DTDB_SUCCESS) {
286  num_good++;
287  cerr << "DbLutNetcdf:: Created " + LUT_MODIS_SURFACE_REFL << endl;
288  }
289  dbViirsSurfReflLUT* vsr_lut = new dbViirsSurfReflLUT;
290  istatus = read_viirs_surf_refl_files( vsr_lut );
291  if ( istatus != DTDB_SUCCESS ) {
292  cerr << "DbLutNetcdf:: Failure reading surface reflectance LUT file " << endl;
293  status = istatus;
294  }
295  istatus = write_viirs_surf_refl_lut( nc_output, vsr_lut );
296  if ( istatus != DTDB_SUCCESS ) {
297  cerr << "DbLutNetcdf:: Failure writing surface reflectance data to netCDF4 LUT file " << endl;
298  status = istatus;
299  }
300  delete vsr_lut;
301  if (istatus == DTDB_SUCCESS) {
302  num_good++;
303  cerr << "DbLutNetcdf:: Created " + LUT_VIIRS_SURFACE_REFL << endl;
304  }
305  dbSurfCoeffLUT* sc_lut = new dbSurfCoeffLUT;
306  istatus = read_surf_coeff_files( sc_lut );
307  if ( istatus != DTDB_SUCCESS ) {
308  cerr << "DbLutNetcdf:: Failure reading surface coefficients LUT file " << endl;
309  status = istatus;
310  }
311  istatus = write_surf_coeff_lut( nc_output, sc_lut );
312  if ( istatus != DTDB_SUCCESS ) {
313  cerr << "DbLutNetcdf:: Failure writing surface coefficients data to netCDF4 LUT file " << endl;
314  status = istatus;
315  }
316  delete sc_lut;
317  if (istatus == DTDB_SUCCESS) {
318  num_good++;
319  cerr << "DbLutNetcdf:: Created " + LUT_SURFACE_COEFF << endl;
320  }
322  istatus = read_surface_pressure_file( sp_lut );
323  if ( istatus != DTDB_SUCCESS ) {
324  cerr << "DbLutNetcdf:: Failure reading surface pressure LUT file " << endl;
325  status = istatus;
326  }
327  istatus = write_surface_pressure_lut( nc_output, sp_lut );
328  if ( istatus != DTDB_SUCCESS ) {
329  cerr << "DbLutNetcdf:: Failure writing surface pressure data to netCDF4 LUT file " << endl;
330  status = istatus;
331  }
332  delete sp_lut;
333  if (istatus == DTDB_SUCCESS) {
334  num_good++;
335  cerr << "DbLutNetcdf:: Created " + LUT_SURFACE_PRESSURE << endl;
336  }
338  istatus = read_swir_file( vsw_lut );
339  if ( istatus != DTDB_SUCCESS ) {
340  cerr << "DbLutNetcdf:: Failure reading VIIRS SWIR LUT file " << endl;
341  status = istatus;
342  }
343  istatus = write_swir_lut( nc_output, vsw_lut );
344  if ( istatus != DTDB_SUCCESS ) {
345  cerr << "DbLutNetcdf:: Failure writing VIIRS SWIR data to netCDF4 LUT file " << endl;
346  status = istatus;
347  }
348  delete vsw_lut;
349  if (istatus == DTDB_SUCCESS) {
350  num_good++;
351  cerr << "DbLutNetcdf:: Created " + LUT_SWIR << endl;
352  }
353 
354  dbVeg_21sfcLUT* v_lut = new dbVeg_21sfcLUT;
355  istatus = read_veg_21sfc_files( v_lut );
356  if ( istatus != DTDB_SUCCESS ) {
357  cerr << "DbLutNetcdf:: Failure reading veg_21sfc LUT files " << endl;
358  status = istatus;
359  }
360  istatus = write_veg_21sfc_lut( nc_output, v_lut );
361  if ( istatus != DTDB_SUCCESS ) {
362  cerr << "DbLutNetcdf:: Failure writing veg_21sfc data to netCDF4 LUT file " << endl;
363  status = istatus;
364  }
365  delete v_lut;
366  if (istatus == DTDB_SUCCESS) {
367  num_good++;
368  cerr << "DbLutNetcdf:: Created " + LUT_NVALX21 << endl;
369  }
370  delete nc_output;
371 
372  if (status == DTDB_SUCCESS) {
373  return status;
374  } else {
375  return num_good++;
376  }
377 }
378 
379 /**************************************************************************
380  * NAME: read_tables_file()
381  *
382  * DESCRIPTION: Read MODIS/SEAWIFS tables file.
383  *
384  *************************************************************************/
385 
387 {
388  int status = DTDB_SUCCESS;
389 
391  if(filepath.empty()) {
392  cerr << "DbLutNetcdf::read_tables_file() Invalid path." << endl;
393  return DTDB_FAIL;
394  }
395  bool isFileBigEndian = true;
396  std::ifstream fin(filepath.c_str(), std::ios::in | std::ios::binary);
397  if(fin.is_open()) {
398  const int RECORD_DELIMITER_LENGTH = 4;
399  int r1_length = (4*20800 + 260)*sizeof(float);
400  int r2_length = (4*160 + 2)*sizeof(float);
401  fin.seekg(RECORD_DELIMITER_LENGTH, ios::cur);
402  fin.read( (char*) mt_lut->LOGI0, r1_length);
403  fin.seekg(RECORD_DELIMITER_LENGTH, ios::cur);
404  fin.seekg(RECORD_DELIMITER_LENGTH, ios::cur);
405  fin.read( (char*) mt_lut->LOGI0R, r2_length);
406  bool good = fin.good();
407  fin.close();
408  if(!good) {
409  cerr <<
410  "DbLutNetcdf::read_tables_file() Error reading binary file "
411  << INPUT_LER_TABLE << endl;
412  return DTDB_FAIL;
413  }
414  }
415  else {
416  cerr << "DbLutNetcdf::read_tables_file() Error opening binary file "
417  << INPUT_LER_TABLE << endl;
418  return DTDB_FAIL;
419  }
420  if ( isPlatformLittleEndian() && isFileBigEndian) {
421  for ( int i=0; i<MTABLE_20800; i++) {
422  byteSwap( mt_lut->LOGI0[i] );
423  byteSwap( mt_lut->Z1I0[i] );
424  byteSwap( mt_lut->Z2I0[i] );
425  byteSwap( mt_lut->TI0[i] );
426  }
427  for ( int i=0; i<MTABLE_260; i++) {
428  byteSwap( mt_lut->SB[i] );
429  }
430  for ( int i=0; i<MTABLE_160; i++) {
431  byteSwap( mt_lut->LOGI0R[i] );
432  byteSwap( mt_lut->Z1I0R[i] );
433  byteSwap( mt_lut->Z2I0R[i] );
434  byteSwap( mt_lut->TI0R[i] );
435  }
436  for ( int i=0; i<MTABLE_2; i++) {
437  byteSwap( mt_lut->SBR[i] );
438  }
439  }
440 
441  return status;
442 }
443 
444 /**************************************************************************
445  * NAME: write_tables_lut()
446  *
447  * DESCRIPTION: Write modis tables LUT to NetCDF4 file.
448  *
449  *************************************************************************/
450 
451 int DbLutNetcdf::write_tables_lut( NcFile* nc_output,
452  dbTablesLUT* mt_lut )
453 {
454  NcGroup lut_grp = nc_output->addGroup( LUT_LER_TABLES );
455 
456  dim_20800_ = lut_grp.addDim( "Dim_20800", MTABLE_20800 );
457  dim_260_ = lut_grp.addDim( "Dim_260", MTABLE_260 );
458  dim_160_ = lut_grp.addDim( "Dim_160", MTABLE_160 );
459  dim_2_ = lut_grp.addDim( "Dim_2", MTABLE_2 );
460 
461  NcVar var = lut_grp.addVar( "LOGI0", ncFloat, dim_20800_ );
462  var.putVar( mt_lut->LOGI0 );
463 
464  var = lut_grp.addVar( "Z1I0", ncFloat, dim_20800_ );
465  var.putVar( mt_lut->Z1I0 );
466 
467  var = lut_grp.addVar( "Z2I0", ncFloat, dim_20800_ );
468  var.putVar( mt_lut->Z2I0 );
469 
470  var = lut_grp.addVar( "TI0", ncFloat, dim_20800_ );
471  var.putVar( mt_lut->TI0 );
472 
473  var = lut_grp.addVar( "SB", ncFloat, dim_260_ );
474  var.putVar( mt_lut->SB );
475 
476  var = lut_grp.addVar( "LOGI0R", ncFloat, dim_160_ );
477  var.putVar( mt_lut->LOGI0R );
478 
479  var = lut_grp.addVar( "Z1I0R", ncFloat, dim_160_ );
480  var.putVar( mt_lut->Z1I0R );
481 
482  var = lut_grp.addVar( "Z2I0R", ncFloat, dim_160_ );
483  var.putVar( mt_lut->Z2I0R );
484 
485  var = lut_grp.addVar( "TI0R", ncFloat, dim_160_ );
486  var.putVar( mt_lut->TI0R );
487 
488  var = lut_grp.addVar( "SBR", ncFloat, dim_2_ );
489  var.putVar( mt_lut->SBR );
490 
491  return DTDB_SUCCESS;
492 }
493 
494 
495 
496 /**************************************************************************
497  * NAME: read_tables_lut()
498  *
499  * DESCRIPTION: Read MODIS Tables NetCDF4 LUT.
500  *
501  *************************************************************************/
502 
504 {
505  int status = DTDB_SUCCESS;
506 
508  if (filepath.empty()) {
510  }
511  NcFile* nc_input;
512  try {
513  nc_input = new NcFile(filepath, NcFile::read );
514  }
515  catch( NcException& e) {
516  e.what();
517  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
518  return DTDB_FAIL;
519  }
520  NcGroup lut_grp = nc_input->getGroup( LUT_LER_TABLES );
521  NcVar var = lut_grp.getVar( "LOGI0" );
522  var.getVar( mt_lut->LOGI0 );
523  var = lut_grp.getVar( "Z1I0" );
524  var.getVar( mt_lut->Z1I0 );
525  var = lut_grp.getVar( "Z2I0" );
526  var.getVar( mt_lut->Z2I0 );
527  var = lut_grp.getVar( "TI0" );
528  var.getVar( mt_lut->TI0 );
529  var = lut_grp.getVar( "SB" );
530  var.getVar( mt_lut->SB );
531  var = lut_grp.getVar( "LOGI0R" );
532  var.getVar( mt_lut->LOGI0R );
533  var = lut_grp.getVar( "Z1I0R" );
534  var.getVar( mt_lut->Z1I0R );
535  var = lut_grp.getVar( "Z2I0R" );
536  var.getVar( mt_lut->Z2I0R );
537  var = lut_grp.getVar( "TI0R" );
538  var.getVar( mt_lut->TI0R );
539  var = lut_grp.getVar( "SBR" );
540  var.getVar( mt_lut->SBR );
541 
542  delete nc_input;
543 
544  return status;
545 }
546 
547 /**************************************************************************
548  * NAME: read_surface_pressure_file()
549  *
550  * DESCRIPTION: Read surface pressure hdf4 file.
551  *
552  *************************************************************************/
553 
555 {
556  int status = DTDB_SUCCESS;
557 
559  if(filepath.empty()) {
560  cerr << "DbLutNetcdf::read_surface_pressure_file() Invalid path." << endl;
561  return DTDB_FAIL;
562  }
563  int fileID;
564  try {
565  fileID = SDstart(filepath.c_str(), DFACC_READ );
566  }
567  catch( std::exception& e) {
568  e.what();
569  cerr << "DbLutNetcdf:: Failure opening surface pressure file: " + filepath << endl;
570  return DTDB_FAIL;
571  }
572  int sds_index, sds_id, numtype, rank, nattrs;
573  int start[2], edges[2], dims[2];
574  start[0] = 0;
575  start[1] = 0;
576  edges[0] = SP_720;
577  edges[1] = SP_360;
578  string sds_name = "ps";
579  sds_index = SDnametoindex(fileID, sds_name.c_str());
580  if (sds_index < 0) {
581  cerr << "DbLutNetcdf::read_surface_pressure_file() " <<
582  "SDnametoindex() failure for "<< sds_name << endl;
583  SDend(fileID);
584  return DTDB_FAIL;
585  }
586  sds_id = SDselect(fileID, sds_index);
587  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
588  SDreaddata(sds_id, start, NULL, edges, &sp_lut->PS[0][0]);
589 
590  edges[0] = SP_SETS*SP_720;
591  edges[1] = SP_SETS*SP_360;
592  sds_name = "surface_pressure";
593  sds_index = SDnametoindex(fileID, sds_name.c_str());
594  if (sds_index < 0) {
595  cerr << "DbLutNetcdf::read_surface_pressure_file() " <<
596  "SDnametoindex() failure for "<< sds_name << endl;
597  SDend(fileID);
598  return DTDB_FAIL;
599  }
600  sds_id = SDselect(fileID, sds_index);
601  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
602  SDreaddata(sds_id, start, NULL, edges, &sp_lut->SURFACE_PRESSURE[0][0]);
603 
604  sds_name = "surface_elevation";
605  sds_index = SDnametoindex(fileID, sds_name.c_str());
606  if (sds_index < 0) {
607  cerr << "DbLutNetcdf::read_surface_pressure_file() " <<
608  "SDnametoindex() failure for "<< sds_name << endl;
609  SDend(fileID);
610  return DTDB_FAIL;
611  }
612  sds_id = SDselect(fileID, sds_index);
613  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
614  SDreaddata(sds_id, start, NULL, edges, &sp_lut->SURFACE_ELEVATION[0][0]);
615 
616  return status;
617 }
618 
619 /**************************************************************************
620  * NAME: write_surface_pressure_lut()
621  *
622  * DESCRIPTION: Write surface pressure LUT to NetCDF4 file.
623  *
624  *************************************************************************/
625 
627  dbSurfacePressureLUT* sp_lut )
628 {
629  NcGroup lut_grp = nc_output->addGroup( LUT_SURFACE_PRESSURE );
630 
631  dim_720_ = lut_grp.addDim( "Dim_720", SP_720 );
632  dim_360_ = lut_grp.addDim( "Dim_360", SP_360 );
633  dim_4320_ = lut_grp.addDim( "Dim_4320", SP_SETS*SP_720 );
634  dim_2160_ = lut_grp.addDim( "Dim_2160", SP_SETS*SP_360 );
635 
636  vector<NcDim> small_dims;
637  small_dims.push_back(dim_720_);
638  small_dims.push_back(dim_360_);
639 
640  vector<NcDim> big_dims;
641  big_dims.push_back(dim_4320_);
642  big_dims.push_back(dim_2160_);
643 
644  NcVar var = lut_grp.addVar( "PS", ncFloat, small_dims );
645  var.putVar( sp_lut->PS );
646 
647  var = lut_grp.addVar( "SURFACE_PRESSURE", ncFloat, big_dims );
648  var.putVar( sp_lut->SURFACE_PRESSURE );
649 
650  var = lut_grp.addVar( "SURFACE_ELEVATION", ncFloat, big_dims );
651  var.putVar( sp_lut->SURFACE_ELEVATION );
652 
653  return DTDB_SUCCESS;
654 }
655 
656 /**************************************************************************
657  * NAME: read_surface_pressure_lut()
658  *
659  * DESCRIPTION: Read surface pressure NetCDF4 LUT.
660  *
661  *************************************************************************/
662 
664 {
665  int status = DTDB_SUCCESS;
666 
668  if (filepath.empty()) {
670  }
671  NcFile* nc_input;
672  try {
673  nc_input = new NcFile(filepath, NcFile::read );
674  }
675  catch( NcException& e) {
676  e.what();
677  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
678  return DTDB_FAIL;
679  }
680  NcGroup lut_grp = nc_input->getGroup( LUT_SURFACE_PRESSURE );
681 
682  NcVar var = lut_grp.getVar( "PS" );
683  var.getVar( sp_lut->PS );
684 
685  var = lut_grp.getVar( "SURFACE_PRESSURE" );
686  var.getVar( sp_lut->SURFACE_PRESSURE );
687 
688  var = lut_grp.getVar( "SURFACE_ELEVATION" );
689  var.getVar( sp_lut->SURFACE_ELEVATION );
690 
691  delete nc_input;
692 
693  return status;
694 }
695 
696 /**************************************************************************
697  * NAME: read_nvalx_files()
698  *
699  * DESCRIPTION: Read nvalx files.
700  *
701  *************************************************************************/
702 
704 {
705  int status = DTDB_SUCCESS;
706 
707  const int RECORD_DELIMITER_LENGTH = 4;
708 
710  if(filepath.empty()) {
711  cerr << "DbLutNetcdf::read_nvalx_file() Invalid path." << endl;
712  return DTDB_FAIL;
713  }
714  bool isFileBigEndian = false;
715  std::ifstream fin1(filepath.c_str(), std::ios::in | std::ios::binary);
716  if(fin1.is_open()) {
717  int length = SR412*SSA412*NTAU*NRAA*NVZA*NSZA*sizeof(float);
718  fin1.seekg(RECORD_DELIMITER_LENGTH, ios::cur);
719  fin1.read( (char*) nv_lut->NVALX_412, length);
720  bool good = fin1.good();
721  fin1.close();
722  if(!good) {
723  cerr <<
724  "DbLutNetcdf::read_nvalx_file() Error reading binary file "
725  << INPUT_LER_TABLE << endl;
726  return DTDB_FAIL;
727  }
728  }
729  else {
730  cerr << "DbLutNetcdf::read_nvalx_file() Error opening binary file "
731  << INPUT_NVALX_412 << endl;
732  return DTDB_FAIL;
733  }
734 
736  if(filepath.empty()) {
737  cerr << "DbLutNetcdf::read_nvalx_file() Invalid path." << endl;
738  return DTDB_FAIL;
739  }
740  isFileBigEndian = false;
741  std::ifstream fin2(filepath.c_str(), std::ios::in | std::ios::binary);
742  if(fin2.is_open()) {
743  int length = SR470*SSA470*NTAU*NRAA*NVZA*NSZA*sizeof(float);
744  fin2.seekg(RECORD_DELIMITER_LENGTH, ios::cur);
745  fin2.read( (char*) nv_lut->NVALX_470, length);
746  bool good = fin2.good();
747  fin2.close();
748  if(!good) {
749  cerr <<
750  "DbLutNetcdf::read_nvalx_file() Error reading binary file "
751  << INPUT_NVALX_470 << endl;
752  return DTDB_FAIL;
753  }
754  }
755  else {
756  cerr << "DbLutNetcdf::read_nvalx_file() Error opening binary file "
757  << INPUT_NVALX_470 << endl;
758  return DTDB_FAIL;
759  }
760 
762  if(filepath.empty()) {
763  cerr << "DbLutNetcdf::read_nvalx_file() Invalid path." << endl;
764  return DTDB_FAIL;
765  }
766  isFileBigEndian = false;
767  std::ifstream fin3(filepath.c_str(), std::ios::in | std::ios::binary);
768  if(fin3.is_open()) {
769  int length = SR650*NTAU*NRAA*NVZA*NSZA*sizeof(float);
770  fin3.seekg(RECORD_DELIMITER_LENGTH, ios::cur);
771  fin3.read( (char*) nv_lut->NVALX_650, length);
772  bool good = fin3.good();
773  fin3.close();
774  if(!good) {
775  cerr <<
776  "DbLutNetcdf::read_nvalx_file() Error reading binary file "
777  << INPUT_NVALX_650 << endl;
778  return DTDB_FAIL;
779  }
780  }
781  else {
782  cerr << "DbLutNetcdf::read_nvalx_file() Error opening binary file "
783  << INPUT_NVALX_650 << endl;
784  return DTDB_FAIL;
785  }
786 
787  if ( isPlatformLittleEndian() && isFileBigEndian) {
788  }
789 
790  return status;
791 }
792 
793 /**************************************************************************
794  * NAME: write_nvalx_lut()
795  *
796  * DESCRIPTION: Write nvalx LUT to NetCDF4 file.
797  *
798  *************************************************************************/
799 
800 int DbLutNetcdf::write_nvalx_lut( NcFile* nc_output,
801  dbNvalxLUT* nv_lut )
802 {
803  NcGroup lut_grp = nc_output->addGroup( LUT_NVALX );
804 
805  dim_nsza_ = lut_grp.addDim( "Dim_NSZA", NSZA );
806  dim_nvza_ = lut_grp.addDim( "Dim_NVZA", NVZA );
807  dim_nraa_ = lut_grp.addDim( "Dim_NRAA", NRAA );
808  dim_ntau_ = lut_grp.addDim( "Dim_NTAU", NTAU );
809  dim_ssa412_ = lut_grp.addDim( "Dim_SSA412", SSA412 );
810  dim_ssa470_ = lut_grp.addDim( "Dim_SSA470", SSA470 );
811  dim_sr412_ = lut_grp.addDim( "Dim_SR412", SR412 );
812  dim_sr470_ = lut_grp.addDim( "Dim_SR470", SR470 );
813  dim_sr650_ = lut_grp.addDim( "Dim_SR650", SR650 );
814 
815  vector<NcDim> nvalx412_dims;
816  nvalx412_dims.push_back(dim_sr412_);
817  nvalx412_dims.push_back(dim_ssa412_);
818  nvalx412_dims.push_back(dim_ntau_);
819  nvalx412_dims.push_back(dim_nraa_);
820  nvalx412_dims.push_back(dim_nvza_);
821  nvalx412_dims.push_back(dim_nsza_);
822 
823  vector<NcDim> nvalx470_dims;
824  nvalx470_dims.push_back(dim_sr470_);
825  nvalx470_dims.push_back(dim_ssa470_);
826  nvalx470_dims.push_back(dim_ntau_);
827  nvalx470_dims.push_back(dim_nraa_);
828  nvalx470_dims.push_back(dim_nvza_);
829  nvalx470_dims.push_back(dim_nsza_);
830 
831  vector<NcDim> nvalx650_dims;
832  nvalx650_dims.push_back(dim_sr650_);
833  nvalx650_dims.push_back(dim_ntau_);
834  nvalx650_dims.push_back(dim_nraa_);
835  nvalx650_dims.push_back(dim_nvza_);
836  nvalx650_dims.push_back(dim_nsza_);
837 
838  NcVar var = lut_grp.addVar( "NVALX_412", ncFloat, nvalx412_dims );
839  var.putVar( nv_lut->NVALX_412 );
840 
841  var = lut_grp.addVar( "NVALX_470", ncFloat, nvalx470_dims );
842  var.putVar( nv_lut->NVALX_470 );
843 
844  var = lut_grp.addVar( "NVALX_650", ncFloat, nvalx650_dims );
845  var.putVar( nv_lut->NVALX_650 );
846 
847  return DTDB_SUCCESS;
848 }
849 
850 /**************************************************************************
851  * NAME: read_nvalx_lut()
852  *
853  * DESCRIPTION: Read nvalx NetCDF4 LUT.
854  *
855  *************************************************************************/
856 
858 {
859  int status = DTDB_SUCCESS;
860 
862  if (filepath.empty()) {
864  }
865  NcFile* nc_input;
866  try {
867  nc_input = new NcFile(filepath, NcFile::read );
868  }
869  catch( NcException& e) {
870  e.what();
871  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
872  return DTDB_FAIL;
873  }
874  NcGroup lut_grp = nc_input->getGroup( LUT_NVALX );
875 
876  NcVar var = lut_grp.getVar( "NVALX_412" );
877  var.getVar( nv_lut->NVALX_412 );
878 
879  var = lut_grp.getVar( "NVALX_470" );
880  var.getVar( nv_lut->NVALX_470 );
881 
882  var = lut_grp.getVar( "NVALX_650" );
883  var.getVar( nv_lut->NVALX_650 );
884 
885  delete nc_input;
886 
887  return status;
888 }
889 
890 /**************************************************************************
891  * NAME: read_veg_21sfc_files()
892  *
893  * DESCRIPTION: Read veg_21sfc files.
894  *
895  *************************************************************************/
896 
898 {
899  int status = DTDB_SUCCESS;
900 
901 // NVALX21
903  if(filepath.empty()) {
904  cerr << "DbLutNetcdf::read_nvalx21_file() Invalid path." << endl;
905  return DTDB_FAIL;
906  }
907  int fileID;
908  try {
909  fileID = SDstart(filepath.c_str(), DFACC_READ );
910  }
911  catch( std::exception& e) {
912  e.what();
913  cerr << "DbLutNetcdf:: Failure opening nvalx21 file: " + filepath << endl;
914  return DTDB_FAIL;
915  }
916  int sds_index, sds_id, numtype, rank, nattrs;
917  int start[4], edges[4], dims[4];
918  start[0] = 0;
919  start[1] = 0;
920  start[2] = 0;
921  start[3] = 0;
922  edges[0] = NSEASONS;
923  edges[1] = NRAA;
924  edges[2] = NVZA;
925  edges[3] = NSZAV;
926 
927  string sds_name = "NVALX21_SFC";
928  sds_index = SDnametoindex(fileID, sds_name.c_str());
929  if (sds_index < 0) {
930  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
931  "SDnametoindex() failure for "<< sds_name << endl;
932  SDend(fileID);
933  return DTDB_FAIL;
934  }
935  sds_id = SDselect(fileID, sds_index);
936  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
937  SDreaddata(sds_id, start, NULL, edges, &nv_lut->NVALX21_SFC[0]);
938 
939  sds_name = "R0X21_SFC";
940  sds_index = SDnametoindex(fileID, sds_name.c_str());
941  if (sds_index < 0) {
942  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
943  "SDnametoindex() failure for "<< sds_name << endl;
944  SDend(fileID);
945  return DTDB_FAIL;
946  }
947  sds_id = SDselect(fileID, sds_index);
948  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
949  SDreaddata(sds_id, start, NULL, edges, &nv_lut->R0X21_SFC[0]);
950 
951  sds_name = "SX21_SFC";
952  sds_index = SDnametoindex(fileID, sds_name.c_str());
953  if (sds_index < 0) {
954  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
955  "SDnametoindex() failure for "<< sds_name << endl;
956  SDend(fileID);
957  return DTDB_FAIL;
958  }
959  sds_id = SDselect(fileID, sds_index);
960  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
961  SDreaddata(sds_id, start, NULL, edges, &nv_lut->SX21_SFC[0]);
962 
963  sds_name = "TX21_SFC";
964  sds_index = SDnametoindex(fileID, sds_name.c_str());
965  if (sds_index < 0) {
966  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
967  "SDnametoindex() failure for "<< sds_name << endl;
968  SDend(fileID);
969  return DTDB_FAIL;
970  }
971  sds_id = SDselect(fileID, sds_index);
972  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
973  SDreaddata(sds_id, start, NULL, edges, &nv_lut->TX21_SFC[0]);
974 
975  sds_name = "NVALX672_SFC";
976  sds_index = SDnametoindex(fileID, sds_name.c_str());
977  if (sds_index < 0) {
978  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
979  "SDnametoindex() failure for "<< sds_name << endl;
980  SDend(fileID);
981  return DTDB_FAIL;
982  }
983  sds_id = SDselect(fileID, sds_index);
984  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
985  SDreaddata(sds_id, start, NULL, edges, &nv_lut->NVALX672_SFC[0]);
986 
987  sds_name = "R0X672_SFC";
988  sds_index = SDnametoindex(fileID, sds_name.c_str());
989  if (sds_index < 0) {
990  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
991  "SDnametoindex() failure for "<< sds_name << endl;
992  SDend(fileID);
993  return DTDB_FAIL;
994  }
995  sds_id = SDselect(fileID, sds_index);
996  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
997  SDreaddata(sds_id, start, NULL, edges, &nv_lut->R0X672_SFC[0]);
998 
999  sds_name = "SX672_SFC";
1000  sds_index = SDnametoindex(fileID, sds_name.c_str());
1001  if (sds_index < 0) {
1002  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
1003  "SDnametoindex() failure for "<< sds_name << endl;
1004  SDend(fileID);
1005  return DTDB_FAIL;
1006  }
1007  sds_id = SDselect(fileID, sds_index);
1008  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1009  SDreaddata(sds_id, start, NULL, edges, &nv_lut->SX672_SFC[0]);
1010 
1011  sds_name = "TX672_SFC";
1012  sds_index = SDnametoindex(fileID, sds_name.c_str());
1013  if (sds_index < 0) {
1014  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
1015  "SDnametoindex() failure for "<< sds_name << endl;
1016  SDend(fileID);
1017  return DTDB_FAIL;
1018  }
1019  sds_id = SDselect(fileID, sds_index);
1020  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1021  SDreaddata(sds_id, start, NULL, edges, &nv_lut->TX672_SFC[0]);
1022 
1023  sds_name = "NVALX865_SFC";
1024  sds_index = SDnametoindex(fileID, sds_name.c_str());
1025  if (sds_index < 0) {
1026  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
1027  "SDnametoindex() failure for "<< sds_name << endl;
1028  SDend(fileID);
1029  return DTDB_FAIL;
1030  }
1031  sds_id = SDselect(fileID, sds_index);
1032  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1033  SDreaddata(sds_id, start, NULL, edges, &nv_lut->NVALX865_SFC[0]);
1034 
1035  sds_name = "R0X865_SFC";
1036  sds_index = SDnametoindex(fileID, sds_name.c_str());
1037  if (sds_index < 0) {
1038  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
1039  "SDnametoindex() failure for "<< sds_name << endl;
1040  SDend(fileID);
1041  return DTDB_FAIL;
1042  }
1043  sds_id = SDselect(fileID, sds_index);
1044  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1045  SDreaddata(sds_id, start, NULL, edges, &nv_lut->R0X865_SFC[0]);
1046 
1047  sds_name = "SX865_SFC";
1048  sds_index = SDnametoindex(fileID, sds_name.c_str());
1049  if (sds_index < 0) {
1050  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
1051  "SDnametoindex() failure for "<< sds_name << endl;
1052  SDend(fileID);
1053  return DTDB_FAIL;
1054  }
1055  sds_id = SDselect(fileID, sds_index);
1056  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1057  SDreaddata(sds_id, start, NULL, edges, &nv_lut->SX865_SFC[0]);
1058 
1059  sds_name = "TX865_SFC";
1060  sds_index = SDnametoindex(fileID, sds_name.c_str());
1061  if (sds_index < 0) {
1062  cerr << "DbLutNetcdf::read_nvalx21_file() " <<
1063  "SDnametoindex() failure for "<< sds_name << endl;
1064  SDend(fileID);
1065  return DTDB_FAIL;
1066  }
1067  sds_id = SDselect(fileID, sds_index);
1068  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1069  SDreaddata(sds_id, start, NULL, edges, &nv_lut->TX865_SFC[0]);
1070 
1071  return status;
1072 }
1073 
1074 /**************************************************************************
1075  * NAME: write_veg_21sfc_lut()
1076  *
1077  * DESCRIPTION: Write veg_21sfc LUT to NetCDF4 file.
1078  *
1079  *************************************************************************/
1080 
1081 int DbLutNetcdf::write_veg_21sfc_lut( NcFile* nc_output,
1082  dbVeg_21sfcLUT* nv_lut )
1083 {
1084  NcGroup lut_grp = nc_output->addGroup( LUT_NVALX21 );
1085 
1086  dim_nszav_ = lut_grp.addDim( "Dim_NSZA", NSZAV );
1087  dim_nvza_ = lut_grp.addDim( "Dim_NVZA", NVZA );
1088  dim_nraa_ = lut_grp.addDim( "Dim_NRAA", NRAA );
1089  dim_4_ = lut_grp.addDim( "Dim_SEASONS", 4 );
1090 
1091  vector<NcDim> nvalx21_dims;
1092  nvalx21_dims.push_back(dim_4_);
1093  nvalx21_dims.push_back(dim_nraa_);
1094  nvalx21_dims.push_back(dim_nvza_);
1095  nvalx21_dims.push_back(dim_nszav_);
1096 
1097  NcVar var = lut_grp.addVar( "NVALX21_SFC", ncFloat, nvalx21_dims );
1098  var.putVar( nv_lut->NVALX21_SFC );
1099 
1100  var = lut_grp.addVar( "R0X21_SFC", ncFloat, nvalx21_dims );
1101  var.putVar( nv_lut->R0X21_SFC );
1102 
1103  var = lut_grp.addVar( "SX21_SFC", ncFloat, nvalx21_dims );
1104  var.putVar( nv_lut->SX21_SFC );
1105 
1106  var = lut_grp.addVar( "TX21_SFC", ncFloat, nvalx21_dims );
1107  var.putVar( nv_lut->TX21_SFC );
1108 
1109  var = lut_grp.addVar( "NVALX672_SFC", ncFloat, nvalx21_dims );
1110  var.putVar( nv_lut->NVALX672_SFC );
1111 
1112  var = lut_grp.addVar( "R0X672_SFC", ncFloat, nvalx21_dims );
1113  var.putVar( nv_lut->R0X672_SFC );
1114 
1115  var = lut_grp.addVar( "SX672_SFC", ncFloat, nvalx21_dims );
1116  var.putVar( nv_lut->SX672_SFC );
1117 
1118  var = lut_grp.addVar( "TX672_SFC", ncFloat, nvalx21_dims );
1119  var.putVar( nv_lut->TX672_SFC );
1120 
1121  var = lut_grp.addVar( "NVALX865_SFC", ncFloat, nvalx21_dims );
1122  var.putVar( nv_lut->NVALX865_SFC );
1123 
1124  var = lut_grp.addVar( "R0X865_SFC", ncFloat, nvalx21_dims );
1125  var.putVar( nv_lut->R0X865_SFC );
1126 
1127  var = lut_grp.addVar( "SX865_SFC", ncFloat, nvalx21_dims );
1128  var.putVar( nv_lut->SX865_SFC );
1129 
1130  var = lut_grp.addVar( "TX865_SFC", ncFloat, nvalx21_dims );
1131  var.putVar( nv_lut->TX865_SFC );
1132 
1133  return DTDB_SUCCESS;
1134 }
1135 
1136 /**************************************************************************
1137  * NAME: read_veg_21sfc_lut()
1138  *
1139  * DESCRIPTION: Read veg_21sfc NetCDF4 LUT.
1140  *
1141  *************************************************************************/
1142 
1144 {
1145  int status = DTDB_SUCCESS;
1146 
1148  if (filepath.empty()) {
1150  }
1151  NcFile* nc_input;
1152  try {
1153  nc_input = new NcFile(filepath, NcFile::read );
1154  }
1155  catch( NcException& e) {
1156  e.what();
1157  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
1158  return DTDB_FAIL;
1159  }
1160  NcGroup lut_grp = nc_input->getGroup( LUT_NVALX21 );
1161 
1162  NcVar var = lut_grp.getVar( "NVALX21_SFC" );
1163  var.getVar( nv_lut->NVALX21_SFC );
1164 
1165  var = lut_grp.getVar( "R0X21_SFC" );
1166  var.getVar( nv_lut->R0X21_SFC );
1167 
1168  var = lut_grp.getVar( "SX21_SFC" );
1169  var.getVar( nv_lut->SX21_SFC );
1170 
1171  var = lut_grp.getVar( "TX21_SFC" );
1172  var.getVar( nv_lut->TX21_SFC );
1173 
1174  var = lut_grp.getVar( "NVALX672_SFC" );
1175  var.getVar( nv_lut->NVALX672_SFC );
1176 
1177  var = lut_grp.getVar( "R0X672_SFC" );
1178  var.getVar( nv_lut->R0X672_SFC );
1179 
1180  var = lut_grp.getVar( "SX672_SFC" );
1181  var.getVar( nv_lut->SX672_SFC );
1182 
1183  var = lut_grp.getVar( "TX672_SFC" );
1184  var.getVar( nv_lut->TX672_SFC );
1185 
1186  var = lut_grp.getVar( "NVALX865_SFC" );
1187  var.getVar( nv_lut->NVALX865_SFC );
1188 
1189  var = lut_grp.getVar( "R0X865_SFC" );
1190  var.getVar( nv_lut->R0X865_SFC );
1191 
1192  var = lut_grp.getVar( "SX865_SFC" );
1193  var.getVar( nv_lut->SX865_SFC );
1194 
1195  var = lut_grp.getVar( "TX865_SFC" );
1196  var.getVar( nv_lut->TX865_SFC );
1197 
1198  delete nc_input;
1199 
1200  return status;
1201 }
1202 
1203 /**************************************************************************
1204  * NAME: read_modis_surf_refl_file()
1205  *
1206  * DESCRIPTION: Read seasonal surface reflectance hdf4 file.
1207  *
1208  *************************************************************************/
1209 
1211 {
1212  int status = DTDB_SUCCESS;
1213 
1215  if(filepath.empty()) {
1216  cerr << "DbLutNetcdf::read_modis_surf_refl_file() Invalid path." << endl;
1217  return DTDB_FAIL;
1218  }
1219  SEASON iseason = SEASON::NEVER;
1220  size_t rpos = 0;
1221  for (int iS=0; iS<NUM_SEASONS; iS++) {
1222  size_t pos = filepath.find(str_season[iS]);
1223  if (pos != string::npos) {
1224  iseason = (SEASON) iS;
1225  rpos = pos;
1226  }
1227  }
1228  if (iseason == SEASON::NEVER) {
1229  cerr << "DbLutNetcdf:: Could not identify season in file name: " + filepath << endl;
1230  return DTDB_FAIL;
1231  }
1232  for (int iS=0; iS<NUM_SEASONS; iS++) {
1233  string rfilepath = filepath;
1234  rfilepath.replace(rpos, str_season[(int)iseason].size(), str_season[iS]);
1235  int fileID;
1236  try {
1237  fileID = SDstart(rfilepath.c_str(), DFACC_READ );
1238  }
1239  catch( std::exception& e) {
1240  e.what();
1241  cerr << "DbLutNetcdf:: Failure opening modis surface refl file: " + rfilepath << endl;
1242  return DTDB_FAIL;
1243  }
1244  int sds_index, sds_id, numtype, rank, nattrs;
1245  int start[2], edges[2], dims[2];
1246  start[0] = 0;
1247  start[1] = 0;
1248  edges[0] = NLATS*10;
1249  edges[1] = NLONS*10;
1250 
1251  string sds_name = "412_all";
1252  sds_index = SDnametoindex(fileID, sds_name.c_str());
1253  if (sds_index < 0) {
1254  cerr << "DbLutNetcdf::read_modis_surf_refl_file() " <<
1255  "SDnametoindex() failure for "<< sds_name << endl;
1256  SDend(fileID);
1257  return DTDB_FAIL;
1258  }
1259  sds_id = SDselect(fileID, sds_index);
1260  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1261  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR412_ALL[iS][0][0]);
1262 // 470
1263  sds_name = "470_all";
1264  sds_index = SDnametoindex(fileID, sds_name.c_str());
1265  if (sds_index < 0) {
1266  cerr << "DbLutNetcdf::read_modis_surf_refl_file() " <<
1267  "SDnametoindex() failure for "<< sds_name << endl;
1268  SDend(fileID);
1269  return DTDB_FAIL;
1270  }
1271  sds_id = SDselect(fileID, sds_index);
1272  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1273  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR470_ALL[iS][0][0]);
1274 // 650
1275  sds_name = "650_all";
1276  sds_index = SDnametoindex(fileID, sds_name.c_str());
1277  if (sds_index < 0) {
1278  cerr << "DbLutNetcdf::read_modis_surf_refl_file() " <<
1279  "SDnametoindex() failure for "<< sds_name << endl;
1280  SDend(fileID);
1281  return DTDB_FAIL;
1282  }
1283  sds_id = SDselect(fileID, sds_index);
1284  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1285  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR650_ALL[iS][0][0]);
1286 
1287 // 865
1288  sds_name = "865_all_all";
1289  sds_index = SDnametoindex(fileID, sds_name.c_str());
1290  if (sds_index < 0) {
1291  cerr << "DbLutNetcdf::read_modis_surf_refl_file() " <<
1292  "SDnametoindex() failure for "<< sds_name << endl;
1293  SDend(fileID);
1294  return DTDB_FAIL;
1295  }
1296  sds_id = SDselect(fileID, sds_index);
1297  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1298  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR865_ALL[iS][0][0]);
1299 
1300  SDend(fileID);
1301  }
1302 
1303  return status;
1304 }
1305 
1306 /**************************************************************************
1307  * NAME: write_modis_surf_refl_lut()
1308  *
1309  * DESCRIPTION: Write surf_refl LUT to NetCDF4 file.
1310  *
1311  *************************************************************************/
1312 
1314  dbModisSurfReflLUT* sr_lut )
1315 {
1316  NcGroup lut_grp = nc_output->addGroup( LUT_MODIS_SURFACE_REFL );
1317 
1318  dim_seasons_ = lut_grp.addDim( "Dim_seasons", NUM_SEASONS );
1319  dim_1800_ = lut_grp.addDim( "Dim_1800", NLATS*10 );
1320  dim_3600_ = lut_grp.addDim( "Dim_3600", NLONS*10 );
1321 
1322  vector<NcDim> latlon_dims;
1323  latlon_dims.push_back(dim_1800_);
1324  latlon_dims.push_back(dim_3600_);
1325 
1326  vector<NcDim> slatlon_dims;
1327  slatlon_dims.push_back(dim_seasons_);
1328  slatlon_dims.push_back(dim_1800_);
1329  slatlon_dims.push_back(dim_3600_);
1330 
1331  NcVar var = lut_grp.addVar( "SR412_ALL", ncFloat, slatlon_dims );
1332  var.putVar( sr_lut->SR412_ALL );
1333 
1334  var = lut_grp.addVar( "SR470_ALL", ncFloat, slatlon_dims );
1335  var.putVar( sr_lut->SR470_ALL );
1336 
1337  var = lut_grp.addVar( "SR650_ALL", ncFloat, slatlon_dims );
1338  var.putVar( sr_lut->SR650_ALL );
1339 
1340  var = lut_grp.addVar( "SR412_FWD", ncFloat, slatlon_dims );
1341  var.putVar( sr_lut->SR412_FWD );
1342 
1343  var = lut_grp.addVar( "SR470_FWD", ncFloat, slatlon_dims );
1344  var.putVar( sr_lut->SR470_FWD );
1345 
1346  var = lut_grp.addVar( "SR650_FWD", ncFloat, slatlon_dims );
1347  var.putVar( sr_lut->SR650_FWD );
1348 
1349  var = lut_grp.addVar( "SR865_ALL", ncFloat, latlon_dims );
1350  var.putVar( sr_lut->SR865_ALL );
1351 
1352  return DTDB_SUCCESS;
1353 }
1354 
1355 /**************************************************************************
1356  * NAME: read_modis_surf_refl_lut()
1357  *
1358  * DESCRIPTION: Read surf_refl NetCDF4 LUT.
1359  *
1360  *************************************************************************/
1361 
1363  int* start, int* edge, int &season, int &dateline )
1364 {
1365  int status = DTDB_SUCCESS;
1366 
1368  if (filepath.empty()) {
1370  }
1371  NcFile* nc_input;
1372  try {
1373  nc_input = new NcFile(filepath, NcFile::read );
1374  }
1375  catch( NcException& e) {
1376  e.what();
1377  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
1378  return DTDB_FAIL;
1379  }
1380  NcGroup lut_grp = nc_input->getGroup( LUT_MODIS_SURFACE_REFL );
1381 
1382  sr_lut->SR412_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1383  sr_lut->SR470_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1384  sr_lut->SR650_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1385  sr_lut->SR412_FWD_L.resize(boost::extents[edge[1]][edge[0]]);
1386  sr_lut->SR470_FWD_L.resize(boost::extents[edge[1]][edge[0]]);
1387  sr_lut->SR650_FWD_L.resize(boost::extents[edge[1]][edge[0]]);
1388  sr_lut->SR865_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1389 
1390  vector<size_t> startp;
1391  vector<size_t> countp;
1392  startp.push_back(season);
1393  startp.push_back(start[1]);
1394  startp.push_back(start[0]);
1395  countp.push_back(1);
1396  countp.push_back(edge[1]);
1397  countp.push_back(edge[0]);
1398 
1399  if (dateline ==0) {
1400  NcVar var = lut_grp.getVar( "SR412_ALL" );
1401  var.getVar( startp, countp, &sr_lut->SR412_ALL_L[0][0] );
1402  var = lut_grp.getVar( "SR470_ALL" );
1403  var.getVar( startp, countp, &sr_lut->SR470_ALL_L[0][0] );
1404  var = lut_grp.getVar( "SR650_ALL" );
1405  var.getVar( startp, countp, &sr_lut->SR650_ALL_L[0][0] );
1406  var = lut_grp.getVar( "SR412_FWD" );
1407  var.getVar( startp, countp, &sr_lut->SR412_FWD_L[0][0] );
1408  var = lut_grp.getVar( "SR470_FWD" );
1409  var.getVar( startp, countp, &sr_lut->SR470_FWD_L[0][0] );
1410  var = lut_grp.getVar( "SR650_FWD" );
1411  var.getVar( startp, countp, &sr_lut->SR650_FWD_L[0][0] );
1412  var = lut_grp.getVar( "SR865_ALL" );
1413  var.getVar( startp, countp, &sr_lut->SR865_ALL_L[0][0] );
1414  } else {
1415  countp[2] = dateline;
1416  NcVar var = lut_grp.getVar( "SR412_ALL" );
1417  var.getVar( startp, countp, &sr_lut->SR412_ALL_L[0][0] );
1418  var = lut_grp.getVar( "SR470_ALL" );
1419  var.getVar( startp, countp, &sr_lut->SR470_ALL_L[0][0] );
1420  var = lut_grp.getVar( "SR650_ALL" );
1421  var.getVar( startp, countp, &sr_lut->SR650_ALL_L[0][0] );
1422  var = lut_grp.getVar( "SR412_FWD" );
1423  var.getVar( startp, countp, &sr_lut->SR412_FWD_L[0][0] );
1424  var = lut_grp.getVar( "SR470_FWD" );
1425  var.getVar( startp, countp, &sr_lut->SR470_FWD_L[0][0] );
1426  var = lut_grp.getVar( "SR650_FWD" );
1427  var.getVar( startp, countp, &sr_lut->SR650_FWD_L[0][0] );
1428  var = lut_grp.getVar( "SR865_ALL" );
1429  var.getVar( startp, countp, &sr_lut->SR865_ALL_L[0][0] );
1430  startp[2] = 0;
1431  countp[2] = edge[0] - dateline;
1432  var = lut_grp.getVar( "SR412_ALL" );
1433  var.getVar( startp, countp, &sr_lut->SR412_ALL_L[0][dateline] );
1434  var = lut_grp.getVar( "SR470_ALL" );
1435  var.getVar( startp, countp, &sr_lut->SR470_ALL_L[0][dateline] );
1436  var = lut_grp.getVar( "SR650_ALL" );
1437  var.getVar( startp, countp, &sr_lut->SR650_ALL_L[0][dateline] );
1438  var = lut_grp.getVar( "SR412_FWD" );
1439  var.getVar( startp, countp, &sr_lut->SR412_FWD_L[0][dateline] );
1440  var = lut_grp.getVar( "SR470_FWD" );
1441  var.getVar( startp, countp, &sr_lut->SR470_FWD_L[0][dateline] );
1442  var = lut_grp.getVar( "SR650_FWD" );
1443  var.getVar( startp, countp, &sr_lut->SR650_FWD_L[0][dateline] );
1444  var = lut_grp.getVar( "SR865_ALL" );
1445  var.getVar( startp, countp, &sr_lut->SR865_ALL_L[0][dateline] );
1446  }
1447  delete nc_input;
1448 
1449  return status;
1450 }
1451 
1452 /**************************************************************************
1453  * NAME: read_viirs_surf_refl_file()
1454  *
1455  * DESCRIPTION: Read seasonal surface reflectance hdf4 file.
1456  *
1457  *************************************************************************/
1458 
1460 {
1461  int status = DTDB_SUCCESS;
1462 
1464  if(filepath.empty()) {
1465  cerr << "DbLutNetcdf::read_surf_refl_file() Invalid path." << endl;
1466  return DTDB_FAIL;
1467  }
1468  SEASON iseason = SEASON::NEVER;
1469  size_t rpos = 0;
1470  for (int iS=0; iS<NUM_SEASONS; iS++) {
1471  size_t pos = filepath.find(str_season[iS]);
1472  if (pos != string::npos) {
1473  iseason = (SEASON) iS;
1474  rpos = pos;
1475  }
1476  }
1477  if (iseason == SEASON::NEVER) {
1478  cerr << "DbLutNetcdf:: Could not identify season in file name: " + filepath << endl;
1479  return DTDB_FAIL;
1480  }
1481  for (int iS=0; iS<NUM_SEASONS; iS++) {
1482  string rfilepath = filepath;
1483  rfilepath.replace(rpos, str_season[(int) iseason].size(), str_season[iS]);
1484  int fileID;
1485  try {
1486  fileID = SDstart(rfilepath.c_str(), DFACC_READ );
1487  }
1488  catch( std::exception& e) {
1489  e.what();
1490  cerr << "DbLutNetcdf:: Failure opening surface refl file: " + rfilepath << endl;
1491  return DTDB_FAIL;
1492  }
1493  int sds_index, sds_id, numtype, rank, nattrs;
1494  int start[2], edges[2], dims[2];
1495  start[0] = 0;
1496  start[1] = 0;
1497  edges[0] = NLATS*10;
1498  edges[1] = NLONS*10;
1499 
1500  string sds_name = "412_all";
1501  sds_index = SDnametoindex(fileID, sds_name.c_str());
1502  if (sds_index < 0) {
1503  cerr << "DbLutNetcdf::read_surf_refl_file() " <<
1504  "SDnametoindex() failure for "<< sds_name << endl;
1505  SDend(fileID);
1506  return DTDB_FAIL;
1507  }
1508  sds_id = SDselect(fileID, sds_index);
1509  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1510  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR412_ALL[iS][0][0]);
1511 // 470
1512  sds_name = "488_all";
1513  sds_index = SDnametoindex(fileID, sds_name.c_str());
1514  if (sds_index < 0) {
1515  cerr << "DbLutNetcdf::read_surf_refl_file() " <<
1516  "SDnametoindex() failure for "<< sds_name << endl;
1517  SDend(fileID);
1518  return DTDB_FAIL;
1519  }
1520  sds_id = SDselect(fileID, sds_index);
1521  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1522  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR488_ALL[iS][0][0]);
1523 // 650
1524  sds_name = "670_all";
1525  sds_index = SDnametoindex(fileID, sds_name.c_str());
1526  if (sds_index < 0) {
1527  cerr << "DbLutNetcdf::read_surf_refl_file() " <<
1528  "SDnametoindex() failure for "<< sds_name << endl;
1529  SDend(fileID);
1530  return DTDB_FAIL;
1531  }
1532  sds_id = SDselect(fileID, sds_index);
1533  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1534  SDreaddata(sds_id, start, NULL, edges, &sr_lut->SR670_ALL[iS][0][0]);
1535 
1536  string filepath = get_option(INPUT_BRDF);
1537  if(filepath.empty()) {
1538  cerr << "DbLutNetcdf::read_landcover_file() Invalid path." << endl;
1539  return DTDB_FAIL;
1540  }
1541  try {
1542  fileID = SDstart(filepath.c_str(), DFACC_READ );
1543  }
1544  catch( std::exception& e) {
1545  e.what();
1546  cerr << "DbLutNetcdf:: Failure opening brdf file: " + filepath << endl;
1547  return DTDB_FAIL;
1548  }
1549  start[0] = 0;
1550  start[1] = 0;
1551  edges[0] = NLATS*10;
1552  edges[1] = NLONS*10;
1553  sds_name = "brdf_base_650";
1554  sds_index = SDnametoindex(fileID, sds_name.c_str());
1555  if (sds_index < 0) {
1556  cerr << "DbLutNetcdf::read_landcover_files() " <<
1557  "SDnametoindex() failure for "<< sds_name << endl;
1558  SDend(fileID);
1559  return DTDB_FAIL;
1560  }
1561  sds_id = SDselect(fileID, sds_index);
1562  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1563  SDreaddata(sds_id, start, NULL, edges, &sr_lut->BRDF_650[0][0]);
1564 
1565  SDend(fileID);
1566  }
1567 
1568  return status;
1569 }
1570 
1571 /**************************************************************************
1572  * NAME: write_viirs_surf_refl_lut()
1573  *
1574  * DESCRIPTION: Write surf_refl LUT to NetCDF4 file.
1575  *
1576  *************************************************************************/
1577 
1579  dbViirsSurfReflLUT* sr_lut )
1580 {
1581  NcGroup lut_grp = nc_output->addGroup( LUT_VIIRS_SURFACE_REFL );
1582 
1583  dim_seasons_ = lut_grp.addDim( "Dim_seasons", NUM_SEASONS );
1584  dim_1800_ = lut_grp.addDim( "Dim_1800", NLATS*10 );
1585  dim_3600_ = lut_grp.addDim( "Dim_3600", NLONS*10 );
1586 
1587  vector<NcDim> latlon_dims;
1588  latlon_dims.push_back(dim_1800_);
1589  latlon_dims.push_back(dim_3600_);
1590 
1591  vector<NcDim> slatlon_dims;
1592  slatlon_dims.push_back(dim_seasons_);
1593  slatlon_dims.push_back(dim_1800_);
1594  slatlon_dims.push_back(dim_3600_);
1595 
1596  NcVar var = lut_grp.addVar( "SR412_ALL", ncFloat, slatlon_dims );
1597  var.putVar( sr_lut->SR412_ALL );
1598 
1599  var = lut_grp.addVar( "SR488_ALL", ncFloat, slatlon_dims );
1600  var.putVar( sr_lut->SR488_ALL );
1601 
1602  var = lut_grp.addVar( "SR670_ALL", ncFloat, slatlon_dims );
1603  var.putVar( sr_lut->SR670_ALL );
1604 
1605  var = lut_grp.addVar( "BRDF_650", ncFloat, latlon_dims );
1606  var.putVar( sr_lut->BRDF_650 );
1607 
1608  return DTDB_SUCCESS;
1609 }
1610 
1611 /**************************************************************************
1612  * NAME: read_viirs_surf_refl_lut()
1613  *
1614  * DESCRIPTION: Read surf_refl NetCDF4 LUT.
1615  *
1616  *************************************************************************/
1617 
1619  int* start, int* edge, int &season, int &dateline )
1620 {
1621  int status = DTDB_SUCCESS;
1622 
1624  if (filepath.empty()) {
1626  }
1627  NcFile* nc_input;
1628  try {
1629  nc_input = new NcFile(filepath, NcFile::read );
1630  }
1631  catch( NcException& e) {
1632  e.what();
1633  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
1634  return DTDB_FAIL;
1635  }
1636  NcGroup lut_grp = nc_input->getGroup( LUT_VIIRS_SURFACE_REFL );
1637 
1638  sr_lut->SR412_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1639  sr_lut->SR488_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1640  sr_lut->SR670_ALL_L.resize(boost::extents[edge[1]][edge[0]]);
1641  sr_lut->BRDF_650_L.resize(boost::extents[edge[1]][edge[0]]);
1642 
1643  vector<size_t> startp;
1644  vector<size_t> countp;
1645  startp.push_back(season);
1646  startp.push_back(start[1]);
1647  startp.push_back(start[0]);
1648  countp.push_back(1);
1649  countp.push_back(edge[1]);
1650  countp.push_back(edge[0]);
1651 
1652  if (dateline ==0) {
1653  NcVar var = lut_grp.getVar( "SR412_ALL" );
1654  var.getVar( startp, countp, &sr_lut->SR412_ALL_L[0][0] );
1655  var = lut_grp.getVar( "SR488_ALL" );
1656  var.getVar( startp, countp, &sr_lut->SR488_ALL_L[0][0] );
1657  var = lut_grp.getVar( "SR670_ALL" );
1658  var.getVar( startp, countp, &sr_lut->SR670_ALL_L[0][0] );
1659  var = lut_grp.getVar( "BRDF_650" );
1660  var.getVar( startp, countp, &sr_lut->BRDF_650_L[0][0] );
1661  } else {
1662  countp[2] = dateline;
1663  NcVar var = lut_grp.getVar( "SR412_ALL" );
1664  var.getVar( startp, countp, &sr_lut->SR412_ALL_L[0][0] );
1665  var = lut_grp.getVar( "SR488_ALL" );
1666  var.getVar( startp, countp, &sr_lut->SR488_ALL_L[0][0] );
1667  var = lut_grp.getVar( "SR670_ALL" );
1668  var.getVar( startp, countp, &sr_lut->SR670_ALL_L[0][0] );
1669  var = lut_grp.getVar( "BRDF_650" );
1670  var.getVar( startp, countp, &sr_lut->BRDF_650_L[0][0] );
1671  startp[2] = 0;
1672  countp[2] = edge[0] - dateline;
1673  var = lut_grp.getVar( "SR412_ALL" );
1674  var.getVar( startp, countp, &sr_lut->SR412_ALL_L[0][dateline] );
1675  var = lut_grp.getVar( "SR488_ALL" );
1676  var.getVar( startp, countp, &sr_lut->SR488_ALL_L[0][dateline] );
1677  var = lut_grp.getVar( "SR670_ALL" );
1678  var.getVar( startp, countp, &sr_lut->SR670_ALL_L[0][dateline] );
1679  var = lut_grp.getVar( "BRDF_650" );
1680  var.getVar( startp, countp, &sr_lut->BRDF_650_L[0][dateline] );
1681  }
1682  delete nc_input;
1683 
1684  return status;
1685 }
1686 
1687 /**************************************************************************
1688  * NAME: read_surf_coeff_files()
1689  *
1690  * DESCRIPTION: Read seasonal surface coefficients hdf4 files.
1691  *
1692  *************************************************************************/
1693 
1695 {
1696  int status = DTDB_SUCCESS;
1697 
1699  if(filepath.empty()) {
1700  cerr << "DbLutNetcdf::read_surf_coeff_file() Invalid path." << endl;
1701  return DTDB_FAIL;
1702  }
1703  SEASON iseason = SEASON::NEVER;
1704  size_t rpos = 0;
1705  for (int iS=0; iS<NUM_SEASONS; iS++) {
1706  size_t pos = filepath.find(str_season[iS]);
1707  if (pos != string::npos) {
1708  iseason = (SEASON) iS;
1709  rpos = pos;
1710  }
1711  }
1712  if (iseason == SEASON::NEVER) {
1713  cerr << "DbLutNetcdf:: Could not identify season in file name: " + filepath << endl;
1714  return DTDB_FAIL;
1715  }
1716  for (int iS=0; iS<NUM_SEASONS; iS++) {
1717  string rfilepath = filepath;
1718  rfilepath.replace(rpos, str_season[(int) iseason].size(), str_season[iS]);
1719  int fileID;
1720  try {
1721  fileID = SDstart(rfilepath.c_str(), DFACC_READ );
1722  }
1723  catch( std::exception& e) {
1724  e.what();
1725  cerr << "DbLutNetcdf:: Failure opening surface coeff file: " + rfilepath << endl;
1726  return DTDB_FAIL;
1727  }
1728  int sds_index, sds_id, numtype, rank, nattrs;
1729  int start[4], edges[4], dims[4];
1730  start[0] = 0;
1731  start[1] = 0;
1732  start[2] = 0;
1733  start[3] = 0;
1734  edges[0] = NNDVI;
1735  edges[1] = NTERMS;
1736  edges[2] = NLATS*10;
1737  edges[3] = NLONS*10;
1738 
1739  string sds_name = "412_all";
1740  sds_index = SDnametoindex(fileID, sds_name.c_str());
1741  if (sds_index < 0) {
1742  cerr << "DbLutNetcdf::read_surf_coeff_file() " <<
1743  "SDnametoindex() failure for "<< sds_name << endl;
1744  SDend(fileID);
1745  return DTDB_FAIL;
1746  }
1747  sds_id = SDselect(fileID, sds_index);
1748  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1749  SDreaddata(sds_id, start, NULL, edges, &sc_lut->SC412_ALL[iS][0][0][0][0]);
1750 
1751  sds_name = "412_fwd";
1752  sds_index = SDnametoindex(fileID, sds_name.c_str());
1753  if (sds_index < 0) {
1754  cerr << "DbLutNetcdf::read_surf_coeff_file() " <<
1755  "SDnametoindex() failure for "<< sds_name << endl;
1756  SDend(fileID);
1757  return DTDB_FAIL;
1758  }
1759  sds_id = SDselect(fileID, sds_index);
1760  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1761  SDreaddata(sds_id, start, NULL, edges, &sc_lut->SC412_FWD[iS][0][0][0][0]);
1762 
1763 // 470
1764  sds_name = "470_all";
1765  sds_index = SDnametoindex(fileID, sds_name.c_str());
1766  if (sds_index < 0) {
1767  cerr << "DbLutNetcdf::read_surf_coeff_file() " <<
1768  "SDnametoindex() failure for "<< sds_name << endl;
1769  SDend(fileID);
1770  return DTDB_FAIL;
1771  }
1772  sds_id = SDselect(fileID, sds_index);
1773  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1774  SDreaddata(sds_id, start, NULL, edges, &sc_lut->SC470_ALL[iS][0][0][0][0]);
1775 
1776  sds_name = "470_fwd";
1777  sds_index = SDnametoindex(fileID, sds_name.c_str());
1778  if (sds_index < 0) {
1779  cerr << "DbLutNetcdf::read_surf_coeff_file() " <<
1780  "SDnametoindex() failure for "<< sds_name << endl;
1781  SDend(fileID);
1782  return DTDB_FAIL;
1783  }
1784  sds_id = SDselect(fileID, sds_index);
1785  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1786  SDreaddata(sds_id, start, NULL, edges, &sc_lut->SC470_FWD[iS][0][0][0][0]);
1787 
1788 // 650
1789  sds_name = "650_all";
1790  sds_index = SDnametoindex(fileID, sds_name.c_str());
1791  if (sds_index < 0) {
1792  cerr << "DbLutNetcdf::read_surf_coeff_file() " <<
1793  "SDnametoindex() failure for "<< sds_name << endl;
1794  SDend(fileID);
1795  return DTDB_FAIL;
1796  }
1797  sds_id = SDselect(fileID, sds_index);
1798  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1799  SDreaddata(sds_id, start, NULL, edges, &sc_lut->SC650_ALL[iS][0][0][0][0]);
1800 
1801  sds_name = "650_fwd";
1802  sds_index = SDnametoindex(fileID, sds_name.c_str());
1803  if (sds_index < 0) {
1804  cerr << "DbLutNetcdf::read_surf_coeff_file() " <<
1805  "SDnametoindex() failure for "<< sds_name << endl;
1806  SDend(fileID);
1807  return DTDB_FAIL;
1808  }
1809  sds_id = SDselect(fileID, sds_index);
1810  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
1811  SDreaddata(sds_id, start, NULL, edges, &sc_lut->SC650_FWD[iS][0][0][0][0]);
1812 
1813  SDend(fileID);
1814  }
1815 
1816  return status;
1817 }
1818 
1819 /**************************************************************************
1820  * NAME: write_surf_coeff_lut()
1821  *
1822  * DESCRIPTION: Write surf_coeff LUT to NetCDF4 file.
1823  *
1824  *************************************************************************/
1825 
1826 int DbLutNetcdf::write_surf_coeff_lut( NcFile* nc_output,
1827  dbSurfCoeffLUT* sc_lut )
1828 {
1829  NcGroup lut_grp = nc_output->addGroup( LUT_SURFACE_COEFF );
1830 
1831  dim_seasons_ = lut_grp.addDim( "Dim_seasons", NUM_SEASONS );
1832  dim_ndvi_ = lut_grp.addDim( "Dim_ndvi", NNDVI );
1833  dim_terms_ = lut_grp.addDim( "Dim_terms", NTERMS );
1834  dim_1800_ = lut_grp.addDim( "Dim_1800", NLATS*10 );
1835  dim_3600_ = lut_grp.addDim( "Dim_3600", NLONS*10 );
1836 
1837  vector<NcDim> latlon_dims;
1838  latlon_dims.push_back(dim_seasons_);
1839  latlon_dims.push_back(dim_ndvi_);
1840  latlon_dims.push_back(dim_terms_);
1841  latlon_dims.push_back(dim_1800_);
1842  latlon_dims.push_back(dim_3600_);
1843 
1844  NcVar var = lut_grp.addVar( "SC412_ALL", ncFloat, latlon_dims );
1845  var.putVar( sc_lut->SC412_ALL );
1846 
1847  var = lut_grp.addVar( "SC412_FWD", ncFloat, latlon_dims );
1848  var.putVar( sc_lut->SC412_FWD );
1849 
1850  var = lut_grp.addVar( "SC470_ALL", ncFloat, latlon_dims );
1851  var.putVar( sc_lut->SC470_ALL );
1852 
1853  var = lut_grp.addVar( "SC470_FWD", ncFloat, latlon_dims );
1854  var.putVar( sc_lut->SC470_FWD );
1855 
1856  var = lut_grp.addVar( "SC650_ALL", ncFloat, latlon_dims );
1857  var.putVar( sc_lut->SC650_ALL );
1858 
1859  var = lut_grp.addVar( "SC650_FWD", ncFloat, latlon_dims );
1860  var.putVar( sc_lut->SC650_FWD );
1861 
1862  return DTDB_SUCCESS;
1863 }
1864 
1865 /**************************************************************************
1866  * NAME: read_surf_coeff_lut()
1867  *
1868  * DESCRIPTION: Read surface coefficients NetCDF4 LUT.
1869  *
1870  *************************************************************************/
1871 
1873  int* edge, int &season, int &dateline )
1874 {
1875  int status = DTDB_SUCCESS;
1876 
1878  if (filepath.empty()) {
1880  }
1881  NcFile* nc_input;
1882  try {
1883  nc_input = new NcFile(filepath, NcFile::read );
1884  }
1885  catch( NcException& e) {
1886  e.what();
1887  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
1888  return DTDB_FAIL;
1889  }
1890  NcGroup lut_grp = nc_input->getGroup( LUT_SURFACE_COEFF );
1891 
1892  sc_lut->SC412_ALL_L.resize(boost::extents[3][4][edge[1]][edge[0]]);
1893  sc_lut->SC412_FWD_L.resize(boost::extents[3][4][edge[1]][edge[0]]);
1894  sc_lut->SC470_ALL_L.resize(boost::extents[3][4][edge[1]][edge[0]]);
1895  sc_lut->SC470_FWD_L.resize(boost::extents[3][4][edge[1]][edge[0]]);
1896  sc_lut->SC650_ALL_L.resize(boost::extents[3][4][edge[1]][edge[0]]);
1897  sc_lut->SC650_FWD_L.resize(boost::extents[3][4][edge[1]][edge[0]]);
1898 
1899  vector<size_t> startp;
1900  vector<size_t> countp;
1901  startp.push_back(season);
1902  startp.push_back(0);
1903  startp.push_back(0);
1904  startp.push_back(start[1]);
1905  startp.push_back(start[0]);
1906  countp.push_back(1);
1907  countp.push_back(3);
1908  countp.push_back(4);
1909  countp.push_back(edge[1]);
1910  countp.push_back(edge[0]);
1911 
1912  if (dateline ==0) {
1913  NcVar var = lut_grp.getVar( "SC412_ALL" );
1914  var.getVar( startp, countp, &sc_lut->SC412_ALL_L[0][0][0][0] );
1915  var = lut_grp.getVar( "SC412_FWD" );
1916  var.getVar( startp, countp, &sc_lut->SC412_FWD_L[0][0][0][0] );
1917  var = lut_grp.getVar( "SC470_ALL" );
1918  var.getVar( startp, countp, &sc_lut->SC470_ALL_L[0][0][0][0] );
1919  var = lut_grp.getVar( "SC470_FWD" );
1920  var.getVar( startp, countp, &sc_lut->SC470_FWD_L[0][0][0][0] );
1921  var = lut_grp.getVar( "SC650_ALL" );
1922  var.getVar( startp, countp, &sc_lut->SC650_ALL_L[0][0][0][0] );
1923  var = lut_grp.getVar( "SC650_FWD" );
1924  var.getVar( startp, countp, &sc_lut->SC650_FWD_L[0][0][0][0] );
1925  } else {
1926  countp[4] = dateline;
1927  NcVar var = lut_grp.getVar( "SC412_ALL" );
1928  var.getVar( startp, countp, &sc_lut->SC412_ALL_L[0][0][0][0] );
1929  var = lut_grp.getVar( "SC412_FWD" );
1930  var.getVar( startp, countp, &sc_lut->SC412_FWD_L[0][0][0][0] );
1931  var = lut_grp.getVar( "SC470_ALL" );
1932  var.getVar( startp, countp, &sc_lut->SC470_ALL_L[0][0][0][0] );
1933  var = lut_grp.getVar( "SC470_FWD" );
1934  var.getVar( startp, countp, &sc_lut->SC470_FWD_L[0][0][0][0] );
1935  var = lut_grp.getVar( "SC650_ALL" );
1936  var.getVar( startp, countp, &sc_lut->SC650_ALL_L[0][0][0][0] );
1937  var = lut_grp.getVar( "SC650_FWD" );
1938  var.getVar( startp, countp, &sc_lut->SC650_FWD_L[0][0][0][0] );
1939  startp[4] = 0;
1940  countp[4] = edge[0] - dateline;
1941  var = lut_grp.getVar( "SC412_ALL" );
1942  var.getVar( startp, countp, &sc_lut->SC412_ALL_L[0][0][0][dateline] );
1943  var = lut_grp.getVar( "SC412_FWD" );
1944  var.getVar( startp, countp, &sc_lut->SC412_FWD_L[0][0][0][dateline] );
1945  var = lut_grp.getVar( "SC470_ALL" );
1946  var.getVar( startp, countp, &sc_lut->SC470_ALL_L[0][0][0][dateline] );
1947  var = lut_grp.getVar( "SC470_FWD" );
1948  var.getVar( startp, countp, &sc_lut->SC470_FWD_L[0][0][0][dateline] );
1949  var = lut_grp.getVar( "SC650_ALL" );
1950  var.getVar( startp, countp, &sc_lut->SC650_ALL_L[0][0][0][dateline] );
1951  var = lut_grp.getVar( "SC650_FWD" );
1952  var.getVar( startp, countp, &sc_lut->SC650_FWD_L[0][0][0][dateline] );
1953  }
1954  delete nc_input;
1955 
1956  return status;
1957 }
1958 
1959 /**************************************************************************
1960  * NAME: read_rayleigh_files()
1961  *
1962  * DESCRIPTION: Read rayleigh files.
1963  *
1964  *************************************************************************/
1965 
1967 {
1968  int status = DTDB_SUCCESS;
1969 
1970  string filepath1 = get_option(INPUT_RAYL_412);
1971  string filepath2 = get_option(INPUT_RAYL_470);
1972  string filepath3 = get_option(INPUT_RAYL_650);
1973  if(filepath1.empty() || filepath2.empty() || filepath3.empty()) {
1974  cerr << "DbLutNetcdf::read_rayleigh_file() Invalid path." << endl;
1975  return DTDB_FAIL;
1976  }
1977  bool isFileBigEndian = false;
1978  string line1, line2, line3;
1979  int nlines = 8556;
1980  int nrows = 5;
1981  float data1[nlines*nrows];
1982  float data2[nlines*nrows];
1983  float data3[nlines*nrows];
1984  ifstream fin1(filepath1.c_str());
1985  ifstream fin2(filepath2.c_str());
1986  ifstream fin3(filepath3.c_str());
1987  if(fin1.is_open() && fin2.is_open() && fin3.is_open()) {
1988  for (int iL=0; iL<nlines; iL++) {
1989  getline(fin1, line1);
1990  getline(fin2, line2);
1991  getline(fin3, line3);
1992  stringstream ss1(line1);
1993  stringstream ss2(line2);
1994  stringstream ss3(line3);
1995  for (int iR=0; iR<nrows; iR++) {
1996  ss1 >> data1[iL*nrows + iR];
1997  ss2 >> data2[iL*nrows + iR];
1998  ss3 >> data3[iL*nrows + iR];
1999  }
2000  }
2001  int iL = 0;
2002  for (int iR=0; iR<NRRAA; iR++) {
2003  for (int iT=0; iT<NVZA; iT++) {
2004  for (int iZ=0; iZ<NSZA; iZ++) {
2005  for (int iS=0; iS<NSTOKES; iS++) {
2006  rl_lut->RAYL_412[iR][iT][iZ][iS] = data1[iL];
2007  rl_lut->RAYL_470[iR][iT][iZ][iS] = data2[iL];
2008  rl_lut->RAYL_650[iR][iT][iZ][iS] = data3[iL];
2009  iL++;
2010  }
2011  }
2012  }
2013  }
2014  } else {
2015  cerr << "DbLutNetcdf::read_rayleigh_file() Error opening file "
2016  << endl;
2017  return DTDB_FAIL;
2018  }
2019 
2020  if ( isPlatformLittleEndian() && isFileBigEndian) {
2021  for( int iRAA=0; iRAA<NRAA; iRAA++) {
2022  for( int iTHE=0; iTHE<NVZA; iTHE++) {
2023  for( int iSZA=0; iSZA<NSZA; iSZA++) {
2024  for( int iSTOKES=0; iSTOKES<NSTOKES; iSTOKES++) {
2025  byteSwap(rl_lut->RAYL_412[iRAA][iTHE][iSZA][iSTOKES]);
2026  byteSwap(rl_lut->RAYL_470[iRAA][iTHE][iSZA][iSTOKES]);
2027  byteSwap(rl_lut->RAYL_650[iRAA][iTHE][iSZA][iSTOKES]);
2028  }
2029  }
2030  }
2031  }
2032  }
2033 
2034  return status;
2035 }
2036 
2037 /**************************************************************************
2038  * NAME: write_rayleigh_lut()
2039  *
2040  * DESCRIPTION: Write rayleigh LUT to NetCDF4 file.
2041  *
2042  *************************************************************************/
2043 
2044 int DbLutNetcdf::write_rayleigh_lut( NcFile* nc_output,
2045  dbRayleighLUT* rl_lut )
2046 {
2047  NcGroup lut_grp = nc_output->addGroup( LUT_RAYLEIGH );
2048 
2049  dim_nraa_ = lut_grp.addDim( "Dim_NRAA", NRRAA );
2050  dim_nvza_ = lut_grp.addDim( "Dim_NVZA", NVZA );
2051  dim_nsza_ = lut_grp.addDim( "Dim_NSZA", NSZA );
2052  dim_nstokes_ = lut_grp.addDim( "Dim_NSTOKES", NSTOKES );
2053 
2054  vector<NcDim> rayl_dims;
2055  rayl_dims.push_back(dim_nrraa_);
2056  rayl_dims.push_back(dim_nvza_);
2057  rayl_dims.push_back(dim_nsza_);
2058  rayl_dims.push_back(dim_nstokes_);
2059 
2060  NcVar var = lut_grp.addVar( "RAYL_412", ncFloat, rayl_dims );
2061  var.putVar( rl_lut->RAYL_412 );
2062 
2063  var = lut_grp.addVar( "RAYL_470", ncFloat, rayl_dims );
2064  var.putVar( rl_lut->RAYL_470 );
2065 
2066  var = lut_grp.addVar( "RAYL_650", ncFloat, rayl_dims );
2067  var.putVar( rl_lut->RAYL_650 );
2068 
2069  return DTDB_SUCCESS;
2070 }
2071 
2072 /**************************************************************************
2073  * NAME: read_rayleigh_lut()
2074  *
2075  * DESCRIPTION: Read rayleigh NetCDF4 LUT.
2076  *
2077  *************************************************************************/
2078 
2080 {
2081  int status = DTDB_SUCCESS;
2082 
2084  if (filepath.empty()) {
2086  }
2087  NcFile* nc_input;
2088  try {
2089  nc_input = new NcFile(filepath, NcFile::read );
2090  }
2091  catch( NcException& e) {
2092  e.what();
2093  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
2094  return DTDB_FAIL;
2095  }
2096  NcGroup lut_grp = nc_input->getGroup( LUT_RAYLEIGH );
2097 
2098  NcVar var = lut_grp.getVar( "RAYL_412" );
2099  var.getVar( rl_lut->RAYL_412 );
2100 
2101  var = lut_grp.getVar( "NVALX_470" );
2102  var.getVar( rl_lut->RAYL_470 );
2103 
2104  var = lut_grp.getVar( "NVALX_650" );
2105  var.getVar( rl_lut->RAYL_650 );
2106 
2107  delete nc_input;
2108 
2109  return status;
2110 }
2111 
2112 /**************************************************************************
2113  * NAME: read_landcover_file()
2114  *
2115  * DESCRIPTION: Read seasonal landcover hdf4 file.
2116  *
2117  *************************************************************************/
2118 
2120 {
2121  int status = DTDB_SUCCESS;
2122 
2124  if(filepath.empty()) {
2125  cerr << "DbLutNetcdf::read_landcover_file() Invalid path." << endl;
2126  return DTDB_FAIL;
2127  }
2128  int fileID;
2129  try {
2130  fileID = SDstart(filepath.c_str(), DFACC_READ );
2131  }
2132  catch( std::exception& e) {
2133  e.what();
2134  cerr << "DbLutNetcdf:: Failure opening landcover file: " + filepath << endl;
2135  return DTDB_FAIL;
2136  }
2137  int sds_index, sds_id, numtype, rank, nattrs;
2138  int start[2], edges[2], dims[2];
2139  start[0] = 0;
2140  start[1] = 0;
2141  edges[0] = 4*NLATS*10;
2142  edges[1] = NLONS*10;
2143  string sds_name = "Land_Vegetation_Type";
2144  sds_index = SDnametoindex(fileID, sds_name.c_str());
2145  if (sds_index < 0) {
2146  cerr << "DbLutNetcdf::read_landcover_file() " <<
2147  "SDnametoindex() failure for "<< sds_name << endl;
2148  SDend(fileID);
2149  return DTDB_FAIL;
2150  }
2151  sds_id = SDselect(fileID, sds_index);
2152  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2153  SDreaddata(sds_id, start, NULL, edges, &lc_lut->VEGETATION[0][0]);
2154 
2156  if(filepath.empty()) {
2157  cerr << "DbLutNetcdf::read_landcover_file() Invalid path." << endl;
2158  return DTDB_FAIL;
2159  }
2160  try {
2161  fileID = SDstart(filepath.c_str(), DFACC_READ );
2162  }
2163  catch( std::exception& e) {
2164  e.what();
2165  cerr << "DbLutNetcdf:: Failure opening global IGBP file: " + filepath << endl;
2166  return DTDB_FAIL;
2167  }
2168  start[0] = 0;
2169  start[1] = 0;
2170  edges[0] = NLATS*10;
2171  edges[1] = NLONS*10;
2172  sds_name = "IGBP_Land_Cover";
2173  sds_index = SDnametoindex(fileID, sds_name.c_str());
2174  if (sds_index < 0) {
2175  cerr << "DbLutNetcdf::read_landcover_file() " <<
2176  "SDnametoindex() failure for "<< sds_name << endl;
2177  SDend(fileID);
2178  return DTDB_FAIL;
2179  }
2180  sds_id = SDselect(fileID, sds_index);
2181  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2182  SDreaddata(sds_id, start, NULL, edges, &lc_lut->IGBP[0][0]);
2183 
2184  sds_name = "Region_Index";
2185  sds_index = SDnametoindex(fileID, sds_name.c_str());
2186  if (sds_index < 0) {
2187  cerr << "DbLutNetcdf::read_landcover_files() " <<
2188  "SDnametoindex() failure for "<< sds_name << endl;
2189  SDend(fileID);
2190  return DTDB_FAIL;
2191  }
2192  sds_id = SDselect(fileID, sds_index);
2193  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2194  SDreaddata(sds_id, start, NULL, edges, &lc_lut->REGION_INDEX[0][0]);
2195 
2197  if(filepath.empty()) {
2198  cerr << "DbLutNetcdf::read_landcover_files() Invalid path." << endl;
2199  return DTDB_FAIL;
2200  }
2201  try {
2202  fileID = SDstart(filepath.c_str(), DFACC_READ );
2203  }
2204  catch( std::exception& e) {
2205  e.what();
2206  cerr << "DbLutNetcdf:: Failure opening seasonal deserts file: " + filepath << endl;
2207  return DTDB_FAIL;
2208  }
2209  start[0] = 0;
2210  start[1] = 0;
2211  edges[0] = NLATS*10;
2212  edges[1] = NLONS*10;
2213  sds_name = "seasonal_desert_flag";
2214  sds_index = SDnametoindex(fileID, sds_name.c_str());
2215  if (sds_index < 0) {
2216  cerr << "DbLutNetcdf::read_deserts_file() " <<
2217  "SDnametoindex() failure for "<< sds_name << endl;
2218  SDend(fileID);
2219  return DTDB_FAIL;
2220  }
2221  sds_id = SDselect(fileID, sds_index);
2222  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2223  SDreaddata(sds_id, start, NULL, edges, &lc_lut->DESERTS_FLAG[0][0]);
2224 
2225  return status;
2226 }
2227 
2228 /**************************************************************************
2229  * NAME: write_landcover_lut()
2230  *
2231  * DESCRIPTION: Write landcover LUT to NetCDF4 file.
2232  *
2233  *************************************************************************/
2234 
2235 int DbLutNetcdf::write_landcover_lut( NcFile* nc_output,
2236  dbLandcoverLUT* lc_lut )
2237 {
2238  NcGroup lut_grp = nc_output->addGroup( LUT_LANDCOVER );
2239 
2240  dim_1800_ = lut_grp.addDim( "Dim_1800", NLATS*10 );
2241  dim_3600_ = lut_grp.addDim( "Dim_3600", NLONS*10 );
2242  dim_7200_ = lut_grp.addDim( "Dim_7200", 4*NLATS*10 );
2243 
2244  vector<NcDim> vegie_dims;
2245  vegie_dims.push_back(dim_7200_);
2246  vegie_dims.push_back(dim_3600_);
2247 
2248  vector<NcDim> latlon_dims;
2249  latlon_dims.push_back(dim_1800_);
2250  latlon_dims.push_back(dim_3600_);
2251 
2252  NcVar var = lut_grp.addVar( "VEGETATION", ncInt, vegie_dims );
2253  var.putVar( lc_lut->VEGETATION );
2254 
2255  var = lut_grp.addVar( "IGBP", ncShort, latlon_dims );
2256  var.putVar( lc_lut->IGBP );
2257 
2258  var = lut_grp.addVar( "REGION_INDEX", ncShort, latlon_dims );
2259  var.putVar( lc_lut->REGION_INDEX );
2260 
2261  var = lut_grp.addVar( "DESERTS_FLAG", ncFloat, latlon_dims );
2262  var.putVar( lc_lut->DESERTS_FLAG );
2263 
2264  return DTDB_SUCCESS;
2265 }
2266 
2267 /**************************************************************************
2268  * NAME: read_landcover_lut()
2269  *
2270  * DESCRIPTION: Read landcover NetCDF4 LUT.
2271  *
2272  *************************************************************************/
2273 
2275 {
2276  int status = DTDB_SUCCESS;
2277 
2279  if (filepath.empty()) {
2281  }
2282  NcFile* nc_input;
2283  try {
2284  nc_input = new NcFile(filepath, NcFile::read );
2285  }
2286  catch( NcException& e) {
2287  e.what();
2288  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
2289  return DTDB_FAIL;
2290  }
2291  NcGroup lut_grp = nc_input->getGroup( LUT_LANDCOVER );
2292 
2293  NcVar var = lut_grp.getVar( "VEGETATION" );
2294  var.getVar( lc_lut->VEGETATION );
2295 
2296  var = lut_grp.getVar( "IGBP" );
2297  var.getVar( lc_lut->IGBP );
2298 
2299  var = lut_grp.getVar( "REGION_INDEX" );
2300  var.getVar( lc_lut->REGION_INDEX );
2301 
2302  var = lut_grp.getVar( "DESERTS_FLAG" );
2303  var.getVar( lc_lut->DESERTS_FLAG );
2304 
2305  delete nc_input;
2306 
2307  return status;
2308 }
2309 
2310 /**************************************************************************
2311  * NAME: read_swir_file()
2312  *
2313  * DESCRIPTION: Read swir vs. vis hdf4 file.
2314  *
2315  *************************************************************************/
2316 
2318 {
2319  int status = DTDB_SUCCESS;
2320 
2321  string filepath = get_option(INPUT_SWIR);
2322  if(filepath.empty()) {
2323  cerr << "DbLutNetcdf::read_swir_file() Invalid path." << endl;
2324  return DTDB_FAIL;
2325  }
2326  SEASON iseason = SEASON::NEVER;
2327  size_t rpos = 0;
2328  for (int iS=0; iS<NUM_SEASONS; iS++) {
2329  size_t pos = filepath.find(str_season[iS]);
2330  if (pos != string::npos) {
2331  iseason = (SEASON) iS;
2332  rpos = pos;
2333  }
2334  }
2335  if (iseason == SEASON::NEVER) {
2336  cerr << "DbLutNetcdf:: Could not identify season in file name: " + filepath << endl;
2337  return DTDB_FAIL;
2338  }
2339  for (int iS=0; iS<NUM_SEASONS; iS++) {
2340  string rfilepath = filepath;
2341  rfilepath.replace(rpos, str_season[(int) iseason].size(), str_season[iS]);
2342  int fileID;
2343  try {
2344  fileID = SDstart(rfilepath.c_str(), DFACC_READ );
2345  }
2346  catch( std::exception& e) {
2347  e.what();
2348  cerr << "DbLutNetcdf:: Failure opening swir file: " + rfilepath << endl;
2349  return DTDB_FAIL;
2350  }
2351  int sds_index, sds_id, numtype, rank, nattrs;
2352  int start[3], edges[3], dims[3];
2353  start[0] = 0;
2354  start[1] = 0;
2355  start[2] = 0;
2356  edges[0] = NSLATS;
2357  edges[1] = NSLONS;
2358  string sds_name = "latitude";
2359  sds_index = SDnametoindex(fileID, sds_name.c_str());
2360  if (sds_index < 0) {
2361  cerr << "DbLutNetcdf::read_swir_file() " <<
2362  "SDnametoindex() failure for "<< sds_name << endl;
2363  SDend(fileID);
2364  return DTDB_FAIL;
2365  }
2366  sds_id = SDselect(fileID, sds_index);
2367  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2368  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->latitude[iS][0][0]);
2369  sds_name = "longitude";
2370  sds_index = SDnametoindex(fileID, sds_name.c_str());
2371  if (sds_index < 0) {
2372  cerr << "DbLutNetcdf::read_swir_file() " <<
2373  "SDnametoindex() failure for "<< sds_name << endl;
2374  SDend(fileID);
2375  return DTDB_FAIL;
2376  }
2377  sds_id = SDselect(fileID, sds_index);
2378  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2379  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->longitude[iS][0][0]);
2380  sds_name = "coeffs_2250_to_412";
2381  sds_index = SDnametoindex(fileID, sds_name.c_str());
2382  if (sds_index < 0) {
2383  cerr << "DbLutNetcdf::read_swir_file() " <<
2384  "SDnametoindex() failure for "<< sds_name << endl;
2385  SDend(fileID);
2386  return DTDB_FAIL;
2387  }
2388  edges[0] = NSCOEF;
2389  edges[1] = NSLATS;
2390  edges[2] = NSLONS;
2391  sds_id = SDselect(fileID, sds_index);
2392  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2393  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->coeffs_2250_to_412[iS][0][0][0]);
2394  sds_name = "coeffs_2250_to_488";
2395  sds_index = SDnametoindex(fileID, sds_name.c_str());
2396  if (sds_index < 0) {
2397  cerr << "DbLutNetcdf::read_swir_file() " <<
2398  "SDnametoindex() failure for "<< sds_name << endl;
2399  SDend(fileID);
2400  return DTDB_FAIL;
2401  }
2402  sds_id = SDselect(fileID, sds_index);
2403  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2404  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->coeffs_2250_to_488[iS][0][0][0]);
2405  sds_name = "coeffs_2250_to_670";
2406  sds_index = SDnametoindex(fileID, sds_name.c_str());
2407  if (sds_index < 0) {
2408  cerr << "DbLutNetcdf::read_swir_file() " <<
2409  "SDnametoindex() failure for "<< sds_name << endl;
2410  SDend(fileID);
2411  return DTDB_FAIL;
2412  }
2413  sds_id = SDselect(fileID, sds_index);
2414  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2415  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->coeffs_2250_to_670[iS][0][0][0]);
2416  sds_name = "min_2250_for_412";
2417  sds_index = SDnametoindex(fileID, sds_name.c_str());
2418  if (sds_index < 0) {
2419  cerr << "DbLutNetcdf::read_swir_file() " <<
2420  "SDnametoindex() failure for "<< sds_name << endl;
2421  SDend(fileID);
2422  return DTDB_FAIL;
2423  }
2424  edges[0] = NSLATS;
2425  edges[1] = NSLONS;
2426  sds_id = SDselect(fileID, sds_index);
2427  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2428  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->min_2250_for_412[iS][0][0]);
2429  sds_name = "max_2250_for_412";
2430  sds_index = SDnametoindex(fileID, sds_name.c_str());
2431  if (sds_index < 0) {
2432  cerr << "DbLutNetcdf::read_swir_file() " <<
2433  "SDnametoindex() failure for "<< sds_name << endl;
2434  SDend(fileID);
2435  return DTDB_FAIL;
2436  }
2437  sds_id = SDselect(fileID, sds_index);
2438  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2439  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->max_2250_for_412[iS][0][0]);
2440  sds_name = "min_2250_for_488";
2441  sds_index = SDnametoindex(fileID, sds_name.c_str());
2442  if (sds_index < 0) {
2443  cerr << "DbLutNetcdf::read_swir_file() " <<
2444  "SDnametoindex() failure for "<< sds_name << endl;
2445  SDend(fileID);
2446  return DTDB_FAIL;
2447  }
2448  sds_id = SDselect(fileID, sds_index);
2449  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2450  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->min_2250_for_488[iS][0][0]);
2451  sds_name = "max_2250_for_488";
2452  sds_index = SDnametoindex(fileID, sds_name.c_str());
2453  if (sds_index < 0) {
2454  cerr << "DbLutNetcdf::read_swir_file() " <<
2455  "SDnametoindex() failure for "<< sds_name << endl;
2456  SDend(fileID);
2457  return DTDB_FAIL;
2458  }
2459  sds_id = SDselect(fileID, sds_index);
2460  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2461  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->max_2250_for_488[iS][0][0]);
2462  sds_name = "min_2250_for_670";
2463  sds_index = SDnametoindex(fileID, sds_name.c_str());
2464  if (sds_index < 0) {
2465  cerr << "DbLutNetcdf::read_swir_file() " <<
2466  "SDnametoindex() failure for "<< sds_name << endl;
2467  SDend(fileID);
2468  return DTDB_FAIL;
2469  }
2470  sds_id = SDselect(fileID, sds_index);
2471  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2472  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->min_2250_for_670[iS][0][0]);
2473  sds_name = "max_2250_for_670";
2474  sds_index = SDnametoindex(fileID, sds_name.c_str());
2475  if (sds_index < 0) {
2476  cerr << "DbLutNetcdf::read_swir_file() " <<
2477  "SDnametoindex() failure for "<< sds_name << endl;
2478  SDend(fileID);
2479  return DTDB_FAIL;
2480  }
2481  sds_id = SDselect(fileID, sds_index);
2482  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2483  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->max_2250_for_670[iS][0][0]);
2484  sds_name = "data_num_total";
2485  sds_index = SDnametoindex(fileID, sds_name.c_str());
2486  if (sds_index < 0) {
2487  cerr << "DbLutNetcdf::read_swir_file() " <<
2488  "SDnametoindex() failure for "<< sds_name << endl;
2489  SDend(fileID);
2490  return DTDB_FAIL;
2491  }
2492  sds_id = SDselect(fileID, sds_index);
2493  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2494  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->data_num_total[iS][0][0]);
2495  sds_name = "data_num_fitting";
2496  sds_index = SDnametoindex(fileID, sds_name.c_str());
2497  if (sds_index < 0) {
2498  cerr << "DbLutNetcdf::read_swir_file() " <<
2499  "SDnametoindex() failure for "<< sds_name << endl;
2500  SDend(fileID);
2501  return DTDB_FAIL;
2502  }
2503  sds_id = SDselect(fileID, sds_index);
2504  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2505  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->data_num_fitting[iS][0][0]);
2506  sds_name = "stderr_412";
2507  sds_index = SDnametoindex(fileID, sds_name.c_str());
2508  if (sds_index < 0) {
2509  cerr << "DbLutNetcdf::read_swir_file() " <<
2510  "SDnametoindex() failure for "<< sds_name << endl;
2511  SDend(fileID);
2512  return DTDB_FAIL;
2513  }
2514  sds_id = SDselect(fileID, sds_index);
2515  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2516  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->stderr_412[iS][0][0]);
2517  sds_name = "stderr_488";
2518  sds_index = SDnametoindex(fileID, sds_name.c_str());
2519  if (sds_index < 0) {
2520  cerr << "DbLutNetcdf::read_swir_file() " <<
2521  "SDnametoindex() failure for "<< sds_name << endl;
2522  SDend(fileID);
2523  return DTDB_FAIL;
2524  }
2525  sds_id = SDselect(fileID, sds_index);
2526  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2527  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->stderr_488[iS][0][0]);
2528  sds_name = "stderr_670";
2529  sds_index = SDnametoindex(fileID, sds_name.c_str());
2530  if (sds_index < 0) {
2531  cerr << "DbLutNetcdf::read_swir_file() " <<
2532  "SDnametoindex() failure for "<< sds_name << endl;
2533  SDend(fileID);
2534  return DTDB_FAIL;
2535  }
2536  sds_id = SDselect(fileID, sds_index);
2537  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2538  SDreaddata(sds_id, start, NULL, edges, &vsw_lut->stderr_670[iS][0][0]);
2539  }
2540 
2541  return status;
2542 }
2543 
2544 /**************************************************************************
2545  * NAME: write_swir_lut()
2546  *
2547  * DESCRIPTION: Write swir LUT to NetCDF4 file.
2548  *
2549  *************************************************************************/
2550 
2551 int DbLutNetcdf::write_swir_lut( NcFile* nc_output,
2552  dbViirsSwirVsVisLUT* vsw_lut )
2553 {
2554  NcGroup lut_grp = nc_output->addGroup( LUT_SWIR );
2555 
2556  dim_seasons_ = lut_grp.addDim( "Dim_seasons", NUM_SEASONS );
2557  dim_3_ = lut_grp.addDim( "Dim_3", NSCOEF );
2558  dim_3000_ = lut_grp.addDim( "Dim_3000", NSLATS );
2559  dim_6000_ = lut_grp.addDim( "Dim_6000", NSLONS );
2560 
2561  vector<NcDim> coef_dims;
2562  coef_dims.push_back(dim_seasons_);
2563  coef_dims.push_back(dim_3_);
2564  coef_dims.push_back(dim_3000_);
2565  coef_dims.push_back(dim_6000_);
2566  vector<NcDim> latlon_dims;
2567  latlon_dims.push_back(dim_seasons_);
2568  latlon_dims.push_back(dim_3000_);
2569  latlon_dims.push_back(dim_6000_);
2570 
2571  NcVar var = lut_grp.addVar( "latitude", ncFloat, latlon_dims );
2572  var.putVar( vsw_lut->latitude );
2573 
2574  var = lut_grp.addVar( "longitude", ncFloat, latlon_dims );
2575  var.putVar( vsw_lut->longitude );
2576 
2577  var = lut_grp.addVar( "coeffs_2250_to_412", ncFloat, coef_dims );
2578  var.putVar( vsw_lut->coeffs_2250_to_412 );
2579 
2580  var = lut_grp.addVar( "coeffs_2250_to_488", ncFloat, coef_dims );
2581  var.putVar( vsw_lut->coeffs_2250_to_488 );
2582 
2583  var = lut_grp.addVar( "coeffs_2250_to_670", ncFloat, coef_dims );
2584  var.putVar( vsw_lut->coeffs_2250_to_670 );
2585 
2586  var = lut_grp.addVar( "min_2250_for_412", ncFloat, latlon_dims );
2587  var.putVar( vsw_lut->min_2250_for_412 );
2588 
2589  var = lut_grp.addVar( "max_2250_for_412", ncFloat, latlon_dims );
2590  var.putVar( vsw_lut->max_2250_for_412 );
2591 
2592  var = lut_grp.addVar( "min_2250_for_488", ncFloat, latlon_dims );
2593  var.putVar( vsw_lut->min_2250_for_488 );
2594 
2595  var = lut_grp.addVar( "max_2250_for_488", ncFloat, latlon_dims );
2596  var.putVar( vsw_lut->max_2250_for_488 );
2597 
2598  var = lut_grp.addVar( "min_2250_for_670", ncFloat, latlon_dims );
2599  var.putVar( vsw_lut->min_2250_for_670 );
2600 
2601  var = lut_grp.addVar( "max_2250_for_670", ncFloat, latlon_dims );
2602  var.putVar( vsw_lut->max_2250_for_670 );
2603 
2604  var = lut_grp.addVar( "data_num_total", ncFloat, latlon_dims );
2605  var.putVar( vsw_lut->data_num_total );
2606 
2607  var = lut_grp.addVar( "data_num_fitting", ncFloat, latlon_dims );
2608  var.putVar( vsw_lut->data_num_fitting );
2609 
2610  var = lut_grp.addVar( "stderr_412", ncFloat, latlon_dims );
2611  var.putVar( vsw_lut->stderr_412 );
2612 
2613  var = lut_grp.addVar( "stderr_488", ncFloat, latlon_dims );
2614  var.putVar( vsw_lut->stderr_488 );
2615 
2616  var = lut_grp.addVar( "stderr_670", ncFloat, latlon_dims );
2617  var.putVar( vsw_lut->stderr_670 );
2618 
2619  return DTDB_SUCCESS;
2620 }
2621 
2622 /**************************************************************************
2623  * NAME: read_swir_lut()
2624  *
2625  * DESCRIPTION: Read swir NetCDF4 LUT.
2626  *
2627  *************************************************************************/
2628 
2630 {
2631  int status = DTDB_SUCCESS;
2632 
2634  if (filepath.empty()) {
2636  }
2637  NcFile* nc_input;
2638  try {
2639  nc_input = new NcFile(filepath, NcFile::read );
2640  }
2641  catch( NcException& e) {
2642  e.what();
2643  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
2644  return DTDB_FAIL;
2645  }
2646  NcGroup lut_grp = nc_input->getGroup( LUT_SWIR );
2647  NcVar var = lut_grp.getVar( "latitude" );
2648  var.getVar( vsw_lut->latitude );
2649  var = lut_grp.getVar( "longitude" );
2650  var.getVar( vsw_lut->longitude );
2651  var = lut_grp.getVar( "coeffs_2250_to_412" );
2652  var.getVar( vsw_lut->coeffs_2250_to_412 );
2653  var = lut_grp.getVar( "coeffs_2250_to_488" );
2654  var.getVar( vsw_lut->coeffs_2250_to_488 );
2655  var = lut_grp.getVar( "coeffs_2250_to_670" );
2656  var.getVar( vsw_lut->coeffs_2250_to_670 );
2657  var = lut_grp.getVar( "min_2250_for_412" );
2658  var.getVar( vsw_lut->min_2250_for_412 );
2659  var = lut_grp.getVar( "max_2250_for_412" );
2660  var.getVar( vsw_lut->max_2250_for_412 );
2661  var = lut_grp.getVar( "min_2250_for_488" );
2662  var.getVar( vsw_lut->min_2250_for_488 );
2663  var = lut_grp.getVar( "max_2250_for_488" );
2664  var.getVar( vsw_lut->max_2250_for_488 );
2665  var = lut_grp.getVar( "min_2250_for_670" );
2666  var.getVar( vsw_lut->min_2250_for_670 );
2667  var = lut_grp.getVar( "max_2250_for_670" );
2668  var.getVar( vsw_lut->max_2250_for_670 );
2669  var = lut_grp.getVar( "data_num_total" );
2670  var.getVar( vsw_lut->data_num_total );
2671  var = lut_grp.getVar( "data_num_fitting" );
2672  var.getVar( vsw_lut->data_num_fitting );
2673  var = lut_grp.getVar( "stderr_412" );
2674  var.getVar( vsw_lut->stderr_412 );
2675  var = lut_grp.getVar( "stderr_488" );
2676  var.getVar( vsw_lut->stderr_488 );
2677  var = lut_grp.getVar( "stderr_670" );
2678  var.getVar( vsw_lut->stderr_670 );
2679 
2680  delete nc_input;
2681 
2682  return status;
2683 }
2684 
2685 /**************************************************************************
2686  * NAME: read_ocean_aero_file()
2687  *
2688  * DESCRIPTION: Read all viirs fine mode aerosol files.
2689  *
2690  *************************************************************************/
2691 
2693  const string sType )
2694 {
2695  int status = DTDB_SUCCESS;
2696 
2697  string filepath = get_option(sType);
2698  if(filepath.empty()) {
2699  cerr << "DbLutNetcdf::read_ocean_aero_file() Invalid path." << endl;
2700  return DTDB_FAIL;
2701  }
2702  int fileID;
2703  try {
2704  fileID = SDstart(filepath.c_str(), DFACC_READ );
2705  }
2706  catch( std::exception& e) {
2707  e.what();
2708  cerr << "DbLutNetcdf:: Failure opening ocean aerosol file: " + filepath << endl;
2709  return DTDB_FAIL;
2710  }
2711 
2712  if (sType == INPUT_AERO_OCEAN_FINE) {
2713  lut->nfmf = NFMF1;
2714  lut->naot = NAOT1;
2715  } else if (sType == INPUT_AERO_OCEAN_DUST) {
2716  lut->nfmf = NFMF2;
2717  lut->naot = NAOT1;
2718  } else if (sType == INPUT_AERO_OCEAN_MARI) {
2719  lut->nfmf = NFMF3;
2720  lut->naot = NAOT2;
2721  }else if (sType == INPUT_AERO_OCEAN_MIX) {
2722  lut->nfmf = NFMF4;
2723  lut->naot = NAOT1;
2724  } else {
2725  return DTDB_FAIL;
2726  };
2727  int sds_index, sds_id, numtype, rank, nattrs;
2728  int dims[7];
2729  int start[7] = {0,0,0,0,0,0,0};
2730  int edges[7] = {(int)NCHL,(int)NWS,(int)lut->nfmf,(int)lut->naot,(int)NVRAA,(int)NVVZA,(int)NVSZA};
2731 
2732  string sds_name = "IoverF_m03";
2733  sds_index = SDnametoindex(fileID, sds_name.c_str());
2734  if (sds_index < 0) {
2735  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2736  "SDnametoindex() failure for "<< sds_name << endl;
2737  SDend(fileID);
2738  return DTDB_FAIL;
2739  }
2740  sds_id = SDselect(fileID, sds_index);
2741  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2742  SDreaddata(sds_id, start, NULL, edges, &lut->m03[0][0][0][0][0][0][0]);
2743  sds_name = "IoverF_m04";
2744  sds_index = SDnametoindex(fileID, sds_name.c_str());
2745  if (sds_index < 0) {
2746  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2747  "SDnametoindex() failure for "<< sds_name << endl;
2748  SDend(fileID);
2749  return DTDB_FAIL;
2750  }
2751  sds_id = SDselect(fileID, sds_index);
2752  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2753  SDreaddata(sds_id, start, NULL, edges, &lut->m04[0][0][0][0][0][0][0]);
2754  sds_name = "IoverF_m05";
2755  sds_index = SDnametoindex(fileID, sds_name.c_str());
2756  if (sds_index < 0) {
2757  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2758  "SDnametoindex() failure for "<< sds_name << endl;
2759  SDend(fileID);
2760  return DTDB_FAIL;
2761  }
2762  sds_id = SDselect(fileID, sds_index);
2763  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2764  SDreaddata(sds_id, start, NULL, edges, &lut->m05[0][0][0][0][0][0][0]);
2765  sds_name = "IoverF_m07";
2766  sds_index = SDnametoindex(fileID, sds_name.c_str());
2767  if (sds_index < 0) {
2768  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2769  "SDnametoindex() failure for "<< sds_name << endl;
2770  SDend(fileID);
2771  return DTDB_FAIL;
2772  }
2773  sds_id = SDselect(fileID, sds_index);
2774  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2775  SDreaddata(sds_id, start, NULL, edges, &lut->m07[0][0][0][0][0][0][0]);
2776  sds_name = "IoverF_m08";
2777  sds_index = SDnametoindex(fileID, sds_name.c_str());
2778  if (sds_index < 0) {
2779  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2780  "SDnametoindex() failure for "<< sds_name << endl;
2781  SDend(fileID);
2782  return DTDB_FAIL;
2783  }
2784  edges[0] = NWS;
2785  edges[1] = lut->nfmf;
2786  edges[2] = lut->naot;
2787  edges[3] = NVRAA;
2788  edges[4] = NVVZA;
2789  edges[5] = NVSZA;
2790  sds_id = SDselect(fileID, sds_index);
2791  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2792  SDreaddata(sds_id, start, NULL, edges, &lut->m08[0][0][0][0][0][0]);
2793  sds_name = "IoverF_m10";
2794  sds_index = SDnametoindex(fileID, sds_name.c_str());
2795  if (sds_index < 0) {
2796  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2797  "SDnametoindex() failure for "<< sds_name << endl;
2798  SDend(fileID);
2799  return DTDB_FAIL;
2800  }
2801  sds_id = SDselect(fileID, sds_index);
2802  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2803  SDreaddata(sds_id, start, NULL, edges, &lut->m10[0][0][0][0][0][0]);
2804  sds_name = "IoverF_m11";
2805  sds_index = SDnametoindex(fileID, sds_name.c_str());
2806  if (sds_index < 0) {
2807  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2808  "SDnametoindex() failure for "<< sds_name << endl;
2809  SDend(fileID);
2810  return DTDB_FAIL;
2811  }
2812  sds_id = SDselect(fileID, sds_index);
2813  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2814  SDreaddata(sds_id, start, NULL, edges, &lut->m11[0][0][0][0][0][0]);
2815  edges[0] = NVSZA;
2816  sds_name = "Solar_Zenith_Angle";
2817  sds_index = SDnametoindex(fileID, sds_name.c_str());
2818  if (sds_index < 0) {
2819  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2820  "SDnametoindex() failure for "<< sds_name << endl;
2821  SDend(fileID);
2822  return DTDB_FAIL;
2823  }
2824  sds_id = SDselect(fileID, sds_index);
2825  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2826  SDreaddata(sds_id, start, NULL, edges, &lut->sza[0]);
2827  edges[0] = NVVZA;
2828  sds_name = "View_Zenith_Angle";
2829  sds_index = SDnametoindex(fileID, sds_name.c_str());
2830  if (sds_index < 0) {
2831  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2832  "SDnametoindex() failure for "<< sds_name << endl;
2833  SDend(fileID);
2834  return DTDB_FAIL;
2835  }
2836  sds_id = SDselect(fileID, sds_index);
2837  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2838  SDreaddata(sds_id, start, NULL, edges, &lut->vza[0]);
2839  edges[0] = NVRAA;
2840  sds_name = "Relative_Azimuth_Angle";
2841  sds_index = SDnametoindex(fileID, sds_name.c_str());
2842  if (sds_index < 0) {
2843  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2844  "SDnametoindex() failure for "<< sds_name << endl;
2845  SDend(fileID);
2846  return DTDB_FAIL;
2847  }
2848  sds_id = SDselect(fileID, sds_index);
2849  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2850  SDreaddata(sds_id, start, NULL, edges, &lut->raa[0]);
2851  edges[0] = lut->naot;
2852  sds_name = "Aerosol_Optical_Depth_550";
2853  sds_index = SDnametoindex(fileID, sds_name.c_str());
2854  if (sds_index < 0) {
2855  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2856  "SDnametoindex() failure for "<< sds_name << endl;
2857  SDend(fileID);
2858  return DTDB_FAIL;
2859  }
2860  sds_id = SDselect(fileID, sds_index);
2861  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2862  SDreaddata(sds_id, start, NULL, edges, &lut->aot550[0]);
2863  edges[0] = lut->nfmf;
2864  sds_name = "Fine_Mode_Fraction_550";
2865  sds_index = SDnametoindex(fileID, sds_name.c_str());
2866  if (sds_index < 0) {
2867  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2868  "SDnametoindex() failure for "<< sds_name << endl;
2869  SDend(fileID);
2870  return DTDB_FAIL;
2871  }
2872  sds_id = SDselect(fileID, sds_index);
2873  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2874  SDreaddata(sds_id, start, NULL, edges, &lut->fmf[0]);
2875  edges[0] = NWS;
2876  sds_name = "Wind_Speed";
2877  sds_index = SDnametoindex(fileID, sds_name.c_str());
2878  if (sds_index < 0) {
2879  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2880  "SDnametoindex() failure for "<< sds_name << endl;
2881  SDend(fileID);
2882  return DTDB_FAIL;
2883  }
2884  sds_id = SDselect(fileID, sds_index);
2885  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2886  SDreaddata(sds_id, start, NULL, edges, &lut->wspd[0]);
2887  edges[0] = NCHL;
2888  sds_name = "Chl_Conc";
2889  sds_index = SDnametoindex(fileID, sds_name.c_str());
2890  if (sds_index < 0) {
2891  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2892  "SDnametoindex() failure for "<< sds_name << endl;
2893  SDend(fileID);
2894  return DTDB_FAIL;
2895  }
2896  sds_id = SDselect(fileID, sds_index);
2897  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2898  SDreaddata(sds_id, start, NULL, edges, &lut->chl[0]);
2899  edges[0] = NDBOWL;
2900  sds_name = "Band_Central_Wavelength";
2901  sds_index = SDnametoindex(fileID, sds_name.c_str());
2902  if (sds_index < 0) {
2903  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2904  "SDnametoindex() failure for "<< sds_name << endl;
2905  SDend(fileID);
2906  return DTDB_FAIL;
2907  }
2908  sds_id = SDselect(fileID, sds_index);
2909  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2910  SDreaddata(sds_id, start, NULL, edges, &lut->wave[0]);
2911 
2912  edges[0] = lut->nfmf;
2913  edges[1] = lut->naot;
2914  sds_name = "Angstrom_Exponent";
2915  sds_index = SDnametoindex(fileID, sds_name.c_str());
2916  if (sds_index < 0) {
2917  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2918  "SDnametoindex() failure for "<< sds_name << endl;
2919  SDend(fileID);
2920  return DTDB_FAIL;
2921  }
2922  sds_id = SDselect(fileID, sds_index);
2923  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2924  SDreaddata(sds_id, start, NULL, edges, &lut->ae[0][0]);
2925  edges[0] = NDBOWL;
2926  edges[1] = lut->nfmf;
2927  edges[2] = lut->naot;
2928  sds_name = "Spectral_Total_AOD";
2929  sds_index = SDnametoindex(fileID, sds_name.c_str());
2930  if (sds_index < 0) {
2931  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2932  "SDnametoindex() failure for "<< sds_name << endl;
2933  SDend(fileID);
2934  return DTDB_FAIL;
2935  }
2936  sds_id = SDselect(fileID, sds_index);
2937  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2938  SDreaddata(sds_id, start, NULL, edges, &lut->aot[0][0][0]);
2939  sds_name = "Spectral_Fine_AOD";
2940  sds_index = SDnametoindex(fileID, sds_name.c_str());
2941  if (sds_index < 0) {
2942  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2943  "SDnametoindex() failure for "<< sds_name << endl;
2944  SDend(fileID);
2945  return DTDB_FAIL;
2946  }
2947  sds_id = SDselect(fileID, sds_index);
2948  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2949  SDreaddata(sds_id, start, NULL, edges, &lut->fine_aot[0][0][0]);
2950  sds_name = "Spectral_Coarse_AOD";
2951  sds_index = SDnametoindex(fileID, sds_name.c_str());
2952  if (sds_index < 0) {
2953  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2954  "SDnametoindex() failure for "<< sds_name << endl;
2955  SDend(fileID);
2956  return DTDB_FAIL;
2957  }
2958  sds_id = SDselect(fileID, sds_index);
2959  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2960  SDreaddata(sds_id, start, NULL, edges, &lut->coarse_aot[0][0][0]);
2961  sds_name = "Spectral_Total_SSA";
2962  sds_index = SDnametoindex(fileID, sds_name.c_str());
2963  if (sds_index < 0) {
2964  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2965  "SDnametoindex() failure for "<< sds_name << endl;
2966  SDend(fileID);
2967  return DTDB_FAIL;
2968  }
2969  sds_id = SDselect(fileID, sds_index);
2970  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2971  SDreaddata(sds_id, start, NULL, edges, &lut->ssa[0][0][0]);
2972  sds_name = "Spectral_Fine_SSA";
2973  sds_index = SDnametoindex(fileID, sds_name.c_str());
2974  if (sds_index < 0) {
2975  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2976  "SDnametoindex() failure for "<< sds_name << endl;
2977  SDend(fileID);
2978  return DTDB_FAIL;
2979  }
2980  sds_id = SDselect(fileID, sds_index);
2981  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2982  SDreaddata(sds_id, start, NULL, edges, &lut->fine_ssa[0][0][0]);
2983  sds_name = "Spectral_Coarse_SSA";
2984  sds_index = SDnametoindex(fileID, sds_name.c_str());
2985  if (sds_index < 0) {
2986  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2987  "SDnametoindex() failure for "<< sds_name << endl;
2988  SDend(fileID);
2989  return DTDB_FAIL;
2990  }
2991  sds_id = SDselect(fileID, sds_index);
2992  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
2993  SDreaddata(sds_id, start, NULL, edges, &lut->coarse_ssa[0][0][0]);
2994  sds_name = "Spectral_Total_ASY";
2995  sds_index = SDnametoindex(fileID, sds_name.c_str());
2996  if (sds_index < 0) {
2997  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
2998  "SDnametoindex() failure for "<< sds_name << endl;
2999  SDend(fileID);
3000  return DTDB_FAIL;
3001  }
3002  sds_id = SDselect(fileID, sds_index);
3003  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3004  SDreaddata(sds_id, start, NULL, edges, &lut->asy[0][0][0]);
3005  sds_name = "Spectral_Fine_ASY";
3006  sds_index = SDnametoindex(fileID, sds_name.c_str());
3007  if (sds_index < 0) {
3008  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
3009  "SDnametoindex() failure for "<< sds_name << endl;
3010  SDend(fileID);
3011  return DTDB_FAIL;
3012  }
3013  sds_id = SDselect(fileID, sds_index);
3014  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3015  SDreaddata(sds_id, start, NULL, edges, &lut->fine_asy[0][0][0]);
3016  sds_name = "Spectral_Coarse_ASY";
3017  sds_index = SDnametoindex(fileID, sds_name.c_str());
3018  if (sds_index < 0) {
3019  cerr << "DbLutNetcdf::read_ocean_aero_fine_file() " <<
3020  "SDnametoindex() failure for "<< sds_name << endl;
3021  SDend(fileID);
3022  return DTDB_FAIL;
3023  }
3024  sds_id = SDselect(fileID, sds_index);
3025  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3026  SDreaddata(sds_id, start, NULL, edges, &lut->coarse_asy[0][0][0]);
3027 
3028  return status;
3029 }
3030 
3031 /**************************************************************************
3032  * NAME: write_ocean_aero_lut()
3033  *
3034  * DESCRIPTION: Write VIIRS Aerosol LUT to NetCDF4 file.
3035  *
3036  *************************************************************************/
3037 
3038 int DbLutNetcdf::write_ocean_aero_lut( NcFile* nc_output,
3039  dbOceanAerosolLUT* lut, const string sType )
3040 {
3041 
3042  NcGroup lut_grp = nc_output->addGroup( sType );
3043  dim_nsza_ = lut_grp.addDim( "Dim_Solar_Zenith_Angle", NVSZA );
3044  dim_nvza_ = lut_grp.addDim( "Dim_View_Zenith_Angle", NVVZA );
3045  dim_nraa_ = lut_grp.addDim( "Dim_Relative_Azimuth_Angle", NVRAA );
3046  dim_ntau_ = lut_grp.addDim( "Dim_Aerosol_Optical_Depth_550", lut->naot );
3047  dim_nfmf_ = lut_grp.addDim( "Dim_Fine_Mode_Fraction_550", lut->nfmf );
3048  dim_nws_ = lut_grp.addDim( "Dim_Wind_Speed", NWS );
3049  dim_nchl_ = lut_grp.addDim( "Dim_Chl_Conc", NCHL );
3050  dim_nwl_ = lut_grp.addDim( "Dim_Band_Central_Wavelength", NDBOWL );
3051  vector<NcDim> ioverf_dims;
3053  vector<size_t> start, edges;
3054  start = {0,0,0,0,0,0,0};
3055  edges = {NCHL,NWS,lut->nfmf,lut->naot,NVRAA,NVVZA,NVSZA};
3056  NcVar var = lut_grp.addVar( "IoverF_m03", ncFloat, ioverf_dims );
3057  var.putVar( start, edges, &lut->m03[0][0][0][0][0][0][0] );
3058  var = lut_grp.addVar( "IoverF_m04", ncFloat, ioverf_dims );
3059  var.putVar( start, edges, &lut->m04[0][0][0][0][0][0][0] );
3060  var = lut_grp.addVar( "IoverF_m05", ncFloat, ioverf_dims );
3061  var.putVar( start, edges, &lut->m05[0][0][0][0][0][0][0] );
3062  var = lut_grp.addVar( "IoverF_m07", ncFloat, ioverf_dims );
3063  var.putVar( start, edges, &lut->m07[0][0][0][0][0][0][0] );
3065  edges = {NWS,lut->nfmf,lut->naot,NVRAA,NVVZA,NVSZA};
3066  var = lut_grp.addVar( "IoverF_m08", ncFloat, ioverf_dims );
3067  var.putVar( start, edges, &lut->m08[0][0][0][0][0][0] );
3068  var = lut_grp.addVar( "IoverF_m10", ncFloat, ioverf_dims );
3069  var.putVar( start, edges, &lut->m10[0][0][0][0][0][0] );
3070  var = lut_grp.addVar( "IoverF_m11", ncFloat, ioverf_dims );
3071  var.putVar( start, edges, &lut->m11[0][0][0][0][0][0] );
3072  var = lut_grp.addVar( "Solar_Zenith_Angle", ncFloat, dim_nsza_ );
3073  var.putVar( &lut->sza[0] );
3074  var = lut_grp.addVar( "View_Zenith_Angle", ncFloat, dim_nvza_ );
3075  var.putVar( &lut->vza[0] );
3076  var = lut_grp.addVar( "Relative_Azimuth_Angle", ncFloat, dim_nraa_ );
3077  var.putVar( &lut->raa[0] );
3078  var = lut_grp.addVar( "Aerosol_Optical_Depth_550", ncFloat, dim_ntau_ );
3079  edges = {lut->naot};
3080  var.putVar( start, edges, &lut->aot550[0] );
3081  var = lut_grp.addVar( "Fine_Mode_Fraction_550", ncFloat, dim_nfmf_ );
3082  edges = {lut->nfmf};
3083  var.putVar( start, edges, &lut->fmf[0] );
3084  var = lut_grp.addVar( "Wind_Speed", ncFloat, dim_nws_ );
3085  var.putVar( &lut->wspd[0] );
3086  var = lut_grp.addVar( "Chl_Conc", ncFloat, dim_nchl_ );
3087  var.putVar( &lut->chl[0] );
3088  var = lut_grp.addVar( "Band_Central_Wavelength", ncFloat, dim_nwl_ );
3089  var.putVar( &lut->wave[0] );
3090  vector<NcDim> ae_dims;
3091  ae_dims = {dim_nfmf_,dim_ntau_};
3092  edges = {lut->nfmf,lut->naot};
3093  var = lut_grp.addVar( "Angstrom_Exponent", ncFloat, ae_dims );
3094  var.putVar( start, edges, &lut->ae[0][0] );
3095  vector<NcDim> spectral_dims;
3096  spectral_dims = {dim_nwl_,dim_nfmf_,dim_ntau_};
3097  edges = {lut->nwave,lut->nfmf,lut->naot};
3098  var = lut_grp.addVar( "Spectral_Total_AOD", ncFloat, spectral_dims );
3099  var.putVar( start, edges, &lut->aot[0][0][0] );
3100  var = lut_grp.addVar( "Spectral_Fine_AOD", ncFloat, spectral_dims );
3101  var.putVar( start, edges, &lut->fine_aot[0][0][0] );
3102  var = lut_grp.addVar( "Spectral_Coarse_AOD", ncFloat, spectral_dims );
3103  var.putVar( start, edges, &lut->coarse_aot[0][0][0] );
3104  var = lut_grp.addVar( "Spectral_Total_SSA", ncFloat, spectral_dims );
3105  var.putVar( start, edges, &lut->ssa[0][0][0] );
3106  var = lut_grp.addVar( "Spectral_Fine_SSA", ncFloat, spectral_dims );
3107  var.putVar( start, edges, &lut->fine_ssa[0][0][0] );
3108  var = lut_grp.addVar( "Spectral_Coarse_SSA", ncFloat, spectral_dims );
3109  var.putVar( start, edges, &lut->coarse_ssa[0][0][0] );
3110  var = lut_grp.addVar( "Spectral_Total_ASY", ncFloat, spectral_dims );
3111  var.putVar( start, edges, &lut->asy[0][0][0] );
3112  var = lut_grp.addVar( "Spectral_Fine_ASY", ncFloat, spectral_dims );
3113  var.putVar( start, edges, &lut->fine_asy[0][0][0] );
3114  var = lut_grp.addVar( "Spectral_Coarse_ASY", ncFloat, spectral_dims );
3115  var.putVar( start, edges, &lut->coarse_asy[0][0][0] );
3116 
3117  return DTDB_SUCCESS;
3118 }
3119 
3120 /**************************************************************************
3121  * NAME: read_ocean_aero_lut()
3122  *
3123  * DESCRIPTION: Read VIIRS aerosol NetCDF4 LUT.
3124  *
3125  *************************************************************************/
3126 
3128  const string sType )
3129 {
3130  int status = DTDB_SUCCESS;
3131 
3133  if (filepath.empty()) {
3135  }
3136  NcFile* nc_input;
3137  try {
3138  nc_input = new NcFile(filepath, NcFile::read );
3139  }
3140  catch( NcException& e) {
3141  e.what();
3142  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
3143  return DTDB_FAIL;
3144  }
3145  if (sType == LUT_OCEAN_AEROSOL_FINE) {
3146  lut->nfmf = NFMF1;
3147  lut->naot = NAOT1;
3148  } else if (sType == LUT_OCEAN_AEROSOL_DUST) {
3149  lut->nfmf = NFMF2;
3150  lut->naot = NAOT1;
3151  } else if (sType == LUT_OCEAN_AEROSOL_MARI) {
3152  lut->nfmf = NFMF3;
3153  lut->naot = NAOT2;
3154  }else if (sType == LUT_OCEAN_AEROSOL_MIX) {
3155  lut->nfmf = NFMF4;
3156  lut->naot = NAOT1;
3157  } else {
3158  return DTDB_FAIL;
3159  };
3160 
3161  vector<size_t> start = {0,0,0,0,0,0,0};
3162  vector<size_t> edges = {NCHL,NWS,lut->nfmf,lut->naot,NVRAA,NVVZA,NVSZA};
3163  NcGroup lut_grp = nc_input->getGroup( sType );
3164  lut->m03.resize(boost::extents[NCHL][NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3165  NcVar var = lut_grp.getVar( "IoverF_m03" );
3166  var.getVar( start, edges, &lut->m03[0][0][0][0][0][0][0] );
3167  lut->m04.resize(boost::extents[NCHL][NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3168  var = lut_grp.getVar( "IoverF_m04" );
3169  var.getVar( start, edges, &lut->m04[0][0][0][0][0][0][0] );
3170  lut->m05.resize(boost::extents[NCHL][NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3171  var = lut_grp.getVar( "IoverF_m05" );
3172  var.getVar( start, edges, &lut->m05[0][0][0][0][0][0][0] );
3173  lut->m07.resize(boost::extents[NCHL][NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3174  var = lut_grp.getVar( "IoverF_m07" );
3175  var.getVar( start, edges, &lut->m07[0][0][0][0][0][0][0] );
3176 
3177  start = {0,0,0,0,0,0,0};
3178  edges = {NWS,lut->nfmf,lut->naot,NVRAA,NVVZA,NVSZA};
3179  lut->m08.resize(boost::extents[NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3180  var = lut_grp.getVar( "IoverF_m08" );
3181  var.getVar( start, edges, &lut->m08[0][0][0][0][0][0] );
3182  lut->m10.resize(boost::extents[NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3183  var = lut_grp.getVar( "IoverF_m10" );
3184  var.getVar( start, edges, &lut->m10[0][0][0][0][0][0] );
3185  lut->m11.resize(boost::extents[NWS][lut->nfmf][lut->naot][NVRAA][NVVZA][NVSZA]);
3186  var = lut_grp.getVar( "IoverF_m11" );
3187  var.getVar( start, edges, &lut->m11[0][0][0][0][0][0] );
3188 
3189  lut->sza.resize(boost::extents[NVSZA]);
3190  var = lut_grp.getVar( "Solar_Zenith_Angle" );
3191  var.getVar( &lut->sza[0] );
3192  lut->vza.resize(boost::extents[NVVZA]);
3193  var = lut_grp.getVar( "View_Zenith_Angle" );
3194  var.getVar( &lut->vza[0] );
3195  lut->raa.resize(boost::extents[NVRAA]);
3196  var = lut_grp.getVar( "Relative_Azimuth_Angle" );
3197  var.getVar( &lut->raa[0] );
3198  lut->aot550.resize(boost::extents[lut->naot]);
3199  var = lut_grp.getVar( "Aerosol_Optical_Depth_550" );
3200  var.getVar( &lut->aot550[0] );
3201  lut->fmf.resize(boost::extents[lut->nfmf]);
3202  var = lut_grp.getVar( "Fine_Mode_Fraction_550" );
3203  var.getVar( &lut->fmf[0] );
3204  lut->wspd.resize(boost::extents[NWS]);
3205  var = lut_grp.getVar( "Wind_Speed" );
3206  var.getVar( &lut->wspd[0] );
3207  lut->chl.resize(boost::extents[NCHL]);
3208  var = lut_grp.getVar( "Chl_Conc" );
3209  var.getVar( &lut->chl[0] );
3210  lut->wave.resize(boost::extents[NDBOWL]);
3211  var = lut_grp.getVar( "Band_Central_Wavelength" );
3212  var.getVar( &lut->wave[0] );
3213 
3214  start = {0,0};
3215  edges = {lut->nfmf,lut->naot};
3216  lut->ae.resize(boost::extents[lut->nfmf][lut->naot]);
3217  var = lut_grp.getVar( "Angstrom_Exponent" );
3218  var.getVar( start, edges, &lut->ae[0][0] );
3219  start = {0,0,0};
3220  edges = {lut->nwave,lut->nfmf,lut->naot};
3221  lut->aot.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3222  var = lut_grp.getVar( "Spectral_Total_AOD" );
3223  var.getVar( start, edges, &lut->aot[0][0][0] );
3224  lut->fine_aot.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3225  var = lut_grp.getVar( "Spectral_Fine_AOD" );
3226  var.getVar( start, edges, &lut->fine_aot[0][0][0] );
3227  lut->coarse_aot.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3228  var = lut_grp.getVar( "Spectral_Coarse_AOD" );
3229  var.getVar( start, edges, &lut->coarse_aot[0][0][0] );
3230  lut->ssa.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3231  var = lut_grp.getVar( "Spectral_Total_SSA" );
3232  var.getVar( start, edges, &lut->ssa[0][0][0] );
3233  lut->fine_ssa.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3234  var = lut_grp.getVar( "Spectral_Fine_SSA" );
3235  var.getVar( start, edges, &lut->fine_ssa[0][0][0] );
3236  lut->coarse_ssa.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3237  var = lut_grp.getVar( "Spectral_Coarse_SSA" );
3238  var.getVar( start, edges, &lut->coarse_ssa[0][0][0] );
3239  lut->asy.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3240  var = lut_grp.getVar( "Spectral_Total_ASY" );
3241  var.getVar( start, edges, &lut->asy[0][0][0] );
3242  lut->fine_asy.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3243  var = lut_grp.getVar( "Spectral_Fine_ASY" );
3244  var.getVar( start, edges, &lut->fine_asy[0][0][0] );
3245  lut->coarse_asy.resize(boost::extents[lut->nwave][lut->nfmf][lut->naot]);
3246  var = lut_grp.getVar( "Spectral_Coarse_ASY" );
3247  var.getVar( start, edges, &lut->coarse_asy[0][0][0] );
3248 
3249  delete nc_input;
3250 
3251  return status;
3252 }
3253 
3254 
3255 /**************************************************************************
3256  * NAME: read_land_aero_file()
3257  *
3258  * DESCRIPTION: Read all land aerosol files.
3259  *
3260  *************************************************************************/
3261 
3263  const string aero_input)
3264 {
3265  int status = DTDB_SUCCESS;
3266 
3267  string filepath = get_option(aero_input);
3268  if(filepath.empty()) {
3269  cerr << "DbLutNetcdf::read_aero_land_files() Invalid path." << endl;
3270  return DTDB_FAIL;
3271  }
3272  int fileID;
3273  try {
3274  fileID = SDstart(filepath.c_str(), DFACC_READ );
3275  }
3276  catch( std::exception& e) {
3277  e.what();
3278  cerr << "DbLutNetcdf:: Failure opening land aerosol file: " + filepath << endl;
3279  return DTDB_FAIL;
3280  }
3281  int sds_index, sds_id, numtype, rank, nattrs;
3282  int start[6], edges[6], dims[6];
3283  start[0] = 0;
3284  start[1] = 0;
3285  start[2] = 0;
3286  start[3] = 0;
3287  start[4] = 0;
3288  start[5] = 0;
3289  edges[0] = NSZA;
3290  string sds_name = "SZA412_Nodes";
3291  sds_index = SDnametoindex(fileID, sds_name.c_str());
3292  sds_id = SDselect(fileID, sds_index);
3293  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3294  SDreaddata(sds_id, start, NULL, edges, &va_lut->SZA412_Nodes[0]);
3295  edges[0] = NVZA;
3296  sds_name = "VZA412_Nodes";
3297  sds_index = SDnametoindex(fileID, sds_name.c_str());
3298  sds_id = SDselect(fileID, sds_index);
3299  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3300  SDreaddata(sds_id, start, NULL, edges, &va_lut->VZA412_Nodes[0]);
3301  edges[0] = NTAU;
3302  sds_name = "AOT412_Nodes";
3303  sds_index = SDnametoindex(fileID, sds_name.c_str());
3304  sds_id = SDselect(fileID, sds_index);
3305  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3306  SDreaddata(sds_id, start, NULL, edges, &va_lut->AOT412_Nodes[0]);
3307  edges[0] = NRAA;
3308  sds_name = "RAA412_Nodes";
3309  sds_index = SDnametoindex(fileID, sds_name.c_str());
3310  sds_id = SDselect(fileID, sds_index);
3311  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3312  SDreaddata(sds_id, start, NULL, edges, &va_lut->RAA412_Nodes[0]);
3313  edges[0] = SSA412;
3314  sds_name = "SSA412_Nodes";
3315  sds_index = SDnametoindex(fileID, sds_name.c_str());
3316  sds_id = SDselect(fileID, sds_index);
3317  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3318  SDreaddata(sds_id, start, NULL, edges, &va_lut->SSA412_Nodes[0]);
3319  edges[0] = SR412;
3320  sds_name = "SR412_Nodes";
3321  sds_index = SDnametoindex(fileID, sds_name.c_str());
3322  sds_id = SDselect(fileID, sds_index);
3323  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3324  SDreaddata(sds_id, start, NULL, edges, &va_lut->SR412_Nodes[0]);
3325  edges[0] = SR412;
3326  edges[1] = SSA412;
3327  edges[2] = NTAU;
3328  edges[3] = NRAA;
3329  edges[4] = NVZA;
3330  edges[5] = NSZA;
3331  sds_name = "nvalx412";
3332  sds_index = SDnametoindex(fileID, sds_name.c_str());
3333  if (sds_index < 0) {
3334  cerr << "DbLutNetcdf::read_land_aero_files() " <<
3335  "SDnametoindex() failure for "<< sds_name << endl;
3336  SDend(fileID);
3337  return DTDB_FAIL;
3338  }
3339  sds_id = SDselect(fileID, sds_index);
3340  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3341  SDreaddata(sds_id, start, NULL, edges, &va_lut->nvalx412[0][0][0][0][0][0]);
3342 
3343  edges[0] = NSZA;
3344  sds_name = "SZA488_Nodes";
3345  sds_index = SDnametoindex(fileID, sds_name.c_str());
3346  sds_id = SDselect(fileID, sds_index);
3347  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3348  SDreaddata(sds_id, start, NULL, edges, &va_lut->SZA488_Nodes[0]);
3349  edges[0] = NVZA;
3350  sds_name = "VZA488_Nodes";
3351  sds_index = SDnametoindex(fileID, sds_name.c_str());
3352  sds_id = SDselect(fileID, sds_index);
3353  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3354  SDreaddata(sds_id, start, NULL, edges, &va_lut->VZA488_Nodes[0]);
3355  edges[0] = NTAU;
3356  sds_name = "AOT488_Nodes";
3357  sds_index = SDnametoindex(fileID, sds_name.c_str());
3358  sds_id = SDselect(fileID, sds_index);
3359  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3360  SDreaddata(sds_id, start, NULL, edges, &va_lut->AOT488_Nodes[0]);
3361  edges[0] = NRAA;
3362  sds_name = "RAA488_Nodes";
3363  sds_index = SDnametoindex(fileID, sds_name.c_str());
3364  sds_id = SDselect(fileID, sds_index);
3365  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3366  SDreaddata(sds_id, start, NULL, edges, &va_lut->RAA488_Nodes[0]);
3367  edges[0] = SSA470;
3368  sds_name = "SSA488_Nodes";
3369  sds_index = SDnametoindex(fileID, sds_name.c_str());
3370  sds_id = SDselect(fileID, sds_index);
3371  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3372  SDreaddata(sds_id, start, NULL, edges, &va_lut->SSA488_Nodes[0]);
3373  edges[0] = SR470;
3374  sds_name = "SR488_Nodes";
3375  sds_index = SDnametoindex(fileID, sds_name.c_str());
3376  sds_id = SDselect(fileID, sds_index);
3377  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3378  SDreaddata(sds_id, start, NULL, edges, &va_lut->SR488_Nodes[0]);
3379  edges[0] = SR470;
3380  edges[1] = SSA470;
3381  edges[2] = NTAU;
3382  edges[3] = NRAA;
3383  edges[4] = NVZA;
3384  edges[5] = NSZA;
3385  sds_name = "nvalx488";
3386  sds_index = SDnametoindex(fileID, sds_name.c_str());
3387  if (sds_index < 0) {
3388  cerr << "DbLutNetcdf::read_land_aero_files() " <<
3389  "SDnametoindex() failure for "<< sds_name << endl;
3390  SDend(fileID);
3391  return DTDB_FAIL;
3392  }
3393  sds_id = SDselect(fileID, sds_index);
3394  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3395  SDreaddata(sds_id, start, NULL, edges, &va_lut->nvalx488[0][0][0][0][0][0]);
3396 
3397  edges[0] = NSZA;
3398  sds_name = "SZA672_Nodes";
3399  sds_index = SDnametoindex(fileID, sds_name.c_str());
3400  sds_id = SDselect(fileID, sds_index);
3401  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3402  SDreaddata(sds_id, start, NULL, edges, &va_lut->SZA672_Nodes[0]);
3403  edges[0] = NVZA;
3404  sds_name = "VZA672_Nodes";
3405  sds_index = SDnametoindex(fileID, sds_name.c_str());
3406  sds_id = SDselect(fileID, sds_index);
3407  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3408  SDreaddata(sds_id, start, NULL, edges, &va_lut->VZA672_Nodes[0]);
3409  edges[0] = NTAU;
3410  sds_name = "AOT672_Nodes";
3411  sds_index = SDnametoindex(fileID, sds_name.c_str());
3412  sds_id = SDselect(fileID, sds_index);
3413  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3414  SDreaddata(sds_id, start, NULL, edges, &va_lut->AOT672_Nodes[0]);
3415  edges[0] = NRAA;
3416  sds_name = "RAA672_Nodes";
3417  sds_index = SDnametoindex(fileID, sds_name.c_str());
3418  sds_id = SDselect(fileID, sds_index);
3419  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3420  SDreaddata(sds_id, start, NULL, edges, &va_lut->RAA672_Nodes[0]);
3421  edges[0] = SSA650;
3422  sds_name = "SSA672_Nodes";
3423  sds_index = SDnametoindex(fileID, sds_name.c_str());
3424  sds_id = SDselect(fileID, sds_index);
3425  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3426  SDreaddata(sds_id, start, NULL, edges, &va_lut->SSA672_Nodes[0]);
3427  edges[0] = SR650;
3428  sds_name = "SR672_Nodes";
3429  sds_index = SDnametoindex(fileID, sds_name.c_str());
3430  sds_id = SDselect(fileID, sds_index);
3431  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3432  SDreaddata(sds_id, start, NULL, edges, &va_lut->SR672_Nodes[0]);
3433  edges[0] = SR650;
3434  edges[1] = SSA650;
3435  edges[2] = NTAU;
3436  edges[3] = NRAA;
3437  edges[4] = NVZA;
3438  edges[5] = NSZA;
3439  sds_name = "nvalx672";
3440  sds_index = SDnametoindex(fileID, sds_name.c_str());
3441  if (sds_index < 0) {
3442  cerr << "DbLutNetcdf::read_land_aero_files() " <<
3443  "SDnametoindex() failure for "<< sds_name << endl;
3444  SDend(fileID);
3445  return DTDB_FAIL;
3446  }
3447  sds_id = SDselect(fileID, sds_index);
3448  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3449  SDreaddata(sds_id, start, NULL, edges, &va_lut->nvalx672[0][0][0][0][0][0]);
3450 
3451  SDend(fileID);
3452  return status;
3453 }
3454 
3455 /**************************************************************************
3456  * NAME: write_land_aero_lut()
3457  *
3458  * DESCRIPTION: Write Land aerosol LUT to NetCDF4 file.
3459  *
3460  *************************************************************************/
3461 
3462 int DbLutNetcdf::write_land_aero_lut( NcFile* nc_output,
3463  dbLandAerosolLUT* va_lut, const string aero_lut )
3464 {
3465  NcGroup lut_grp = nc_output->addGroup( aero_lut );
3466 
3467  dim_nsza_ = lut_grp.addDim( "Dim_Solar_Zenith_Angle", NSZA );
3468  dim_nvza_ = lut_grp.addDim( "Dim_View_Zenith_Angle", NVZA );
3469  dim_nraa_ = lut_grp.addDim( "Dim_Relative_Azimuth_Angle", NRAA );
3470  dim_ntau_ = lut_grp.addDim( "Dim_Aerosol_Optical_Depth", NTAU );
3471  dim_nssa_ = lut_grp.addDim( "Dim_SSA_412", SSA412 );
3472  dim_nsr_ = lut_grp.addDim( "Dim_SR_412", SR412 );
3473 
3474  vector<NcDim> nvalx_dims;
3475  nvalx_dims.push_back(dim_nsr_);
3476  nvalx_dims.push_back(dim_nssa_);
3477  nvalx_dims.push_back(dim_ntau_);
3478  nvalx_dims.push_back(dim_nraa_);
3479  nvalx_dims.push_back(dim_nvza_);
3480  nvalx_dims.push_back(dim_nsza_);
3481  NcVar var = lut_grp.addVar( "SZA412_Nodes", ncFloat, dim_nsza_ );
3482  var.putVar( va_lut->SZA412_Nodes );
3483  var = lut_grp.addVar( "VZA412_Nodes", ncFloat, dim_nvza_ );
3484  var.putVar( va_lut->VZA412_Nodes );
3485  var = lut_grp.addVar( "RAA412_Nodes", ncFloat, dim_nraa_ );
3486  var.putVar( va_lut->RAA412_Nodes );
3487  var = lut_grp.addVar( "AOT412_Nodes", ncFloat, dim_ntau_ );
3488  var.putVar( va_lut->AOT412_Nodes );
3489  var = lut_grp.addVar( "SSA412_Nodes", ncFloat, dim_nssa_ );
3490  var.putVar( va_lut->SSA412_Nodes );
3491  var = lut_grp.addVar( "SR412_Nodes", ncFloat, dim_nsr_ );
3492  var.putVar( va_lut->SR412_Nodes );
3493  var = lut_grp.addVar( "NVALX412", ncFloat, nvalx_dims );
3494  var.putVar( va_lut->nvalx412 );
3495 
3496  dim_nssa_ = lut_grp.addDim( "Dim_SSA_488", SSA470 );
3497  dim_nsr_ = lut_grp.addDim( "Dim_SR_488", SR470 );
3498  nvalx_dims.clear();
3499  nvalx_dims.push_back(dim_nsr_);
3500  nvalx_dims.push_back(dim_nssa_);
3501  nvalx_dims.push_back(dim_ntau_);
3502  nvalx_dims.push_back(dim_nraa_);
3503  nvalx_dims.push_back(dim_nvza_);
3504  nvalx_dims.push_back(dim_nsza_);
3505  var = lut_grp.addVar( "SZA488_Nodes", ncFloat, dim_nsza_ );
3506  var.putVar( va_lut->SZA488_Nodes );
3507  var = lut_grp.addVar( "VZA488_Nodes", ncFloat, dim_nvza_ );
3508  var.putVar( va_lut->VZA488_Nodes );
3509  var = lut_grp.addVar( "RAA488_Nodes", ncFloat, dim_nraa_ );
3510  var.putVar( va_lut->RAA488_Nodes );
3511  var = lut_grp.addVar( "AOT488_Nodes", ncFloat, dim_ntau_ );
3512  var.putVar( va_lut->AOT488_Nodes );
3513  var = lut_grp.addVar( "SSA488_Nodes", ncFloat, dim_nssa_ );
3514  var.putVar( va_lut->SSA488_Nodes );
3515  var = lut_grp.addVar( "SR488_Nodes", ncFloat, dim_nsr_ );
3516  var.putVar( va_lut->SR488_Nodes );
3517  var = lut_grp.addVar( "NVALX488", ncFloat, nvalx_dims );
3518  var.putVar( va_lut->nvalx488 );
3519 
3520  dim_nssa_ = lut_grp.addDim( "Dim_SSA_672", SSA650 );
3521  dim_nsr_ = lut_grp.addDim( "Dim_SR_672", SR650 );
3522  nvalx_dims.clear();
3523  nvalx_dims.push_back(dim_nsr_);
3524  nvalx_dims.push_back(dim_nssa_);
3525  nvalx_dims.push_back(dim_ntau_);
3526  nvalx_dims.push_back(dim_nraa_);
3527  nvalx_dims.push_back(dim_nvza_);
3528  nvalx_dims.push_back(dim_nsza_);
3529  var = lut_grp.addVar( "SZA672_Nodes", ncFloat, dim_nsza_ );
3530  var.putVar( va_lut->SZA672_Nodes );
3531  var = lut_grp.addVar( "VZA672_Nodes", ncFloat, dim_nvza_ );
3532  var.putVar( va_lut->VZA672_Nodes );
3533  var = lut_grp.addVar( "RAA672_Nodes", ncFloat, dim_nraa_ );
3534  var.putVar( va_lut->RAA672_Nodes );
3535  var = lut_grp.addVar( "AOT672_Nodes", ncFloat, dim_ntau_ );
3536  var.putVar( va_lut->AOT672_Nodes );
3537  var = lut_grp.addVar( "SSA672_Nodes", ncFloat, dim_nssa_ );
3538  var.putVar( va_lut->SSA672_Nodes );
3539  var = lut_grp.addVar( "SR672_Nodes", ncFloat, dim_nsr_ );
3540  var.putVar( va_lut->SR672_Nodes );
3541  var = lut_grp.addVar( "NVALX672", ncFloat, nvalx_dims );
3542  var.putVar( va_lut->nvalx672 );
3543 
3544  return DTDB_SUCCESS;
3545 }
3546 
3547 /**************************************************************************
3548  * NAME: read_land_aero_lut()
3549  *
3550  * DESCRIPTION: Read land aerosol NetCDF4 LUT.
3551  *
3552  *************************************************************************/
3553 
3555  const string aero_lut)
3556 {
3557  int status = DTDB_SUCCESS;
3558 
3560  if (filepath.empty()) {
3562  }
3563  NcFile* nc_input;
3564  try {
3565  nc_input = new NcFile(filepath, NcFile::read );
3566  }
3567  catch( NcException& e) {
3568  e.what();
3569  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
3570  return DTDB_FAIL;
3571  }
3572  NcGroup lut_grp = nc_input->getGroup( aero_lut );
3573 
3574  NcVar var = lut_grp.getVar( "SZA412_Nodes" );
3575  var.getVar( va_lut->SZA412_Nodes );
3576  var = lut_grp.getVar( "VZA412_Nodes" );
3577  var.getVar( va_lut->VZA412_Nodes );
3578  var = lut_grp.getVar( "RAA412_Nodes" );
3579  var.getVar( va_lut->RAA412_Nodes );
3580  var = lut_grp.getVar( "AOT412_Nodes" );
3581  var.getVar( va_lut->AOT412_Nodes );
3582  var = lut_grp.getVar( "SSA412_Nodes" );
3583  var.getVar( va_lut->SSA412_Nodes );
3584  var = lut_grp.getVar( "SR412_Nodes" );
3585  var.getVar( va_lut->SR412_Nodes );
3586  var = lut_grp.getVar( "NVALX412" );
3587  var.getVar( va_lut->nvalx412 );
3588 
3589  var = lut_grp.getVar( "SZA488_Nodes" );
3590  var.getVar( va_lut->SZA488_Nodes );
3591  var = lut_grp.getVar( "VZA488_Nodes" );
3592  var.getVar( va_lut->VZA488_Nodes );
3593  var = lut_grp.getVar( "RAA488_Nodes" );
3594  var.getVar( va_lut->RAA488_Nodes );
3595  var = lut_grp.getVar( "AOT488_Nodes" );
3596  var.getVar( va_lut->AOT488_Nodes );
3597  var = lut_grp.getVar( "SSA488_Nodes" );
3598  var.getVar( va_lut->SSA488_Nodes );
3599  var = lut_grp.getVar( "SR488_Nodes" );
3600  var.getVar( va_lut->SR488_Nodes );
3601  var = lut_grp.getVar( "NVALX488" );
3602  var.getVar( va_lut->nvalx488 );
3603 
3604  var = lut_grp.getVar( "SZA672_Nodes" );
3605  var.getVar( va_lut->SZA672_Nodes );
3606  var = lut_grp.getVar( "VZA672_Nodes" );
3607  var.getVar( va_lut->VZA672_Nodes );
3608  var = lut_grp.getVar( "RAA672_Nodes" );
3609  var.getVar( va_lut->RAA672_Nodes );
3610  var = lut_grp.getVar( "AOT672_Nodes" );
3611  var.getVar( va_lut->AOT672_Nodes );
3612  var = lut_grp.getVar( "SSA672_Nodes" );
3613  var.getVar( va_lut->SSA672_Nodes );
3614  var = lut_grp.getVar( "SR672_Nodes" );
3615  var.getVar( va_lut->SR672_Nodes );
3616  var = lut_grp.getVar( "NVALX672" );
3617  var.getVar( va_lut->nvalx672 );
3618 
3619  delete nc_input;
3620 
3621  return status;
3622 }
3623 
3624 /**************************************************************************
3625  * NAME: read_bathymetry_files()
3626  *
3627  * DESCRIPTION: Read all bathymetry files.
3628  *
3629  *************************************************************************/
3630 
3632 {
3633  int status = DTDB_SUCCESS;
3634 
3636  if(filepath.empty()) {
3637  cerr << "DbLutNetcdf::read_bathymetry_files() Invalid path." << endl;
3638  return DTDB_FAIL;
3639  }
3640  int fileID;
3641  try {
3642  fileID = SDstart(filepath.c_str(), DFACC_READ );
3643  }
3644  catch( std::exception& e) {
3645  e.what();
3646  cerr << "DbLutNetcdf:: Failure opening bathymetry file: " + filepath << endl;
3647  return DTDB_FAIL;
3648  }
3649  int sds_index, sds_id, numtype, rank, nattrs;
3650  int start[2], edges[2], dims[2];
3651  start[0] = 0;
3652  start[1] = 0;
3653  edges[0] = NUMY;
3654  edges[1] = NUMX;
3655  string sds_name = "z";
3656  sds_index = SDnametoindex(fileID, sds_name.c_str());
3657  sds_id = SDselect(fileID, sds_index);
3658  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3659  SDreaddata(sds_id, start, NULL, edges, &b_lut->z[0][0]);
3660  edges[0] = NUMX;
3661  sds_name = "x";
3662  sds_index = SDnametoindex(fileID, sds_name.c_str());
3663  sds_id = SDselect(fileID, sds_index);
3664  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3665  SDreaddata(sds_id, start, NULL, edges, &b_lut->x[0]);
3666  edges[0] = NUMY;
3667  sds_name = "y";
3668  sds_index = SDnametoindex(fileID, sds_name.c_str());
3669  sds_id = SDselect(fileID, sds_index);
3670  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3671  SDreaddata(sds_id, start, NULL, edges, &b_lut->y[0]);
3672 
3673  SDend(fileID);
3674  return status;
3675 }
3676 
3677 /**************************************************************************
3678  * NAME: write_bathymetry_lut()
3679  *
3680  * DESCRIPTION: Write bathymetry LUT to NetCDF4 file.
3681  *
3682  *************************************************************************/
3683 
3684 int DbLutNetcdf::write_bathymetry_lut( NcFile* nc_output,
3685  dbBathymetryLUT* b_lut )
3686 {
3687  NcGroup lut_grp = nc_output->addGroup( LUT_BATHYMETRY );
3688 
3689  dim_nx_ = lut_grp.addDim( "Dim_Bathymetry_X", NUMX );
3690  dim_ny_ = lut_grp.addDim( "Dim_Bathymetry_Y", NUMY );
3691 
3692  vector<NcDim> bath_dims;
3693  bath_dims.push_back(dim_ny_);
3694  bath_dims.push_back(dim_nx_);
3695  NcVar var = lut_grp.addVar( "X", ncDouble, dim_nx_ );
3696  var.putVar( b_lut->x );
3697  var = lut_grp.addVar( "Y", ncDouble, dim_ny_ );
3698  var.putVar( b_lut->y );
3699  var = lut_grp.addVar( "Z", ncInt, bath_dims );
3700  var.putVar( b_lut->z );
3701 
3702  return DTDB_SUCCESS;
3703 }
3704 
3705 /**************************************************************************
3706  * NAME: read_bathymetry_lut()
3707  *
3708  * DESCRIPTION: Read bathymetry NetCDF4 LUT.
3709  *
3710  *************************************************************************/
3711 
3713 {
3714  int status = DTDB_SUCCESS;
3715 
3717  if (filepath.empty()) {
3719  }
3720  NcFile* nc_input;
3721  try {
3722  nc_input = new NcFile(filepath, NcFile::read );
3723  }
3724  catch( NcException& e) {
3725  e.what();
3726  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
3727  return DTDB_FAIL;
3728  }
3729  NcGroup lut_grp = nc_input->getGroup( LUT_BATHYMETRY );
3730 
3731  NcVar var = lut_grp.getVar( "X" );
3732  var.getVar( b_lut->x );
3733  var = lut_grp.getVar( "Y" );
3734  var.getVar( b_lut->y );
3735  var = lut_grp.getVar( "Z" );
3736  var.getVar( b_lut->z );
3737  delete nc_input;
3738 
3739  return status;
3740 }
3741 
3742 /**************************************************************************
3743  * NAME: read_chl_files()
3744  *
3745  * DESCRIPTION: Read all chl files.
3746  *
3747  *************************************************************************/
3748 
3750 {
3751  int status = DTDB_SUCCESS;
3752 
3753  string filepath = get_option(INPUT_CHL);
3754  if(filepath.empty()) {
3755  cerr << "DbLutNetcdf::read_chl_files() Invalid path." << endl;
3756  return DTDB_FAIL;
3757  }
3758  NcFile* nc_input;
3759  try {
3760  nc_input = new NcFile(filepath, NcFile::read );
3761  }
3762  catch( NcException& e) {
3763  e.what();
3764  cerr << "DbLutNetcdf:: Failure opening chl file: " + filepath << endl;
3765  return DTDB_FAIL;
3766  }
3767  NcVar var = nc_input->getVar( "latitude" );
3768  var.getVar( c_lut->latitude );
3769  var = nc_input->getVar( "longitude" );
3770  var.getVar( c_lut->longitude );
3771  var = nc_input->getVar( "time" );
3772  var.getVar( c_lut->time );
3773  var = nc_input->getVar( "log_chl" );
3774  var.getVar( c_lut->log_chl );
3775 
3776  delete nc_input;
3777  return status;
3778 }
3779 
3780 /**************************************************************************
3781  * NAME: write_chl_lut()
3782  *
3783  * DESCRIPTION: Write chl LUT to NetCDF4 file.
3784  *
3785  *************************************************************************/
3786 
3787 int DbLutNetcdf::write_chl_lut( NcFile* nc_output,
3788  dbChlLUT* c_lut )
3789 {
3790  NcGroup lut_grp = nc_output->addGroup( LUT_CHL );
3791 
3792  dim_1800_ = lut_grp.addDim( "Dim_Latitude", NLATS*10 );
3793  dim_3600_ = lut_grp.addDim( "Dim_Longitude", NLONS*10 );
3794  dim_months_ = lut_grp.addDim( "Dim_Time", NMONTHS );
3795  vector<NcDim> map_dims;
3796  map_dims.push_back(dim_1800_);
3797  map_dims.push_back(dim_3600_);
3798  vector<NcDim> chl_dims;
3799  chl_dims.push_back(dim_1800_);
3800  chl_dims.push_back(dim_3600_);
3801  chl_dims.push_back(dim_months_);
3802  NcVar var = lut_grp.addVar( "LATITUDE", ncFloat, map_dims );
3803  var.putVar( c_lut->latitude );
3804  var = lut_grp.addVar( "LONGITUDE", ncFloat, map_dims );
3805  var.putVar( c_lut->latitude );
3806  var = lut_grp.addVar( "TIME", ncDouble, dim_months_ );
3807  var.putVar( c_lut->time );
3808  var = lut_grp.addVar( "LOG_CHL", ncFloat, chl_dims );
3809  var.putVar( c_lut->log_chl );
3810 
3811  return DTDB_SUCCESS;
3812 }
3813 
3814 /**************************************************************************
3815  * NAME: read_chl_lut()
3816  *
3817  * DESCRIPTION: Read chl NetCDF4 LUT.
3818  *
3819  *************************************************************************/
3820 
3822 {
3823  int status = DTDB_SUCCESS;
3824 
3826  if (filepath.empty()) {
3828  }
3829  NcFile* nc_input;
3830  try {
3831  nc_input = new NcFile(filepath, NcFile::read );
3832  }
3833  catch( NcException& e) {
3834  e.what();
3835  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
3836  return DTDB_FAIL;
3837  }
3838  NcGroup lut_grp = nc_input->getGroup( LUT_CHL );
3839 
3840  NcVar var = lut_grp.getVar( "LATITUDE" );
3841  var.getVar( c_lut->latitude);
3842  var = lut_grp.getVar( "LONGITUDE" );
3843  var.getVar( c_lut->longitude );
3844  var = lut_grp.getVar( "TIME" );
3845  var.getVar( c_lut->time );
3846  var = lut_grp.getVar( "LOG_CHL" );
3847  var.getVar( c_lut->log_chl );
3848 
3849  delete nc_input;
3850 
3851  return status;
3852 }
3853 
3854 /**************************************************************************
3855  * NAME: read_geozone_files()
3856  *
3857  * DESCRIPTION: Read all geozone files.
3858  *
3859  *************************************************************************/
3860 
3862 {
3863  int status = DTDB_SUCCESS;
3864 
3865  string filepath = get_option(INPUT_GEOZONE);
3866  if(filepath.empty()) {
3867  cerr << "DbLutNetcdf::read_geozone_files() Invalid path." << endl;
3868  return DTDB_FAIL;
3869  }
3870  int fileID;
3871  try {
3872  fileID = SDstart(filepath.c_str(), DFACC_READ );
3873  }
3874  catch( std::exception& e) {
3875  e.what();
3876  cerr << "DbLutNetcdf:: Failure opening geozone file: " + filepath << endl;
3877  return DTDB_FAIL;
3878  }
3879  int sds_index, sds_id, numtype, rank, nattrs;
3880  int start[3], edges[3], dims[3];
3881  start[0] = 0;
3882  start[1] = 0;
3883  start[2] = 0;
3884  edges[0] = NLATS*10;
3885  edges[1] = NLONS*10;
3886  string sds_name = "geographical_zone_flag";
3887  sds_index = SDnametoindex(fileID, sds_name.c_str());
3888  sds_id = SDselect(fileID, sds_index);
3889  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3890  SDreaddata(sds_id, start, NULL, edges, &g_lut->GEOZONE_FLAG[0][0]);
3891  sds_name = "surface_elevation_stddev";
3892  sds_index = SDnametoindex(fileID, sds_name.c_str());
3893  sds_id = SDselect(fileID, sds_index);
3894  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3895  SDreaddata(sds_id, start, NULL, edges, &g_lut->ELEVATION_STDV[0][0]);
3896  edges[0] = NSEASONS;
3897  edges[1] = NLATS;
3898  edges[2] = NLONS;
3899  sds_name = "background_aod";
3900  sds_index = SDnametoindex(fileID, sds_name.c_str());
3901  sds_id = SDselect(fileID, sds_index);
3902  SDgetinfo(sds_id, (char*) sds_name.c_str(), &rank, dims, &numtype, &nattrs);
3903  SDreaddata(sds_id, start, NULL, edges, &g_lut->BACKGROUND_AOD[0]);
3904 
3905  SDend(fileID);
3906  return status;
3907 }
3908 
3909 /**************************************************************************
3910  * NAME: write_geozone_lut()
3911  *
3912  * DESCRIPTION: Write geozone LUT to NetCDF4 file.
3913  *
3914  *************************************************************************/
3915 
3916 int DbLutNetcdf::write_geozone_lut( NcFile* nc_output,
3917  dbGeozoneLUT* g_lut )
3918 {
3919  NcGroup lut_grp = nc_output->addGroup( LUT_GEOZONE );
3920 
3921  dim_1800_ = lut_grp.addDim( "Dim_Latx10", NLATS*10 );
3922  dim_3600_ = lut_grp.addDim( "Dim_Lonx10", NLONS*10 );
3923  dim_180_ = lut_grp.addDim( "Dim_Lat", NLATS );
3924  dim_360_ = lut_grp.addDim( "Dim_Lon", NLONS );
3925  dim_seasons_ = lut_grp.addDim( "Dim_Seasons", NSEASONS );
3926  vector<NcDim> map_dims;
3927  map_dims.push_back(dim_1800_);
3928  map_dims.push_back(dim_3600_);
3929  vector<NcDim> aod_dims;
3930  aod_dims.push_back(dim_seasons_);
3931  aod_dims.push_back(dim_180_);
3932  aod_dims.push_back(dim_360_);
3933  NcVar var = lut_grp.addVar( "GEOZONE_FLAG", ncFloat, map_dims );
3934  var.putVar( g_lut->GEOZONE_FLAG );
3935  var = lut_grp.addVar( "ELEVATION_STDV", ncFloat, map_dims );
3936  var.putVar( g_lut->ELEVATION_STDV );
3937  var = lut_grp.addVar( "BACKGROUND_AOD", ncFloat, aod_dims );
3938  var.putVar( g_lut->BACKGROUND_AOD );
3939 
3940  return DTDB_SUCCESS;
3941 }
3942 
3943 /**************************************************************************
3944  * NAME: read_geozone_lut()
3945  *
3946  * DESCRIPTION: Read geozone NetCDF4 LUT.
3947  *
3948  *************************************************************************/
3949 
3951 {
3952  int status = DTDB_SUCCESS;
3953 
3955  if (filepath.empty()) {
3957  }
3958  NcFile* nc_input;
3959  try {
3960  nc_input = new NcFile(filepath, NcFile::read );
3961  }
3962  catch( NcException& e) {
3963  e.what();
3964  cerr << "DbLutNetcdf:: Failure opening netcdf LUT file: " + filepath << endl;
3965  return DTDB_FAIL;
3966  }
3967  NcGroup lut_grp = nc_input->getGroup( LUT_GEOZONE );
3968 
3969  NcVar var = lut_grp.getVar( "GEOZONE_FLAG" );
3970  var.getVar( g_lut->GEOZONE_FLAG);
3971  var = lut_grp.getVar( "ELEVATION_STDV" );
3972  var.getVar( g_lut->ELEVATION_STDV );
3973  var = lut_grp.getVar( "BACKGROUND_AOD" );
3974  var.getVar( g_lut->BACKGROUND_AOD );
3975 
3976  delete nc_input;
3977 
3978  return status;
3979 }
3980 
3981 /**************************************************************************
3982  * write_global_attributes()
3983  *
3984  * Write global attributes to specified netCDF file ID
3985  *
3986  **************************************************************************/
3987 
3989 {
3990  nc_output->putAtt( "processing_version", processing_version_);
3991  nc_output->putAtt( "Conventions", Conventions_);
3992  nc_output->putAtt( "institution", institution_);
3993  nc_output->putAtt( "license", license_);
3994  nc_output->putAtt( "naming_authority", naming_authority_);
3995  nc_output->putAtt( "date_created", date_created_);
3996  nc_output->putAtt( "ProductionTime", date_created_);
3997  nc_output->putAtt( "keywords_vocabulary", keywords_vocabulary_);
3998  nc_output->putAtt( "stdname_vocabulary", stdname_vocabulary_);
3999  nc_output->putAtt( "creator_name", creator_name_);
4000  nc_output->putAtt( "creator_email", creator_email_);
4001  nc_output->putAtt( "creator_url", creator_url_);
4002  nc_output->putAtt( "project", project_);
4003  nc_output->putAtt( "publisher_name", publisher_name_);
4004  nc_output->putAtt( "publisher_url", publisher_url_);
4005  nc_output->putAtt( "publisher_email", publisher_email_);
4006  nc_output->putAtt( "processing_level", processing_level_);
4007  nc_output->putAtt( "cdm_data_type", cdm_data_type_);
4008  nc_output->putAtt( "orbit_number", ncInt, orbit_number_);
4009  nc_output->putAtt( "history", history_);
4010  nc_output->putAtt( "source", source_files_);
4011  nc_output->putAtt( "time_coverage_start", time_coverage_start_);
4012  nc_output->putAtt( "time_coverage_end", time_coverage_end_);
4013  string pge_name_ = basename((char*)get_option("PGE_Name").c_str());
4014  if (!pge_name_.empty()) {
4015  nc_output->putAtt("PGE_Name",pge_name_);
4016  }
4017  string versionid_ = basename((char*)get_option("VersionID").c_str());
4018  if (!versionid_.empty()) {
4019  nc_output->putAtt("VersionId",versionid_);
4020  }
4021 
4022  nc_output->putAtt( "format_version", ncInt, format_version_);
4023  nc_output->putAtt( "instrument_number", ncInt, instrument_number_);
4024 
4025  return DTDB_SUCCESS;
4026 }
4027 
4028 
4029 /**************************************************************************
4030  * NAME: isPlatformLittleEndian()
4031  *
4032  * DESCRIPTION: Determine if target platform is little endian.
4033  * Return true if platform is little endian.
4034  *
4035  *************************************************************************/
4036 
4038 {
4039  unsigned short checkValue = 0xAABB;
4040  unsigned char* bytePtr = reinterpret_cast<unsigned char*>(&checkValue);
4041 
4042  if (bytePtr[0] == 0xAA) { // big-endian
4043  return false;
4044  } else { // little-endian
4045  return true;
4046  }
4047 }
4048 
4049 
4050 
boost::multi_array< float, 1 > vza
Definition: DbLutNetcdf.h:293
int read_rayleigh_lut(dbRayleighLUT *lut)
float SR412_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:84
float chl[NCHL]
Definition: DbLutNetcdf.h:334
string publisher_name_
Definition: DbLutNetcdf.h:418
NcDim dim_terms_
Definition: DbLutNetcdf.h:575
const string INPUT_SURFACE_PRESSURE
Definition: DDOptions.cpp:102
int write_land_aero_lut(NcFile *nc_output, dbLandAerosolLUT *lut, const string strType)
float SZA488_Nodes[NSZA]
Definition: DbLutNetcdf.h:357
string creator_email_
Definition: DbLutNetcdf.h:415
const int bindx[3]
Definition: DbLutNetcdf.cpp:28
string time_coverage_start_
Definition: DbLutNetcdf.h:426
int read_landcover_lut(dbLandcoverLUT *lut)
float SX672_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:186
const static size_t nwave
Definition: DbLutNetcdf.h:320
const string LUT_NVALX21
Definition: DDOptions.cpp:136
boost::multi_array< float, 1 > aot550
Definition: DbLutNetcdf.h:295
int write_viirs_surf_refl_lut(NcFile *nc_output, dbViirsSurfReflLUT *lut)
boost::multi_array< float, 3 > coarse_asy
Definition: DbLutNetcdf.h:309
int read_land_aero_lut(dbLandAerosolLUT *lut, const string sType)
float latitude[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:243
boost::multi_array< float, 7 > m04
Definition: DbLutNetcdf.h:286
NcDim dim_ny_
Definition: DbLutNetcdf.h:595
float R0X865_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:189
float SR412_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:195
float m10[NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:326
int status
Definition: l1_czcs_hdf.c:32
const string LUT_VIIRS_SURFACE_REFL
Definition: DDOptions.cpp:139
float RAA488_Nodes[NRAA]
Definition: DbLutNetcdf.h:359
float NVALX_470[SR470][SSA470][NTAU][NRAA][NVZA][NSZA]
Definition: DbLutNetcdf.h:145
const static size_t nwave
Definition: DbLutNetcdf.h:284
const string LUT_OCEAN_AEROSOL_DUST
Definition: DDOptions.cpp:144
string publisher_email_
Definition: DbLutNetcdf.h:420
float RAA412_Nodes[NRAA]
Definition: DbLutNetcdf.h:352
const string INPUT_RAYL_470
Definition: DDOptions.cpp:112
boost::multi_array< float, 1 > wave
Definition: DbLutNetcdf.h:299
string creator_name_
Definition: DbLutNetcdf.h:414
NcDim dim_months_
Definition: DbLutNetcdf.h:550
const string INPUT_NC4_LUT
Definition: DDOptions.cpp:118
int read_veg_21sfc_lut(dbVeg_21sfcLUT *lut)
int z[NUMY][NUMX]
Definition: DbLutNetcdf.h:379
float longitude[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:383
int write_tables_lut(NcFile *nc_output, dbTablesLUT *lut)
int16_t fileID
int format_version_
Definition: DbLutNetcdf.h:428
NcDim dim_4_
Definition: DbLutNetcdf.h:556
int read_surf_coeff_files(dbSurfCoeffLUT *lut)
bool isPlatformLittleEndian()
#define NULL
Definition: decode_rs.h:63
NcDim dim_180_
Definition: DbLutNetcdf.h:558
float nvalx672[SR650][SSA650][NTAU][NRAA][NVZA][NSZA]
Definition: DbLutNetcdf.h:370
boost::multi_array< float, 2 > BRDF_650_L
Definition: DbLutNetcdf.h:205
const string INPUT_RAYL_650
Definition: DDOptions.cpp:113
float SC650_ALL[NSEASONS][NNDVI][NTERMS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:213
int write_chl_lut(NcFile *nc_output, dbChlLUT *lut)
NcDim dim_nchl_
Definition: DbLutNetcdf.h:592
NcDim dim_nstokes_
Definition: DbLutNetcdf.h:582
NcDim dim_360_
Definition: DbLutNetcdf.h:559
float NVALX672_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:184
int read_swir_file(dbViirsSwirVsVisLUT *lut)
float SC650_FWD[NSEASONS][NNDVI][NTERMS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:214
NcDim dim_seasons_
Definition: DbLutNetcdf.h:549
float PS[SP_720][SP_360]
Definition: DbLutNetcdf.h:123
const int chindx[8]
Definition: DbLutNetcdf.cpp:27
string get_option(const string &name)
Definition: DDOptions.cpp:211
float max_2250_for_488[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:251
float SR650_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:88
float SSA488_Nodes[SSA470]
Definition: DbLutNetcdf.h:361
boost::multi_array< float, 1 > chl
Definition: DbLutNetcdf.h:298
boost::multi_array< float, 2 > SR412_FWD_L
Definition: DbLutNetcdf.h:95
float SR470_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:86
float32 * pos
Definition: l1_czcs_hdf.c:35
int read_tables_lut(dbTablesLUT *lut)
NcDim dim_2_
Definition: DbLutNetcdf.h:554
float coeffs_2250_to_412[NSEASONS][NSCOEF][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:245
float longitude[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:244
float sza[NVSZA]
Definition: DbLutNetcdf.h:328
float ssa[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:340
float SR470_FWD[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:87
int read_nvalx_files(dbNvalxLUT *lut)
float coarse_aot[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:339
float R0X21_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:181
const string LUT_SURFACE_PRESSURE
Definition: DDOptions.cpp:129
NcDim dim_160_
Definition: DbLutNetcdf.h:553
boost::multi_array< float, 3 > coarse_aot
Definition: DbLutNetcdf.h:303
NcDim dim_ssa470_
Definition: DbLutNetcdf.h:570
float m05[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:323
int read_ocean_aero_lut(dbOceanAerosolLUMA *lut, const string sType)
const string NETCDF_LUT_PATH
Definition: DDOptions.cpp:194
float max_2250_for_670[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:253
float nvalx488[SR470][SSA470][NTAU][NRAA][NVZA][NSZA]
Definition: DbLutNetcdf.h:363
NcDim dim_ndvi_
Definition: DbLutNetcdf.h:574
@ string
int instrument_number_
Definition: DbLutNetcdf.h:429
const string LUT_BATHYMETRY
Definition: DDOptions.cpp:149
const string LUT_CHL
Definition: DDOptions.cpp:150
float SR865_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:90
int read_surface_pressure_file(dbSurfacePressureLUT *lut)
const string LUT_MODIS_SURFACE_REFL
Definition: DDOptions.cpp:131
SEASON
Definition: DDProcess.h:72
float SC412_FWD[NSEASONS][NNDVI][NTERMS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:210
string Conventions_
Definition: DbLutNetcdf.h:407
int read_tables_file(dbTablesLUT *lut)
NcDim dim_nsza_
Definition: DbLutNetcdf.h:563
float SR412_Nodes[SR412]
Definition: DbLutNetcdf.h:355
NcDim dim_nfmf_
Definition: DbLutNetcdf.h:590
string naming_authority_
Definition: DbLutNetcdf.h:410
const string INPUT_VEG_LANDCOVER
Definition: DDOptions.cpp:109
float data_num_fitting[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:255
float SURFACE_ELEVATION[SP_SETS *SP_720][SP_SETS *SP_360]
Definition: DbLutNetcdf.h:125
const string INPUT_SURF_COEFF
Definition: DDOptions.cpp:107
float SR412_FWD[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:85
float DESERTS_FLAG[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:230
float VZA488_Nodes[NVZA]
Definition: DbLutNetcdf.h:358
float log_chl[NLATS *10][NLONS *10][NMONTHS]
Definition: DbLutNetcdf.h:386
boost::multi_array< float, 1 > raa
Definition: DbLutNetcdf.h:294
int read_modis_surf_refl_lut(dbModisSurfReflLimited *lut, int *start, int *edge, int &season, int &dateline)
float AOT412_Nodes[NTAU]
Definition: DbLutNetcdf.h:353
float m07[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:324
boost::multi_array< float, 4 > SC470_FWD_L
Definition: DbLutNetcdf.h:221
int write_geozone_lut(NcFile *nc_output, dbGeozoneLUT *lut)
boost::multi_array< float, 2 > SR865_ALL_L
Definition: DbLutNetcdf.h:100
const string LUT_LANDCOVER
Definition: DDOptions.cpp:141
float fmf[NFMF3]
Definition: DbLutNetcdf.h:332
float Z2I0[MTABLE_20800]
Definition: DbLutNetcdf.h:169
string history_
Definition: DbLutNetcdf.h:424
string keywords_vocabulary_
Definition: DbLutNetcdf.h:412
float TX865_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:191
float NVALX_650[SR650][NTAU][NRAA][NVZA][NSZA]
Definition: DbLutNetcdf.h:146
const string LUT_OCEAN_AEROSOL_MIX
Definition: DDOptions.cpp:146
float coarse_ssa[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:342
const string LUT_OCEAN_AEROSOL_MARI
Definition: DDOptions.cpp:145
int write_bathymetry_lut(NcFile *nc_output, dbBathymetryLUT *lut)
const string INPUT_AERO_OCEAN_MARI
Definition: DDOptions.cpp:96
float SB[MTABLE_260]
Definition: DbLutNetcdf.h:171
int read_modis_surf_refl_files(dbModisSurfReflLUT *lut)
const string LUT_OCEAN_AEROSOL_FINE
Definition: DDOptions.cpp:143
float asy[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:343
float latitude[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:384
float SC470_FWD[NSEASONS][NNDVI][NTERMS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:212
float TI0R[MTABLE_160]
Definition: DbLutNetcdf.h:175
int read_surf_coeff_lut(dbSurfCoeffLimited *lut, int *start, int *edge, int &season, int &dateline)
NcDim dim_sr470_
Definition: DbLutNetcdf.h:572
float RAYL_470[NRRAA][NVZA][NSZA][NSTOKES]
Definition: DbLutNetcdf.h:154
string path
Definition: color_dtdb.py:221
float fine_asy[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:344
NcDim dim_sr412_
Definition: DbLutNetcdf.h:571
short IGBP[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:228
boost::multi_array< float, 3 > asy
Definition: DbLutNetcdf.h:307
NcDim dim_260_
Definition: DbLutNetcdf.h:552
boost::multi_array< float, 7 > m05
Definition: DbLutNetcdf.h:287
NcDim dim_nx_
Definition: DbLutNetcdf.h:594
float vza[NVVZA]
Definition: DbLutNetcdf.h:329
int read_nvalx_lut(dbNvalxLUT *lut)
float RAYL_412[NRRAA][NVZA][NSZA][NSTOKES]
Definition: DbLutNetcdf.h:153
int write_global_attributes(NcFile *nc_output)
float min_2250_for_412[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:248
int read_surface_pressure_lut(dbSurfacePressureLUT *lut)
int read_bathymetry_lut(dbBathymetryLUT *lut)
float SSA672_Nodes[SSA650]
Definition: DbLutNetcdf.h:368
float Z1I0R[MTABLE_160]
Definition: DbLutNetcdf.h:173
NcDim dim_3_
Definition: DbLutNetcdf.h:555
const string INPUT_DB_NC4_LUT
Definition: DDOptions.cpp:120
float nvalx412[SR412][SSA412][NTAU][NRAA][NVZA][NSZA]
Definition: DbLutNetcdf.h:356
float min_2250_for_670[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:252
NcDim dim_720_
Definition: DbLutNetcdf.h:557
NcDim dim_nrraa_
Definition: DbLutNetcdf.h:581
const std::string str_season[NUM_SEASONS]
Definition: DbLutNetcdf.cpp:29
int read_geozone_files(dbGeozoneLUT *lut)
float m11[NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:327
NcDim dim_sr650_
Definition: DbLutNetcdf.h:573
float aot550[NAOT1]
Definition: DbLutNetcdf.h:331
NcDim dim_4320_
Definition: DbLutNetcdf.h:560
int read_bathymetry_files(dbBathymetryLUT *lut)
boost::multi_array< float, 4 > SC650_ALL_L
Definition: DbLutNetcdf.h:222
string publisher_url_
Definition: DbLutNetcdf.h:419
boost::multi_array< float, 1 > wspd
Definition: DbLutNetcdf.h:297
int read_viirs_surf_refl_lut(dbViirsSurfReflLimited *lut, int *start, int *edge, int &season, int &dateline)
NcDim dim_nwl_
Definition: DbLutNetcdf.h:593
float SR488_Nodes[SR470]
Definition: DbLutNetcdf.h:362
float SC470_ALL[NSEASONS][NNDVI][NTERMS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:211
int VEGETATION[4 *NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:227
boost::multi_array< float, 7 > m07
Definition: DbLutNetcdf.h:288
const string INPUT_CHL
Definition: DDOptions.cpp:99
float SSA412_Nodes[SSA412]
Definition: DbLutNetcdf.h:354
const string INPUT_NVALX_650
Definition: DDOptions.cpp:81
const string INPUT_RAYL_412
Definition: DDOptions.cpp:111
int32 nrows
NcDim dim_nsr_
Definition: DbLutNetcdf.h:568
int initialize()
Definition: DbLutNetcdf.cpp:57
boost::multi_array< float, 3 > ssa
Definition: DbLutNetcdf.h:304
float Z2I0R[MTABLE_160]
Definition: DbLutNetcdf.h:174
const string INPUT_NVALX_412
Definition: DDOptions.cpp:79
float SR650_FWD[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:89
float NVALX865_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:188
int create_db_nc4_lut()
Definition: DbLutNetcdf.cpp:69
NcDim dim_ntau_
Definition: DbLutNetcdf.h:566
const string LUT_LER_TABLES
Definition: DDOptions.cpp:137
float m03[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:321
float coeffs_2250_to_488[NSEASONS][NSCOEF][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:246
const string LUT_GEOZONE
Definition: DDOptions.cpp:142
float AOT672_Nodes[NTAU]
Definition: DbLutNetcdf.h:367
boost::multi_array< float, 2 > SR650_FWD_L
Definition: DbLutNetcdf.h:99
int write_nvalx_lut(NcFile *nc_output, dbNvalxLUT *lut)
boost::multi_array< float, 6 > m10
Definition: DbLutNetcdf.h:290
int read_swir_lut(dbViirsSwirVsVisLUT *lut)
float VZA412_Nodes[NVZA]
Definition: DbLutNetcdf.h:351
string processing_level_
Definition: DbLutNetcdf.h:421
int write_surface_pressure_lut(NcFile *nc_output, dbSurfacePressureLUT *mt_lut)
#define NUM_SEASONS
Definition: AfrtConstants.h:32
float SR672_Nodes[SR650]
Definition: DbLutNetcdf.h:369
float SBR[MTABLE_2]
Definition: DbLutNetcdf.h:176
string cdm_data_type_
Definition: DbLutNetcdf.h:422
int read_viirs_surf_refl_files(dbViirsSurfReflLUT *lut)
boost::multi_array< float, 1 > fmf
Definition: DbLutNetcdf.h:296
boost::multi_array< float, 1 > sza
Definition: DbLutNetcdf.h:292
float NVALX_412[SR412][SSA412][NTAU][NRAA][NVZA][NSZA]
Definition: DbLutNetcdf.h:144
boost::multi_array< float, 2 > SR412_ALL_L
Definition: DbLutNetcdf.h:202
const string LUT_RAYLEIGH
Definition: DDOptions.cpp:134
string filepath
Definition: color_dtdb.py:207
boost::multi_array< float, 4 > SC650_FWD_L
Definition: DbLutNetcdf.h:223
double y[NUMY]
Definition: DbLutNetcdf.h:378
const string LUT_SURFACE_COEFF
Definition: DDOptions.cpp:140
float wave[NDBOWL]
Definition: DbLutNetcdf.h:335
boost::multi_array< float, 2 > SR488_ALL_L
Definition: DbLutNetcdf.h:203
#define basename(s)
Definition: l0chunk_modis.c:29
int read_rayleigh_files(dbRayleighLUT *lut)
int read_veg_21sfc_files(dbVeg_21sfcLUT *lut)
int orbit_number_
Definition: DbLutNetcdf.h:423
const string INPUT_BRDF
Definition: DDOptions.cpp:105
float ELEVATION_STDV[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:235
NcDim dim_6000_
Definition: DbLutNetcdf.h:577
const string INPUT_AERO_LAND_FINE
Definition: DDOptions.cpp:92
NcDim dim_nszav_
Definition: DbLutNetcdf.h:562
float BACKGROUND_AOD[4][NLATS][NLONS]
Definition: DbLutNetcdf.h:236
NcDim dim_3600_
Definition: DbLutNetcdf.h:579
float fine_aot[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:338
const string INPUT_LER_TABLE
Definition: DDOptions.cpp:100
string processing_version_
Definition: DbLutNetcdf.h:406
float max_2250_for_412[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:249
const string INPUT_AERO_OCEAN_FINE
Definition: DDOptions.cpp:95
float stderr_412[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:256
int read_chl_files(dbChlLUT *lut)
float SX21_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:182
float BRDF_650[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:198
float TI0[MTABLE_20800]
Definition: DbLutNetcdf.h:170
float Z1I0[MTABLE_20800]
Definition: DbLutNetcdf.h:168
boost::multi_array< float, 2 > SR470_ALL_L
Definition: DbLutNetcdf.h:96
float SX865_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:190
const string INPUT_MODIS_SURF_REFL
Definition: DDOptions.cpp:85
int write_swir_lut(NcFile *nc_output, dbViirsSwirVsVisLUT *lut)
float SZA412_Nodes[NSZA]
Definition: DbLutNetcdf.h:350
string date_created_
Definition: DbLutNetcdf.h:411
float LOGI0R[MTABLE_160]
Definition: DbLutNetcdf.h:172
const string LUT_SWIR
Definition: DDOptions.cpp:138
boost::multi_array< float, 2 > SR650_ALL_L
Definition: DbLutNetcdf.h:98
int read_land_aero_file(dbLandAerosolLUT *lut, const string strType)
const string INPUT_AERO_LAND_DUST
Definition: DDOptions.cpp:93
float stderr_670[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:258
boost::multi_array< float, 2 > SR470_FWD_L
Definition: DbLutNetcdf.h:97
float NVALX21_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:180
NcDim dim_nvza_
Definition: DbLutNetcdf.h:564
int write_ocean_aero_lut(NcFile *nc_output, dbOceanAerosolLUT *lut, const string strType)
short REGION_INDEX[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:229
Extra metadata that will be written to the HDF4 file l2prod rank
int read_geozone_lut(dbGeozoneLUT *lut)
float SZA672_Nodes[NSZA]
Definition: DbLutNetcdf.h:364
float TX21_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:183
boost::multi_array< float, 4 > SC412_FWD_L
Definition: DbLutNetcdf.h:219
NcDim dim_7200_
Definition: DbLutNetcdf.h:580
float coarse_asy[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:345
float min_2250_for_488[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:250
int write_landcover_lut(NcFile *nc_output, dbLandcoverLUT *lut)
NcDim dim_20800_
Definition: DbLutNetcdf.h:551
NcDim dim_nws_
Definition: DbLutNetcdf.h:591
float GEOZONE_FLAG[NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:234
float SR488_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:196
string time_coverage_end_
Definition: DbLutNetcdf.h:427
int read_ocean_aero_file(dbOceanAerosolLUT *lut, const string strType)
int write_rayleigh_lut(NcFile *nc_output, dbRayleighLUT *lut)
boost::multi_array< float, 4 > SC412_ALL_L
Definition: DbLutNetcdf.h:218
float RAA672_Nodes[NRAA]
Definition: DbLutNetcdf.h:366
boost::multi_array< float, 3 > fine_asy
Definition: DbLutNetcdf.h:308
const string INPUT_AERO_OCEAN_DUST
Definition: DDOptions.cpp:94
float LOGI0[MTABLE_20800]
Definition: DbLutNetcdf.h:167
float stderr_488[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:257
float SR670_ALL[NSEASONS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:197
boost::multi_array< float, 7 > m03
Definition: DbLutNetcdf.h:285
float SC412_ALL[NSEASONS][NNDVI][NTERMS][NLATS *10][NLONS *10]
Definition: DbLutNetcdf.h:209
float AOT488_Nodes[NTAU]
Definition: DbLutNetcdf.h:360
NcDim dim_nssa_
Definition: DbLutNetcdf.h:567
float fine_ssa[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:341
double x[NUMX]
Definition: DbLutNetcdf.h:377
const string INPUT_LANDCOVER
Definition: DDOptions.cpp:101
int write_modis_surf_refl_lut(NcFile *nc_output, dbModisSurfReflLUT *lut)
string institution_
Definition: DbLutNetcdf.h:408
const string INPUT_GEOZONE
Definition: DDOptions.cpp:103
float TX672_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:187
const string INPUT_VIIRS_SURF_REFL
Definition: DDOptions.cpp:106
const string INPUT_BATHYMETRY
Definition: DDOptions.cpp:98
float ae[NFMF3][NAOT1]
Definition: DbLutNetcdf.h:336
const string LUT_LAND_AEROSOL_FINE
Definition: DDOptions.cpp:147
float R0X672_SFC[NSEASONS][NRAA][NVZA][NSZAV]
Definition: DbLutNetcdf.h:185
string source_files_
Definition: DbLutNetcdf.h:425
float aot[NDBOWL][NFMF3][NAOT1]
Definition: DbLutNetcdf.h:337
NcDim dim_2160_
Definition: DbLutNetcdf.h:561
float SURFACE_PRESSURE[SP_SETS *SP_720][SP_SETS *SP_360]
Definition: DbLutNetcdf.h:124
int read_chl_lut(dbChlLUT *lut)
int i
Definition: decode_rs.h:71
const string LUT_LAND_AEROSOL_DUST
Definition: DDOptions.cpp:148
boost::multi_array< float, 3 > coarse_ssa
Definition: DbLutNetcdf.h:306
boost::multi_array< float, 6 > m08
Definition: DbLutNetcdf.h:289
double time[NMONTHS]
Definition: DbLutNetcdf.h:385
int write_surf_coeff_lut(NcFile *nc_output, dbSurfCoeffLUT *lut)
boost::multi_array< float, 3 > fine_aot
Definition: DbLutNetcdf.h:302
string stdname_vocabulary_
Definition: DbLutNetcdf.h:413
boost::multi_array< float, 3 > aot
Definition: DbLutNetcdf.h:301
const string INPUT_SWIR
Definition: DDOptions.cpp:108
float raa[NVRAA]
Definition: DbLutNetcdf.h:330
float coeffs_2250_to_670[NSEASONS][NSCOEF][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:247
const string INPUT_NVALX_470
Definition: DDOptions.cpp:80
float wspd[NWS]
Definition: DbLutNetcdf.h:333
float m08[NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:325
const string INPUT_AERO_OCEAN_MIX
Definition: DDOptions.cpp:97
string project_
Definition: DbLutNetcdf.h:417
float RAYL_650[NRRAA][NVZA][NSZA][NSTOKES]
Definition: DbLutNetcdf.h:155
string creator_url_
Definition: DbLutNetcdf.h:416
NcDim dim_nraa_
Definition: DbLutNetcdf.h:565
static void byteSwap(T &aValue)
Definition: DbLutNetcdf.h:614
float VZA672_Nodes[NVZA]
Definition: DbLutNetcdf.h:365
const string INPUT_VEG_21SFC
Definition: DDOptions.cpp:110
NcDim dim_1800_
Definition: DbLutNetcdf.h:578
NcDim dim_ssa412_
Definition: DbLutNetcdf.h:569
boost::multi_array< float, 2 > SR670_ALL_L
Definition: DbLutNetcdf.h:204
string license_
Definition: DbLutNetcdf.h:409
float data_num_total[NSEASONS][NSLATS][NSLONS]
Definition: DbLutNetcdf.h:254
const string LUT_NVALX
Definition: DDOptions.cpp:133
boost::multi_array< float, 3 > fine_ssa
Definition: DbLutNetcdf.h:305
const string INPUT_SEASONAL_DESERTS
Definition: DDOptions.cpp:104
boost::multi_array< float, 4 > SC470_ALL_L
Definition: DbLutNetcdf.h:220
int read_landcover_files(dbLandcoverLUT *lut)
NcDim dim_3000_
Definition: DbLutNetcdf.h:576
boost::multi_array< float, 2 > SR412_ALL_L
Definition: DbLutNetcdf.h:94
float m04[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA]
Definition: DbLutNetcdf.h:322
boost::multi_array< float, 6 > m11
Definition: DbLutNetcdf.h:291
int write_veg_21sfc_lut(NcFile *nc_output, dbVeg_21sfcLUT *lut)
boost::multi_array< float, 2 > ae
Definition: DbLutNetcdf.h:300