43 using namespace HDFSP;
47 template <
typename T,
typename U,
typename V,
typename W,
typename X >
static void
48 _throw5 (
const char *fname,
int line,
int numarg,
49 const T & a1,
const U & a2,
const V & a3,
const W & a4,
const X & a5)
51 std::ostringstream ss;
52 ss << fname <<
":" << line <<
":";
53 for (
int i = 0; i < numarg; ++i) {
80 #define throw1(a1) _throw5(__FILE__, __LINE__, 1, a1, 0, 0, 0, 0)
81 #define throw2(a1, a2) _throw5(__FILE__, __LINE__, 2, a1, a2, 0, 0, 0)
82 #define throw3(a1, a2, a3) _throw5(__FILE__, __LINE__, 3, a1, a2, a3, 0, 0)
83 #define throw4(a1, a2, a3, a4) _throw5(__FILE__, __LINE__, 4, a1, a2, a3, a4, 0)
84 #define throw5(a1, a2, a3, a4, a5) _throw5(__FILE__, __LINE__, 5, a1, a2, a3, a4, a5)
86 #define assert_throw0(e) do { if (!(e)) throw1("assertion failure"); } while (false)
87 #define assert_range_throw0(e, ge, l) assert_throw0((ge) <= (e) && (e) < (l))
93 template <
typename T >
void operator () (T * ptr)
105 if (this->sdfd != -1) {
115 if (this->fileid != -1) {
117 for (vector < VDATA * >::const_iterator i = this->vds.begin ();
118 i != this->vds.end (); ++i) {
122 for (vector < AttrContainer * >::const_iterator i = this->vg_attrs.begin ();
123 i != this->vg_attrs.end (); ++i) {
138 std::for_each (this->vdfields.begin (), this->vdfields.end (),
142 std::for_each (this->attrs.begin (), this->attrs.end (), delete_elem ());
149 std::for_each (this->attrs.begin (), this->attrs.end (), delete_elem ());
152 std::for_each (this->sdfields.begin (), this->sdfields.end (),
161 std::for_each (this->dims.begin (), this->dims.end (), delete_elem ());
164 std::for_each (this->correcteddims.begin (), this->correcteddims.end (),
168 std::for_each (this->dims_info.begin (), this->dims_info.end (), delete_elem ());
183 std::for_each (this->attrs.begin (), this->attrs.end (), delete_elem ());
189 std::for_each (this->attrs.begin (), this->attrs.end (), delete_elem ());
209 SDstart (const_cast < char *>(file->
path.c_str ()),
210 DFACC_READ)) == -1) {
221 file->fileid = myfileid;
224 int32 status = Vstart (file->fileid);
225 if (status == FAIL) {
227 throw2 (
"Cannot start vdata/vgroup interface", path);
232 file->
sd =
SD::Read (file->sdfd, file->fileid);
260 SDstart (const_cast < char *>(file->
path.c_str ()),
261 DFACC_READ)) == -1) {
272 file->fileid = myfileid;
275 int status = Vstart (file->fileid);
276 if (status == FAIL) {
278 throw2 (
"Cannot start vdata/vgroup interface", path);
308 int status = Vstart (file->fileid);
310 throw2 (
"Cannot start vdata/vgroup interface", path);
314 int num_lone_vdata = VSlone (file->fileid,
NULL, 0);
316 if (num_lone_vdata == FAIL)
317 throw2 (
"Fail to obtain lone vdata number", path);
323 char vdata_class[VSNAMELENMAX], vdata_name[VSNAMELENMAX];
325 if (num_lone_vdata > 0) {
327 vector<int32>ref_array;
328 ref_array.resize(num_lone_vdata);
330 if (VSlone (file->fileid, &ref_array[0], num_lone_vdata) == FAIL) {
331 throw2 (
"cannot obtain lone vdata reference arrays", path);
334 for (
int i = 0; i < num_lone_vdata; i++) {
338 vdata_id = VSattach (file->fileid, ref_array[i],
"r");
339 if (vdata_id == FAIL) {
340 throw2 (
"Fail to attach Vdata", path);
342 status = VSgetclass (vdata_id, vdata_class);
343 if (status == FAIL) {
345 throw2 (
"Fail to obtain Vdata class", path);
348 if (VSgetname (vdata_id, vdata_name) == FAIL) {
350 throw3 (
"Fail to obtain Vdata name", path, vdata_name);
355 if (VSisattr (vdata_id) ==
TRUE
358 || !strncmp (vdata_class, _HDF_SDSVAR, strlen (_HDF_SDSVAR))
359 || !strncmp (vdata_class, _HDF_CRDVAR, strlen (_HDF_CRDVAR))
360 || !strncmp (vdata_class, DIM_VALS, strlen (DIM_VALS))
361 || !strncmp (vdata_class, DIM_VALS01, strlen (DIM_VALS01))
362 || !strncmp (vdata_class, RIGATTRCLASS, strlen (RIGATTRCLASS))
363 || !strncmp (vdata_name, RIGATTRNAME, strlen (RIGATTRNAME))) {
365 status = VSdetach (vdata_id);
366 if (status == FAIL) {
367 throw3 (
"VSdetach failed ",
"Vdata name ", vdata_name);
386 for (std::vector < VDField * >::const_iterator it_vdf =
388 it_vdf != vdataobj->
getFields ().end (); it_vdf++) {
393 "vdata_" + vdataobj->
newname +
"_vdf_" +
402 file->vds.push_back (vdataobj);
418 char *fieldname =
NULL;
421 int num_field = VFnfields (vdata_id);
422 if (num_field == FAIL) {
424 throw3 (
"number of fields at Vdata ", vdata_name,
" is -1");
428 for (
int j = 0; j < num_field; j++) {
430 fieldname = VFfieldname (vdata_id, j);
431 if (fieldname ==
NULL) {
433 throw5 (
"vdata ", vdata_name,
" field index ", j,
434 " field name is NULL.");
440 int32 fieldsize = -1;
444 fieldsize = VFfieldesize (vdata_id, j);
445 if (fieldsize == FAIL) {
447 throw5 (
"vdata ", vdata_name,
" field ",fieldname,
" size is wrong.");
451 nelms = VSelts (vdata_id);
454 throw5 (
"vdata ", vdata_name,
455 " number of field record ", nelms,
" is wrong.");
459 char *databuf = (
char *)
malloc (fieldsize * nelms);
460 if (databuf ==
NULL) {
462 throw1(
"no enough memory to allocate buffer.");
466 if (VSseek (vdata_id, 0) == FAIL) {
469 throw5 (
"vdata ", vdata_name,
"field ",
477 throw5 (
"vdata ", vdata_name,
"field ",
482 if (VSread(vdata_id, (uint8 *) databuf, 1,FULL_INTERLACE)
486 throw5 (
"vdata ", vdata_name,
"field ",
532 int32 vgroup_id = -1;
540 int32 lone_vg_number = 0;
541 int32 num_of_lones = -1;
542 int32 num_gobjects = 0;
547 char vdata_name[VSNAMELENMAX];
548 char vdata_class[VSNAMELENMAX];
549 char vgroup_name[VGNAMELENMAX*4];
550 char vgroup_class[VGNAMELENMAX*4];
553 char *full_path =
NULL;
556 char *cfull_path =
NULL;
559 file_id = file->fileid;
564 status = Vstart (file_id);
566 throw2 (
"Cannot start vdata/vgroup interface", path);
572 num_of_lones = Vlone (file_id,
NULL, 0);
573 if (num_of_lones == FAIL)
574 throw3 (
"Fail to obtain lone vgroup number",
"file id is", file_id);
577 if (num_of_lones > 0) {
583 vector<int32>ref_array;
584 ref_array.resize(num_of_lones);
588 num_of_lones = Vlone (file_id, &ref_array[0], num_of_lones);
589 if (num_of_lones == FAIL) {
590 throw3 (
"Cannot obtain lone vgroup reference arrays ",
591 "file id is ", file_id);
595 for (lone_vg_number = 0; lone_vg_number < num_of_lones;
599 vgroup_id = Vattach (file_id, ref_array[lone_vg_number],
"r");
600 if (vgroup_id == FAIL) {
601 throw3 (
"Vattach failed ",
"Reference number is ",
602 ref_array[lone_vg_number]);
606 status = Vgetname (vgroup_id, vgroup_name);
607 if (status == FAIL) {
609 throw3 (
"Vgetname failed ",
"vgroup_id is ", vgroup_id);
613 status = Vgetclass (vgroup_id, vgroup_class);
614 if (status == FAIL) {
616 throw3 (
"Vgetclass failed ",
"vgroup_name is ", vgroup_name);
620 if (strcmp (vgroup_class, _HDF_ATTRIBUTE) == 0
621 || strcmp (vgroup_class, _HDF_VARIABLE) == 0
622 || strcmp (vgroup_class, _HDF_DIMENSION) == 0
623 || strcmp (vgroup_class, _HDF_UDIMENSION) == 0
624 || strcmp (vgroup_class, _HDF_CDF) == 0
625 || strcmp (vgroup_class, GR_NAME) == 0
626 || strcmp (vgroup_class, RI_NAME) == 0) {
632 num_gobjects = Vntagrefs (vgroup_id);
633 if (num_gobjects < 0) {
635 throw3 (
"Vntagrefs failed ",
"vgroup_name is ", vgroup_name);
643 if (full_path ==
NULL) {
645 throw1 (
"No enough memory to allocate the buffer.");
651 strncat(full_path,vgroup_name,strlen(vgroup_name));
656 if (cfull_path ==
NULL) {
659 throw1 (
"No enough memory to allocate the buffer.");
662 strncpy(cfull_path,full_path,strlen(full_path));
665 for (
int i = 0; i < num_gobjects; i++) {
668 if (Vgettagref (vgroup_id, i, &obj_tag, &obj_ref) == FAIL) {
672 throw5 (
"Vgettagref failed ",
"vgroup_name is ",
673 vgroup_name,
" reference number is ", obj_ref);
678 if (Visvg (vgroup_id, obj_ref) ==
TRUE) {
679 strncpy(full_path,cfull_path,strlen(cfull_path)+1);
680 full_path[strlen(cfull_path)]=
'\0';
681 obtain_vdata_path (file_id, full_path, obj_ref);
685 else if (Visvs (vgroup_id, obj_ref)) {
688 vdata_id = VSattach (file_id, obj_ref,
"r");
689 if (vdata_id == FAIL) {
693 throw5 (
"VSattach failed ",
"vgroup_name is ",
694 vgroup_name,
" reference number is ",
699 status = VSgetname (vdata_id, vdata_name);
700 if (status == FAIL) {
704 throw5 (
"VSgetclass failed ",
"vgroup_name is ",
705 vgroup_name,
" reference number is ",
710 status = VSgetclass (vdata_id, vdata_class);
711 if (status == FAIL) {
715 throw5 (
"VSgetclass failed ",
"vgroup_name is ",
716 vgroup_name,
" reference number is ",
721 if (VSisattr (vdata_id) ==
TRUE
724 || !strncmp (vdata_class, _HDF_SDSVAR,
725 strlen (_HDF_SDSVAR))
726 || !strncmp (vdata_class, _HDF_CRDVAR,
727 strlen (_HDF_CRDVAR))
728 || !strncmp (vdata_class, DIM_VALS, strlen (DIM_VALS))
729 || !strncmp (vdata_class, DIM_VALS01,
731 || !strncmp (vdata_class, RIGATTRCLASS,
732 strlen (RIGATTRCLASS))
733 || !strncmp (vdata_name, RIGATTRNAME,
734 strlen (RIGATTRNAME))) {
736 status = VSdetach (vdata_id);
737 if (status == FAIL) {
741 throw3 (
"VSdetach failed ",
742 "Vdata is under vgroup ", vgroup_name);
766 for (std::vector <VDField * >::const_iterator it_vdf =
775 "vdata" + vdataobj->
newname +
"_vdf_" + (*it_vdf)->name;
787 this->vds.push_back (vdataobj);
789 status = VSdetach (vdata_id);
790 if (status == FAIL) {
794 throw3 (
"VSdetach failed ",
795 "Vdata is under vgroup ", vgroup_name);
806 status = Vdetach (vgroup_id);
807 if (status == FAIL) {
808 throw3 (
"Vdetach failed ",
"vgroup_name is ", vgroup_name);
827 set<string> dimnameset;
828 set<SDField*> fldset;
836 string FullXDim,FullYDim;
840 FullXDim= FullXDim+grid_name;
841 FullYDim =FullYDim+grid_name;
843 for (vector < SDField * >::const_iterator i =
844 this->sd->getFields ().begin ();
845 i != this->sd->getFields ().end (); ++i) {
847 for (vector < Dimension * >::const_iterator k =
848 (*i)->getDimensions ().begin ();
849 k != (*i)->getDimensions ().end (); ++k) {
850 if((*k)->getName() !=FullXDim && (*k)->getName()!=FullYDim)
851 dimnameset.insert((*k)->getName());
854 if (1==(*i)->getRank())
865 if (fldset.size() < (dimnameset.size()+2))
868 int total_num_dims = 0;
869 size_t grid_name_size = grid_name.size();
870 string reduced_dimname;
872 for(set<SDField*>::const_iterator j =
873 fldset.begin(); j!=fldset.end(); ++ j) {
875 size_t dim_size = ((*j)->getDimensions())[0]->getName().size();
876 if( dim_size > grid_name_size){
877 reduced_dimname = ((*j)->getDimensions())[0]->getName().substr(0,dim_size-grid_name_size-1);
878 if ((*j)->getName() == reduced_dimname)
883 if((
size_t)total_num_dims != (dimnameset.size()+2))
887 for (vector < SDField * >::const_iterator i =
888 this->sd->getFields ().begin ();
889 i != this->sd->getFields ().end (); ++i) {
891 for (vector < Dimension * >::const_iterator k =
892 (*i)->getDimensions ().begin ();
893 k != (*i)->getDimensions ().end (); ++k) {
895 size_t dim_size = (*k)->getName().size();
896 if( dim_size > grid_name_size){
897 reduced_dimname = (*k)->getName().substr(0,dim_size-grid_name_size-1);
898 (*k)->name = reduced_dimname;
907 for(std::set<SDField*>::const_iterator j =
908 fldset.begin(); j!=fldset.end(); ++ j) {
910 if ((*j)->getName() == ((*j)->getDimensions())[0]->getName()) {
912 if(
"XDim" == (*j)->getName()){
913 std::string tempunits =
"degrees_east";
914 (*j)->setUnits (tempunits);
918 else if(
"YDim" == (*j)->getName()){
919 std::string tempunits =
"degrees_north";
920 (*j)->setUnits (tempunits);
924 else if(
"Pressure_Level" == (*j)->getName()) {
925 std::string tempunits =
"hPa";
926 (*j)->setUnits (tempunits);
930 std::string tempunits =
"level";
931 (*j)->setUnits (tempunits);
949 File::Check_if_special(
const string& grid_name)
throw(
Exception) {
952 bool xdim_is_lon =
false;
953 bool ydim_is_lat =
false;
954 bool pre_unit_hpa =
true;
955 for (vector < SDField * >::const_iterator i =
956 this->sd->getFields ().begin ();
957 i != this->sd->getFields ().end (); ++i) {
958 if (1==(*i)->getRank()) {
959 if(1 == ((*i)->fieldtype)) {
960 if(
"YDim" == (*j)->getName()
978 set<string> scaled_dname_set;
981 set<string> non_scaled_dname_set;
982 pair<set<string>::iterator,
bool> ret;
985 map<string,int> non_scaled_dname_to_size;
989 for (std::vector < SDField * >::const_iterator i =
992 string tempname = (*i)->name;
993 size_t found_colon = tempname.find_first_of(
':');
994 if(found_colon!=string::npos)
995 (*i)->newname = tempname.substr(0,found_colon);
997 for (vector < Dimension * >::const_iterator k =
998 (*i)->getDimensions ().begin ();
999 k != (*i)->getDimensions ().end (); ++k) {
1001 string tempname = (*k)->name;
1002 size_t found_colon = tempname.find_first_of(
':');
1003 if(found_colon!=string::npos)
1004 (*k)->name = tempname.substr(0,found_colon);
1006 if(0==(*k)->getType()) {
1007 ret = non_scaled_dname_set.insert((*k)->name);
1008 if (
true == ret.second)
1009 non_scaled_dname_to_size[(*k)->name] = (*k)->dimsize;
1012 scaled_dname_set.insert((*k)->name);
1019 for(set<string>::const_iterator sdim_it = scaled_dname_set.begin();
1020 sdim_it !=scaled_dname_set.end();
1022 cerr<<
"scaled dim. name "<<*sdim_it <<endl;
1034 if(
true == airs_l3) {
1035 set<string>scaled_dname_set_marker = scaled_dname_set;
1044 for (std::vector < SDField * >::iterator i =
1046 if(1 == (*i)->getRank()) {
1047 if(scaled_dname_set.find((*i)->getNewName())!=scaled_dname_set.end()) {
1048 if(scaled_dname_set_marker.find((*i)->getNewName())!=scaled_dname_set_marker.end()) {
1049 scaled_dname_set_marker.erase((*i)->getNewName());
1062 else if( 2 == (*i)->getRank()) {
1063 if (
"Latitude" == (*i)->getNewName() ||
"Longitude" == (*i)->getNewName()) {
1075 for(set<string>::const_iterator sdim_it = scaled_dname_set.begin();
1076 sdim_it !=scaled_dname_set.end();
1078 cerr<<
"new scaled dim. name "<<*sdim_it <<endl;
1086 set<string>final_non_scaled_dname_set;
1087 for(set<string>::const_iterator non_sdim_it = non_scaled_dname_set.begin();
1088 non_sdim_it !=non_scaled_dname_set.end();
1091 if(scaled_dname_set.find(*non_sdim_it)==scaled_dname_set.end())
1092 final_non_scaled_dname_set.insert(*non_sdim_it);
1096 for(set<string>::const_iterator non_sdim_it = final_non_scaled_dname_set.begin();
1097 non_sdim_it !=final_non_scaled_dname_set.end();
1104 missingfield->
type = DFNT_INT32;
1105 missingfield->
name = *non_sdim_it;
1106 missingfield->
newname = *non_sdim_it;
1107 missingfield->
rank = 1;
1110 Dimension *dim =
new Dimension (*non_sdim_it,non_scaled_dname_to_size[*non_sdim_it] , 0);
1112 missingfield->
dims.push_back (dim);
1119 if(
true == airs_l3) {
1120 for (std::vector < SDField * >::const_iterator i =
1123 if(1 ==(*i)->getRank()){
1124 if (
"XDim" == (*i)->newname)
1125 (*i)->newname =
"Longitude";
1126 else if (
"YDim" == (*i)->newname)
1127 (*i)->newname =
"Latitude";
1130 for (vector < Dimension * >::const_iterator k =
1131 (*i)->getDimensions ().begin ();
1132 k != (*i)->getDimensions ().end (); ++k) {
1133 if(
"XDim" == (*k)->name)
1134 (*k)->name =
"Longitude";
1135 else if (
"YDim" == (*k)->name)
1136 (*k)->name =
"Latitude";
1143 if(
false == airs_l3) {
1145 bool change_lat_unit =
false;
1146 bool change_lon_unit =
false;
1147 string ll_dimname1 =
"";
1148 string ll_dimname2 =
"";
1152 for (std::vector < SDField * >::const_iterator i =
1155 if(2 == (*i)->getRank()) {
1156 if(
"Latitude" == (*i)->newname){
1157 (*i)->fieldtype = 1;
1158 change_lat_unit =
true;
1159 string tempunits =
"degrees_north";
1160 (*i)->setUnits(tempunits);
1161 ll_dimname1 = (*i)->getDimensions()[0]->getName();
1162 ll_dimname2 = (*i)->getDimensions()[1]->getName();
1165 else if(
"Longitude" == (*i)->newname) {
1166 (*i)->fieldtype = 2;
1167 change_lon_unit =
true;
1168 string tempunits =
"degrees_east";
1169 (*i)->setUnits(tempunits);
1171 if((
true == change_lat_unit) && (
true == change_lon_unit))
1177 string tempcoordinates =
"";
1178 string tempfieldname =
"";
1181 for (std::vector < SDField * >::const_iterator i =
1185 bool dimscale_var =
false;
1186 dimscale_var = ((*i)->rank == 1) & (((*i)->newname) == ((*i)->getDimensions()[0]->getName()));
1188 if((0 ==(*i)->fieldtype) && (
false == dimscale_var)) {
1191 tempcoordinates =
"";
1195 bool has_lldim1 =
false;
1196 bool has_lldim2 =
false;
1197 for (std::vector < Dimension * >::const_iterator j =
1198 (*i)->getDimensions ().begin ();
1199 j != (*i)->getDimensions ().end (); ++j) {
1200 if((*j)->name == ll_dimname1)
1202 else if ((*j)->name == ll_dimname2)
1204 if((
true == has_lldim1) && (
true == has_lldim2))
1210 if((
true == has_lldim1) && (
true == has_lldim2)) {
1211 for (std::vector < Dimension * >::const_iterator j =
1212 (*i)->getDimensions ().begin ();
1213 j != (*i)->getDimensions ().end (); ++j) {
1214 if((*j)->name == ll_dimname1)
1215 tempfieldname =
"Latitude";
1216 else if ((*j)->name == ll_dimname2)
1217 tempfieldname =
"Longitude";
1219 tempfieldname = (*j)->name;
1222 tempcoordinates = tempfieldname;
1224 tempcoordinates = tempcoordinates +
" " + tempfieldname;
1229 for (std::vector < Dimension * >::const_iterator j =
1230 (*i)->getDimensions ().begin ();
1231 j != (*i)->getDimensions ().end (); ++j) {
1233 tempcoordinates = (*j)->name;
1235 tempcoordinates = tempcoordinates +
" " + (*j)->name;
1240 (*i)->setCoordinates (tempcoordinates);
1260 int trmm_multi_gridflag = 0;
1261 int trmm_single_gridflag = 0;
1262 int trmm_swathflag = 0;
1264 for (std::vector < Attribute * >::const_iterator i =
1265 this->sd->getAttributes ().begin ();
1266 i != this->sd->getAttributes ().end (); ++i) {
1267 if ((*i)->getName () ==
"FileHeader") {
1268 trmm_multi_gridflag++;
1269 trmm_single_gridflag++;
1272 if ((*i)->getName () ==
"FileInfo") {
1273 trmm_multi_gridflag++;
1274 trmm_single_gridflag++;
1277 if ((*i)->getName () ==
"SwathHeader")
1280 if ((*i)->getName () ==
"GridHeader")
1281 trmm_single_gridflag++;
1283 else if (((*i)->getName ().find (
"GridHeader") == 0) &&
1284 (((*i)->getName()).size() >10))
1285 trmm_multi_gridflag++;
1290 if(3 == trmm_single_gridflag)
1292 else if(3 == trmm_swathflag)
1294 else if(trmm_multi_gridflag >3)
1303 int metadataflag = 0;
1305 for (std::vector < Attribute * >::const_iterator i =
1306 this->sd->getAttributes ().begin ();
1307 i != this->sd->getAttributes ().end (); ++i) {
1308 if ((*i)->getName () ==
"CoreMetadata.0")
1310 if ((*i)->getName () ==
"ArchiveMetadata.0")
1312 if ((*i)->getName () ==
"StructMetadata.0")
1314 if ((*i)->getName ().find (
"SubsettingMethod") !=
1323 if (metadataflag == 4)
1328 if (metadataflag == 2) {
1330 for (std::vector < SDField * >::const_iterator i =
1331 this->sd->getFields ().begin ();
1332 i != this->sd->getFields ().end (); ++i) {
1333 if (((*i)->getName () ==
"geolocation")
1334 && (*i)->getNewName ().find (
"DATA_GRANULE") !=
1336 && (*i)->getNewName ().find (
"SwathData") !=
1337 std::string::npos && (*i)->getRank () == 3) {
1352 for (std::vector < SDField * >::const_iterator i =
1353 this->sd->getFields ().begin ();
1354 i != this->sd->getFields ().end (); ++i) {
1355 if ((*i)->getNewName ().find (
"DATA_GRANULE") !=
1356 std::string::npos) {
1357 bool l3b_v6_lonflag =
false;
1358 bool l3b_v6_latflag =
false;
1359 for (std::vector < Dimension * >::const_iterator k =
1360 (*i)->getDimensions ().begin ();
1361 k != (*i)->getDimensions ().end (); ++k) {
1362 if ((*k)->getSize () == 1440)
1363 l3b_v6_lonflag =
true;
1365 if ((*k)->getSize () == 400)
1366 l3b_v6_latflag =
true;
1368 if (l3b_v6_lonflag ==
true && l3b_v6_latflag ==
true) {
1374 bool l3a_v6_latflag =
false;
1375 bool l3a_v6_lonflag =
false;
1377 bool l3c_v6_lonflag =
false;
1378 bool l3c_v6_latflag =
false;
1380 if ((*i)->getRank()>2) {
1381 for (std::vector < Dimension * >::const_iterator k =
1382 (*i)->getDimensions ().begin ();
1383 k != (*i)->getDimensions ().end (); ++k) {
1384 if ((*k)->getSize () == 360)
1385 l3a_v6_lonflag =
true;
1387 if ((*k)->getSize () == 180)
1388 l3a_v6_latflag =
true;
1390 if ((*k)->getSize () == 720)
1391 l3c_v6_lonflag =
true;
1393 if ((*k)->getSize () == 148)
1394 l3c_v6_latflag =
true;
1399 if (
true == l3a_v6_latflag &&
true == l3a_v6_lonflag) {
1404 if (
true == l3c_v6_latflag &&
true == l3c_v6_lonflag) {
1417 cerr<<
"3A46 products "<<endl;
1419 cerr<<
"CSH products "<<endl;
1434 int modisal2flag = 0;
1437 int modistl2flag = 0;
1443 int seawifsl2flag = 0;
1449 int modisal3mflag = 0;
1452 int modistl3mflag = 0;
1455 int octsl3mflag = 0;
1458 int seawifsl3mflag = 0;
1461 int czcsl3mflag = 0;
1466 for (std::vector < Attribute * >::const_iterator i =
1467 this->sd->getAttributes ().begin ();
1468 i != this->sd->getAttributes ().end (); ++i) {
1469 if ((*i)->getName () ==
"Product Name") {
1471 std::string attrvalue ((*i)->getValue ().begin (),
1472 (*i)->getValue ().end ());
1473 if ((attrvalue.find_first_of (
'A', 0) == 0)
1474 && (attrvalue.find (
".L2", 0) != std::string::npos))
1476 else if ((attrvalue.find_first_of (
'A', 0) == 0)
1477 && (attrvalue.find (
".L3m", 0) != std::string::npos))
1479 else if ((attrvalue.find_first_of (
'T', 0) == 0)
1480 && (attrvalue.find (
".L2", 0) != std::string::npos))
1482 else if ((attrvalue.find_first_of (
'T', 0) == 0)
1483 && (attrvalue.find (
".L3m", 0) != std::string::npos))
1485 else if ((attrvalue.find_first_of (
'O', 0) == 0)
1486 && (attrvalue.find (
".L2", 0) != std::string::npos))
1488 else if ((attrvalue.find_first_of (
'O', 0) == 0)
1489 && (attrvalue.find (
".L3m", 0) != std::string::npos))
1491 else if ((attrvalue.find_first_of (
'S', 0) == 0)
1492 && (attrvalue.find (
".L2", 0) != std::string::npos))
1494 else if ((attrvalue.find_first_of (
'S', 0) == 0)
1495 && (attrvalue.find (
".L3m", 0) != std::string::npos))
1497 else if ((attrvalue.find_first_of (
'C', 0) == 0)
1498 && ((attrvalue.find (
".L2", 0) != std::string::npos)
1500 ((attrvalue.find (
".L1A", 0) != std::string::npos))))
1502 else if ((attrvalue.find_first_of (
'C', 0) == 0)
1503 && (attrvalue.find (
".L3m", 0) != std::string::npos))
1507 if ((*i)->getName () ==
"Sensor Name") {
1509 std::string attrvalue ((*i)->getValue ().begin (),
1510 (*i)->getValue ().end ());
1511 if (attrvalue.find (
"MODISA", 0) != std::string::npos) {
1515 else if (attrvalue.find (
"MODIST", 0) != std::string::npos) {
1519 else if (attrvalue.find (
"OCTS", 0) != std::string::npos) {
1523 else if (attrvalue.find (
"SeaWiFS", 0) != std::string::npos) {
1527 else if (attrvalue.find (
"CZCS", 0) != std::string::npos) {
1534 if ((modisal2flag == 2) || (modisal3mflag == 2)
1535 || (modistl2flag == 2) || (modistl3mflag == 2)
1536 || (octsl2flag == 2) || (octsl3mflag == 2)
1537 || (seawifsl2flag == 2) || (seawifsl3mflag == 2)
1538 || (czcsl2flag == 2) || (czcsl3mflag == 2))
1544 if ((modisal2flag == 2) || (modistl2flag == 2) ||
1545 (octsl2flag == 2) || (seawifsl2flag == 2) || (czcsl2flag == 2))
1548 if ((modisal3mflag == 2) ||
1549 (modistl3mflag == 2) || (octsl3mflag == 2) ||
1550 (seawifsl3mflag == 2) || (czcsl3mflag == 2))
1569 int32 n_sd_attrs = 0;
1578 int32 dim_sizes[H4_MAX_VAR_DIMS];
1581 int32 n_sds_attrs = 0;
1587 char sds_name[H4_MAX_NC_NAME];
1590 char dim_name[H4_MAX_NC_NAME];
1593 char attr_name[H4_MAX_NC_NAME];
1609 int32 attr_value_count = 0;
1612 SD* sd =
new SD (sdfd, fileid);
1615 if (SDfileinfo (sdfd, &n_sds, &n_sd_attrs) == FAIL) {
1617 throw2 (
"SDfileinfo failed ", sdfd);
1621 for (sds_index = 0; sds_index < n_sds; sds_index++) {
1627 sds_id = SDselect (sdfd, sds_index);
1628 if (sds_id == FAIL) {
1632 SDendaccess (sds_id);
1633 throw3 (
"SDselect Failed ",
"SDS index ", sds_index);
1637 sds_ref = SDidtoref (sds_id);
1638 if (sds_ref == FAIL) {
1641 SDendaccess (sds_id);
1642 throw3 (
"Cannot obtain SDS reference number",
" SDS ID is ",
1647 status = SDgetinfo (sds_id, sds_name, &field->
rank, dim_sizes,
1648 &field->
type, &n_sds_attrs);
1649 if (status == FAIL) {
1652 SDendaccess (sds_id);
1653 throw2 (
"SDgetinfo failed ", sds_name);
1657 string tempname (sds_name);
1658 field->
name = tempname;
1665 bool dim_no_dimscale =
false;
1666 vector <int> dimids;
1668 dimids.assign(field->
rank,0);
1671 vector <int>num_dim_attrs;
1673 num_dim_attrs.assign(field->
rank,0);
1676 for (
int dimindex = 0; dimindex < field->
rank; dimindex++) {
1679 int dimid = SDgetdimid (sds_id, dimindex);
1680 if (dimid == FAIL) {
1683 SDendaccess (sds_id);
1684 throw5 (
"SDgetdimid failed ",
"SDS name ", sds_name,
1685 "dim index= ", dimindex);
1689 int temp_num_dim_attrs = 0;
1691 SDdiminfo (dimid, dim_name, &dim_size, &dim_type,
1692 (int32*)&temp_num_dim_attrs);
1693 if (status == FAIL) {
1696 SDendaccess (sds_id);
1697 throw5 (
"SDdiminfo failed ",
"SDS name ", sds_name,
1698 "dim index= ", dimindex);
1701 num_dim_attrs[dimindex] = temp_num_dim_attrs;
1720 string dim_name_str (dim_name);
1725 new Dimension (dim_name_str, dim_sizes[dimindex], dim_type);
1728 field->
dims.push_back (dim);
1732 dimids[dimindex] = dimid;
1733 if (0 == dim_type) {
1734 if (
false == dim_no_dimscale)
1735 dim_no_dimscale =
true;
1736 if ((dim_name_str == field->
name) && (1 == field->
rank))
1744 if(
true == dim_no_dimscale) {
1746 for (
int dimindex = 0; dimindex < field->
rank; dimindex++) {
1748 string dim_name_str = (field->
dims)[dimindex]->name;
1751 stringstream out_index;
1752 out_index << dimindex;
1753 index_str = out_index.str();
1754 dim_info->
name =
"_dim_" + index_str;
1758 bool dimname_flag =
false;
1760 int32 dummy_type = 0;
1761 int32 dummy_value_count = 0;
1764 for (
int attrindex = 0; attrindex < num_dim_attrs[dimindex]; attrindex++) {
1766 status = SDattrinfo(dimids[dimindex],attrindex,attr_name,
1767 &dummy_type,&dummy_value_count);
1768 if (status == FAIL) {
1771 SDendaccess (sds_id);
1772 throw3 (
"SDattrinfo failed ",
"SDS name ", sds_name);
1775 string tempname(attr_name);
1776 if (
"name"==tempname) {
1777 dimname_flag =
true;
1783 for (
int attrindex = 0; attrindex < num_dim_attrs[dimindex]; attrindex++) {
1786 status = SDattrinfo(dimids[dimindex],attrindex,attr_name,
1787 &attr->
type,&attr_value_count);
1788 if (status == FAIL) {
1791 SDendaccess (sds_id);
1792 throw3 (
"SDattrinfo failed ",
"SDS name ", sds_name);
1794 string tempname (attr_name);
1795 attr->
name = tempname;
1799 attr->
count = attr_value_count;
1800 attr->
value.resize (attr_value_count * DFKNTsize (attr->
type));
1801 if (SDreadattr (dimids[dimindex], attrindex, &attr->
value[0]) == -1) {
1804 SDendaccess (sds_id);
1805 throw5 (
"read SDS attribute failed ",
"Field name ",
1806 field->
name,
" Attribute name ", attr->
name);
1809 dim_info->
attrs.push_back (attr);
1815 if (
false == dimname_flag) {
1818 attr->
name =
"name";
1820 attr->
type = DFNT_CHAR;
1821 attr->
count = dim_name_str.size();
1823 copy(dim_name_str.begin(),dim_name_str.end(),attr->
value.begin());
1824 dim_info->
attrs.push_back(attr);
1832 for (
int attrindex = 0; attrindex < n_sds_attrs; attrindex++) {
1835 SDattrinfo (sds_id, attrindex, attr_name, &attr->
type,
1838 if (status == FAIL) {
1842 SDendaccess (sds_id);
1843 throw3 (
"SDattrinfo failed ",
"SDS name ", sds_name);
1846 string tempname (attr_name);
1847 attr->
name = tempname;
1851 attr->
count = attr_value_count;
1852 attr->
value.resize (attr_value_count * DFKNTsize (attr->
type));
1853 if (SDreadattr (sds_id, attrindex, &attr->
value[0]) == -1) {
1857 SDendaccess (sds_id);
1858 throw5 (
"read SDS attribute failed ",
"Field name ",
1859 field->
name,
" Attribute name ", attr->
name);
1861 field->
attrs.push_back (attr);
1863 SDendaccess (sds_id);
1868 for (
int attrindex = 0; attrindex < n_sd_attrs; attrindex++) {
1871 status = SDattrinfo (sdfd, attrindex, attr_name, &attr->
type,
1873 if (status == FAIL) {
1876 throw3 (
"SDattrinfo failed ",
"SD id ", sdfd);
1878 std::string tempname (attr_name);
1879 attr->
name = tempname;
1884 attr->
count = attr_value_count;
1885 attr->
value.resize (attr_value_count * DFKNTsize (attr->
type));
1886 if (SDreadattr (sdfd, attrindex, &attr->
value[0]) == -1) {
1889 throw3 (
"Cannot read SD attribute",
" Attribute name ",
1892 sd->
attrs.push_back (attr);
1911 int32 n_sd_attrs = 0;
1917 int extra_sds_index = 0;
1923 int32 dim_sizes[H4_MAX_VAR_DIMS];
1926 int32 n_sds_attrs = 0;
1932 char sds_name[H4_MAX_NC_NAME];
1935 char dim_name[H4_MAX_NC_NAME];
1938 char attr_name[H4_MAX_NC_NAME];
1951 int32 num_dim_attrs = 0;
1954 int32 attr_value_count = 0;
1958 int32 vgroup_id = 0;
1961 int32 lone_vg_number = 0;
1964 int32 num_of_lones = -1;
1977 char vgroup_name[VGNAMELENMAX*4];
1978 char vgroup_class[VGNAMELENMAX*4];
1991 SD *sd =
new SD (sdfd, fileid);
1994 if (SDfileinfo (sdfd, &n_sds, &n_sd_attrs) == FAIL) {
1996 throw2 (
"SDfileinfo failed ", sdfd);
2001 for (sds_index = 0; sds_index < n_sds; sds_index++) {
2002 sds_id = SDselect (sdfd, sds_index);
2004 if (sds_id == FAIL) {
2008 SDendaccess (sds_id);
2009 throw3 (
"SDselect Failed ",
"SDS index ", sds_index);
2012 sds_ref = SDidtoref (sds_id);
2013 if (sds_ref == FAIL) {
2015 SDendaccess (sds_id);
2016 throw3 (
"Cannot obtain SDS reference number",
" SDS ID is ",
2020 SDendaccess(sds_id);
2029 num_of_lones = Vlone (fileid,
NULL, 0);
2030 if (num_of_lones == FAIL){
2032 throw3 (
"Fail to obtain lone vgroup number",
"file id is", fileid);
2036 if (num_of_lones > 0) {
2040 vector<int32>ref_array;
2041 ref_array.resize(num_of_lones);
2045 num_of_lones = Vlone (fileid, &ref_array[0], num_of_lones);
2046 if (num_of_lones == FAIL) {
2048 throw3 (
"Cannot obtain lone vgroup reference arrays ",
2049 "file id is ", fileid);
2053 for (lone_vg_number = 0; lone_vg_number < num_of_lones;
2057 vgroup_id = Vattach (fileid, ref_array[lone_vg_number],
"r");
2058 if (vgroup_id == FAIL) {
2060 throw3 (
"Vattach failed ",
"Reference number is ",
2061 ref_array[lone_vg_number]);
2064 status = Vgetname (vgroup_id, vgroup_name);
2065 if (status == FAIL) {
2067 Vdetach (vgroup_id);
2068 throw3 (
"Vgetname failed ",
"vgroup_id is ", vgroup_id);
2071 status = Vgetclass (vgroup_id, vgroup_class);
2072 if (status == FAIL) {
2074 Vdetach (vgroup_id);
2075 throw3 (
"Vgetclass failed ",
"vgroup_name is ", vgroup_name);
2079 if (strcmp (vgroup_class, _HDF_ATTRIBUTE) == 0
2080 || strcmp (vgroup_class, _HDF_VARIABLE) == 0
2081 || strcmp (vgroup_class, _HDF_DIMENSION) == 0
2082 || strcmp (vgroup_class, _HDF_UDIMENSION) == 0
2083 || strcmp (vgroup_class, _HDF_CDF) == 0
2084 || strcmp (vgroup_class, GR_NAME) == 0
2085 || strcmp (vgroup_class, RI_NAME) == 0) {
2086 Vdetach (vgroup_id);
2091 num_gobjects = Vntagrefs (vgroup_id);
2092 if (num_gobjects < 0) {
2094 Vdetach (vgroup_id);
2095 throw3 (
"Vntagrefs failed ",
"vgroup_name is ", vgroup_name);
2109 if (full_path ==
NULL) {
2111 Vdetach (vgroup_id);
2112 throw1 (
"No enough memory to allocate the buffer.");
2117 strncat(full_path, vgroup_name,strlen(vgroup_name));
2120 if (cfull_path ==
NULL) {
2122 Vdetach (vgroup_id);
2124 throw1 (
"No enough memory to allocate the buffer.");
2127 strncpy (cfull_path, full_path,strlen(full_path));
2130 for (i = 0; i < num_gobjects; i++) {
2133 if (Vgettagref (vgroup_id, i, &obj_tag, &obj_ref) == FAIL) {
2135 Vdetach (vgroup_id);
2138 throw5 (
"Vgettagref failed ",
"vgroup_name is ",
2139 vgroup_name,
" reference number is ", obj_ref);
2143 if (Visvg (vgroup_id, obj_ref) ==
TRUE) {
2144 strncpy(full_path,cfull_path,strlen(cfull_path)+1);
2145 full_path[strlen(cfull_path)]=
'\0';
2150 else if (obj_tag == DFTAG_NDG || obj_tag == DFTAG_SDG
2151 || obj_tag == DFTAG_SD) {
2157 string temp_str = string(full_path);
2158 if((temp_str.find(
"Data Fields") != std::string::npos)||
2159 (temp_str.find(
"Geolocation Fields") != std::string::npos))
2169 status = Vdetach (vgroup_id);
2171 if (status == FAIL) {
2173 throw3 (
"Vdetach failed ",
"vgroup_name is ", vgroup_name);
2180 for(std::list<int32>::iterator sds_ref_it = sd->
sds_ref_list.begin();
2183 extra_sds_index = SDreftoindex(sdfd,*sds_ref_it);
2184 if(extra_sds_index == FAIL) {
2186 throw3(
"SDreftoindex Failed ",
"SDS reference number ", *sds_ref_it);
2190 sds_id = SDselect (sdfd, extra_sds_index);
2191 if (sds_id == FAIL) {
2195 SDendaccess (sds_id);
2196 throw3 (
"SDselect Failed ",
"SDS index ", extra_sds_index);
2200 status = SDgetinfo (sds_id, sds_name, &field->
rank, dim_sizes,
2201 &field->
type, &n_sds_attrs);
2202 if (status == FAIL) {
2205 SDendaccess (sds_id);
2206 throw2 (
"SDgetinfo failed ", sds_name);
2210 string tempname (sds_name);
2211 field->
name = tempname;
2213 field->
newname = tempname+
"_"+
"NONEOS";
2218 for (
int dimindex = 0; dimindex < field->
rank; dimindex++) {
2219 int dimid = SDgetdimid (sds_id, dimindex);
2220 if (dimid == FAIL) {
2223 SDendaccess (sds_id);
2224 throw5 (
"SDgetdimid failed ",
"SDS name ", sds_name,
2225 "dim index= ", dimindex);
2227 status = SDdiminfo (dimid, dim_name, &dim_size, &dim_type,
2230 if (status == FAIL) {
2233 SDendaccess (sds_id);
2234 throw5 (
"SDdiminfo failed ",
"SDS name ", sds_name,
2235 "dim index= ", dimindex);
2238 string dim_name_str (dim_name);
2243 new Dimension (dim_name_str, dim_sizes[dimindex], dim_type);
2245 field->
dims.push_back (dim);
2265 new Dimension (cfdimname, dim_sizes[dimindex], dim_type);
2272 for (
int attrindex = 0; attrindex < n_sds_attrs; attrindex++) {
2276 status = SDattrinfo (sds_id, attrindex, attr_name, &attr->
type,
2278 if (status == FAIL) {
2282 SDendaccess (sds_id);
2283 throw3 (
"SDattrinfo failed ",
"SDS name ", sds_name);
2286 string tempname (attr_name);
2287 attr->
name = tempname;
2292 attr->
count = attr_value_count;
2293 attr->
value.resize (attr_value_count * DFKNTsize (attr->
type));
2294 if (SDreadattr (sds_id, attrindex, &attr->
value[0]) == -1) {
2298 SDendaccess (sds_id);
2299 throw5 (
"read SDS attribute failed ",
"Field name ",
2300 field->
name,
" Attribute name ", attr->
name);
2302 field->
attrs.push_back (attr);
2304 SDendaccess (sds_id);
2317 int32 fieldsize = 0;
2320 int32 fieldtype = 0;
2323 int32 fieldorder = 0;
2326 char *fieldname =
NULL;
2330 char vdata_name[VSNAMELENMAX];
2332 VDATA *vdata =
new VDATA (vdata_id, obj_ref);
2334 vdata->
vdref = obj_ref;
2336 if (VSQueryname (vdata_id, vdata_name) == FAIL){
2338 throw3 (
"VSQueryname failed ",
"vdata id is ", vdata_id);
2341 string vdatanamestr (vdata_name);
2343 vdata->
name = vdatanamestr;
2345 int32 num_field = VFnfields (vdata_id);
2347 if (num_field == -1){
2349 throw3 (
"For vdata, VFnfields failed. ",
"vdata name is ",
2353 int32 num_record = VSelts (vdata_id);
2355 if (num_record == -1) {
2357 throw3 (
"For vdata, VSelts failed. ",
"vdata name is ", vdata->
name);
2364 string check_vdata_to_attr_key=
"H4.EnableVdata_to_Attr";
2365 bool turn_on_vdata_to_attr_key =
false;
2373 if (num_record <= 10 &&
true == turn_on_vdata_to_attr_key)
2379 for (
int i = 0; i < num_field; i++) {
2382 fieldsize = VFfieldesize (vdata_id, i);
2383 if (fieldsize == FAIL) {
2386 throw5 (
"For vdata field, VFfieldsize failed. ",
"vdata name is ",
2387 vdata->
name,
" index is ", i);
2390 fieldname = VFfieldname (vdata_id, i);
2391 if (fieldname ==
NULL) {
2394 throw5 (
"For vdata field, VFfieldname failed. ",
"vdata name is ",
2395 vdata->
name,
" index is ", i);
2398 fieldtype = VFfieldtype (vdata_id, i);
2399 if (fieldtype == FAIL) {
2402 throw5 (
"For vdata field, VFfieldtype failed. ",
"vdata name is ",
2403 vdata->
name,
" index is ", i);
2406 fieldorder = VFfieldorder (vdata_id, i);
2407 if (fieldorder == FAIL) {
2410 throw5 (
"For vdata field, VFfieldtype failed. ",
"vdata name is ",
2411 vdata->
name,
" index is ", i);
2414 field->
name = fieldname;
2416 field->
type = fieldtype;
2417 field->
order = fieldorder;
2418 field->
size = fieldsize;
2420 field->
numrec = num_record;
2427 field->
value.resize (num_record * fieldsize);
2428 if (VSseek (vdata_id, 0) == FAIL) {
2431 throw5 (
"vdata ", vdata_name,
"field ", fieldname,
2435 if (VSsetfields (vdata_id, fieldname) == FAIL) {
2438 throw3 (
"vdata field ", fieldname,
" VSsetfields failed.");
2442 (vdata_id, (uint8 *) & field->
value[0], num_record,
2443 FULL_INTERLACE) == FAIL){
2446 throw3 (
"vdata field ", fieldname,
" VSread failed.");
2483 char attr_name[H4_MAX_NC_NAME];
2495 nattrs = VSfnattrs (vdata_id, _HDF_VDATA);
2500 throw3 (
"VSfnattrs failed ",
"vdata id is ", vdata_id);
2506 for (
int i = 0; i < nattrs; i++) {
2510 status = VSattrinfo (vdata_id, _HDF_VDATA, i, attr_name,
2512 if (status == FAIL) {
2514 throw5 (
"VSattrinfo failed ",
"vdata id is ", vdata_id,
2515 " attr index is ", i);
2519 string tempname(attr_name);
2520 attr->
name = tempname;
2522 attr->
value.resize (attrsize);
2523 if (VSgetattr (vdata_id, _HDF_VDATA, i, &attr->
value[0]) == FAIL) {
2525 throw5 (
"VSgetattr failed ",
"vdata id is ", vdata_id,
2526 " attr index is ", i);
2528 attrs.push_back (attr);
2543 char attr_name[H4_MAX_NC_NAME];
2555 nattrs = VSfnattrs (vdata_id, fieldindex);
2560 throw5 (
"VSfnattrs failed ",
"vdata id is ", vdata_id,
2561 "Field index is ", fieldindex);
2567 for (
int i = 0; i < nattrs; i++) {
2571 status = VSattrinfo (vdata_id, fieldindex, i, attr_name,
2574 if (status == FAIL) {
2576 throw5 (
"VSattrinfo failed ",
"vdata field index ",
2577 fieldindex,
" attr index is ", i);
2580 string tempname(attr_name);
2581 attr->
name = tempname;
2586 attr->
value.resize (attrsize);
2587 if (VSgetattr (vdata_id, fieldindex, i, &attr->
value[0]) == FAIL) {
2589 throw5 (
"VSgetattr failed ",
"vdata field index is ",
2590 fieldindex,
" attr index is ", i);
2592 attrs.push_back (attr);
2602 char attr_name[H4_MAX_NC_NAME];
2605 intn n_attrs = Vnattrs(vgroup_id);
2607 throw1(
"Vnattrs failed");
2610 string temp_container_name(fullpath);
2614 for(
int attr_index = 0; attr_index <n_attrs; attr_index++) {
2617 int32 value_size_32 = 0;
2618 status_n = Vattrinfo(vgroup_id, (intn)attr_index, attr_name, &attr->
type,
2619 &attr->
count, &value_size_32);
2620 if(status_n == FAIL) {
2622 throw1(
"Vattrinfo failed.");
2624 int value_size = value_size_32;
2626 string tempname (attr_name);
2627 attr->
name = tempname;
2630 attr->
value.resize (value_size);
2632 status_n = Vgetattr(vgroup_id,(intn)attr_index,&attr->
value[0]);
2633 if(status_n == FAIL) {
2635 throw3(
"Vgetattr failed. ",
"The attribute name is ",attr->
name);
2637 vg_attr->
attrs.push_back(attr);
2641 vg_attrs.push_back(vg_attr);
2661 int32 vgroup_id = 0;
2667 int32 lone_vg_number = 0;
2670 int32 num_of_lones = -1;
2673 int32 num_gobjects = 0;
2683 char vdata_name[VSNAMELENMAX];
2686 char vdata_class[VSNAMELENMAX];
2689 char vgroup_name[VGNAMELENMAX*4];
2692 char vgroup_class[VGNAMELENMAX*4];
2703 file_id = this->fileid;
2709 num_of_lones = Vlone (file_id,
NULL, 0);
2710 if (num_of_lones == FAIL)
2711 throw3 (
"Fail to obtain lone vgroup number",
"file id is", file_id);
2714 if (num_of_lones > 0) {
2718 vector<int32>ref_array;
2719 ref_array.resize(num_of_lones);
2723 num_of_lones = Vlone (file_id, &ref_array[0], num_of_lones);
2724 if (num_of_lones == FAIL) {
2725 throw3 (
"Cannot obtain lone vgroup reference arrays ",
2726 "file id is ", file_id);
2730 for (lone_vg_number = 0; lone_vg_number < num_of_lones;
2734 vgroup_id = Vattach (file_id, ref_array[lone_vg_number],
"r");
2735 if (vgroup_id == FAIL) {
2736 throw3 (
"Vattach failed ",
"Reference number is ",
2737 ref_array[lone_vg_number]);
2740 status = Vgetname (vgroup_id, vgroup_name);
2741 if (status == FAIL) {
2742 Vdetach (vgroup_id);
2743 throw3 (
"Vgetname failed ",
"vgroup_id is ", vgroup_id);
2746 status = Vgetclass (vgroup_id, vgroup_class);
2747 if (status == FAIL) {
2748 Vdetach (vgroup_id);
2749 throw3 (
"Vgetclass failed ",
"vgroup_name is ", vgroup_name);
2753 if (strcmp (vgroup_class, _HDF_ATTRIBUTE) == 0
2754 || strcmp (vgroup_class, _HDF_VARIABLE) == 0
2755 || strcmp (vgroup_class, _HDF_DIMENSION) == 0
2756 || strcmp (vgroup_class, _HDF_UDIMENSION) == 0
2757 || strcmp (vgroup_class, _HDF_CDF) == 0
2758 || strcmp (vgroup_class, GR_NAME) == 0
2759 || strcmp (vgroup_class, RI_NAME) == 0) {
2764 num_gobjects = Vntagrefs (vgroup_id);
2765 if (num_gobjects < 0) {
2766 Vdetach (vgroup_id);
2767 throw3 (
"Vntagrefs failed ",
"vgroup_name is ", vgroup_name);
2776 if (full_path ==
NULL) {
2777 Vdetach (vgroup_id);
2778 throw1 (
"No enough memory to allocate the buffer.");
2783 strncat(full_path,vgroup_name,strlen(vgroup_name));
2785 ReadVgattrs(vgroup_id,full_path);
2789 Vdetach (vgroup_id);
2791 throw1 (
"ReadVgattrs failed ");
2796 if (cfull_path ==
NULL) {
2797 Vdetach (vgroup_id);
2799 throw1 (
"No enough memory to allocate the buffer.");
2802 strncpy (cfull_path, full_path,strlen(full_path));
2805 for (
int i = 0; i < num_gobjects; i++) {
2806 if (Vgettagref (vgroup_id, i, &obj_tag, &obj_ref) == FAIL) {
2807 Vdetach (vgroup_id);
2810 throw5 (
"Vgettagref failed ",
"vgroup_name is ",
2811 vgroup_name,
" reference number is ", obj_ref);
2815 if (Visvg (vgroup_id, obj_ref) ==
TRUE) {
2816 strncpy (full_path, cfull_path,strlen(cfull_path)+1);
2817 full_path[strlen(cfull_path)]=
'\0';
2818 obtain_path (file_id, sd_id, full_path, obj_ref);
2821 else if (Visvs (vgroup_id, obj_ref)) {
2823 vdata_id = VSattach (file_id, obj_ref,
"r");
2824 if (vdata_id == FAIL) {
2825 Vdetach (vgroup_id);
2828 throw5 (
"VSattach failed ",
"vgroup_name is ",
2829 vgroup_name,
" reference number is ",
2832 status = VSgetname (vdata_id, vdata_name);
2833 if (status == FAIL) {
2834 Vdetach (vgroup_id);
2837 throw5 (
"VSgetclass failed ",
"vgroup_name is ",
2838 vgroup_name,
" reference number is ",
2842 status = VSgetclass (vdata_id, vdata_class);
2843 if (status == FAIL) {
2844 Vdetach (vgroup_id);
2847 throw5 (
"VSgetclass failed ",
"vgroup_name is ",
2848 vgroup_name,
" reference number is ",
2861 if (VSisattr (vdata_id) ==
TRUE
2864 || !strncmp (vdata_class, _HDF_SDSVAR,
2865 strlen (_HDF_SDSVAR))
2866 || !strncmp (vdata_class, _HDF_CRDVAR,
2867 strlen (_HDF_CRDVAR))
2868 || !strncmp (vdata_class, DIM_VALS, strlen (DIM_VALS))
2869 || !strncmp (vdata_class, DIM_VALS01,
2870 strlen (DIM_VALS01))
2871 || !strncmp (vdata_class, RIGATTRCLASS,
2872 strlen (RIGATTRCLASS))
2873 || !strncmp (vdata_name, RIGATTRNAME,
2874 strlen (RIGATTRNAME))) {
2876 status = VSdetach (vdata_id);
2877 if (status == FAIL) {
2878 Vdetach (vgroup_id);
2881 throw3 (
"VSdetach failed ",
2882 "Vdata is under vgroup ", vgroup_name);
2896 Vdetach (vgroup_id);
2906 for (std::vector <VDField * >::const_iterator it_vdf =
2908 it_vdf != vdataobj->
getFields ().end ();
2914 (*it_vdf)->newname =
2915 "vdata" + vdataobj->
newname +
"_vdf_" + (*it_vdf)->name;
2925 this->vds.push_back (vdataobj);
2927 status = VSdetach (vdata_id);
2928 if (status == FAIL) {
2929 Vdetach (vgroup_id);
2932 throw3 (
"VSdetach failed ",
2933 "Vdata is under vgroup ", vgroup_name);
2939 else if (obj_tag == DFTAG_NDG || obj_tag == DFTAG_SDG
2940 || obj_tag == DFTAG_SD) {
2943 if (this->sd->refindexlist.find (obj_ref) !=
2944 sd->refindexlist.end ())
2945 this->sd->sdfields[this->sd->refindexlist[obj_ref]]->newname =
2947 this->sd->sdfields[this->sd->refindexlist[obj_ref]]->name;
2949 Vdetach (vgroup_id);
2952 throw3 (
"SDS with the reference number ", obj_ref,
2961 status = Vdetach (vgroup_id);
2962 if (status == FAIL) {
2963 throw3 (
"Vdetach failed ",
"vgroup_name is ", vgroup_name);
2979 int32 vgroup_pid = 0;
2988 int num_gobjects = 0;
2996 char cvgroup_name[VGNAMELENMAX*4];
2999 char vdata_name[VSNAMELENMAX];
3002 char vdata_class[VSNAMELENMAX];
3005 int32 vdata_id = -1;
3026 if (cfull_path ==
NULL)
3027 throw1 (
"No enough memory to allocate the buffer");
3030 vgroup_pid = Vattach (file_id, pobj_ref,
"r");
3031 if (vgroup_pid == FAIL) {
3033 throw3 (
"Vattach failed ",
"Object reference number is ", pobj_ref);
3036 if (Vgetname (vgroup_pid, cvgroup_name) == FAIL) {
3037 Vdetach (vgroup_pid);
3039 throw3 (
"Vgetname failed ",
"Object reference number is ", pobj_ref);
3041 num_gobjects = Vntagrefs (vgroup_pid);
3042 if (num_gobjects < 0) {
3043 Vdetach (vgroup_pid);
3045 throw3 (
"Vntagrefs failed ",
"Object reference number is ", pobj_ref);
3048 strncpy(cfull_path,full_path,strlen(full_path));
3049 strncat(cfull_path,cvgroup_name,strlen(cvgroup_name));
3051 ReadVgattrs(vgroup_pid,cfull_path);
3055 Vdetach (vgroup_pid);
3057 throw1 (
"ReadVgattrs failed ");
3064 for (i = 0; i < num_gobjects; i++) {
3066 if (Vgettagref (vgroup_pid, i, &obj_tag, &obj_ref) == FAIL) {
3067 Vdetach (vgroup_pid);
3069 throw3 (
"Vgettagref failed ",
"object index is ", i);
3072 if (Visvg (vgroup_pid, obj_ref) ==
TRUE) {
3073 strncpy(full_path,cfull_path,strlen(cfull_path)+1);
3074 full_path[strlen(cfull_path)]=
'\0';
3075 obtain_path (file_id, sd_id, full_path, obj_ref);
3077 else if (Visvs (vgroup_pid, obj_ref)) {
3079 vdata_id = VSattach (file_id, obj_ref,
"r");
3080 if (vdata_id == FAIL) {
3081 Vdetach (vgroup_pid);
3083 throw3 (
"VSattach failed ",
"object index is ", i);
3087 status = VSQueryname (vdata_id, vdata_name);
3088 if (status == FAIL) {
3089 Vdetach (vgroup_pid);
3091 throw3 (
"VSgetclass failed ",
"object index is ", i);
3094 status = VSgetclass (vdata_id, vdata_class);
3095 if (status == FAIL) {
3096 Vdetach (vgroup_pid);
3098 throw3 (
"VSgetclass failed ",
"object index is ", i);
3101 if (VSisattr (vdata_id) !=
TRUE) {
3113 Vdetach (vgroup_pid);
3123 for (std::vector <VDField * >::const_iterator it_vdf =
3125 it_vdf != vdataobj->
getFields ().end ();
3130 (*it_vdf)->newname =
3131 "vdata" + vdataobj->
newname +
"_vdf_" +
3139 this->vds.push_back (vdataobj);
3142 status = VSdetach (vdata_id);
3143 if (status == FAIL) {
3145 throw3 (
"VSdetach failed ",
"object index is ", i);
3148 else if (obj_tag == DFTAG_NDG || obj_tag == DFTAG_SDG
3149 || obj_tag == DFTAG_SD) {
3150 if (this->sd->refindexlist.find (obj_ref) !=
3151 this->sd->refindexlist.end ())
3152 this->sd->sdfields[this->sd->refindexlist[obj_ref]]->newname =
3154 cfull_path + this->sd->sdfields[this->sd->refindexlist[obj_ref]]->name;
3156 Vdetach (vgroup_pid);
3158 throw3 (
"SDS with the reference number ", obj_ref,
3164 status = Vdetach (vgroup_pid);
3165 if (status == FAIL) {
3167 throw3 (
"Vdetach failed ",
"vgroup name is ", cvgroup_name);
3179 SD::obtain_noneos2_sds_path (int32 file_id,
char *full_path, int32 pobj_ref)
3183 int32 vgroup_cid = 0;
3186 int num_gobjects = 0;
3191 char cvgroup_name[VGNAMELENMAX*4];
3193 int32 obj_tag, obj_ref;
3206 if (cfull_path ==
NULL)
3207 throw1 (
"No enough memory to allocate the buffer");
3211 vgroup_cid = Vattach (file_id, pobj_ref,
"r");
3212 if (vgroup_cid == FAIL) {
3214 throw3 (
"Vattach failed ",
"Object reference number is ", pobj_ref);
3217 if (Vgetname (vgroup_cid, cvgroup_name) == FAIL) {
3218 Vdetach (vgroup_cid);
3220 throw3 (
"Vgetname failed ",
"Object reference number is ", pobj_ref);
3222 num_gobjects = Vntagrefs (vgroup_cid);
3223 if (num_gobjects < 0) {
3224 Vdetach (vgroup_cid);
3226 throw3 (
"Vntagrefs failed ",
"Object reference number is ", pobj_ref);
3230 strncpy(cfull_path,full_path,strlen(full_path));
3231 strncat(cfull_path,cvgroup_name,strlen(cvgroup_name));
3234 for (i = 0; i < num_gobjects; i++) {
3236 if (Vgettagref (vgroup_cid, i, &obj_tag, &obj_ref) == FAIL) {
3237 Vdetach (vgroup_cid);
3239 throw3 (
"Vgettagref failed ",
"object index is ", i);
3242 if (Visvg (vgroup_cid, obj_ref) ==
TRUE) {
3243 strncpy (full_path, cfull_path,strlen(cfull_path)+1);
3244 full_path[strlen(cfull_path)]=
'\0';
3245 obtain_noneos2_sds_path (file_id, full_path, obj_ref);
3247 else if (obj_tag == DFTAG_NDG || obj_tag == DFTAG_SDG
3248 || obj_tag == DFTAG_SD) {
3254 string temp_str = string(cfull_path);
3255 if((temp_str.find(
"Data Fields") != std::string::npos)||
3256 (temp_str.find(
"Geolocation Fields") != std::string::npos))
3257 sds_ref_list.remove(obj_ref);
3261 status = Vdetach (vgroup_cid);
3262 if (status == FAIL) {
3264 throw3 (
"Vdetach failed ",
"vgroup name is ", cvgroup_name);
3277 File::obtain_vdata_path (int32 file_id,
char *full_path,
3282 int32 vgroup_cid = -1;
3285 int num_gobjects = -1;
3290 char cvgroup_name[VGNAMELENMAX*4];
3291 char vdata_name[VSNAMELENMAX];
3292 char vdata_class[VSNAMELENMAX];
3293 int32 vdata_id = -1;
3308 if (cfull_path ==
NULL)
3309 throw1 (
"No enough memory to allocate the buffer");
3312 vgroup_cid = Vattach (file_id, pobj_ref,
"r");
3313 if (vgroup_cid == FAIL) {
3315 throw3 (
"Vattach failed ",
"Object reference number is ", pobj_ref);
3318 if (Vgetname (vgroup_cid, cvgroup_name) == FAIL) {
3319 Vdetach (vgroup_cid);
3321 throw3 (
"Vgetname failed ",
"Object reference number is ", pobj_ref);
3323 num_gobjects = Vntagrefs (vgroup_cid);
3324 if (num_gobjects < 0) {
3325 Vdetach (vgroup_cid);
3327 throw3 (
"Vntagrefs failed ",
"Object reference number is ", pobj_ref);
3330 strncpy(cfull_path,full_path,strlen(full_path));
3331 strncat(cfull_path,cvgroup_name,strlen(cvgroup_name));
3336 std::string temp_str = std::string(cfull_path);
3338 if (temp_str.find(
"Geolocation Fields") != string::npos) {
3339 if(
false == this->EOS2Swathflag)
3340 this->EOS2Swathflag =
true;
3343 for (i = 0; i < num_gobjects; i++) {
3345 if (Vgettagref (vgroup_cid, i, &obj_tag, &obj_ref) == FAIL) {
3346 Vdetach (vgroup_cid);
3348 throw3 (
"Vgettagref failed ",
"object index is ", i);
3351 if (Visvg (vgroup_cid, obj_ref) ==
TRUE) {
3352 strncpy(full_path,cfull_path,strlen(cfull_path)+1);
3353 full_path[strlen(cfull_path)] =
'\0';
3354 obtain_vdata_path (file_id, full_path, obj_ref);
3356 else if (Visvs (vgroup_cid, obj_ref)) {
3358 vdata_id = VSattach (file_id, obj_ref,
"r");
3359 if (vdata_id == FAIL) {
3360 Vdetach (vgroup_cid);
3362 throw3 (
"VSattach failed ",
"object index is ", i);
3365 status = VSQueryname (vdata_id, vdata_name);
3366 if (status == FAIL) {
3367 Vdetach (vgroup_cid);
3369 throw3 (
"VSgetclass failed ",
"object index is ", i);
3372 status = VSgetclass (vdata_id, vdata_class);
3373 if (status == FAIL) {
3374 Vdetach (vgroup_cid);
3376 throw3 (
"VSgetclass failed ",
"object index is ", i);
3380 string temp_str = string(cfull_path);
3390 bool ignore_eos2_geo_vdata =
false;
3391 bool ignore_eos2_data_vdata =
false;
3392 if (temp_str.find(
"Geolocation Fields") != string::npos) {
3393 ignore_eos2_geo_vdata =
true;
3397 if (temp_str.find(
"Data Fields") != string::npos) {
3398 if (
true == this->EOS2Swathflag)
3399 ignore_eos2_data_vdata =
true;
3401 if ((
true == ignore_eos2_data_vdata)
3402 ||(
true == ignore_eos2_geo_vdata)
3403 || VSisattr (vdata_id) ==
TRUE
3406 || !strncmp (vdata_class, _HDF_SDSVAR,
3407 strlen (_HDF_SDSVAR))
3408 || !strncmp (vdata_class, _HDF_CRDVAR,
3409 strlen (_HDF_CRDVAR))
3410 || !strncmp (vdata_class, DIM_VALS, strlen (DIM_VALS))
3411 || !strncmp (vdata_class, DIM_VALS01,
3412 strlen (DIM_VALS01))
3413 || !strncmp (vdata_class, RIGATTRCLASS,
3414 strlen (RIGATTRCLASS))
3415 || !strncmp (vdata_name, RIGATTRNAME,
3416 strlen (RIGATTRNAME))) {
3418 status = VSdetach (vdata_id);
3419 if (status == FAIL) {
3420 Vdetach (vgroup_cid);
3422 throw3 (
"VSdetach failed ",
3423 "Vdata is under vgroup ", cvgroup_name);
3430 vdataobj = VDATA::Read (vdata_id, obj_ref);
3435 Vdetach (vgroup_cid);
3444 for (std::vector <VDField * >::const_iterator it_vdf =
3446 it_vdf != vdataobj->
getFields ().end ();
3451 (*it_vdf)->newname =
3452 "vdata" + vdataobj->
newname +
"_vdf_" +
3460 this->vds.push_back (vdataobj);
3461 status = VSdetach (vdata_id);
3462 if (status == FAIL) {
3464 Vdetach(vgroup_cid);
3465 throw3 (
"VSdetach failed ",
"object index is ", i);
3471 status = Vdetach (vgroup_cid);
3472 if (status == FAIL) {
3474 throw3 (
"Vdetach failed ",
"vgroup name is ", cvgroup_name);
3498 std::string tempdimname;
3499 std::pair < std::set < std::string >::iterator,
bool > ret;
3500 std::string temppath;
3501 std::set < int32 > fakedimsizeset;
3502 std::pair < std::set < int32 >::iterator,
bool > fakedimsizeit;
3503 std::map < int32, std::string > fakedimsizenamelist;
3504 std::map < int32, std::string >::iterator fakedimsizenamelistit;
3506 for (std::vector < SDField * >::const_iterator i =
3509 for (std::vector < Dimension * >::const_iterator j =
3510 (*i)->getDimensions ().begin ();
3511 j != (*i)->getDimensions ().end (); ++j) {
3515 tempdimname = (*j)->getName ();
3517 tempdimname = (*j)->getName () + temppath;
3520 new Dimension (tempdimname, (*j)->getSize (),
3522 (*i)->correcteddims.push_back (dim);
3523 if (tempdimname.find (
"fakeDim") != std::string::npos) {
3524 fakedimsizeit = fakedimsizeset.insert ((*j)->getSize ());
3525 if (fakedimsizeit.second ==
true) {
3526 fakedimsizenamelist[(*j)->getSize ()] = (*j)->getName ();
3537 for (std::vector < SDField * >::const_iterator i =
3539 for (std::vector < Dimension * >::const_iterator j =
3540 (*i)->getCorrectedDimensions ().begin ();
3541 j != (*i)->getCorrectedDimensions ().end (); ++j) {
3542 if ((*j)->getName ().find (
"fakeDim") != std::string::npos) {
3543 if (fakedimsizenamelist.find ((*j)->getSize ()) !=
3544 fakedimsizenamelist.end ()) {
3545 (*j)->name = fakedimsizenamelist[(*j)->getSize ()];
3548 throw5 (
"The fakeDim name ", (*j)->getName (),
3549 "with the size", (*j)->getSize (),
3550 "does not in the fakedimsize list");
3563 for (std::vector < SDField * >::const_iterator i =
3565 for (std::vector < Dimension * >::const_iterator j =
3566 (*i)->getCorrectedDimensions ().begin ();
3567 j != (*i)->getCorrectedDimensions ().end (); ++j) {
3568 std::pair < std::set < std::string >::iterator,
bool > ret;
3572 if (ret.second ==
true) {
3590 for (std::map < std::string, int32 >::const_iterator i =
3601 missingfield->
type = DFNT_INT32;
3602 missingfield->
name = (*i).first;
3603 missingfield->
newname = (*i).first;
3604 missingfield->
rank = 1;
3608 missingfield->
dims.push_back (dim);
3609 dim =
new Dimension ((*i).first, (*i).second, 0);
3626 vector<string>tempfulldimnamelist;
3627 for (std::set < std::string >::const_iterator i =
3635 int total_dcounter = 0;
3636 for (std::set < std::string >::const_iterator i =
3644 std::map < std::string, std::string >::iterator tempmapit;
3645 for (std::vector < SDField * >::const_iterator i =
3647 for (std::vector < Dimension * >::const_iterator j =
3648 (*i)->getCorrectedDimensions ().begin ();
3649 j != (*i)->getCorrectedDimensions ().end (); ++j) {
3652 (*j)->name = tempmapit->second;
3654 throw5 (
"This dimension with the name ", (*j)->name,
3655 "and the field name ", (*i)->name,
3656 " is not found in the dimension list.");
3679 string check_ceres_short_name_key=
"H4.EnableCERESMERRAShortName";
3680 bool turn_on_ceres_short_name_key=
false;
3684 if (
true == turn_on_ceres_short_name_key && (file->sptype ==
CER_ES4 || file->sptype ==
CER_SRB
3687 || file->sptype ==
CER_AVG)) {
3689 for (
unsigned int i = 0; i < file->
sd->
sdfields.size (); ++i) {
3696 vector<string>sd_data_fieldnamelist;
3697 vector<string>sd_latlon_fieldnamelist;
3698 vector<string>sd_nollcv_fieldnamelist;
3700 set<string>sd_fieldnamelist;
3702 for (std::vector < SDField * >::const_iterator i =
3704 if ((*i)->fieldtype ==0)
3706 else if ((*i)->fieldtype == 1 || (*i)->fieldtype == 2)
3719 int total_data_counter = 0;
3720 int total_latlon_counter = 0;
3721 int total_nollcv_counter = 0;
3728 std::map < std::string, std::string >::iterator tempmapit;
3731 for (std::vector < SDField * >::const_iterator i =
3747 if ((*i)->fieldtype != 0) {
3748 if ((*i)->fieldtype == 1 || (*i)->fieldtype == 2) {
3750 (*i)->newname = sd_latlon_fieldnamelist[total_latlon_counter];
3751 total_latlon_counter++;
3753 if ((*i)->getRank () > 2)
3754 throw3 (
"the lat/lon rank should NOT be greater than 2",
3755 (*i)->name, (*i)->getRank ());
3756 else if ((*i)->getRank () == 2) {
3757 for (std::vector < Dimension * >::const_iterator j =
3758 (*i)->getCorrectedDimensions ().begin ();
3759 j != (*i)->getCorrectedDimensions ().end (); ++j) {
3766 if (lldimname1 ==
"")
3767 lldimname1 =(*j)->name;
3769 lldimname2 = (*j)->name;
3780 (*i)->getCorrectedDimensions ()[0]->getName ();
3788 (*i)->newname = sd_data_fieldnamelist[total_data_counter];
3789 total_data_counter++;
3794 for (std::vector < SDField * >::const_iterator i =
3811 if ((*i)->fieldtype != 0) {
3812 if ((*i)->fieldtype != 1 && (*i)->fieldtype != 2) {
3815 (*i)->newname = sd_nollcv_fieldnamelist[total_nollcv_counter];
3816 total_nollcv_counter++;
3818 if ((*i)->getRank () > 1)
3819 throw3 (
"The lat/lon rank should be 1", (*i)->name,
3825 if (COARDFLAG || file->sptype ==
OTHERHDF)
3827 (*i)->getCorrectedDimensions ()[0]->getName ();
3831 (*i)->getCorrectedDimensions ()[0]->getName ();
3849 std::map < std::string, std::string >::iterator tempmapit;
3852 std::string tempcoordinates, tempfieldname;
3853 for (std::vector < SDField * >::const_iterator i =
3855 if ((*i)->fieldtype == 0) {
3857 tempcoordinates =
"";
3860 for (std::vector < Dimension * >::const_iterator j =
3861 (*i)->getCorrectedDimensions ().begin ();
3862 j != (*i)->getCorrectedDimensions ().end (); ++j) {
3863 tempmapit = (file->
sd->
dimcvarlist).find ((*j)->getName ());
3865 tempfieldname = tempmapit->second;
3867 throw3 (
"The dimension with the name ", (*j)->getName (),
3868 "must have corresponding coordinate variables.");
3870 tempcoordinates = tempfieldname;
3872 tempcoordinates = tempcoordinates +
" " + tempfieldname;
3875 (*i)->setCoordinates (tempcoordinates);
3879 if ((*i)->fieldtype == 1) {
3880 std::string tempunits =
"degrees_north";
3881 (*i)->setUnits (tempunits);
3884 if ((*i)->fieldtype == 2) {
3885 std::string tempunits =
"degrees_east";
3886 (*i)->setUnits (tempunits);
3890 if (((*i)->fieldtype == 3) || ((*i)->fieldtype == 4)) {
3891 std::string tempunits =
"level";
3892 (*i)->setUnits (tempunits);
3900 if (
false == COARDFLAG) {
3901 for (std::vector < SDField * >::const_iterator i =
3903 if ((*i)->fieldtype == 0) {
3904 bool has_lldim1 =
false;
3905 bool has_lldim2 =
false;
3906 for (std::vector < Dimension * >::const_iterator j =
3907 (*i)->getCorrectedDimensions ().begin ();
3908 j != (*i)->getCorrectedDimensions ().end (); ++j) {
3909 if(lldimname1 == (*j)->name)
3911 else if(lldimname2 == (*j)->name)
3916 if (has_lldim1^has_lldim2)
3917 (*i)->coordinates =
"";
3937 string check_disable_vdata_nameclashing_key=
"H4.DisableVdataNameclashingCheck";
3938 bool turn_on_disable_vdata_nameclashing_key =
false;
3942 if (
false == turn_on_disable_vdata_nameclashing_key) {
3944 vector<string> tempvdatafieldnamelist;
3946 for (std::vector < VDATA * >::const_iterator i = file->
vds.begin ();
3947 i != file->
vds.end (); ++i) {
3948 for (std::vector < VDField * >::const_iterator j =
3949 (*i)->getFields ().begin (); j != (*i)->getFields ().end ();
3951 tempvdatafieldnamelist.push_back((*j)->newname);
3956 int total_vfd_counter = 0;
3958 for (std::vector < VDATA * >::const_iterator i = file->
vds.begin ();
3959 i != file->
vds.end (); ++i) {
3960 for (std::vector < VDField * >::const_iterator j =
3961 (*i)->getFields ().begin (); j != (*i)->getFields ().end ();
3963 (*j)->newname = tempvdatafieldnamelist[total_vfd_counter];
3964 total_vfd_counter++;
3990 for (std::vector < SDField * >::const_iterator i =
3992 for (vector<AttrContainer *>::iterator j = (*i)->dims_info.begin();
3993 j!= (*i)->dims_info.end(); ++j) {
3995 (*i)->dims_info.erase(j);
3998 if ((*i)->dims_info.size() != 0)
3999 throw1(
"Not totally erase the dimension container ");
4009 switch (file->sptype) {
4104 throw3 (
"No such SP datatype ",
"sptype is ", sptype);
4119 bool COARDFLAG =
false;
4137 for (std::vector < Attribute * >::const_iterator i =
4138 this->sd->getAttributes ().begin ();
4139 i != this->sd->getAttributes ().end (); ++i) {
4141 if ((*i)->getName () ==
"GridHeader") {
4142 float lat_start = 0.;
4143 float lon_start = 0.;
4147 lat_start,lon_start,
4148 lat_res,lon_res,
false);
4156 const int lonsize,
string& latname,
string& lonname)
throw(
Exception) {
4161 int latname_index = -1;
4162 int lonname_index = -1;
4163 for (
int temp_index = 0; temp_index <sdfield->getRank(); ++temp_index) {
4164 if(-1==latname_index && sdfield->getCorrectedDimensions()[temp_index]->getSize() == latsize) {
4165 latname_index = temp_index;
4167 latname = sdfield->getCorrectedDimensions()[temp_index]->getName();
4169 else if (-1 == lonname_index && sdfield->getCorrectedDimensions()[temp_index]->getSize() == lonsize) {
4170 lonname_index = temp_index;
4172 lonname = sdfield->getCorrectedDimensions()[temp_index]->getName();
4176 return (latname_index + lonname_index == 1);
4185 std::string tempdimname1, tempdimname2;
4186 std::string tempnewdimname1, tempnewdimname2;
4187 std::string temppath;
4194 std::set < int32 > tempdimsizeset;
4195 std::map < int32, std::string > tempdimsizenamelist;
4196 std::map < int32, std::string >::iterator tempsizemapit;
4197 std::pair < std::set < int32 >::iterator,
bool > tempsetit;
4200 for (std::vector < SDField * >::const_iterator i =
4202 for (std::vector < Dimension * >::const_iterator j =
4203 (*i)->getCorrectedDimensions ().begin ();
4204 j != (*i)->getCorrectedDimensions ().end (); ++j) {
4205 if (((*j)->getName ()).find (
"fakeDim") == std::string::npos) {
4206 tempsetit = tempdimsizeset.insert ((*j)->getSize ());
4207 if (tempsetit.second ==
true)
4208 tempdimsizenamelist[(*j)->getSize ()] = (*j)->getName ();
4214 for (std::vector < SDField * >::const_iterator i =
4217 string temp_name = (*i)->newname.substr(1) ;
4218 size_t temp_pos = temp_name.find_first_of(
'/');
4219 if (temp_pos !=string::npos)
4220 (*i)->newname = temp_name.substr(temp_pos+1);
4226 for (std::vector < SDField * >::const_iterator i =
4229 if((*i)->getName() ==
"Latitude") {
4230 if((*i)->getRank() ==2) {
4233 ((*i)->getCorrectedDimensions ())[0]->getName ();
4235 ((*i)->getCorrectedDimensions ())[1]->getName ();
4238 (*i)->fieldtype = 1;
4241 else if ((*i)->getName() ==
"Longitude") {
4242 (*i)->fieldtype = 2;
4249 for (std::vector < Dimension * >::const_iterator k =
4250 (*i)->getCorrectedDimensions ().begin ();
4251 k != (*i)->getCorrectedDimensions ().end (); ++k) {
4252 size_t fakeDimpos = ((*k)->getName ()).find (
"fakeDim");
4254 if (fakeDimpos != std::string::npos) {
4256 tempdimsizenamelist.find ((*k)->getSize ());
4257 if (tempsizemapit != tempdimsizenamelist.end ())
4258 (*k)->name = tempdimsizenamelist[(*k)->getSize ()];
4266 if(tempnewdimname1.empty()!=
true)
4269 if(tempnewdimname2.empty()!=
true)
4272 string base_filename;
4273 size_t last_slash_pos = file->
getPath().find_last_of(
"/");
4274 if(last_slash_pos != string::npos)
4275 base_filename = file->
getPath().substr(last_slash_pos+1);
4276 if(
""==base_filename)
4277 base_filename = file->
getPath();
4280 if(base_filename.find(
"2A12")!=string::npos) {
4282 string nlayer_name =
"nlayer";
4284 for (vector < SDField * >::iterator i =
4287 bool has_nlayer =
false;
4289 for (vector < Dimension * >::const_iterator k =
4290 (*i)->getDimensions ().begin ();
4291 k != (*i)->getDimensions ().end (); ++k) {
4293 if((*k)->getSize() == 28 && (*k)->name == nlayer_name) {
4296 nlayer->
name = nlayer_name;
4298 nlayer->
type = DFNT_FLOAT32;
4304 nlayer->
dims.push_back(dim);
4315 if(
true == has_nlayer)
4331 for (std::vector < SDField * >::iterator i =
4335 if((*i)->name ==
"InputFileNames") {
4340 else if((*i)->name ==
"InputAlgorithmVersions") {
4345 else if((*i)->name ==
"InputGenerationDateTimes") {
4351 (*i)->newname = (*i)->name;
4356 string nlayer_name =
"nlayer";
4358 for (vector < SDField * >::iterator i =
4361 bool has_nlayer =
false;
4363 for (vector < Dimension * >::const_iterator k =
4364 (*i)->getDimensions ().begin ();
4365 k != (*i)->getDimensions ().end (); ++k) {
4367 if((*k)->getSize() == 28 && (*k)->name == nlayer_name) {
4370 nlayer->
name = nlayer_name;
4372 nlayer->
type = DFNT_FLOAT32;
4378 nlayer->
dims.push_back(dim);
4389 if(
true == has_nlayer)
4408 bool llname_found =
false;
4409 for (std::vector < SDField * >::iterator i =
4412 if(2 == (*i)->getRank()) {
4415 if (
true == llname_found)
4425 longitude->
name = lonname;
4426 longitude->
rank = 1;
4427 longitude->
type = DFNT_FLOAT32;
4433 longitude->
dims.push_back (dim);
4435 dim =
new Dimension (lonname, lonsize, 0);
4440 latitude->
name = latname;
4442 latitude->
type = DFNT_FLOAT32;
4446 dim =
new Dimension (latname, latsize, 0);
4447 latitude->
dims.push_back (dim);
4449 dim =
new Dimension (latname, latsize, 0);
4460 string base_filename;
4461 if(
path.find_last_of(
"/") != string::npos)
4462 base_filename =
path.substr(
path.find_last_of(
"/")+1);
4463 if(base_filename.find(
"3A26")!=string::npos) {
4465 bool ZOflag =
false;
4466 bool SRTflag =
false;
4467 bool HBflag =
false;
4468 string nthrsh_base_name =
"nthrsh";
4469 string nthrsh_zo_name =
"nthrshZO";
4470 string nthrsh_hb_name =
"nthrshHB";
4471 string nthrsh_srt_name =
"nthrshSRT";
4477 for (vector < SDField * >::iterator i =
4480 if(ZOflag !=
true) {
4481 if((*i)->name.find(
"Order")!=string::npos) {
4482 for (vector < Dimension * >::const_iterator k =
4483 (*i)->getDimensions ().begin ();
4484 k != (*i)->getDimensions ().end (); ++k) {
4486 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4488 nthrsh_zo->
name = nthrsh_zo_name;
4489 nthrsh_zo->
rank = 1;
4490 nthrsh_zo->
type = DFNT_FLOAT32;
4496 nthrsh_zo->
dims.push_back(dim);
4509 else if(SRTflag !=
true) {
4510 if((*i)->name.find(
"2A25")!=string::npos) {
4512 for (vector < Dimension * >::const_iterator k =
4513 (*i)->getDimensions ().begin ();
4514 k != (*i)->getDimensions ().end (); ++k) {
4516 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4518 nthrsh_srt->
name = nthrsh_srt_name;
4519 nthrsh_srt->
rank = 1;
4520 nthrsh_srt->
type = DFNT_FLOAT32;
4526 nthrsh_srt->
dims.push_back(dim);
4537 else if(HBflag !=
true) {
4538 if((*i)->name.find(
"hb")!=string::npos || (*i)->name.find(
"HB")!=string::npos) {
4540 for (vector < Dimension * >::const_iterator k =
4541 (*i)->getDimensions ().begin ();
4542 k != (*i)->getDimensions ().end (); ++k) {
4544 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4547 nthrsh_hb->
name = nthrsh_hb_name;
4548 nthrsh_hb->
rank = 1;
4549 nthrsh_hb->
type = DFNT_FLOAT32;
4555 nthrsh_hb->
dims.push_back(dim);
4569 for (vector < SDField * >::iterator i =
4572 if((*i)->name.find(
"Order")!=string::npos && ZOflag ==
true) {
4573 for (vector < Dimension * >::const_iterator k =
4574 (*i)->getDimensions ().begin ();
4575 k != (*i)->getDimensions ().end (); ++k) {
4577 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4578 (*k)->name = nthrsh_zo_name;
4583 for (std::vector < Dimension * >::const_iterator k =
4584 (*i)->getCorrectedDimensions ().begin ();
4585 k != (*i)->getCorrectedDimensions ().end (); ++k) {
4586 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4587 (*k)->name = nthrsh_zo_name;
4594 else if(((*i)->name.find(
"hb")!=string::npos || (*i)->name.find(
"HB")!=string::npos)&& HBflag ==
true) {
4595 for (vector < Dimension * >::const_iterator k =
4596 (*i)->getDimensions ().begin ();
4597 k != (*i)->getDimensions ().end (); ++k) {
4599 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4600 (*k)->name = nthrsh_hb_name;
4605 for (std::vector < Dimension * >::const_iterator k =
4606 (*i)->getCorrectedDimensions ().begin ();
4607 k != (*i)->getCorrectedDimensions ().end (); ++k) {
4608 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4609 (*k)->name = nthrsh_hb_name;
4615 else if(((*i)->name.find(
"2A25")!=string::npos) && SRTflag ==
true) {
4616 for (vector < Dimension * >::const_iterator k =
4617 (*i)->getDimensions ().begin ();
4618 k != (*i)->getDimensions ().end (); ++k) {
4620 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4621 (*k)->name = nthrsh_srt_name;
4626 for (std::vector < Dimension * >::const_iterator k =
4627 (*i)->getCorrectedDimensions ().begin ();
4628 k != (*i)->getCorrectedDimensions ().end (); ++k) {
4629 if((*k)->getSize() == 6 && (*k)->name == nthrsh_base_name) {
4630 (*k)->name = nthrsh_srt_name;
4640 if(nthrsh_zo !=
NULL) {
4645 if(nthrsh_hb !=
NULL) {
4650 if(nthrsh_srt !=
NULL) {
4663 for (std::vector < SDField * >::iterator i =
4666 if((*i)->name ==
"InputFileNames") {
4671 else if((*i)->name ==
"InputAlgorithmVersions") {
4676 else if((*i)->name ==
"InputGenerationDateTimes") {
4685 NOTE
for programming:
4686 1. Outer loop: loop global attribute
for GridHeader?. Retrieve ? as a number
for index.
4687 1.5. Obtain the lat/lon sizes
for this grid.
4688 The
following steps are to retrieve lat/lon names
for this grid.
4689 2. Inner loop: Then loop through the field
4690 3. Check the field rank,
4691 3.1
if the rank is not 2, (
if the index is the first index, change the newname to name )
4694 3.2.1 Retrieve the index from the field
new name(retrieve last
path Grid1 then retrieve 1)
4695 3.2.2 If the index from the field is the same as that from the GridHeader,
continue checking
4696 the lat/lon name
for this grid as the single grid.
4697 change the newname to name.
4704 int first_index = -1;
4705 for (vector < Attribute * >::const_iterator i =
4709 if ((*i)->getName ().find(
"GridHeader")==0) {
4710 string temp_name = (*i)->getName();
4713 string str_num = temp_name.substr(10);
4714 stringstream ss_num(str_num);
4717 ss_num >> grid_index;
4719 if ( -1 == first_index)
4720 first_index = grid_index;
4722 float lat_start = 0.;
4723 float lon_start = 0.;
4730 lat_start,lon_start,
4731 lat_res, lon_res,
false);
4736 bool llname_found =
false;
4737 for (std::vector < SDField * >::iterator i =
4741 if(2 == (*i)->getRank()) {
4744 if ((*i)->newname !=(*i)->name) {
4746 string temp_field_full_path = (*i)->getNewName();
4747 size_t last_path_pos = temp_field_full_path.find_last_of(
'/');
4748 char str_index = temp_field_full_path[last_path_pos-1];
4749 if(grid_index ==(
int)(str_index -
'0')) {
4750 if(llname_found !=
true)
4752 (*i)->newname = (*i)->name;
4756 else if (first_index == grid_index)
4757 (*i)->newname = (*i)->name;
4762 longitude->
name = lonname;
4763 longitude->
rank = 1;
4764 longitude->
type = DFNT_FLOAT32;
4771 longitude->
dims.push_back (dim);
4773 dim =
new Dimension (lonname, lonsize, 0);
4778 latitude->
name = latname;
4780 latitude->
type = DFNT_FLOAT32;
4785 dim =
new Dimension (latname, latsize, 0);
4786 latitude->
dims.push_back (dim);
4788 dim =
new Dimension (latname, latsize, 0);
4811 std::string tempdimname1, tempdimname2;
4812 std::string tempnewdimname1, tempnewdimname2;
4813 std::string temppath;
4815 int32 tempdimsize1, tempdimsize2;
4820 std::set < int32 > tempdimsizeset;
4821 std::map < int32, std::string > tempdimsizenamelist;
4822 std::map < int32, std::string >::iterator tempsizemapit;
4823 std::pair < std::set < int32 >::iterator,
bool > tempsetit;
4826 for (std::vector < SDField * >::const_iterator i =
4828 for (std::vector < Dimension * >::const_iterator j =
4829 (*i)->getCorrectedDimensions ().begin ();
4830 j != (*i)->getCorrectedDimensions ().end (); ++j) {
4831 if (((*j)->getName ()).find (
"fakeDim") == std::string::npos) {
4832 tempsetit = tempdimsizeset.insert ((*j)->getSize ());
4833 if (tempsetit.second ==
true)
4834 tempdimsizenamelist[(*j)->getSize ()] = (*j)->getName ();
4839 for (std::vector < SDField * >::const_iterator i =
4842 if ((*i)->getName () ==
"geolocation") {
4846 tempdimname1 = ((*i)->getDimensions ())[0]->getName ();
4847 tempdimsize1 = ((*i)->getDimensions ())[0]->getSize ();
4848 tempdimname2 = ((*i)->getDimensions ())[1]->getName ();
4849 tempdimsize2 = ((*i)->getDimensions ())[1]->getSize ();
4852 ((*i)->getCorrectedDimensions ())[0]->getName ();
4854 ((*i)->getCorrectedDimensions ())[1]->getName ();
4857 latitude->
name =
"latitude";
4859 latitude->
fieldref = (*i)->fieldref;
4860 latitude->
type = (*i)->getType ();
4861 temppath = (*i)->newname.substr ((*i)->name.size ());
4868 latitude->
dims.push_back (dim);
4870 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
4871 latitude->
dims.push_back (dim);
4873 dim =
new Dimension (tempnewdimname1, tempdimsize1, 0);
4876 dim =
new Dimension (tempnewdimname2, tempdimsize2, 0);
4880 longitude->
name =
"longitude";
4881 longitude->
rank = 2;
4882 longitude->
fieldref = (*i)->fieldref;
4883 longitude->
type = (*i)->getType ();
4888 dim =
new Dimension (tempdimname1, tempdimsize1, 0);
4889 longitude->
dims.push_back (dim);
4890 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
4891 longitude->
dims.push_back (dim);
4893 dim =
new Dimension (tempnewdimname1, tempdimsize1, 0);
4896 dim =
new Dimension (tempnewdimname2, tempdimsize2, 0);
4904 for (std::vector < Dimension * >::const_iterator k =
4905 (*i)->getCorrectedDimensions ().begin ();
4906 k != (*i)->getCorrectedDimensions ().end (); ++k) {
4907 size_t fakeDimpos = ((*k)->getName ()).find (
"fakeDim");
4909 if (fakeDimpos != std::string::npos) {
4911 tempdimsizenamelist.find ((*k)->getSize ());
4912 if (tempsizemapit != tempdimsizenamelist.end ())
4913 (*k)->name = tempdimsizenamelist[(*k)->getSize ()];
4925 std::vector < SDField * >::iterator toeraseit;
4926 for (std::vector < SDField * >::iterator i = file->
sd->
sdfields.begin ();
4928 if ((*i)->getName () ==
"geolocation") {
4951 std::string tempnewdimname1, tempnewdimname2;
4955 std::string temppath;
4960 for (std::vector < SDField * >::const_iterator i =
4963 for (std::vector < Dimension * >::const_iterator k =
4964 (*i)->getDimensions ().begin ();
4965 k != (*i)->getDimensions ().end (); ++k) {
4968 if ((((*k)->getName ()).find (
"fakeDim")) == std::string::npos) {
4970 temppath = (*i)->newname.substr ((*i)->name.size ());
4973 if ((*k)->getSize () == 1440 && (*k)->getType () == 0) {
4976 longitude->
name =
"longitude";
4977 longitude->
rank = 1;
4978 longitude->
type = DFNT_FLOAT32;
4983 new Dimension ((*k)->getName (), (*k)->getSize (), 0);
4984 longitude->
dims.push_back (dim);
4985 tempnewdimname2 = (*k)->getName ();
4988 new Dimension ((*k)->getName (), (*k)->getSize (), 0);
4993 if ((*k)->getSize () == 400 && (*k)->getType () == 0) {
4996 latitude->
name =
"latitude";
4998 latitude->
type = DFNT_FLOAT32;
5002 new Dimension ((*k)->getName (), (*k)->getSize (), 0);
5003 latitude->
dims.push_back (dim);
5004 tempnewdimname1 = (*k)->getName ();
5012 new Dimension ((*k)->getName (), (*k)->getSize (), 0);
5018 if (latflag == 1 && lonflag == 1)
5022 if (latflag == 1 && lonflag == 1)
5031 if (latflag != 1 || lonflag != 1) {
5032 if(latitude !=
NULL)
5034 if(longitude !=
NULL)
5036 throw5 (
"Either latitude or longitude doesn't exist.",
"lat. flag= ",
5037 latflag,
"lon. flag= ", lonflag);
5054 std::string tempnewdimname1, tempnewdimname2;
5055 bool latflag =
false;
5056 bool lonflag =
false;
5062 for (std::vector < SDField * >::const_iterator i =
5065 for (std::vector < Dimension * >::const_iterator k =
5066 (*i)->getDimensions ().begin ();
5067 k != (*i)->getDimensions ().end (); ++k) {
5068 if ((((*k)->getName ()).find (
"latitude")) == 0)
5069 (*k)->name =
"fakeDim1";
5070 if ((((*k)->getName()).find (
"longitude")) == 0)
5071 (*k)->name =
"fakeDim2";
5077 for (std::vector < Dimension * >::const_iterator k =
5078 (*i)->getCorrectedDimensions ().begin ();
5079 k != (*i)->getCorrectedDimensions ().end (); ++k) {
5080 if ((((*k)->getName ()).find (
"latitude")) == 0)
5081 (*k)->name =
"fakeDim1";
5082 if ((((*k)->getName()).find (
"longitude")) == 0)
5083 (*k)->name =
"fakeDim2";
5088 for (std::vector < SDField * >::const_iterator i =
5092 for (std::vector < Dimension * >::const_iterator k =
5093 (*i)->getDimensions ().begin ();
5094 k != (*i)->getDimensions ().end (); ++k) {
5102 if ((*k)->getSize () == 360 && (*k)->getType () == 0) {
5105 longitude->
name =
"longitude";
5106 longitude->
rank = 1;
5107 longitude->
type = DFNT_FLOAT32;
5113 longitude->
dims.push_back (dim);
5114 tempnewdimname2 = longitude->
name;
5122 if ((*k)->getSize () == 180 && (*k)->getType () == 0) {
5125 latitude->
name =
"latitude";
5127 latitude->
type = DFNT_FLOAT32;
5133 latitude->
dims.push_back (dim);
5134 tempnewdimname1 = latitude->
getName ();
5148 if (latflag ==
true && lonflag ==
true)
5152 if (latflag ==
true && lonflag ==
true)
5161 if (latflag !=
true || lonflag !=
true) {
5162 if(latitude !=
NULL)
5164 if(longitude !=
NULL)
5166 throw5 (
"Either latitude or longitude doesn't exist.",
"lat. flag= ",
5167 latflag,
"lon. flag= ", lonflag);
5170 for (std::vector < SDField * >::const_iterator i =
5174 for (std::vector < Dimension * >::const_iterator k =
5175 (*i)->getDimensions ().begin ();
5176 k != (*i)->getDimensions ().end (); ++k) {
5178 if ((*k)->getSize () == 360 )
5179 (*k)->name = longitude->
name;
5181 if ((*k)->getSize () == 180 )
5182 (*k)->name = latitude->
name;
5186 for (std::vector < Dimension * >::const_iterator k =
5187 (*i)->getCorrectedDimensions ().begin ();
5188 k != (*i)->getCorrectedDimensions ().end (); ++k) {
5190 if ((*k)->getSize () == 360 )
5191 (*k)->name = longitude->
name;
5193 if ((*k)->getSize () == 180 )
5194 (*k)->name = latitude->
name;
5218 std::string tempnewdimname1, tempnewdimname2,tempnewdimname3;
5219 bool latflag =
false;
5220 bool lonflag =
false;
5221 bool heiflag =
false;
5229 for (std::vector < SDField * >::const_iterator i =
5233 for (std::vector < Dimension * >::const_iterator k =
5234 (*i)->getDimensions ().begin ();
5235 k != (*i)->getDimensions ().end (); ++k) {
5243 if ((*k)->getSize () == 720 && (*k)->getType () == 0) {
5246 longitude->
name =
"longitude";
5247 longitude->
rank = 1;
5248 longitude->
type = DFNT_FLOAT32;
5254 longitude->
dims.push_back (dim);
5255 tempnewdimname2 = longitude->
name;
5263 if ((*k)->getSize () == 148 && (*k)->getType () == 0) {
5266 latitude->
name =
"latitude";
5268 latitude->
type = DFNT_FLOAT32;
5274 latitude->
dims.push_back (dim);
5275 tempnewdimname1 = latitude->
getName ();
5288 if ((*k)->getSize () == 19 && (*k)->getType () == 0) {
5291 height->
name =
"height";
5293 height->
type = DFNT_FLOAT32;
5299 height->
dims.push_back (dim);
5300 tempnewdimname3 = height->
getName ();
5316 if (latflag ==
true && lonflag ==
true)
5326 if (latflag !=
true || lonflag !=
true) {
5327 if(latitude !=
NULL)
5329 if(longitude !=
NULL)
5331 throw5 (
"Either latitude or longitude doesn't exist.",
"lat. flag= ",
5332 latflag,
"lon. flag= ", lonflag);
5335 if(height!=
NULL && heiflag !=
true) {
5337 throw1(
"Height is allocated but the flag is not true");
5346 if(heiflag !=
true) {
5348 throw1(
"Height is allocated but the flag is not true");
5367 int pixels_per_scan_line = 0;
5369 std::string pixels_per_scan_line_name =
"Pixels per Scan Line";
5370 std::string number_pixels_control_points =
"Number of Pixel Control Points";
5371 std::string tempnewdimname1, tempnewdimname2;
5376 for (std::vector < Attribute * >::const_iterator i =
5379 if ((*i)->getName () == pixels_per_scan_line_name) {
5380 int *attrvalueptr = (
int *) (&((*i)->getValue ()[0]));
5381 pixels_per_scan_line = *attrvalueptr;
5386 if ( 0 == pixels_per_scan_line)
5387 throw1(
"The attribute 'Pixels per Scan Line' doesn't exist");
5392 int tempcountllflag = 0;
5394 for (std::vector < SDField * >::const_iterator i =
5397 if ((*i)->getName () ==
"longitude" || (*i)->getName () ==
"latitude") {
5398 if ((*i)->getName () ==
"longitude")
5399 (*i)->fieldtype = 2;
5400 if ((*i)->getName () ==
"latitude")
5401 (*i)->fieldtype = 1;
5404 if ((*i)->getRank () != 2)
5405 throw3 (
"The lat/lon rank must be 2", (*i)->getName (),
5407 for (std::vector < Dimension * >::const_iterator k =
5408 (*i)->getDimensions ().begin ();
5409 k != (*i)->getDimensions ().end (); ++k) {
5410 if ((*k)->getName () == number_pixels_control_points) {
5411 (*k)->name = pixels_per_scan_line_name;
5412 (*k)->dimsize = pixels_per_scan_line;
5417 for (std::vector < Dimension * >::const_iterator k =
5418 (*i)->getCorrectedDimensions ().begin ();
5419 k != (*i)->getCorrectedDimensions ().end (); ++k) {
5420 if ((*k)->getName ().find (number_pixels_control_points) !=
5421 std::string::npos) {
5422 (*k)->name = pixels_per_scan_line_name;
5423 (*k)->dimsize = pixels_per_scan_line;
5424 if (tempcountllflag == 1)
5425 tempnewdimname2 = (*k)->name;
5428 if (tempcountllflag == 1)
5429 tempnewdimname1 = (*k)->name;
5433 if (tempcountllflag == 2)
5453 std::string num_lat_name =
"Number of Lines";
5454 std::string num_lon_name =
"Number of Columns";
5460 int tempcountllflag = 0;
5462 for (std::vector < Attribute * >::const_iterator i =
5466 if ((*i)->getName () == num_lon_name) {
5469 int *attrvalue = (
int *) (&((*i)->getValue ()[0]));
5471 num_lon = *attrvalue;
5475 if ((*i)->getName () == num_lat_name) {
5477 int *attrvalue = (
int *) (&((*i)->getValue ()[0]));
5479 num_lat = *attrvalue;
5482 if (tempcountllflag == 2)
5489 longitude->
name =
"longitude";
5490 longitude->
rank = 1;
5491 longitude->
type = DFNT_FLOAT32;
5498 throw3(
"The size of the dimension of the longitude ",longitude->
name,
" is 0.");
5503 longitude->
dims.push_back (dim);
5506 dim =
new Dimension (num_lon_name, num_lon, 0);
5511 latitude->
name =
"latitude";
5513 latitude->
type = DFNT_FLOAT32;
5521 throw3(
"The size of the dimension of the latitude ",latitude->
name,
" is 0.");
5524 dim =
new Dimension (num_lat_name, num_lat, 0);
5525 latitude->
dims.push_back (dim);
5528 dim =
new Dimension (num_lat_name, num_lat, 0);
5532 for (std::vector < SDField * >::const_iterator i =
5534 if ((*i)->getRank () != 2) {
5537 throw3 (
"The lat/lon rank must be 2", (*i)->getName (),
5540 for (std::vector < Dimension * >::const_iterator k =
5541 (*i)->getDimensions ().begin ();
5542 k != (*i)->getDimensions ().end (); ++k) {
5543 if ((((*k)->getName ()).find (
"fakeDim")) != std::string::npos) {
5544 if ((*k)->getSize () == num_lon)
5545 (*k)->name = num_lon_name;
5546 if ((*k)->getSize () == num_lat)
5547 (*k)->name = num_lat_name;
5550 for (std::vector < Dimension * >::const_iterator k =
5551 (*i)->getCorrectedDimensions ().begin ();
5552 k != (*i)->getCorrectedDimensions ().end (); ++k) {
5553 if ((((*k)->getName ()).find (
"fakeDim")) != std::string::npos) {
5554 if ((*k)->getSize () == num_lon)
5555 (*k)->name = num_lon_name;
5556 if ((*k)->getSize () == num_lat)
5557 (*k)->name = num_lat_name;
5577 bool colatflag =
false;
5578 bool lonflag =
false;
5580 std::string tempnewdimname1, tempnewdimname2;
5581 std::string tempcvarname1, tempcvarname2;
5585 std::vector < SDField * >::iterator beerasedit;
5589 for (std::vector < SDField * >::iterator i = file->
sd->
sdfields.begin ();
5593 if (((*i)->getName ()).find (
"Colatitude") != std::string::npos) {
5595 if ((*i)->getRank () != 2)
5596 throw3 (
"The lat/lon rank must be 2", (*i)->getName (),
5598 int dimsize0 = (*i)->getDimensions ()[0]->getSize ();
5599 int dimsize1 = (*i)->getDimensions ()[1]->getSize ();
5604 if (dimsize0 < dimsize1) {
5605 tempnewdimname1 = (*i)->getDimensions ()[0]->getName ();
5606 tempnewdimname2 = (*i)->getDimensions ()[1]->getName ();
5609 tempnewdimname1 = (*i)->getDimensions ()[1]->getName ();
5610 tempnewdimname2 = (*i)->getDimensions ()[0]->getName ();
5615 (*i)->fieldtype = 1;
5616 tempcvarname1 = (*i)->getName ();
5628 else if (((*i)->getName ()).find (
"Longitude") != std::string::npos) {
5631 (*i)->fieldtype = 2;
5632 tempcvarname2 = (*i)->getName ();
5656 std::string tempdimname1, tempdimname2;
5657 int tempdimsize1 = 0;
5658 int tempdimsize2 = 0;
5659 std::string tempcvarname1, tempcvarname2;
5660 std::string temppath;
5661 std::set < std::string > tempdimnameset;
5662 std::pair < std::set < std::string >::iterator,
bool > tempsetit;
5665 bool cvflag =
false;
5670 for (std::vector < SDField * >::iterator i = file->
sd->
sdfields.begin ();
5672 std::string tempfieldname = (*i)->getName ();
5673 if (tempfieldname.find (
"Colatitude") != std::string::npos) {
5675 for (std::vector < Dimension * >::const_iterator j =
5676 (*i)->getDimensions ().begin ();
5677 j != (*i)->getDimensions ().end (); ++j) {
5678 if ((((*j)->getName ()).find (
"regional colat") !=
5679 std::string::npos)) {
5680 tempsetit = tempdimnameset.insert ((*j)->getName ());
5681 if (tempsetit.second ==
true) {
5682 tempdimname1 = (*j)->getName ();
5683 tempdimsize1 = (*j)->getSize ();
5684 (*i)->fieldtype = 1;
5694 for (std::vector < Dimension * >::const_iterator j =
5695 (*i)->getDimensions ().begin ();
5696 j != (*i)->getDimensions ().end (); ++j)
5698 for (std::vector < Dimension * >::const_iterator j =
5699 (*i)->getCorrectedDimensions ().begin ();
5700 j != (*i)->getCorrectedDimensions ().end (); ++j)
5702 (*i)->dims.clear ();
5703 (*i)->correcteddims.clear ();
5706 new Dimension (tempdimname1, tempdimsize1, 0);
5707 (*i)->dims.push_back (dim);
5708 dim =
new Dimension (tempdimname1, tempdimsize1, 0);
5709 (*i)->correcteddims.push_back (dim);
5724 else if (tempfieldname.find (
"Longitude") != std::string::npos) {
5725 for (std::vector < Dimension * >::const_iterator j =
5726 (*i)->getDimensions ().begin ();
5727 j != (*i)->getDimensions ().end (); ++j) {
5728 if (((*j)->getName ()).find (
"regional long") !=
5729 std::string::npos) {
5730 tempsetit = tempdimnameset.insert ((*j)->getName ());
5731 if (tempsetit.second ==
true) {
5732 tempdimname2 = (*j)->getName ();
5733 tempdimsize2 = (*j)->getSize ();
5734 (*i)->fieldtype = 2;
5743 for (std::vector < Dimension * >::const_iterator j =
5744 (*i)->getDimensions ().begin ();
5745 j != (*i)->getDimensions ().end (); ++j) {
5748 for (std::vector < Dimension * >::const_iterator j =
5749 (*i)->getCorrectedDimensions ().begin ();
5750 j != (*i)->getCorrectedDimensions ().end (); ++j) {
5753 (*i)->dims.clear ();
5754 (*i)->correcteddims.clear ();
5757 new Dimension (tempdimname2, tempdimsize2, 0);
5758 (*i)->dims.push_back (dim);
5759 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
5760 (*i)->correcteddims.push_back (dim);
5792 std::string tempdimname1 =
"1.0 deg. regional colat. zones";
5793 std::string tempdimname2 =
"1.0 deg. regional long. zones";
5794 std::string tempdimname3 =
"1.0 deg. zonal colat. zones";
5795 std::string tempdimname4 =
"1.0 deg. zonal long. zones";
5796 int tempdimsize1 = 180;
5797 int tempdimsize2 = 360;
5798 int tempdimsize3 = 180;
5799 int tempdimsize4 = 1;
5801 std::string tempnewdimname1, tempnewdimname2;
5802 std::string tempcvarname1, tempcvarname2;
5809 latitude->
name =
"latitude";
5811 latitude->
type = DFNT_FLOAT32;
5819 latitude->
dims.push_back (dim);
5821 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
5822 latitude->
dims.push_back (dim);
5824 dim =
new Dimension (tempdimname1, tempdimsize1, 0);
5827 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
5833 longitude->
name =
"longitude";
5834 longitude->
rank = 2;
5835 longitude->
type = DFNT_FLOAT32;
5841 dim =
new Dimension (tempdimname1, tempdimsize1, 0);
5842 longitude->
dims.push_back (dim);
5844 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
5845 longitude->
dims.push_back (dim);
5847 dim =
new Dimension (tempdimname1, tempdimsize1, 0);
5850 dim =
new Dimension (tempdimname2, tempdimsize2, 0);
5856 if (file->sptype ==
CER_SRB) {
5860 latitudez->
name =
"latitudez";
5861 latitudez->
rank = 1;
5862 latitudez->
type = DFNT_FLOAT32;
5866 dim =
new Dimension (tempdimname3, tempdimsize3, 0);
5867 latitudez->
dims.push_back (dim);
5869 dim =
new Dimension (tempdimname3, tempdimsize3, 0);
5874 longitudez->
name =
"longitudez";
5875 longitudez->
rank = 1;
5876 longitudez->
type = DFNT_FLOAT32;
5880 dim =
new Dimension (tempdimname4, tempdimsize4, 0);
5881 longitudez->
dims.push_back (dim);
5883 dim =
new Dimension (tempdimname4, tempdimsize4, 0);
5888 if (file->sptype ==
CER_SRB) {
5898 string odddimname1=
"1.0 deg. regional Colat. zones";
5899 string odddimname2 =
"1.0 deg. regional Long. zones";
5902 for (std::vector < SDField * >::const_iterator i =
5904 for (std::vector < Dimension * >::const_iterator j =
5905 (*i)->getDimensions ().begin ();
5906 j != (*i)->getDimensions ().end (); ++j) {
5907 if (odddimname1 == (*j)->name)
5908 (*j)->name = tempdimname1;
5909 if (odddimname2 == (*j)->name)
5910 (*j)->name = tempdimname2;
5912 for (std::vector < Dimension * >::const_iterator j =
5913 (*i)->getCorrectedDimensions ().begin ();
5914 j != (*i)->getCorrectedDimensions ().end (); ++j) {
5915 if (odddimname1 == (*j)->name)
5916 (*j)->name = tempdimname1;
5917 if (odddimname2 == (*j)->name)
5918 (*j)->name = tempdimname2;
5932 std::string tempdimname3 =
"1.0 deg. zonal colat. zones";
5933 std::string tempdimname4 =
"1.0 deg. zonal long. zones";
5934 int tempdimsize3 = 180;
5935 int tempdimsize4 = 1;
5940 latitudez->
name =
"latitudez";
5941 latitudez->
rank = 1;
5942 latitudez->
type = DFNT_FLOAT32;
5948 latitudez->
dims.push_back (dim);
5950 dim =
new Dimension (tempdimname3, tempdimsize3, 0);
5956 longitudez->
name =
"longitudez";
5957 longitudez->
rank = 1;
5958 longitudez->
type = DFNT_FLOAT32;
5962 dim =
new Dimension (tempdimname4, tempdimsize4, 0);
5963 longitudez->
dims.push_back (dim);
5965 dim =
new Dimension (tempdimname4, tempdimsize4, 0);
5983 std::set < std::string > tempfulldimnamelist;
5984 std::pair < std::set < std::string >::iterator,
bool > ret;
5986 std::map < int, std::string > tempsizedimnamelist;
5990 for (std::vector < SDField * >::const_iterator i =
5992 if ((*i)->getName () ==
"Latitude")
5993 (*i)->fieldtype = 1;
5994 if ((*i)->getName () ==
"Longitude") {
5995 (*i)->fieldtype = 2;
6000 for (std::vector < Dimension * >::const_iterator j =
6001 (*i)->getCorrectedDimensions ().begin ();
6002 j != (*i)->getCorrectedDimensions ().end (); ++j) {
6003 tempsizedimnamelist[(*j)->getSize ()] = (*j)->getName ();
6009 for (std::vector < SDField * >::const_iterator i =
6011 for (std::vector < Dimension * >::const_iterator j =
6012 (*i)->getCorrectedDimensions ().begin ();
6013 j != (*i)->getCorrectedDimensions ().end (); ++j) {
6017 if ((*i)->fieldtype == 0) {
6018 if ((tempsizedimnamelist.find ((*j)->getSize ())) !=
6019 tempsizedimnamelist.end ())
6020 (*j)->name = tempsizedimnamelist[(*j)->getSize ()];
6035 std::set < std::string > tempfulldimnamelist;
6036 std::pair < std::set < std::string >::iterator,
bool > ret;
6046 bool merra_is_eos2 =
false;
6047 size_t found_forward_slash = file->
path.find_last_of(
"/");
6048 if ((found_forward_slash != string::npos) &&
6049 (((file->
path).substr(found_forward_slash+1).compare(0,5,
"MERRA"))==0)){
6051 for (std::vector < Attribute * >::const_iterator i =
6056 if(((*i)->getName().compare(0, 14,
"StructMetadata" )== 0) ||
6057 ((*i)->getName().compare(0, 14,
"structmetadata" )== 0)) {
6058 merra_is_eos2 =
true;
6065 if(
true == merra_is_eos2) {
6066 vector <string> noneos_newnamelist;
6069 for (std::vector < SDField * >::const_iterator i =
6071 (*i)->special_product_fullpath = (*i)->newname;
6073 string EOSGRIDstring=
":EOSGRID";
6074 size_t found = ((*i)->name).rfind(EOSGRIDstring);
6076 if (found !=string::npos && (((*i)->name).size() == (found + EOSGRIDstring.size()))) {
6078 (*i)->newname = (*i)->name.substr(0,found);
6079 noneos_newnamelist.push_back((*i)->newname);
6082 (*i)->newname = (*i)->name;
6089 for (std::vector < SDField * >::const_iterator i =
6092 for(vector<string>::const_iterator j =
6093 noneos_newnamelist.begin(); j !=noneos_newnamelist.end();++j) {
6095 if ((*i)->newname == (*j) && (*i)->name == (*j)) {
6097 (*i)->newname = (*i)->newname +
"_EOS";
6104 map<string,string> dimname_to_newdimname;
6105 for (std::vector < SDField * >::const_iterator i =
6107 for (std::vector < Dimension * >::const_iterator j =
6108 (*i)->getCorrectedDimensions ().begin ();
6109 j != (*i)->getCorrectedDimensions ().end (); ++j) {
6111 if ((*j)->getType () != 0) {
6112 if ((*i)->name == (*j)->getName () && (*i)->getRank () == 1){
6113 (*i)->fieldtype = 3;
6114 (*i)->is_dim_scale =
true;
6115 (*j)->name = (*i)->newname;
6126 map<string,string>::iterator itmap;
6127 for (std::vector < SDField * >::const_iterator i =
6130 if (0 == (*i)->fieldtype) {
6131 for (std::vector < Dimension * >::const_iterator j =
6132 (*i)->getCorrectedDimensions ().begin ();
6133 j != (*i)->getCorrectedDimensions ().end (); ++j) {
6134 itmap = dimname_to_newdimname.find((*j)->name);
6135 if (itmap == dimname_to_newdimname.end())
6136 throw2(
"Cannot find the corresponding new dim. name for dim. name ",(*j)->name);
6138 (*j)->name = (*itmap).second;
6146 for (std::vector < SDField * >::const_iterator i =
6147 file->
sd->
sdfields.begin (); i != file->
sd->
sdfields.end () && (
false == this->OTHERHDF_Has_Dim_NoScale_Field); ++i) {
6148 for (std::vector < Dimension * >::const_iterator j =
6149 (*i)->getCorrectedDimensions ().begin ();
6150 j != (*i)->getCorrectedDimensions ().end () && (
false == this->OTHERHDF_Has_Dim_NoScale_Field); ++j) {
6152 if ((*j)->getType () != 0) {
6153 if ((*i)->name == (*j)->getName () && (*i)->getRank () == 1)
6154 (*i)->fieldtype = 3;
6158 this->OTHERHDF_Has_Dim_NoScale_Field =
true;
6166 if (
true == this->OTHERHDF_Has_Dim_NoScale_Field)
std::vector< VDATA * > vds
Vdata objects in this file.
std::string name
Original vdata name.
void PrepareCERSAVGID()
Special method to prepare CERES SAVG (CER_SAVG_???) and CERES ISCCP DAYLIKE(CER_ISCCP__???DAYLIKE) latitude and longitude information. Essentially nested CERES 2-d lat/lon need to be provided. https://eosweb.larc.nasa.gov/sites/default/files/project/ceres/quality_summaries/srbavg_ed2d/nestedgrid.pdf.
static void parser_trmm_v7_gridheader(const std::vector< char > &value, int &latsize, int &lonsize, float &lat_start, float &lon_start, float &lat_res, float &lon_res, bool check_reg_orig)
#define throw5(a1, a2, a3, a4, a5)
std::map< std::string, std::string > dimcvarlist
dimension name to coordinate variable name list: the key list to generate CF "coordinates" attributes...
int32 count
The number of elements.
void PrepareCERAVGSYN()
Special method to prepare CERES AVG (CER_AVG_???) and CERES SYN(CER_SYN_???) latitude and longitude i...
static bool insert_map(std::map< std::string, std::string > &m, std::string key, std::string val)
This is a safer way to insert and update a c++ map value. Otherwise, the local testsuite at The HDF G...
#define _HDF_CHK_TBL_CLASS
void ReadHybridNonLoneVdatas(File *)
Handle non-attribute non-lone vdatas. Note: this function is only used for handling hybrid Vdata func...
static SD * Read_Hybrid(int32 sdfileid, int32 hfileid)
Read the information of all hybrid SDS objects from the HDF4 file.
void handle_sds_coords(bool &COARDFLAG, std::string &lldimname1, std::string &lldimname2)
Create "coordinates", "units" CF attributes.
void handle_sds_final_dim_names()
Create the final CF-compliant dimension name list for each field.
string basename(const string &path)
void ReadAttributes(int32 vdata_id, int32 fieldindex)
Read vdata field attributes.
void PrepareTRMML2_V6()
Latitude and longitude are stored in one array(geolocation). Need to separate.
void handle_vdata()
Handle Vdata.
bool TreatAsAttrFlag
Flag to map vdata fields to DAP variables or DAP attributes.
This class retrieves all information from an HDF4 file. It is a container for SDS and Vdata...
This class retrieves all SDS objects and SD file attributes.
void PrepareTRMML3S_V7()
Special method to prepare TRMM single grid Level 3 geolocation fields(latitude,longitude,etc) information.
void PrepareCERZAVG()
Special method to prepare CERES Zonal Average latitude and longitude information. ...
int32 type
Attribute type.
std::set< std::string > fulldimnamelist
Full dimension name list set.
void PrepareOBPGL3()
Special method to prepare OBPG Level 3 latitude and longitude information. The latitude and longitude...
std::vector< char > value
Vdata field value.
One instance of this class represents one Vdata field.
bool is_noscale_dim
Some fields have dimensions but don't have dimension scales. In HDF4, such dimension appears as a fie...
std::vector< Attribute * > attrs
The attributes of this field.
void PrepareTRMML3M_V7()
Special method to prepare TRMM multiple grid Level 3 geolocation fields(latitude,longitude,etc) information.
void PrepareTRMML2_V7()
Latitude and longitude are stored in different fields. Need to separate.
std::string newname
The CF full path(special characters replaced by underscores) of this field.
std::vector< AttrContainer * > dims_info
OTHERHDF dimension information. See the description of the class AttrContainer.
void PrepareTRMML3A_V6()
Special method to prepare TRMM Level 3A46 latitude and longitude information.
std::vector< char > value
Attribute values.
void ReadAttributes(int32 vdata_id)
Retrieve all attributes of this Vdata.
void setUnits(std::string uni)
static void Handle_NameClashing(std::vector< std::string > &newobjnamelist)
General routines to handle name clashings.
int32 numrec
Number of record of the vdata field.
This class retrieves all information of one Vdata.
void PrepareMODISARNSS()
MODISARNSS is a special MODIS product saved as pure HDF4 files. Dimension names of different fields n...
bool Obtain_TRMM_V7_latlon_name(const SDField *sdfield, const int latsize, const int lonsize, std::string &latname, std::string &lonname)
int32 size
Vdata field size.
static VDATA * Read(int32 vdata_id, int32 obj_ref)
Retrieve all information of this Vdata.
std::vector< Dimension * > correcteddims
Corrected dimensions of this field. The only difference between the correcteddims and dims is the cor...
std::set< std::string > nonmisscvdimnamelist
This set stores non-missing coordinate variable dimension names. Many third dimensions of HDF4 files ...
One instance of this class represents one SDS object.
void handle_sds_missing_fields()
Add the missing coordinate variables based on the corrected dimension name list.
bool Check_update_special(const std::string &gridname)
void Prepare()
The main step to make HDF4 SDS objects CF-complaint. All dimension(coordinate variables) information ...
#define throw1(a1)
The followings are convenient functions to throw exceptions with different.
bool getTreatAsAttrFlag() const
Some Vdata fields are very large in size. Some Vdata fields are very small. So we map smaller Vdata f...
void obtain_path(int32 file_id, int32 sd_id, char *full_path, int32 pobj_ref)
The internal function used by InsertOrigFieldPath_ReadVgVdata.
void PrepareTRMML3B_V6()
Special method to prepare TRMM Level 3B latitude and longitude information.
TRMML2_V6: TRMM Level2 1B21,2A12,2B31,2A25 TRMML3A_V6: TRMM Level3 3A46 TRMML3C_V6: TRMM Level3 CSH T...
void create_sds_dim_name_list()
Create the new dimension name set and the dimension name to size map.
static SD * Read(int32 sdfileid, int32 hfileid)
Read the information of all SDS objects from the HDF4 file.
static File * Read(const char *path, int32 sdid, int32 fileid)
Retrieve SDS and Vdata information from the HDF4 file.
It repersents one dimension of an SDS or a VDATA. It holds the dimension name and the size of that di...
void handle_sds_fakedim_names()
Check name clashing for fields. Borrowed from HDFEOS.cc, unused. bool check_field_name_clashing (bool...
std::vector< Attribute * > attrs
const std::string & getPath() const
Obtain the path of the file.
const std::string & getName() const
Get the name of this field.
static File * Read_Hybrid(const char *path, int32 sdid, int32 fileid)
Retrieve SDS and Vdata information from the hybrid HDF-EOS file. Currently we only support the access...
std::map< std::string, std::string > n2dimnamelist
Original dimension name to corrected dimension name map.
void PrepareCERES4IG()
Special method to prepare CERES ES4 (CER_ES4_???) and CERES ISCCP GEO(CER_ISCCP__???GEO) latitude and longitude information. Essentially the lat/lon need to be condensed to 1-D for the geographic projection.
std::vector< Dimension * > dims
Dimensions of this field.
std::list< int32 > sds_ref_list
SDS reference number list.
std::string newname
CF attribute name(special characters are replaced by underscores)
#define CERE_META_FIELD_NAME
int32 type
The datatype of this field.
void obtain_noneos2_sds_path(int32, char *, int32)
Obtain SDS path, this is like a clone of obtain_path in File class, except the Vdata and some minor p...
int32 vdref
Vdata reference number.
void handle_sds_names(bool &COARDFLAG, std::string &lldimname1, std::string &lldimname2)
Create the final CF-compliant field name list.
std::vector< SDField * > sdfields
SDS objects stored in vectors.
const std::vector< VDField * > & getFields() const
Obtain Vdata fields.
std::string name
Original attribute name.
std::string name
The original name of this field.
const std::vector< Attribute * > & getAttributes() const
Public interface to obtain the SD(file) attributes.
void ReadVgattrs(int32 vgroup_id, char *fullpath)
Obtain vgroup attributes.
SD * sd
Pointer to the SD instance. There is only one SD instance in an HDF4 file.
#define throw3(a1, a2, a3)
#define MAX_FULL_PATH_LEN
HDFSP.h and HDFSP.cc include the core part of retrieving HDF-SP Grid and Swath metadata info and tran...
int32 fieldref
SDS reference number. This and the object tag are a key to identify a SDS object. ...
void PrepareOTHERHDF()
We still provide a hook for other HDF data product although no CF compliant is followed.
const char * _BACK_SLASH
HDFSP.h and HDFSP.cc include the core part of retrieving HDF-SP Grid and Swath metadata info and tran...
void PrepareTRMML3C_V6()
Special method to prepare TRMM Level 3 CSH latitude,longitude and Height information.
int fieldtype
This flag will specify the fieldtype. 0 means this field is general field. 1 means this field is lat...
This class only applies to the OTHERHDF products when there are dimensions but not dimension scales...
void ReadLoneVdatas(File *)
Handle non-attribute lone vdatas.
int32 order
Vdata field order.
std::map< int32, int > refindexlist
SDS reference number to index map, use to quickly obtain the SDS id.
static std::string get_CF_string(std::string s)
Change special characters to "_".
static bool check_beskeys(const std::string &key)
Check the BES key. This function will check a BES key specified at the file h4.conf.in. If the key's value is either true or yes. The handler claims to find a key and will do some operations. Otherwise, will do different operations. For example, One may find a line H4.EnableCF=true at h4.conf.in. That means, the HDF4 handler will handle the HDF4 files by following CF conventions.
int32 rank
The rank of this field.
std::string path
The absolute path of the file.
std::vector< Attribute * > attrs
SD attributes stored in vectors.
void PrepareOBPGL2()
Special method to prepare OBPG Level 2 latitude and longitude information. The latitude and longitude...
std::vector< VDField * > vdfields
Vdata field vectors.
void Obtain_TRMML3S_V7_latlon_size(int &latsize, int &lonsize)
Representing one attribute in grid or swath.
std::map< std::string, int32 > n1dimnamelist
Unique dimension name to its size map, may be replaced in the current implementation. Still leave it here for potential fakeDim handling in the future.
void CheckSDType()
This method will check if the HDF4 file is one of TRMM or OBPG products we supported.
std::string newname
New name with path and CF compliant(no special characters and name clashing).
std::string rootfieldname
In some TRMM versions, latitude and longitude are combined into one field geolocation. This variable is to remember the root field for latitude and longitude.
void InsertOrigFieldPath_ReadVgVdata()
The full path of SDS and Vdata will be obtained.