27 const int chindx[8] = { 1,2,3,4,5,6,10,11 };
72 int istatus = DTDB_SUCCESS;
76 string filepath =
path +
"/VIIRS_DEEPBLUE_LUT_" +
"version_source" +
".nc";
81 nc_output =
new NcFile(
filepath, NcFile::replace );
83 catch( NcException& e) {
85 cerr <<
"DbLutNetcdf:: Failure creating netCDF4 LUT file: " +
filepath +
"." << endl;
88 nc_output->putAtt(
"title",
"VIIRS DEEP BLUE LUTs" );
93 cerr <<
"DbLutNetcdf:: Begin moving LUTs to NetCDF4 LUT file" << endl;
97 if ( istatus != DTDB_SUCCESS ) {
98 cerr <<
"DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
102 if ( istatus != DTDB_SUCCESS ) {
103 cerr <<
"DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
107 if (istatus == DTDB_SUCCESS) {
113 if ( istatus != DTDB_SUCCESS ) {
114 cerr <<
"DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
118 if ( istatus != DTDB_SUCCESS ) {
119 cerr <<
"DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
123 if (istatus == DTDB_SUCCESS) {
129 if ( istatus != DTDB_SUCCESS ) {
130 cerr <<
"DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
134 if ( istatus != DTDB_SUCCESS ) {
135 cerr <<
"DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
139 if (istatus == DTDB_SUCCESS) {
145 if ( istatus != DTDB_SUCCESS ) {
146 cerr <<
"DbLutNetcdf:: Failure reading VIIRS Ocean Aerosol LUT file " << endl;
150 if ( istatus != DTDB_SUCCESS ) {
151 cerr <<
"DbLutNetcdf:: Failure writing VIIRS Ocean Aerosol data to netCDF4 LUT file " << endl;
155 if (istatus == DTDB_SUCCESS) {
161 if ( istatus != DTDB_SUCCESS ) {
162 cerr <<
"DbLutNetcdf:: Failure reading Land Aerosol LUT file " << endl;
167 if ( istatus != DTDB_SUCCESS ) {
168 cerr <<
"DbLutNetcdf:: Failure writing Land Aerosol data to netCDF4 LUT file " << endl;
172 if (istatus == DTDB_SUCCESS) {
178 if ( istatus != DTDB_SUCCESS ) {
179 cerr <<
"DbLutNetcdf:: Failure reading Land Aerosol LUT file " << endl;
184 if ( istatus != DTDB_SUCCESS ) {
185 cerr <<
"DbLutNetcdf:: Failure writing Land Aerosol data to netCDF4 LUT file " << endl;
189 if (istatus == DTDB_SUCCESS) {
195 if ( istatus != DTDB_SUCCESS ) {
196 cerr <<
"DbLutNetcdf:: Failure reading bathymetry LUT file " << endl;
200 if ( istatus != DTDB_SUCCESS ) {
201 cerr <<
"DbLutNetcdf:: Failure writing bathymetry data to netCDF4 LUT file " << endl;
205 if (istatus == DTDB_SUCCESS) {
211 if ( istatus != DTDB_SUCCESS ) {
212 cerr <<
"DbLutNetcdf:: Failure reading CHL LUT file " << endl;
216 if ( istatus != DTDB_SUCCESS ) {
217 cerr <<
"DbLutNetcdf:: Failure writing CHL data to netCDF4 LUT file " << endl;
221 if (istatus == DTDB_SUCCESS) {
223 cerr <<
"DbLutNetcdf:: Created " +
LUT_CHL << endl;
227 if ( istatus != DTDB_SUCCESS ) {
228 cerr <<
"DbLutNetcdf:: Failure reading LER tables file " << endl;
232 if ( istatus != DTDB_SUCCESS ) {
233 cerr <<
"DbLutNetcdf:: Failure writing LER tables to netCDF4 LUT file " << endl;
237 if (istatus == DTDB_SUCCESS) {
243 if ( istatus != DTDB_SUCCESS ) {
244 cerr <<
"DbLutNetcdf:: Failure reading Landcover LUT file " << endl;
248 if ( istatus != DTDB_SUCCESS ) {
249 cerr <<
"DbLutNetcdf:: Failure writing Landcover data to netCDF4 LUT file " << endl;
253 if (istatus == DTDB_SUCCESS) {
259 if ( istatus != DTDB_SUCCESS ) {
260 cerr <<
"DbLutNetcdf:: Failure reading geozone LUT file " << endl;
264 if ( istatus != DTDB_SUCCESS ) {
265 cerr <<
"DbLutNetcdf:: Failure writing geozone data to netCDF4 LUT file " << endl;
269 if (istatus == DTDB_SUCCESS) {
271 cerr <<
"DbLutNetcdf:: Created " +
LUT_GEOZONE << endl;
275 if ( istatus != DTDB_SUCCESS ) {
276 cerr <<
"DbLutNetcdf:: Failure reading surface reflectance LUT file " << endl;
280 if ( istatus != DTDB_SUCCESS ) {
281 cerr <<
"DbLutNetcdf:: Failure writing surface reflectance data to netCDF4 LUT file " << endl;
285 if (istatus == DTDB_SUCCESS) {
291 if ( istatus != DTDB_SUCCESS ) {
292 cerr <<
"DbLutNetcdf:: Failure reading surface reflectance LUT file " << endl;
296 if ( istatus != DTDB_SUCCESS ) {
297 cerr <<
"DbLutNetcdf:: Failure writing surface reflectance data to netCDF4 LUT file " << endl;
301 if (istatus == DTDB_SUCCESS) {
307 if ( istatus != DTDB_SUCCESS ) {
308 cerr <<
"DbLutNetcdf:: Failure reading surface coefficients LUT file " << endl;
312 if ( istatus != DTDB_SUCCESS ) {
313 cerr <<
"DbLutNetcdf:: Failure writing surface coefficients data to netCDF4 LUT file " << endl;
317 if (istatus == DTDB_SUCCESS) {
323 if ( istatus != DTDB_SUCCESS ) {
324 cerr <<
"DbLutNetcdf:: Failure reading surface pressure LUT file " << endl;
328 if ( istatus != DTDB_SUCCESS ) {
329 cerr <<
"DbLutNetcdf:: Failure writing surface pressure data to netCDF4 LUT file " << endl;
333 if (istatus == DTDB_SUCCESS) {
339 if ( istatus != DTDB_SUCCESS ) {
340 cerr <<
"DbLutNetcdf:: Failure reading VIIRS SWIR LUT file " << endl;
344 if ( istatus != DTDB_SUCCESS ) {
345 cerr <<
"DbLutNetcdf:: Failure writing VIIRS SWIR data to netCDF4 LUT file " << endl;
349 if (istatus == DTDB_SUCCESS) {
351 cerr <<
"DbLutNetcdf:: Created " +
LUT_SWIR << endl;
356 if ( istatus != DTDB_SUCCESS ) {
357 cerr <<
"DbLutNetcdf:: Failure reading veg_21sfc LUT files " << endl;
361 if ( istatus != DTDB_SUCCESS ) {
362 cerr <<
"DbLutNetcdf:: Failure writing veg_21sfc data to netCDF4 LUT file " << endl;
366 if (istatus == DTDB_SUCCESS) {
368 cerr <<
"DbLutNetcdf:: Created " +
LUT_NVALX21 << endl;
372 if (
status == DTDB_SUCCESS) {
388 int status = DTDB_SUCCESS;
392 cerr <<
"DbLutNetcdf::read_tables_file() Invalid path." << endl;
395 bool isFileBigEndian =
true;
396 std::ifstream fin(
filepath.c_str(), std::ios::in | std::ios::binary);
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();
410 "DbLutNetcdf::read_tables_file() Error reading binary file "
416 cerr <<
"DbLutNetcdf::read_tables_file() Error opening binary file "
421 for (
int i=0;
i<MTABLE_20800;
i++) {
427 for (
int i=0;
i<MTABLE_260;
i++) {
430 for (
int i=0;
i<MTABLE_160;
i++) {
436 for (
int i=0;
i<MTABLE_2;
i++) {
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 );
461 NcVar var = lut_grp.addVar(
"LOGI0", ncFloat,
dim_20800_ );
462 var.putVar( mt_lut->
LOGI0 );
464 var = lut_grp.addVar(
"Z1I0", ncFloat,
dim_20800_ );
465 var.putVar( mt_lut->
Z1I0 );
467 var = lut_grp.addVar(
"Z2I0", ncFloat,
dim_20800_ );
468 var.putVar( mt_lut->
Z2I0 );
470 var = lut_grp.addVar(
"TI0", ncFloat,
dim_20800_ );
471 var.putVar( mt_lut->
TI0 );
473 var = lut_grp.addVar(
"SB", ncFloat,
dim_260_ );
474 var.putVar( mt_lut->
SB );
476 var = lut_grp.addVar(
"LOGI0R", ncFloat,
dim_160_ );
477 var.putVar( mt_lut->
LOGI0R );
479 var = lut_grp.addVar(
"Z1I0R", ncFloat,
dim_160_ );
480 var.putVar( mt_lut->
Z1I0R );
482 var = lut_grp.addVar(
"Z2I0R", ncFloat,
dim_160_ );
483 var.putVar( mt_lut->
Z2I0R );
485 var = lut_grp.addVar(
"TI0R", ncFloat,
dim_160_ );
486 var.putVar( mt_lut->
TI0R );
488 var = lut_grp.addVar(
"SBR", ncFloat,
dim_2_ );
489 var.putVar( mt_lut->
SBR );
505 int status = DTDB_SUCCESS;
513 nc_input =
new NcFile(
filepath, NcFile::read );
515 catch( NcException& e) {
517 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
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 );
556 int status = DTDB_SUCCESS;
560 cerr <<
"DbLutNetcdf::read_surface_pressure_file() Invalid path." << endl;
567 catch( std::exception& e) {
569 cerr <<
"DbLutNetcdf:: Failure opening surface pressure file: " +
filepath << endl;
572 int sds_index, sds_id, numtype,
rank, nattrs;
578 string sds_name =
"ps";
579 sds_index = SDnametoindex(
fileID, sds_name.c_str());
581 cerr <<
"DbLutNetcdf::read_surface_pressure_file() " <<
582 "SDnametoindex() failure for "<< sds_name << endl;
586 sds_id = SDselect(
fileID, sds_index);
587 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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());
595 cerr <<
"DbLutNetcdf::read_surface_pressure_file() " <<
596 "SDnametoindex() failure for "<< sds_name << endl;
600 sds_id = SDselect(
fileID, sds_index);
601 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
604 sds_name =
"surface_elevation";
605 sds_index = SDnametoindex(
fileID, sds_name.c_str());
607 cerr <<
"DbLutNetcdf::read_surface_pressure_file() " <<
608 "SDnametoindex() failure for "<< sds_name << endl;
612 sds_id = SDselect(
fileID, sds_index);
613 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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 );
636 vector<NcDim> small_dims;
640 vector<NcDim> big_dims;
644 NcVar var = lut_grp.addVar(
"PS", ncFloat, small_dims );
645 var.putVar( sp_lut->
PS );
647 var = lut_grp.addVar(
"SURFACE_PRESSURE", ncFloat, big_dims );
650 var = lut_grp.addVar(
"SURFACE_ELEVATION", ncFloat, big_dims );
665 int status = DTDB_SUCCESS;
673 nc_input =
new NcFile(
filepath, NcFile::read );
675 catch( NcException& e) {
677 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
682 NcVar var = lut_grp.getVar(
"PS" );
683 var.getVar( sp_lut->
PS );
685 var = lut_grp.getVar(
"SURFACE_PRESSURE" );
688 var = lut_grp.getVar(
"SURFACE_ELEVATION" );
705 int status = DTDB_SUCCESS;
707 const int RECORD_DELIMITER_LENGTH = 4;
711 cerr <<
"DbLutNetcdf::read_nvalx_file() Invalid path." << endl;
714 bool isFileBigEndian =
false;
715 std::ifstream fin1(
filepath.c_str(), std::ios::in | std::ios::binary);
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();
724 "DbLutNetcdf::read_nvalx_file() Error reading binary file "
730 cerr <<
"DbLutNetcdf::read_nvalx_file() Error opening binary file "
737 cerr <<
"DbLutNetcdf::read_nvalx_file() Invalid path." << endl;
740 isFileBigEndian =
false;
741 std::ifstream fin2(
filepath.c_str(), std::ios::in | std::ios::binary);
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();
750 "DbLutNetcdf::read_nvalx_file() Error reading binary file "
756 cerr <<
"DbLutNetcdf::read_nvalx_file() Error opening binary file "
763 cerr <<
"DbLutNetcdf::read_nvalx_file() Invalid path." << endl;
766 isFileBigEndian =
false;
767 std::ifstream fin3(
filepath.c_str(), std::ios::in | std::ios::binary);
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();
776 "DbLutNetcdf::read_nvalx_file() Error reading binary file "
782 cerr <<
"DbLutNetcdf::read_nvalx_file() Error opening binary file "
803 NcGroup lut_grp = nc_output->addGroup(
LUT_NVALX );
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 );
815 vector<NcDim> nvalx412_dims;
823 vector<NcDim> nvalx470_dims;
831 vector<NcDim> nvalx650_dims;
838 NcVar var = lut_grp.addVar(
"NVALX_412", ncFloat, nvalx412_dims );
841 var = lut_grp.addVar(
"NVALX_470", ncFloat, nvalx470_dims );
844 var = lut_grp.addVar(
"NVALX_650", ncFloat, nvalx650_dims );
859 int status = DTDB_SUCCESS;
867 nc_input =
new NcFile(
filepath, NcFile::read );
869 catch( NcException& e) {
871 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
874 NcGroup lut_grp = nc_input->getGroup(
LUT_NVALX );
876 NcVar var = lut_grp.getVar(
"NVALX_412" );
879 var = lut_grp.getVar(
"NVALX_470" );
882 var = lut_grp.getVar(
"NVALX_650" );
899 int status = DTDB_SUCCESS;
904 cerr <<
"DbLutNetcdf::read_nvalx21_file() Invalid path." << endl;
911 catch( std::exception& e) {
913 cerr <<
"DbLutNetcdf:: Failure opening nvalx21 file: " +
filepath << endl;
916 int sds_index, sds_id, numtype,
rank, nattrs;
927 string sds_name =
"NVALX21_SFC";
928 sds_index = SDnametoindex(
fileID, sds_name.c_str());
930 cerr <<
"DbLutNetcdf::read_nvalx21_file() " <<
931 "SDnametoindex() failure for "<< sds_name << endl;
935 sds_id = SDselect(
fileID, sds_index);
936 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
939 sds_name =
"R0X21_SFC";
940 sds_index = SDnametoindex(
fileID, sds_name.c_str());
942 cerr <<
"DbLutNetcdf::read_nvalx21_file() " <<
943 "SDnametoindex() failure for "<< sds_name << endl;
947 sds_id = SDselect(
fileID, sds_index);
948 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
951 sds_name =
"SX21_SFC";
952 sds_index = SDnametoindex(
fileID, sds_name.c_str());
954 cerr <<
"DbLutNetcdf::read_nvalx21_file() " <<
955 "SDnametoindex() failure for "<< sds_name << endl;
959 sds_id = SDselect(
fileID, sds_index);
960 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
963 sds_name =
"TX21_SFC";
964 sds_index = SDnametoindex(
fileID, sds_name.c_str());
966 cerr <<
"DbLutNetcdf::read_nvalx21_file() " <<
967 "SDnametoindex() failure for "<< sds_name << endl;
971 sds_id = SDselect(
fileID, sds_index);
972 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
975 sds_name =
"NVALX672_SFC";
976 sds_index = SDnametoindex(
fileID, sds_name.c_str());
978 cerr <<
"DbLutNetcdf::read_nvalx21_file() " <<
979 "SDnametoindex() failure for "<< sds_name << endl;
983 sds_id = SDselect(
fileID, sds_index);
984 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
987 sds_name =
"R0X672_SFC";
988 sds_index = SDnametoindex(
fileID, sds_name.c_str());
990 cerr <<
"DbLutNetcdf::read_nvalx21_file() " <<
991 "SDnametoindex() failure for "<< sds_name << endl;
995 sds_id = SDselect(
fileID, sds_index);
996 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1007 sds_id = SDselect(
fileID, sds_index);
1008 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1019 sds_id = SDselect(
fileID, sds_index);
1020 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1031 sds_id = SDselect(
fileID, sds_index);
1032 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1043 sds_id = SDselect(
fileID, sds_index);
1044 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1055 sds_id = SDselect(
fileID, sds_index);
1056 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1067 sds_id = SDselect(
fileID, sds_index);
1068 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
1084 NcGroup lut_grp = nc_output->addGroup(
LUT_NVALX21 );
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 );
1091 vector<NcDim> nvalx21_dims;
1092 nvalx21_dims.push_back(
dim_4_);
1097 NcVar var = lut_grp.addVar(
"NVALX21_SFC", ncFloat, nvalx21_dims );
1100 var = lut_grp.addVar(
"R0X21_SFC", ncFloat, nvalx21_dims );
1103 var = lut_grp.addVar(
"SX21_SFC", ncFloat, nvalx21_dims );
1106 var = lut_grp.addVar(
"TX21_SFC", ncFloat, nvalx21_dims );
1109 var = lut_grp.addVar(
"NVALX672_SFC", ncFloat, nvalx21_dims );
1112 var = lut_grp.addVar(
"R0X672_SFC", ncFloat, nvalx21_dims );
1115 var = lut_grp.addVar(
"SX672_SFC", ncFloat, nvalx21_dims );
1118 var = lut_grp.addVar(
"TX672_SFC", ncFloat, nvalx21_dims );
1121 var = lut_grp.addVar(
"NVALX865_SFC", ncFloat, nvalx21_dims );
1124 var = lut_grp.addVar(
"R0X865_SFC", ncFloat, nvalx21_dims );
1127 var = lut_grp.addVar(
"SX865_SFC", ncFloat, nvalx21_dims );
1130 var = lut_grp.addVar(
"TX865_SFC", ncFloat, nvalx21_dims );
1133 return DTDB_SUCCESS;
1145 int status = DTDB_SUCCESS;
1153 nc_input =
new NcFile(
filepath, NcFile::read );
1155 catch( NcException& e) {
1157 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
1160 NcGroup lut_grp = nc_input->getGroup(
LUT_NVALX21 );
1162 NcVar var = lut_grp.getVar(
"NVALX21_SFC" );
1165 var = lut_grp.getVar(
"R0X21_SFC" );
1168 var = lut_grp.getVar(
"SX21_SFC" );
1171 var = lut_grp.getVar(
"TX21_SFC" );
1174 var = lut_grp.getVar(
"NVALX672_SFC" );
1177 var = lut_grp.getVar(
"R0X672_SFC" );
1180 var = lut_grp.getVar(
"SX672_SFC" );
1183 var = lut_grp.getVar(
"TX672_SFC" );
1186 var = lut_grp.getVar(
"NVALX865_SFC" );
1189 var = lut_grp.getVar(
"R0X865_SFC" );
1192 var = lut_grp.getVar(
"SX865_SFC" );
1195 var = lut_grp.getVar(
"TX865_SFC" );
1212 int status = DTDB_SUCCESS;
1216 cerr <<
"DbLutNetcdf::read_modis_surf_refl_file() Invalid path." << endl;
1223 if (
pos != string::npos) {
1229 cerr <<
"DbLutNetcdf:: Could not identify season in file name: " +
filepath << endl;
1237 fileID = SDstart(rfilepath.c_str(), DFACC_READ );
1239 catch( std::exception& e) {
1241 cerr <<
"DbLutNetcdf:: Failure opening modis surface refl file: " + rfilepath << endl;
1244 int sds_index, sds_id, numtype,
rank, nattrs;
1248 edges[0] = NLATS*10;
1249 edges[1] = NLONS*10;
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;
1259 sds_id = SDselect(
fileID, sds_index);
1260 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1271 sds_id = SDselect(
fileID, sds_index);
1272 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1283 sds_id = SDselect(
fileID, sds_index);
1284 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1296 sds_id = SDselect(
fileID, sds_index);
1297 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
1319 dim_1800_ = lut_grp.addDim(
"Dim_1800", NLATS*10 );
1320 dim_3600_ = lut_grp.addDim(
"Dim_3600", NLONS*10 );
1322 vector<NcDim> latlon_dims;
1326 vector<NcDim> slatlon_dims;
1331 NcVar var = lut_grp.addVar(
"SR412_ALL", ncFloat, slatlon_dims );
1334 var = lut_grp.addVar(
"SR470_ALL", ncFloat, slatlon_dims );
1337 var = lut_grp.addVar(
"SR650_ALL", ncFloat, slatlon_dims );
1340 var = lut_grp.addVar(
"SR412_FWD", ncFloat, slatlon_dims );
1343 var = lut_grp.addVar(
"SR470_FWD", ncFloat, slatlon_dims );
1346 var = lut_grp.addVar(
"SR650_FWD", ncFloat, slatlon_dims );
1349 var = lut_grp.addVar(
"SR865_ALL", ncFloat, latlon_dims );
1352 return DTDB_SUCCESS;
1363 int*
start,
int* edge,
int &season,
int &dateline )
1365 int status = DTDB_SUCCESS;
1373 nc_input =
new NcFile(
filepath, NcFile::read );
1375 catch( NcException& e) {
1377 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
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]]);
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]);
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] );
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] );
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] );
1461 int status = DTDB_SUCCESS;
1465 cerr <<
"DbLutNetcdf::read_surf_refl_file() Invalid path." << endl;
1472 if (
pos != string::npos) {
1478 cerr <<
"DbLutNetcdf:: Could not identify season in file name: " +
filepath << endl;
1486 fileID = SDstart(rfilepath.c_str(), DFACC_READ );
1488 catch( std::exception& e) {
1490 cerr <<
"DbLutNetcdf:: Failure opening surface refl file: " + rfilepath << endl;
1493 int sds_index, sds_id, numtype,
rank, nattrs;
1497 edges[0] = NLATS*10;
1498 edges[1] = NLONS*10;
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;
1508 sds_id = SDselect(
fileID, sds_index);
1509 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1520 sds_id = SDselect(
fileID, sds_index);
1521 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1532 sds_id = SDselect(
fileID, sds_index);
1533 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
1538 cerr <<
"DbLutNetcdf::read_landcover_file() Invalid path." << endl;
1544 catch( std::exception& e) {
1546 cerr <<
"DbLutNetcdf:: Failure opening brdf file: " +
filepath << endl;
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;
1561 sds_id = SDselect(
fileID, sds_index);
1562 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
1584 dim_1800_ = lut_grp.addDim(
"Dim_1800", NLATS*10 );
1585 dim_3600_ = lut_grp.addDim(
"Dim_3600", NLONS*10 );
1587 vector<NcDim> latlon_dims;
1591 vector<NcDim> slatlon_dims;
1596 NcVar var = lut_grp.addVar(
"SR412_ALL", ncFloat, slatlon_dims );
1599 var = lut_grp.addVar(
"SR488_ALL", ncFloat, slatlon_dims );
1602 var = lut_grp.addVar(
"SR670_ALL", ncFloat, slatlon_dims );
1605 var = lut_grp.addVar(
"BRDF_650", ncFloat, latlon_dims );
1608 return DTDB_SUCCESS;
1619 int*
start,
int* edge,
int &season,
int &dateline )
1621 int status = DTDB_SUCCESS;
1629 nc_input =
new NcFile(
filepath, NcFile::read );
1631 catch( NcException& e) {
1633 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
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]]);
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]);
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] );
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] );
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] );
1696 int status = DTDB_SUCCESS;
1700 cerr <<
"DbLutNetcdf::read_surf_coeff_file() Invalid path." << endl;
1707 if (
pos != string::npos) {
1713 cerr <<
"DbLutNetcdf:: Could not identify season in file name: " +
filepath << endl;
1721 fileID = SDstart(rfilepath.c_str(), DFACC_READ );
1723 catch( std::exception& e) {
1725 cerr <<
"DbLutNetcdf:: Failure opening surface coeff file: " + rfilepath << endl;
1728 int sds_index, sds_id, numtype,
rank, nattrs;
1736 edges[2] = NLATS*10;
1737 edges[3] = NLONS*10;
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;
1747 sds_id = SDselect(
fileID, sds_index);
1748 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1759 sds_id = SDselect(
fileID, sds_index);
1760 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1772 sds_id = SDselect(
fileID, sds_index);
1773 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1784 sds_id = SDselect(
fileID, sds_index);
1785 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1797 sds_id = SDselect(
fileID, sds_index);
1798 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
1809 sds_id = SDselect(
fileID, sds_index);
1810 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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 );
1837 vector<NcDim> latlon_dims;
1844 NcVar var = lut_grp.addVar(
"SC412_ALL", ncFloat, latlon_dims );
1847 var = lut_grp.addVar(
"SC412_FWD", ncFloat, latlon_dims );
1850 var = lut_grp.addVar(
"SC470_ALL", ncFloat, latlon_dims );
1853 var = lut_grp.addVar(
"SC470_FWD", ncFloat, latlon_dims );
1856 var = lut_grp.addVar(
"SC650_ALL", ncFloat, latlon_dims );
1859 var = lut_grp.addVar(
"SC650_FWD", ncFloat, latlon_dims );
1862 return DTDB_SUCCESS;
1873 int* edge,
int &season,
int &dateline )
1875 int status = DTDB_SUCCESS;
1883 nc_input =
new NcFile(
filepath, NcFile::read );
1885 catch( NcException& e) {
1887 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
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]]);
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]);
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] );
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] );
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] );
1968 int status = DTDB_SUCCESS;
1973 if(filepath1.empty() || filepath2.empty() || filepath3.empty()) {
1974 cerr <<
"DbLutNetcdf::read_rayleigh_file() Invalid path." << endl;
1977 bool isFileBigEndian =
false;
1978 string line1, line2, line3;
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];
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];
2015 cerr <<
"DbLutNetcdf::read_rayleigh_file() Error opening file "
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++) {
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 );
2054 vector<NcDim> rayl_dims;
2060 NcVar var = lut_grp.addVar(
"RAYL_412", ncFloat, rayl_dims );
2063 var = lut_grp.addVar(
"RAYL_470", ncFloat, rayl_dims );
2066 var = lut_grp.addVar(
"RAYL_650", ncFloat, rayl_dims );
2069 return DTDB_SUCCESS;
2081 int status = DTDB_SUCCESS;
2089 nc_input =
new NcFile(
filepath, NcFile::read );
2091 catch( NcException& e) {
2093 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
2098 NcVar var = lut_grp.getVar(
"RAYL_412" );
2101 var = lut_grp.getVar(
"NVALX_470" );
2104 var = lut_grp.getVar(
"NVALX_650" );
2121 int status = DTDB_SUCCESS;
2125 cerr <<
"DbLutNetcdf::read_landcover_file() Invalid path." << endl;
2132 catch( std::exception& e) {
2134 cerr <<
"DbLutNetcdf:: Failure opening landcover file: " +
filepath << endl;
2137 int sds_index, sds_id, numtype,
rank, nattrs;
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;
2151 sds_id = SDselect(
fileID, sds_index);
2152 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
2157 cerr <<
"DbLutNetcdf::read_landcover_file() Invalid path." << endl;
2163 catch( std::exception& e) {
2165 cerr <<
"DbLutNetcdf:: Failure opening global IGBP file: " +
filepath << endl;
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;
2180 sds_id = SDselect(
fileID, sds_index);
2181 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2192 sds_id = SDselect(
fileID, sds_index);
2193 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
2198 cerr <<
"DbLutNetcdf::read_landcover_files() Invalid path." << endl;
2204 catch( std::exception& e) {
2206 cerr <<
"DbLutNetcdf:: Failure opening seasonal deserts file: " +
filepath << endl;
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;
2221 sds_id = SDselect(
fileID, sds_index);
2222 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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 );
2244 vector<NcDim> vegie_dims;
2248 vector<NcDim> latlon_dims;
2252 NcVar var = lut_grp.addVar(
"VEGETATION", ncInt, vegie_dims );
2255 var = lut_grp.addVar(
"IGBP", ncShort, latlon_dims );
2256 var.putVar( lc_lut->
IGBP );
2258 var = lut_grp.addVar(
"REGION_INDEX", ncShort, latlon_dims );
2261 var = lut_grp.addVar(
"DESERTS_FLAG", ncFloat, latlon_dims );
2264 return DTDB_SUCCESS;
2276 int status = DTDB_SUCCESS;
2284 nc_input =
new NcFile(
filepath, NcFile::read );
2286 catch( NcException& e) {
2288 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
2293 NcVar var = lut_grp.getVar(
"VEGETATION" );
2296 var = lut_grp.getVar(
"IGBP" );
2297 var.getVar( lc_lut->
IGBP );
2299 var = lut_grp.getVar(
"REGION_INDEX" );
2302 var = lut_grp.getVar(
"DESERTS_FLAG" );
2319 int status = DTDB_SUCCESS;
2323 cerr <<
"DbLutNetcdf::read_swir_file() Invalid path." << endl;
2330 if (
pos != string::npos) {
2336 cerr <<
"DbLutNetcdf:: Could not identify season in file name: " +
filepath << endl;
2344 fileID = SDstart(rfilepath.c_str(), DFACC_READ );
2346 catch( std::exception& e) {
2348 cerr <<
"DbLutNetcdf:: Failure opening swir file: " + rfilepath << endl;
2351 int sds_index, sds_id, numtype,
rank, nattrs;
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;
2366 sds_id = SDselect(
fileID, sds_index);
2367 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2377 sds_id = SDselect(
fileID, sds_index);
2378 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2391 sds_id = SDselect(
fileID, sds_index);
2392 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2402 sds_id = SDselect(
fileID, sds_index);
2403 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2413 sds_id = SDselect(
fileID, sds_index);
2414 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2426 sds_id = SDselect(
fileID, sds_index);
2427 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2437 sds_id = SDselect(
fileID, sds_index);
2438 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2448 sds_id = SDselect(
fileID, sds_index);
2449 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2459 sds_id = SDselect(
fileID, sds_index);
2460 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2470 sds_id = SDselect(
fileID, sds_index);
2471 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2481 sds_id = SDselect(
fileID, sds_index);
2482 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2492 sds_id = SDselect(
fileID, sds_index);
2493 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2503 sds_id = SDselect(
fileID, sds_index);
2504 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2514 sds_id = SDselect(
fileID, sds_index);
2515 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2525 sds_id = SDselect(
fileID, sds_index);
2526 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2536 sds_id = SDselect(
fileID, sds_index);
2537 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
2554 NcGroup lut_grp = nc_output->addGroup(
LUT_SWIR );
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 );
2561 vector<NcDim> coef_dims;
2563 coef_dims.push_back(
dim_3_);
2566 vector<NcDim> latlon_dims;
2571 NcVar var = lut_grp.addVar(
"latitude", ncFloat, latlon_dims );
2574 var = lut_grp.addVar(
"longitude", ncFloat, latlon_dims );
2577 var = lut_grp.addVar(
"coeffs_2250_to_412", ncFloat, coef_dims );
2580 var = lut_grp.addVar(
"coeffs_2250_to_488", ncFloat, coef_dims );
2583 var = lut_grp.addVar(
"coeffs_2250_to_670", ncFloat, coef_dims );
2586 var = lut_grp.addVar(
"min_2250_for_412", ncFloat, latlon_dims );
2589 var = lut_grp.addVar(
"max_2250_for_412", ncFloat, latlon_dims );
2592 var = lut_grp.addVar(
"min_2250_for_488", ncFloat, latlon_dims );
2595 var = lut_grp.addVar(
"max_2250_for_488", ncFloat, latlon_dims );
2598 var = lut_grp.addVar(
"min_2250_for_670", ncFloat, latlon_dims );
2601 var = lut_grp.addVar(
"max_2250_for_670", ncFloat, latlon_dims );
2604 var = lut_grp.addVar(
"data_num_total", ncFloat, latlon_dims );
2607 var = lut_grp.addVar(
"data_num_fitting", ncFloat, latlon_dims );
2610 var = lut_grp.addVar(
"stderr_412", ncFloat, latlon_dims );
2613 var = lut_grp.addVar(
"stderr_488", ncFloat, latlon_dims );
2616 var = lut_grp.addVar(
"stderr_670", ncFloat, latlon_dims );
2619 return DTDB_SUCCESS;
2631 int status = DTDB_SUCCESS;
2639 nc_input =
new NcFile(
filepath, NcFile::read );
2641 catch( NcException& e) {
2643 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
2646 NcGroup lut_grp = nc_input->getGroup(
LUT_SWIR );
2647 NcVar var = lut_grp.getVar(
"latitude" );
2649 var = lut_grp.getVar(
"longitude" );
2651 var = lut_grp.getVar(
"coeffs_2250_to_412" );
2653 var = lut_grp.getVar(
"coeffs_2250_to_488" );
2655 var = lut_grp.getVar(
"coeffs_2250_to_670" );
2657 var = lut_grp.getVar(
"min_2250_for_412" );
2659 var = lut_grp.getVar(
"max_2250_for_412" );
2661 var = lut_grp.getVar(
"min_2250_for_488" );
2663 var = lut_grp.getVar(
"max_2250_for_488" );
2665 var = lut_grp.getVar(
"min_2250_for_670" );
2667 var = lut_grp.getVar(
"max_2250_for_670" );
2669 var = lut_grp.getVar(
"data_num_total" );
2671 var = lut_grp.getVar(
"data_num_fitting" );
2673 var = lut_grp.getVar(
"stderr_412" );
2675 var = lut_grp.getVar(
"stderr_488" );
2677 var = lut_grp.getVar(
"stderr_670" );
2693 const string sType )
2695 int status = DTDB_SUCCESS;
2699 cerr <<
"DbLutNetcdf::read_ocean_aero_file() Invalid path." << endl;
2706 catch( std::exception& e) {
2708 cerr <<
"DbLutNetcdf:: Failure opening ocean aerosol file: " +
filepath << endl;
2727 int sds_index, sds_id, numtype,
rank, nattrs;
2729 int start[7] = {0,0,0,0,0,0,0};
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;
2740 sds_id = SDselect(
fileID, sds_index);
2741 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2751 sds_id = SDselect(
fileID, sds_index);
2752 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2762 sds_id = SDselect(
fileID, sds_index);
2763 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2773 sds_id = SDselect(
fileID, sds_index);
2774 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2790 sds_id = SDselect(
fileID, sds_index);
2791 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2801 sds_id = SDselect(
fileID, sds_index);
2802 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2812 sds_id = SDselect(
fileID, sds_index);
2813 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2824 sds_id = SDselect(
fileID, sds_index);
2825 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2836 sds_id = SDselect(
fileID, sds_index);
2837 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2848 sds_id = SDselect(
fileID, sds_index);
2849 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2860 sds_id = SDselect(
fileID, sds_index);
2861 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2872 sds_id = SDselect(
fileID, sds_index);
2873 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2884 sds_id = SDselect(
fileID, sds_index);
2885 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2896 sds_id = SDselect(
fileID, sds_index);
2897 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2908 sds_id = SDselect(
fileID, sds_index);
2909 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2922 sds_id = SDselect(
fileID, sds_index);
2923 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2936 sds_id = SDselect(
fileID, sds_index);
2937 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2947 sds_id = SDselect(
fileID, sds_index);
2948 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2958 sds_id = SDselect(
fileID, sds_index);
2959 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2969 sds_id = SDselect(
fileID, sds_index);
2970 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2980 sds_id = SDselect(
fileID, sds_index);
2981 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
2991 sds_id = SDselect(
fileID, sds_index);
2992 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
3002 sds_id = SDselect(
fileID, sds_index);
3003 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
3013 sds_id = SDselect(
fileID, sds_index);
3014 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
3024 sds_id = SDselect(
fileID, sds_index);
3025 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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;
3054 start = {0,0,0,0,0,0,0};
3056 NcVar var = lut_grp.addVar(
"IoverF_m03", ncFloat, ioverf_dims );
3058 var = lut_grp.addVar(
"IoverF_m04", ncFloat, ioverf_dims );
3060 var = lut_grp.addVar(
"IoverF_m05", ncFloat, ioverf_dims );
3062 var = lut_grp.addVar(
"IoverF_m07", ncFloat, ioverf_dims );
3066 var = lut_grp.addVar(
"IoverF_m08", ncFloat, ioverf_dims );
3068 var = lut_grp.addVar(
"IoverF_m10", ncFloat, ioverf_dims );
3070 var = lut_grp.addVar(
"IoverF_m11", ncFloat, ioverf_dims );
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_ );
3081 var = lut_grp.addVar(
"Fine_Mode_Fraction_550", ncFloat,
dim_nfmf_ );
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;
3093 var = lut_grp.addVar(
"Angstrom_Exponent", ncFloat, ae_dims );
3095 vector<NcDim> spectral_dims;
3098 var = lut_grp.addVar(
"Spectral_Total_AOD", ncFloat, spectral_dims );
3100 var = lut_grp.addVar(
"Spectral_Fine_AOD", ncFloat, spectral_dims );
3102 var = lut_grp.addVar(
"Spectral_Coarse_AOD", ncFloat, spectral_dims );
3104 var = lut_grp.addVar(
"Spectral_Total_SSA", ncFloat, spectral_dims );
3106 var = lut_grp.addVar(
"Spectral_Fine_SSA", ncFloat, spectral_dims );
3108 var = lut_grp.addVar(
"Spectral_Coarse_SSA", ncFloat, spectral_dims );
3110 var = lut_grp.addVar(
"Spectral_Total_ASY", ncFloat, spectral_dims );
3112 var = lut_grp.addVar(
"Spectral_Fine_ASY", ncFloat, spectral_dims );
3114 var = lut_grp.addVar(
"Spectral_Coarse_ASY", ncFloat, spectral_dims );
3117 return DTDB_SUCCESS;
3128 const string sType )
3130 int status = DTDB_SUCCESS;
3138 nc_input =
new NcFile(
filepath, NcFile::read );
3140 catch( NcException& e) {
3142 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
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" );
3167 lut->
m04.resize(boost::extents[NCHL][NWS][lut->
nfmf][lut->
naot][NVRAA][NVVZA][NVSZA]);
3168 var = lut_grp.getVar(
"IoverF_m04" );
3170 lut->
m05.resize(boost::extents[NCHL][NWS][lut->
nfmf][lut->
naot][NVRAA][NVVZA][NVSZA]);
3171 var = lut_grp.getVar(
"IoverF_m05" );
3173 lut->
m07.resize(boost::extents[NCHL][NWS][lut->
nfmf][lut->
naot][NVRAA][NVVZA][NVSZA]);
3174 var = lut_grp.getVar(
"IoverF_m07" );
3177 start = {0,0,0,0,0,0,0};
3179 lut->
m08.resize(boost::extents[NWS][lut->
nfmf][lut->
naot][NVRAA][NVVZA][NVSZA]);
3180 var = lut_grp.getVar(
"IoverF_m08" );
3182 lut->
m10.resize(boost::extents[NWS][lut->
nfmf][lut->
naot][NVRAA][NVVZA][NVSZA]);
3183 var = lut_grp.getVar(
"IoverF_m10" );
3185 lut->
m11.resize(boost::extents[NWS][lut->
nfmf][lut->
naot][NVRAA][NVVZA][NVSZA]);
3186 var = lut_grp.getVar(
"IoverF_m11" );
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] );
3216 lut->
ae.resize(boost::extents[lut->
nfmf][lut->
naot]);
3217 var = lut_grp.getVar(
"Angstrom_Exponent" );
3222 var = lut_grp.getVar(
"Spectral_Total_AOD" );
3225 var = lut_grp.getVar(
"Spectral_Fine_AOD" );
3228 var = lut_grp.getVar(
"Spectral_Coarse_AOD" );
3231 var = lut_grp.getVar(
"Spectral_Total_SSA" );
3234 var = lut_grp.getVar(
"Spectral_Fine_SSA" );
3237 var = lut_grp.getVar(
"Spectral_Coarse_SSA" );
3240 var = lut_grp.getVar(
"Spectral_Total_ASY" );
3243 var = lut_grp.getVar(
"Spectral_Fine_ASY" );
3246 var = lut_grp.getVar(
"Spectral_Coarse_ASY" );
3263 const string aero_input)
3265 int status = DTDB_SUCCESS;
3269 cerr <<
"DbLutNetcdf::read_aero_land_files() Invalid path." << endl;
3276 catch( std::exception& e) {
3278 cerr <<
"DbLutNetcdf:: Failure opening land aerosol file: " +
filepath << endl;
3281 int sds_index, sds_id, numtype,
rank, nattrs;
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);
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);
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);
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);
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);
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);
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;
3339 sds_id = SDselect(
fileID, sds_index);
3340 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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);
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);
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);
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);
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);
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);
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;
3393 sds_id = SDselect(
fileID, sds_index);
3394 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
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);
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);
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);
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);
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);
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);
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;
3447 sds_id = SDselect(
fileID, sds_index);
3448 SDgetinfo(sds_id, (
char*) sds_name.c_str(), &
rank, dims, &numtype, &nattrs);
3465 NcGroup lut_grp = nc_output->addGroup( aero_lut );
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 );
3474 vector<NcDim> nvalx_dims;
3481 NcVar var = lut_grp.addVar(
"SZA412_Nodes", ncFloat,
dim_nsza_ );
3483 var = lut_grp.addVar(
"VZA412_Nodes", ncFloat,
dim_nvza_ );
3485 var = lut_grp.addVar(
"RAA412_Nodes", ncFloat,
dim_nraa_ );
3487 var = lut_grp.addVar(
"AOT412_Nodes", ncFloat,
dim_ntau_ );
3489 var = lut_grp.addVar(
"SSA412_Nodes", ncFloat,
dim_nssa_ );
3491 var = lut_grp.addVar(
"SR412_Nodes", ncFloat,
dim_nsr_ );
3493 var = lut_grp.addVar(
"NVALX412", ncFloat, nvalx_dims );
3496 dim_nssa_ = lut_grp.addDim(
"Dim_SSA_488", SSA470 );
3497 dim_nsr_ = lut_grp.addDim(
"Dim_SR_488", SR470 );
3505 var = lut_grp.addVar(
"SZA488_Nodes", ncFloat,
dim_nsza_ );
3507 var = lut_grp.addVar(
"VZA488_Nodes", ncFloat,
dim_nvza_ );
3509 var = lut_grp.addVar(
"RAA488_Nodes", ncFloat,
dim_nraa_ );
3511 var = lut_grp.addVar(
"AOT488_Nodes", ncFloat,
dim_ntau_ );
3513 var = lut_grp.addVar(
"SSA488_Nodes", ncFloat,
dim_nssa_ );
3515 var = lut_grp.addVar(
"SR488_Nodes", ncFloat,
dim_nsr_ );
3517 var = lut_grp.addVar(
"NVALX488", ncFloat, nvalx_dims );
3520 dim_nssa_ = lut_grp.addDim(
"Dim_SSA_672", SSA650 );
3521 dim_nsr_ = lut_grp.addDim(
"Dim_SR_672", SR650 );
3529 var = lut_grp.addVar(
"SZA672_Nodes", ncFloat,
dim_nsza_ );
3531 var = lut_grp.addVar(
"VZA672_Nodes", ncFloat,
dim_nvza_ );
3533 var = lut_grp.addVar(
"RAA672_Nodes", ncFloat,
dim_nraa_ );
3535 var = lut_grp.addVar(
"AOT672_Nodes", ncFloat,
dim_ntau_ );
3537 var = lut_grp.addVar(
"SSA672_Nodes", ncFloat,
dim_nssa_ );
3539 var = lut_grp.addVar(
"SR672_Nodes", ncFloat,
dim_nsr_ );
3541 var = lut_grp.addVar(
"NVALX672", ncFloat, nvalx_dims );
3544 return DTDB_SUCCESS;
3555 const string aero_lut)
3557 int status = DTDB_SUCCESS;
3565 nc_input =
new NcFile(
filepath, NcFile::read );
3567 catch( NcException& e) {
3569 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
3572 NcGroup lut_grp = nc_input->getGroup( aero_lut );
3574 NcVar var = lut_grp.getVar(
"SZA412_Nodes" );
3576 var = lut_grp.getVar(
"VZA412_Nodes" );
3578 var = lut_grp.getVar(
"RAA412_Nodes" );
3580 var = lut_grp.getVar(
"AOT412_Nodes" );
3582 var = lut_grp.getVar(
"SSA412_Nodes" );
3584 var = lut_grp.getVar(
"SR412_Nodes" );
3586 var = lut_grp.getVar(
"NVALX412" );
3589 var = lut_grp.getVar(
"SZA488_Nodes" );
3591 var = lut_grp.getVar(
"VZA488_Nodes" );
3593 var = lut_grp.getVar(
"RAA488_Nodes" );
3595 var = lut_grp.getVar(
"AOT488_Nodes" );
3597 var = lut_grp.getVar(
"SSA488_Nodes" );
3599 var = lut_grp.getVar(
"SR488_Nodes" );
3601 var = lut_grp.getVar(
"NVALX488" );
3604 var = lut_grp.getVar(
"SZA672_Nodes" );
3606 var = lut_grp.getVar(
"VZA672_Nodes" );
3608 var = lut_grp.getVar(
"RAA672_Nodes" );
3610 var = lut_grp.getVar(
"AOT672_Nodes" );
3612 var = lut_grp.getVar(
"SSA672_Nodes" );
3614 var = lut_grp.getVar(
"SR672_Nodes" );
3616 var = lut_grp.getVar(
"NVALX672" );
3633 int status = DTDB_SUCCESS;
3637 cerr <<
"DbLutNetcdf::read_bathymetry_files() Invalid path." << endl;
3644 catch( std::exception& e) {
3646 cerr <<
"DbLutNetcdf:: Failure opening bathymetry file: " +
filepath << endl;
3649 int sds_index, sds_id, numtype,
rank, nattrs;
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);
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);
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);
3689 dim_nx_ = lut_grp.addDim(
"Dim_Bathymetry_X", NUMX );
3690 dim_ny_ = lut_grp.addDim(
"Dim_Bathymetry_Y", NUMY );
3692 vector<NcDim> bath_dims;
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 );
3702 return DTDB_SUCCESS;
3714 int status = DTDB_SUCCESS;
3722 nc_input =
new NcFile(
filepath, NcFile::read );
3724 catch( NcException& e) {
3726 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
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 );
3751 int status = DTDB_SUCCESS;
3755 cerr <<
"DbLutNetcdf::read_chl_files() Invalid path." << endl;
3760 nc_input =
new NcFile(
filepath, NcFile::read );
3762 catch( NcException& e) {
3764 cerr <<
"DbLutNetcdf:: Failure opening chl file: " +
filepath << endl;
3767 NcVar var = nc_input->getVar(
"latitude" );
3769 var = nc_input->getVar(
"longitude" );
3771 var = nc_input->getVar(
"time" );
3772 var.getVar( c_lut->
time );
3773 var = nc_input->getVar(
"log_chl" );
3790 NcGroup lut_grp = nc_output->addGroup(
LUT_CHL );
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;
3798 vector<NcDim> chl_dims;
3802 NcVar var = lut_grp.addVar(
"LATITUDE", ncFloat, map_dims );
3804 var = lut_grp.addVar(
"LONGITUDE", ncFloat, map_dims );
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 );
3811 return DTDB_SUCCESS;
3823 int status = DTDB_SUCCESS;
3831 nc_input =
new NcFile(
filepath, NcFile::read );
3833 catch( NcException& e) {
3835 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
3838 NcGroup lut_grp = nc_input->getGroup(
LUT_CHL );
3840 NcVar var = lut_grp.getVar(
"LATITUDE" );
3842 var = lut_grp.getVar(
"LONGITUDE" );
3844 var = lut_grp.getVar(
"TIME" );
3845 var.getVar( c_lut->
time );
3846 var = lut_grp.getVar(
"LOG_CHL" );
3863 int status = DTDB_SUCCESS;
3867 cerr <<
"DbLutNetcdf::read_geozone_files() Invalid path." << endl;
3874 catch( std::exception& e) {
3876 cerr <<
"DbLutNetcdf:: Failure opening geozone file: " +
filepath << endl;
3879 int sds_index, sds_id, numtype,
rank, nattrs;
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);
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);
3896 edges[0] = NSEASONS;
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);
3919 NcGroup lut_grp = nc_output->addGroup(
LUT_GEOZONE );
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;
3929 vector<NcDim> aod_dims;
3933 NcVar var = lut_grp.addVar(
"GEOZONE_FLAG", ncFloat, map_dims );
3935 var = lut_grp.addVar(
"ELEVATION_STDV", ncFloat, map_dims );
3937 var = lut_grp.addVar(
"BACKGROUND_AOD", ncFloat, aod_dims );
3940 return DTDB_SUCCESS;
3952 int status = DTDB_SUCCESS;
3960 nc_input =
new NcFile(
filepath, NcFile::read );
3962 catch( NcException& e) {
3964 cerr <<
"DbLutNetcdf:: Failure opening netcdf LUT file: " +
filepath << endl;
3967 NcGroup lut_grp = nc_input->getGroup(
LUT_GEOZONE );
3969 NcVar var = lut_grp.getVar(
"GEOZONE_FLAG" );
3971 var = lut_grp.getVar(
"ELEVATION_STDV" );
3973 var = lut_grp.getVar(
"BACKGROUND_AOD" );
3993 nc_output->putAtt(
"license",
license_);
4002 nc_output->putAtt(
"project",
project_);
4009 nc_output->putAtt(
"history",
history_);
4014 if (!pge_name_.empty()) {
4015 nc_output->putAtt(
"PGE_Name",pge_name_);
4018 if (!versionid_.empty()) {
4019 nc_output->putAtt(
"VersionId",versionid_);
4025 return DTDB_SUCCESS;
4039 unsigned short checkValue = 0xAABB;
4040 unsigned char* bytePtr =
reinterpret_cast<unsigned char*
>(&checkValue);
4042 if (bytePtr[0] == 0xAA) {