39 #include "h5apicompatible.h"
45 using namespace HDF5CF;
48 GMCVar::GMCVar(
Var*var) {
50 BESDEBUG(
"h5",
"Coming to GMCVar()"<<endl);
51 newname = var->newname;
53 fullpath = var->fullpath;
55 total_elems = var->total_elems;
56 zero_storage_size = var->zero_storage_size;
58 unsupported_attr_dtype = var->unsupported_attr_dtype;
59 unsupported_dspace = var->unsupported_dspace;
60 coord_attr_add_path =
false;
62 for (vector<Attribute*>::iterator ira = var->attrs.begin();
63 ira!=var->attrs.end(); ++ira) {
65 attr->name = (*ira)->name;
66 attr->newname = (*ira)->newname;
67 attr->dtype =(*ira)->dtype;
68 attr->count =(*ira)->count;
69 attr->strsize = (*ira)->strsize;
70 attr->fstrsize = (*ira)->fstrsize;
71 attr->value =(*ira)->value;
72 attrs.push_back(attr);
75 for (vector<Dimension*>::iterator ird = var->dims.begin();
76 ird!=var->dims.end(); ++ird) {
78 dim->name = (*ird)->name;
79 dim->newname = (*ird)->newname;
80 dim->unlimited_dim = (*ird)->unlimited_dim;
83 product_type = General_Product;
87 GMCVar::GMCVar(
GMCVar*cvar) {
89 newname = cvar->newname;
91 fullpath = cvar->fullpath;
94 unsupported_attr_dtype = cvar->unsupported_attr_dtype;
95 unsupported_dspace = cvar->unsupported_dspace;
97 for (vector<Attribute*>::iterator ira = cvar->attrs.begin();
98 ira!=cvar->attrs.end(); ++ira) {
100 attr->name = (*ira)->name;
101 attr->newname = (*ira)->newname;
102 attr->dtype =(*ira)->dtype;
103 attr->count =(*ira)->count;
104 attr->strsize = (*ira)->strsize;
105 attr->fstrsize = (*ira)->fstrsize;
106 attr->value =(*ira)->value;
107 attrs.push_back(attr);
110 for (vector<Dimension*>::iterator ird = cvar->dims.begin();
111 ird!=cvar->dims.end(); ++ird) {
115 dim->name = (*ird)->name;
116 dim->newname = (*ird)->newname;
120 GMcvar->cfdimname = latdim0;
121 GMcvar->cvartype = CV_EXIST;
122 GMcvar->product_type = product_type;
129 GMSPVar::GMSPVar(
Var*var) {
131 BESDEBUG(
"h5",
"Coming to GMSPVar()"<<endl);
132 fullpath = var->fullpath;
134 total_elems = var->total_elems;
135 zero_storage_size = var->zero_storage_size;
136 unsupported_attr_dtype = var->unsupported_attr_dtype;
137 unsupported_dspace = var->unsupported_dspace;
138 coord_attr_add_path = var->coord_attr_add_path;
145 for (vector<Attribute*>::iterator ira = var->attrs.begin();
146 ira!=var->attrs.end(); ++ira) {
148 attr->name = (*ira)->name;
149 attr->newname = (*ira)->newname;
150 attr->dtype =(*ira)->dtype;
151 attr->count =(*ira)->count;
152 attr->strsize = (*ira)->strsize;
153 attr->fstrsize = (*ira)->fstrsize;
154 attr->value =(*ira)->value;
155 attrs.push_back(attr);
158 for (vector<Dimension*>::iterator ird = var->dims.begin();
159 ird!=var->dims.end(); ++ird) {
161 dim->name = (*ird)->name;
162 dim->newname = (*ird)->newname;
163 dim->unlimited_dim = (*ird)->unlimited_dim;
169 GMFile::GMFile(
const char*file_fullpath, hid_t file_id, H5GCFProduct product_type, GMPattern gproduct_pattern):
170 File(file_fullpath,file_id), product_type(product_type),gproduct_pattern(gproduct_pattern),iscoard(false),have_nc4_non_coord(false)
179 if (!this->cvars.empty()){
180 for (vector<GMCVar *>:: const_iterator i= this->cvars.begin(); i!=this->cvars.end(); ++i) {
185 if (!this->spvars.empty()){
186 for (vector<GMSPVar *>:: const_iterator i= this->spvars.begin(); i!=this->spvars.end(); ++i) {
194 string GMFile::get_CF_string(
string s) {
201 return File::get_CF_string(s);
202 else if (General_Product == product_type && OTHERGMS == gproduct_pattern) {
204 if(
true == HDF5RequestHandler::get_keep_var_leading_underscore())
205 return File::get_CF_string(s);
208 return File::get_CF_string(s);
214 return File::get_CF_string(s);
220 hid_t file_id,
bool include_attr) {
222 BESDEBUG(
"h5",
"Coming to Retrieve_H5_Info()"<<endl);
225 if (product_type == Mea_SeaWiFS_L2 || product_type == Mea_SeaWiFS_L3
226 || GPMS_L3 == product_type || GPMM_L3 == product_type || GPM_L1 == product_type || OBPG_L3 == product_type
227 || Mea_Ozone == product_type || General_Product == product_type)
240 BESDEBUG(
"h5",
"Coming to Update_Product_Type()"<<endl);
241 if(GPMS_L3 == this->product_type || GPMM_L3 == this->product_type) {
245 Check_Dimscale_General_Product_Pattern();
246 if(GENERAL_DIMSCALE == this->gproduct_pattern){
247 if(GPMS_L3 == this->product_type) {
248 for (vector<Var *>::iterator irv = this->
vars.begin();
249 irv != this->vars.end(); ++irv)
250 (*irv)->newname = (*irv)->name;
252 this->product_type = General_Product;
256 else if(General_Product == this->product_type)
257 Check_General_Product_Pattern();
263 BESDEBUG(
"h5",
"Coming to Remove_Unneeded_Objects()"<<endl);
264 if(General_Product == this->product_type) {
265 string file_path = this->path;
266 if(HDF5CFUtil::obtain_string_after_lastslash(file_path).find(
"OMPS-NPP")==0)
267 Remove_OMPSNPP_InputPointers();
269 if((General_Product == this->product_type) && (GENERAL_DIMSCALE == this->gproduct_pattern)) {
270 set<string> nc4_non_coord_set;
271 string nc4_non_coord=
"_nc4_non_coord_";
272 size_t nc4_non_coord_size= nc4_non_coord.size();
273 for (vector<Var *>::iterator irv = this->
vars.begin();
274 irv != this->vars.end(); ++irv) {
275 if((*irv)->name.find(nc4_non_coord)==0)
276 nc4_non_coord_set.insert((*irv)->name.substr(nc4_non_coord_size,(*irv)->name.size()-nc4_non_coord_size));
280 for (vector<Var *>::iterator irv = this->
vars.begin();
281 irv != this->vars.end();) {
282 if(nc4_non_coord_set.find((*irv)->name)!=nc4_non_coord_set.end()){
284 irv=this->
vars.erase(irv);
290 if(nc4_non_coord_set.size()!=0)
291 this->have_nc4_non_coord =
true;
293 else if(GPM_L3_New == this->product_type) {
294 for (vector<Group *>::iterator irg = this->
groups.begin();
295 irg != this->groups.end(); ) {
296 if((*irg)->attrs.empty()) {
298 irg = this->
groups.erase(irg);
307 void GMFile::Remove_OMPSNPP_InputPointers() {
311 for (vector<Group *>::iterator irg = this->
groups.begin();
312 irg != this->groups.end(); ) {
313 if((*irg)->path.find(
"/InputPointers")==0) {
315 irg = this->
groups.erase(irg);
322 for (vector<Var *>::iterator irv = this->
vars.begin();
323 irv != this->vars.end(); ) {
324 if((*irv)->fullpath.find(
"/InputPointers")==0) {
326 irv = this->
vars.erase(irv);
335 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
336 ircv != this->cvars.end(); ++ircv) {
338 if ((*ircv)->cvartype != CV_NONLATLON_MISS){
339 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
340 ira != (*ircv)->attrs.end(); ++ira) {
341 Retrieve_H5_Attr_Value(*ira,(*ircv)->fullpath);
350 BESDEBUG(
"h5",
"Coming to Retrieve_H5_Supported_Attr_Values()"<<endl);
356 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
357 ircv != this->cvars.end(); ++ircv) {
359 if ((*ircv)->cvartype != CV_NONLATLON_MISS){
360 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
361 ira != (*ircv)->attrs.end(); ++ira) {
362 Retrieve_H5_Attr_Value(*ira,(*ircv)->fullpath);
368 for (vector<GMSPVar *>::iterator irspv = this->spvars.begin();
369 irspv != this->spvars.end(); ++irspv) {
371 for (vector<Attribute *>::iterator ira = (*irspv)->attrs.begin();
372 ira != (*irspv)->attrs.end(); ++ira) {
373 Retrieve_H5_Attr_Value(*ira,(*irspv)->fullpath);
384 BESDEBUG(
"h5",
"Coming to Adjust_H5_Attr_Value()"<<endl);
385 if (product_type == ACOS_L2S_OR_OCO2_L1B) {
386 if ((
"Type" == attr->name) && (H5VSTRING == attr->dtype)) {
387 string orig_attrvalues(attr->value.begin(),attr->value.end());
388 if (orig_attrvalues !=
"Signed64")
return;
389 string new_attrvalues =
"Signed32";
393 attr->value.resize(new_attrvalues.size());
394 copy(new_attrvalues.begin(),new_attrvalues.end(),attr->value.begin());
402 BESDEBUG(
"h5",
"Coming to Handle_Unsupported_Dtype()"<<endl);
403 if(
true == check_ignored) {
404 Gen_Unsupported_Dtype_Info(include_attr);
407 Handle_GM_Unsupported_Dtype(include_attr);
411 void GMFile:: Handle_GM_Unsupported_Dtype(
bool include_attr) {
413 BESDEBUG(
"h5",
"Coming to Handle_GM_Unsupported_Dtype()"<<endl);
414 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
415 ircv != this->cvars.end(); ) {
416 if (
true == include_attr) {
417 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
418 ira != (*ircv)->attrs.end(); ) {
419 H5DataType temp_dtype = (*ira)->getType();
420 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
422 ira = (*ircv)->attrs.erase(ira);
429 H5DataType temp_dtype = (*ircv)->getType();
430 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
438 ircv = this->cvars.erase(ircv);
445 for (vector<GMSPVar *>::iterator ircv = this->spvars.begin();
446 ircv != this->spvars.end(); ) {
448 if (
true == include_attr) {
449 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
450 ira != (*ircv)->attrs.end(); ) {
451 H5DataType temp_dtype = (*ira)->getType();
452 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
454 ira = (*ircv)->attrs.erase(ira);
461 H5DataType temp_dtype = (*ircv)->getType();
462 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
464 ircv = this->spvars.erase(ircv);
474 void GMFile:: Gen_Unsupported_Dtype_Info(
bool include_attr) {
476 BESDEBUG(
"h5",
"GMFile::Coming to Gen_Unsupported_Dtype_Info()"<<endl);
477 if(
true == include_attr) {
479 File::Gen_Group_Unsupported_Dtype_Info();
480 File::Gen_Var_Unsupported_Dtype_Info();
481 Gen_VarAttr_Unsupported_Dtype_Info();
487 void GMFile:: Gen_VarAttr_Unsupported_Dtype_Info() {
489 BESDEBUG(
"h5",
"GMFile::Coming to Gen_Unsupported_Dtype_Info()"<<endl);
491 if((General_Product == this->product_type && GENERAL_DIMSCALE== this->gproduct_pattern)
492 || (Mea_Ozone == this->product_type) || (Mea_SeaWiFS_L2 == this->product_type) || (Mea_SeaWiFS_L3 == this->product_type)
493 || (OBPG_L3 == this->product_type)) {
494 Gen_DimScale_VarAttr_Unsupported_Dtype_Info();
498 File::Gen_VarAttr_Unsupported_Dtype_Info();
501 Gen_GM_VarAttr_Unsupported_Dtype_Info();
506 void GMFile:: Gen_GM_VarAttr_Unsupported_Dtype_Info(){
508 BESDEBUG(
"h5",
"GMFile::Coming to Gen_GM_VarAttr_Unsupported_Dtype_Info()"<<endl);
509 if((General_Product == this->product_type && GENERAL_DIMSCALE== this->gproduct_pattern)
510 || (Mea_Ozone == this->product_type) || (Mea_SeaWiFS_L2 == this->product_type) || (Mea_SeaWiFS_L3 == this->product_type)
511 || (OBPG_L3 == this->product_type)) {
513 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
514 irv != this->cvars.end(); ++irv) {
517 bool is_ignored = ignored_dimscale_ref_list((*irv));
518 if (
false == (*irv)->attrs.empty()) {
519 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
520 ira != (*irv)->attrs.end(); ++ira) {
521 H5DataType temp_dtype = (*ira)->getType();
522 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
526 if ((
"DIMENSION_LIST" !=(*ira)->name) &&
527 (
"REFERENCE_LIST" != (*ira)->name ||
true == is_ignored))
528 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
534 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
535 irv != this->spvars.end(); ++irv) {
538 bool is_ignored = ignored_dimscale_ref_list((*irv));
539 if (
false == (*irv)->attrs.empty()) {
541 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
542 ira != (*irv)->attrs.end(); ++ira) {
543 H5DataType temp_dtype = (*ira)->getType();
544 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
548 if ((
"DIMENSION_LIST" !=(*ira)->name) &&
549 (
"REFERENCE_LIST" != (*ira)->name ||
true == is_ignored))
550 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
558 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
559 irv != this->cvars.end(); ++irv) {
560 if (
false == (*irv)->attrs.empty()) {
562 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
563 ira != (*irv)->attrs.end(); ++ira) {
564 H5DataType temp_dtype = (*ira)->getType();
565 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
566 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
573 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
574 irv != this->spvars.end(); ++irv) {
575 if (
false == (*irv)->attrs.empty()) {
577 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
578 ira != (*irv)->attrs.end(); ++ira) {
579 H5DataType temp_dtype = (*ira)->getType();
580 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
581 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
595 BESDEBUG(
"h5",
"Coming to GMFile:Handle_Unsupported_Dspace()"<<endl);
596 if(
true == check_ignored)
597 Gen_Unsupported_Dspace_Info();
600 Handle_GM_Unsupported_Dspace(include_attr);
605 void GMFile:: Handle_GM_Unsupported_Dspace(
bool include_attr) {
607 BESDEBUG(
"h5",
"Coming to GMFile:Handle_GM_Unsupported_Dspace()"<<endl);
608 if(
true == this->unsupported_var_dspace) {
609 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
610 ircv != this->cvars.end(); ) {
611 if (
true == (*ircv)->unsupported_dspace ) {
619 ircv = this->cvars.erase(ircv);
626 for (vector<GMSPVar *>::iterator ircv = this->spvars.begin();
627 ircv != this->spvars.end(); ) {
629 if (
true == (*ircv)->unsupported_dspace) {
631 ircv = this->spvars.erase(ircv);
640 if(
true == include_attr) {
641 if(
true == this->unsupported_var_attr_dspace) {
642 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
643 ircv != this->cvars.end(); ++ircv) {
644 if (
false == (*ircv)->attrs.empty()) {
645 if (
true == (*ircv)->unsupported_attr_dspace) {
646 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
647 ira != (*ircv)->attrs.end(); ) {
648 if (0 == (*ira)->count) {
650 ira = (*ircv)->attrs.erase(ira);
660 for (vector<GMSPVar *>::iterator ircv = this->spvars.begin();
661 ircv != this->spvars.end(); ++ircv) {
662 if (
false == (*ircv)->attrs.empty()) {
663 if (
true == (*ircv)->unsupported_attr_dspace) {
664 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
665 ira != (*ircv)->attrs.end(); ) {
666 if (0 == (*ira)->count) {
668 ira = (*ircv)->attrs.erase(ira);
683 void GMFile:: Gen_Unsupported_Dspace_Info() {
685 File::Gen_Unsupported_Dspace_Info();
692 BESDEBUG(
"h5",
"Coming to GMFile:Handle_Unsupported_Others()"<<endl);
697 if(General_Product != this->product_type
698 || (General_Product == this->product_type && OTHERGMS != this->gproduct_pattern)){
701 if((General_Product == this->product_type && GENERAL_DIMSCALE== this->gproduct_pattern)
702 || (Mea_Ozone == this->product_type) || (Mea_SeaWiFS_L2 == this->product_type)
703 || (Mea_SeaWiFS_L3 == this->product_type)
704 || (OBPG_L3 == this->product_type))
706 remove_netCDF_internal_attributes(include_attr);
707 if(include_attr ==
true) {
709 for (vector<Attribute *>::iterator ira = this->
root_attrs.begin(); ira != this->root_attrs.end();) {
711 if((*ira)->name ==
"_nc3_strict") {
716 else if((*ira)->name ==
"_NCProperties") {
720 else if((*ira)->name ==
"_Netcdf4Coordinates") {
729 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
730 irv != this->cvars.end(); ++irv) {
731 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
732 ira != (*irv)->attrs.end();) {
733 if((*ira)->name ==
"CLASS") {
734 string class_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
738 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
740 ira = (*irv)->attrs.erase(ira);
747 else if((*ira)->name ==
"NAME") {
749 ira =(*irv)->attrs.erase(ira);
753 string name_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
754 if( 0 == name_value.compare(0,(*irv)->name.size(),(*irv)->name)) {
756 ira =(*irv)->attrs.erase(ira);
759 string netcdf_dim_mark=
"This is a netCDF dimension but not a netCDF variable";
760 if( 0 == name_value.compare(0,netcdf_dim_mark.size(),netcdf_dim_mark)) {
762 ira =(*irv)->attrs.erase(ira);
770 else if((*ira)->name ==
"_Netcdf4Dimid") {
772 ira =(*irv)->attrs.erase(ira);
774 else if((*ira)->name ==
"_Netcdf4Coordinates") {
776 ira =(*irv)->attrs.erase(ira);
780 else if((*ira)->name ==
"_nc3_strict") {
782 ira =(*irv)->attrs.erase(ira);
795 if(
true == this->check_ignored &&
true == include_attr) {
796 if(
true == HDF5RequestHandler::get_drop_long_string()){
797 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
798 irv != this->cvars.end(); ++irv) {
799 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
800 ira != (*irv)->attrs.end();++ira) {
801 if(
true == Check_DropLongStr((*irv),(*ira))) {
802 this->add_ignored_droplongstr_hdr();
803 this->add_ignored_var_longstr_info((*irv),(*ira));
808 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
809 irv != this->spvars.end(); ++irv) {
810 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
811 ira != (*irv)->attrs.end();++ira) {
812 if(
true == Check_DropLongStr((*irv),(*ira))) {
813 this->add_ignored_droplongstr_hdr();
814 this->add_ignored_var_longstr_info((*irv),(*ira));
823 if(
false == this->have_ignored)
824 this->add_no_ignored_info();
831 BESDEBUG(
"h5",
"Coming to GMFile:Add_Dim_Name()"<<endl);
832 switch(product_type) {
835 Add_Dim_Name_Mea_SeaWiFS();
838 Add_Dim_Name_Aqu_L3();
841 Add_Dim_Name_OSMAPL2S();
843 case ACOS_L2S_OR_OCO2_L1B:
844 Add_Dim_Name_ACOS_L2S_OCO2_L1B();
847 Add_Dim_Name_Mea_Ozonel3z();
856 Add_Dim_Name_OBPG_L3();
858 case General_Product:
859 Add_Dim_Name_General_Product();
862 throw1(
"Cannot generate dim. names for unsupported datatype");
867 for (vector<Var*>::iterator irv2 = this->
vars.begin();
868 irv2 != this->vars.end(); irv2++) {
869 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
870 ird !=(*irv2)->dims.end(); ird++) {
871 cerr<<
"Dimension name afet Add_Dim_Name "<<(*ird)->newname <<endl;
879 void GMFile::Add_Dim_Name_OBPG_L3() {
881 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_OBPG_L3()"<<endl);
884 Check_General_Product_Pattern();
885 Add_Dim_Name_General_Product();
889 void GMFile::Add_Dim_Name_Mea_SeaWiFS() {
891 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Mea_SeaWiFS()"<<endl);
892 pair<set<string>::iterator,
bool> setret;
893 if (Mea_SeaWiFS_L3 == product_type)
895 for (vector<Var *>::iterator irv = this->
vars.begin();
896 irv != this->vars.end(); ++irv) {
897 Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone((*irv));
898 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
899 ird !=(*irv)->dims.end();++ird) {
900 setret = dimnamelist.insert((*ird)->name);
901 if (
true == setret.second)
902 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
906 if (
true == dimnamelist.empty())
907 throw1(
"This product should have the dimension names, but no dimension names are found");
911 void GMFile::Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(
Var* var)
914 BESDEBUG(
"h5",
"Coming to Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone()"<<endl);
916 bool has_dimlist =
false;
917 bool has_class =
false;
918 bool has_reflist =
false;
920 for(vector<Attribute *>::iterator ira = var->attrs.begin();
921 ira != var->attrs.end();ira++) {
922 if (
"DIMENSION_LIST" == (*ira)->name) {
926 if (
"CLASS" == (*ira)->name)
928 if (
"REFERENCE_LIST" == (*ira)->name)
931 if (
true == has_dimlist)
933 if (
true == has_class &&
true == has_reflist)
937 if (
true == has_dimlist)
938 Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(var,dimlistattr);
941 else if(
true == has_class &&
true == has_reflist) {
942 if (var->dims.size() !=1)
943 throw2(
"dimension scale dataset must be 1 dimension, this is not true for variable ",
948 (var->dims)[0]->name = var->fullpath;
949 (var->dims)[0]->newname = var->fullpath;
950 pair<set<string>::iterator,
bool> setret;
951 setret = dimnamelist.insert((var->dims)[0]->name);
952 if (
true == setret.second)
953 Insert_One_NameSizeMap_Element((var->dims)[0]->name,(var->dims)[0]->size,(var->dims)[0]->unlimited_dim);
961 set<hsize_t> fakedimsize;
962 pair<set<hsize_t>::iterator,
bool> setsizeret;
963 for (vector<Dimension *>::iterator ird= var->dims.begin();
964 ird != var->dims.end(); ++ird) {
965 Add_One_FakeDim_Name(*ird);
966 setsizeret = fakedimsize.insert((*ird)->size);
967 if (
false == setsizeret.second)
968 Adjust_Duplicate_FakeDim_Name(*ird);
972 for (
int i = 0; i < var->dims.size(); ++i) {
973 Add_One_FakeDim_Name((var->dims)[i]);
974 bool gotoMainLoop =
false;
975 for (
int j =i-1; j>=0 && !gotoMainLoop; --j) {
976 if (((var->dims)[i])->size == ((var->dims)[j])->size){
977 Adjust_Duplicate_FakeDim_Name((var->dims)[i]);
988 void GMFile::Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(
Var *var,
Attribute*dimlistattr)
991 BESDEBUG(
"h5",
"Coming to Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone()"<<endl);
992 ssize_t objnamelen = -1;
999 hid_t amemtype_id = -1;
1000 hid_t aspace_id = -1;
1001 hid_t ref_dset = -1;
1004 if(NULL == dimlistattr)
1005 throw2(
"Cannot obtain the dimension list attribute for variable ",var->name);
1008 throw2(
"The number of dimension should NOT be 0 for the variable ",var->name);
1012 vlbuf.resize(var->rank);
1014 dset_id = H5Dopen(this->fileid,(var->fullpath).c_str(),H5P_DEFAULT);
1016 throw2(
"Cannot open the dataset ",var->fullpath);
1018 attr_id = H5Aopen(dset_id,(dimlistattr->name).c_str(),H5P_DEFAULT);
1020 throw4(
"Cannot open the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
1022 atype_id = H5Aget_type(attr_id);
1024 throw4(
"Cannot obtain the datatype of the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
1026 amemtype_id = H5Tget_native_type(atype_id, H5T_DIR_ASCEND);
1028 if (amemtype_id < 0)
1029 throw2(
"Cannot obtain the memory datatype for the attribute ",dimlistattr->name);
1032 if (H5Aread(attr_id,amemtype_id,&vlbuf[0]) <0)
1033 throw2(
"Cannot obtain the referenced object for the variable ",var->name);
1036 vector<char> objname;
1037 int vlbuf_index = 0;
1040 for (vector<Dimension *>::iterator ird = var->dims.begin();
1041 ird != var->dims.end(); ++ird) {
1043 if(vlbuf[vlbuf_index].p== NULL)
1044 throw4(
"The dimension doesn't exist. Var name is ",var->name,
"; the dimension index is ",vlbuf_index);
1045 rbuf =((hobj_ref_t*)vlbuf[vlbuf_index].p)[0];
1046 if ((ref_dset = H5RDEREFERENCE(attr_id, H5R_OBJECT, &rbuf)) < 0)
1047 throw2(
"Cannot dereference from the DIMENSION_LIST attribute for the variable ",var->name);
1049 if ((objnamelen= H5Iget_name(ref_dset,NULL,0))<=0)
1050 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
1051 objname.resize(objnamelen+1);
1052 if ((objnamelen= H5Iget_name(ref_dset,&objname[0],objnamelen+1))<=0)
1053 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
1055 string objname_str = string(objname.begin(),objname.end());
1056 string trim_objname = objname_str.substr(0,objnamelen);
1057 (*ird)->name = string(trim_objname.begin(),trim_objname.end());
1059 pair<set<string>::iterator,
bool> setret;
1060 setret = dimnamelist.insert((*ird)->name);
1061 if (
true == setret.second)
1062 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1063 (*ird)->newname = (*ird)->name;
1069 if(vlbuf.size()!= 0) {
1071 if ((aspace_id = H5Aget_space(attr_id)) < 0)
1072 throw2(
"Cannot get hdf5 dataspace id for the attribute ",dimlistattr->name);
1074 if (H5Dvlen_reclaim(amemtype_id,aspace_id,H5P_DEFAULT,(
void*)&vlbuf[0])<0)
1075 throw2(
"Cannot successfully clean up the variable length memory for the variable ",var->name);
1077 H5Sclose(aspace_id);
1082 H5Tclose(amemtype_id);
1093 if(amemtype_id != -1)
1094 H5Tclose(amemtype_id);
1097 H5Sclose(aspace_id);
1111 void GMFile::Add_Dim_Name_Mea_Ozonel3z() {
1113 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Mea_Ozonel3z()"<<endl);
1115 bool use_dimscale =
false;
1117 for (vector<Group *>::iterator irg = this->
groups.begin();
1118 irg != this->groups.end(); ++ irg) {
1119 if (
"/Dimensions" == (*irg)->path) {
1120 use_dimscale =
true;
1125 if (
false == use_dimscale) {
1127 bool has_dimlist =
false;
1128 bool has_class =
false;
1129 bool has_reflist =
false;
1131 for (vector<Var *>::iterator irv = this->
vars.begin();
1132 irv != this->vars.end(); irv++) {
1134 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1135 ira != (*irv)->attrs.end();ira++) {
1136 if (
"DIMENSION_LIST" == (*ira)->name)
1139 if (
true == has_dimlist)
1143 if (
true == has_dimlist) {
1144 for (vector<Var *>::iterator irv = this->
vars.begin();
1145 irv != this->vars.end(); irv++) {
1147 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1148 ira != (*irv)->attrs.end();ira++) {
1149 if (
"CLASS" == (*ira)->name)
1151 if (
"REFERENCE_LIST" == (*ira)->name)
1153 if (
true == has_class &&
true == has_reflist)
1157 if (
true == has_class &&
1158 true == has_reflist)
1162 if (
true == has_class &&
true == has_reflist)
1163 use_dimscale =
true;
1167 if (
true == use_dimscale) {
1169 pair<set<string>::iterator,
bool> setret;
1170 for (vector<Var *>::iterator irv = this->
vars.begin();
1171 irv != this->vars.end(); ++irv) {
1172 Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone((*irv));
1173 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
1174 ird !=(*irv)->dims.end();++ird) {
1175 setret = dimnamelist.insert((*ird)->name);
1176 if(
true == setret.second)
1177 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1181 if (
true == dimnamelist.empty())
1182 throw1(
"This product should have the dimension names, but no dimension names are found");
1188 multimap<hsize_t,string> ozonedimsize_to_dimname;
1189 pair<multimap<hsize_t,string>::iterator,multimap<hsize_t,string>::iterator> mm_er_ret;
1190 multimap<hsize_t,string>::iterator irmm;
1192 for (vector<Var *>::iterator irv = this->
vars.begin();
1193 irv != this->vars.end(); ++irv) {
1194 bool is_cv = check_cv((*irv)->name);
1195 if (
true == is_cv) {
1196 if ((*irv)->dims.size() != 1)
1197 throw3(
"The coordinate variable", (*irv)->name,
" must be one dimension for the zonal average product");
1198 ozonedimsize_to_dimname.insert(pair<hsize_t,string>(((*irv)->dims)[0]->size,(*irv)->fullpath));
1202 set<hsize_t> fakedimsize;
1203 pair<set<hsize_t>::iterator,
bool> setsizeret;
1204 pair<set<string>::iterator,
bool> setret;
1205 pair<set<string>::iterator,
bool> tempsetret;
1206 set<string> tempdimnamelist;
1207 bool fakedimflag =
false;
1209 for (vector<Var *>::iterator irv = this->
vars.begin();
1210 irv != this->vars.end(); ++irv) {
1212 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
1213 ird != (*irv)->dims.end(); ++ird) {
1216 mm_er_ret = ozonedimsize_to_dimname.equal_range((*ird)->size);
1217 for (irmm = mm_er_ret.first; irmm!=mm_er_ret.second;irmm++) {
1218 setret = tempdimnamelist.insert(irmm->second);
1219 if (
true == setret.second) {
1220 (*ird)->name = irmm->second;
1221 (*ird)->newname = (*ird)->name;
1222 setret = dimnamelist.insert((*ird)->name);
1223 if(setret.second) Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1224 fakedimflag =
false;
1229 if (
true == fakedimflag) {
1230 Add_One_FakeDim_Name(*ird);
1231 setsizeret = fakedimsize.insert((*ird)->size);
1232 if (
false == setsizeret.second)
1233 Adjust_Duplicate_FakeDim_Name(*ird);
1237 tempdimnamelist.clear();
1238 fakedimsize.clear();
1244 bool GMFile::check_cv(
const string & varname)
const {
1246 BESDEBUG(
"h5",
"Coming to check_cv()"<<endl);
1247 const string lat_name =
"Latitude";
1248 const string time_name =
"Time";
1249 const string ratio_pressure_name =
"MixingRatioPressureLevels";
1250 const string profile_pressure_name =
"ProfilePressureLevels";
1251 const string wave_length_name =
"Wavelength";
1253 if (lat_name == varname)
1255 else if (time_name == varname)
1257 else if (ratio_pressure_name == varname)
1259 else if (profile_pressure_name == varname)
1261 else if (wave_length_name == varname)
1268 void GMFile::Add_Dim_Name_GPM()
1271 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_GPM()"<<endl);
1273 pair<set<string>::iterator,
bool> setret;
1285 for (vector<Var *>::iterator irv = this->
vars.begin();
1286 irv != this->vars.end(); irv++) {
1288 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1289 ira != (*irv)->attrs.end(); ++ira) {
1291 if(
"DimensionNames" == (*ira)->name) {
1293 Retrieve_H5_Attr_Value(*ira,(*irv)->fullpath);
1294 string dimname_value((*ira)->value.begin(),(*ira)->value.end());
1296 vector<string> ind_elems;
1300 if(ind_elems.size() != (
size_t)((*irv)->getRank())) {
1301 throw2(
"The number of dims obtained from the <DimensionNames> attribute is not equal to the rank ",
1305 for(
unsigned int i = 0; i<ind_elems.size(); ++i) {
1307 ((*irv)->dims)[i]->name = ind_elems[i];
1311 if(((*irv)->dims)[i]->name==
""){
1312 Add_One_FakeDim_Name(((*irv)->dims)[i]);
1315 string fakedim =
"FakeDim";
1316 stringstream sdim_count;
1317 sdim_count << dim_count;
1318 fakedim = fakedim + sdim_count.str();
1320 ((*irv)->dims)[i]->name = fakedim;
1321 ((*irv)->dims)[i]->newname = fakedim;
1322 ind_elems[i] = fakedim;
1327 ((*irv)->dims)[i]->newname = ind_elems[i];
1328 setret = dimnamelist.insert(((*irv)->dims)[i]->name);
1330 if (
true == setret.second) {
1331 Insert_One_NameSizeMap_Element(((*irv)->dims)[i]->name,
1332 ((*irv)->dims)[i]->size,
1333 ((*irv)->dims)[i]->unlimited_dim);
1336 if(dimname_to_dimsize[((*irv)->dims)[i]->name] !=((*irv)->dims)[i]->size)
1337 throw5(
"Dimension ",((*irv)->dims)[i]->name,
"has two sizes",
1338 ((*irv)->dims)[i]->size,dimname_to_dimsize[((*irv)->dims)[i]->name]);
1350 if(
false == has_dim_name_attr) {
1352 throw4(
"The variable ", (*irv)->name,
" doesn't have the DimensionNames attribute.",
1353 "We currently don't support this case. Please report to the NASA data center.");
1362 void GMFile::Add_Dim_Name_Aqu_L3()
1364 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Aqu_L3()"<<endl);
1365 for (vector<Var *>::iterator irv = this->
vars.begin();
1366 irv != this->vars.end(); irv++) {
1367 if (
"l3m_data" == (*irv)->name) {
1368 ((*irv)->dims)[0]->name =
"lat";
1369 ((*irv)->dims)[0]->newname =
"lat";
1370 ((*irv)->dims)[1]->name =
"lon";
1371 ((*irv)->dims)[1]->newname =
"lon";
1378 if (
"palette" == (*irv)->name) {
1380 ((*irv)->dims)[0]->name =
"paldim0";
1381 ((*irv)->dims)[0]->newname =
"paldim0";
1382 ((*irv)->dims)[1]->name =
"paldim1";
1383 ((*irv)->dims)[1]->newname =
"paldim1";
1391 void GMFile::Add_Dim_Name_OSMAPL2S(){
1393 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_OSMAPL2S()"<<endl);
1394 string tempvarname =
"";
1395 string key =
"_lat";
1396 string osmapl2sdim0 =
"YDim";
1397 string osmapl2sdim1 =
"XDim";
1400 multimap<hsize_t,string> osmapl2sdimsize_to_dimname;
1401 pair<multimap<hsize_t,string>::iterator,multimap<hsize_t,string>::iterator> mm_er_ret;
1402 multimap<hsize_t,string>::iterator irmm;
1405 for (vector<Var *>::iterator irv = this->
vars.begin();
1406 irv != this->vars.end(); ++irv) {
1407 tempvarname = (*irv)->name;
1408 if ((tempvarname.size() > key.size())&&
1409 (key == tempvarname.substr(tempvarname.size()-key.size(),key.size()))){
1410 if ((*irv)->dims.size() !=2)
1411 throw1(
"Currently only 2D lat/lon is supported for OSMAPL2S");
1412 osmapl2sdimsize_to_dimname.insert(pair<hsize_t,string>(((*irv)->dims)[0]->size,osmapl2sdim0));
1413 osmapl2sdimsize_to_dimname.insert(pair<hsize_t,string>(((*irv)->dims)[1]->size,osmapl2sdim1));
1418 set<hsize_t> fakedimsize;
1419 pair<set<hsize_t>::iterator,
bool> setsizeret;
1420 pair<set<string>::iterator,
bool> setret;
1421 pair<set<string>::iterator,
bool> tempsetret;
1422 set<string> tempdimnamelist;
1423 bool fakedimflag =
false;
1426 for (vector<Var *>::iterator irv = this->
vars.begin();
1427 irv != this->vars.end(); ++irv) {
1429 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
1430 ird != (*irv)->dims.end(); ++ird) {
1433 mm_er_ret = osmapl2sdimsize_to_dimname.equal_range((*ird)->size);
1434 for (irmm = mm_er_ret.first; irmm!=mm_er_ret.second;irmm++) {
1435 setret = tempdimnamelist.insert(irmm->second);
1436 if (setret.second) {
1437 (*ird)->name = irmm->second;
1438 (*ird)->newname = (*ird)->name;
1439 setret = dimnamelist.insert((*ird)->name);
1440 if(setret.second) Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1441 fakedimflag =
false;
1446 if (
true == fakedimflag) {
1447 Add_One_FakeDim_Name(*ird);
1448 setsizeret = fakedimsize.insert((*ird)->size);
1449 if (!setsizeret.second)
1450 Adjust_Duplicate_FakeDim_Name(*ird);
1453 tempdimnamelist.clear();
1454 fakedimsize.clear();
1459 void GMFile::Add_Dim_Name_ACOS_L2S_OCO2_L1B(){
1461 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_ACOS_L2S_OCO2_L1B()"<<endl);
1462 for (vector<Var *>::iterator irv = this->
vars.begin();
1463 irv != this->vars.end(); ++irv) {
1465 set<hsize_t> fakedimsize;
1466 pair<set<hsize_t>::iterator,
bool> setsizeret;
1467 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
1468 ird != (*irv)->dims.end(); ++ird) {
1469 Add_One_FakeDim_Name(*ird);
1470 setsizeret = fakedimsize.insert((*ird)->size);
1471 if (
false == setsizeret.second)
1472 Adjust_Duplicate_FakeDim_Name(*ird);
1478 void GMFile::Add_Dim_Name_General_Product(){
1480 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_General_Product()"<<endl);
1483 if (GENERAL_DIMSCALE == this->gproduct_pattern){
1484 Add_Dim_Name_Dimscale_General_Product();
1487 else if (GENERAL_LATLON2D == this->gproduct_pattern)
1488 Add_Dim_Name_LatLon2D_General_Product();
1490 else if (GENERAL_LATLON1D == this->gproduct_pattern || GENERAL_LATLON_COOR_ATTR == this->gproduct_pattern)
1491 Add_Dim_Name_LatLon1D_Or_CoordAttr_General_Product();
1504 void GMFile::Check_General_Product_Pattern() {
1506 BESDEBUG(
"h5",
"Coming to Check_General_Product_Pattern()"<<endl);
1507 if(
false == Check_Dimscale_General_Product_Pattern()) {
1509 if(
false == Check_And_Update_New_GPM_L3())
1510 if(
false == Check_LatLon2D_General_Product_Pattern())
1511 if(
false == Check_LatLon1D_General_Product_Pattern())
1512 Check_LatLon_With_Coordinate_Attr_General_Product_Pattern();
1519 bool GMFile::Check_Dimscale_General_Product_Pattern() {
1521 BESDEBUG(
"h5",
"Coming to Check_Dimscale_General_Product_Pattern()"<<endl);
1522 bool ret_value =
false;
1523 bool has_dimlist =
false;
1524 bool has_dimscalelist =
false;
1527 for (vector<Var *>::iterator irv = this->
vars.begin();
1528 irv != this->vars.end(); ++irv) {
1529 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1530 ira != (*irv)->attrs.end();ira++) {
1531 if (
"DIMENSION_LIST" == (*ira)->name) {
1536 if (
true == has_dimlist)
1545 for (vector<Var *>::iterator irv = this->
vars.begin();
1546 irv != this->vars.end(); ++irv) {
1549 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1550 ira != (*irv)->attrs.end();ira++) {
1551 if (
"CLASS" == (*ira)->name) {
1553 Retrieve_H5_Attr_Value(*ira,(*irv)->fullpath);
1555 class_value.resize((*ira)->value.size());
1556 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
1560 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
1561 has_dimscalelist =
true;
1567 if (
true == has_dimscalelist)
1572 if (
true == has_dimscalelist) {
1573 if (
true == has_dimlist ) {
1574 this->gproduct_pattern = GENERAL_DIMSCALE;
1582 bool is_general_dimscale =
false;
1584 for (vector<Var *>::iterator irv = this->
vars.begin();
1585 irv != this->vars.end(); ++irv) {
1587 bool has_class_dscale =
false;
1588 bool has_name =
false;
1589 bool has_netcdf4_id =
false;
1591 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1592 ira != (*irv)->attrs.end();ira++) {
1593 if (
"CLASS" == (*ira)->name) {
1595 Retrieve_H5_Attr_Value(*ira,(*irv)->fullpath);
1597 class_value.resize((*ira)->value.size());
1598 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
1602 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE"))
1603 has_class_dscale=
true;
1605 else if (
"NAME" == (*ira)->name)
1607 else if (
"_Netcdf4Dimid" == (*ira)->name)
1608 has_netcdf4_id =
true;
1609 if(
true == has_class_dscale &&
true == has_name &&
true == has_netcdf4_id)
1610 is_general_dimscale =
true;
1613 if(
true == is_general_dimscale)
1618 if (
true == is_general_dimscale) {
1619 this->gproduct_pattern = GENERAL_DIMSCALE;
1628 bool GMFile::Check_And_Update_New_GPM_L3() {
1630 bool is_new_gpm_l3 =
false;
1631 unsigned int num_vars = this->
vars.size();
1632 unsigned sel_steps = num_vars/5;
1633 string dim_name=
"DimensionNames";
1634 bool has_dim_name =
false;
1641 vector<Var *>::iterator it_var_end;
1644 it_var_end = this->
vars.end();
1646 it_var_end = this->
vars.begin()+5*sel_steps;
1648 for (vector<Var *>::iterator irv = this->
vars.begin();
1649 irv != it_var_end; irv+=sel_steps) {
1651 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1652 ira != (*irv)->attrs.end();ira++) {
1653 if(H5FSTRING == (*ira)->getType()) {
1654 if((*ira)->name == dim_name){
1655 has_dim_name =
true;
1660 if(
true == has_dim_name)
1669 if(
true == has_dim_name) {
1670 string attr_name_subset =
"GridHeader";
1671 BESDEBUG(
"h5",
"GMFile::Check_And_Update_New_GPM_L3() has attribute <DimensionNames>. "<<endl);
1672 for (vector<Group *>::iterator irg = this->
groups.begin();
1673 irg != this->groups.end(); ++ irg) {
1674 for(vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
1675 ira != (*irg)->attrs.end();ira++) {
1676 string attr_name = (*ira)->name;
1678 if(attr_name.find(attr_name_subset)!=string::npos) {
1679 this->product_type = GPM_L3_New;
1680 is_new_gpm_l3 =
true;
1684 if(
true == is_new_gpm_l3)
1688 return is_new_gpm_l3;
1694 bool GMFile::Check_LatLon2D_General_Product_Pattern() {
1696 BESDEBUG(
"h5",
"Coming to Check_LatLon2D_General_Product_Pattern()"<<endl);
1697 bool ret_value =
false;
1699 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"latitude",
"longitude");
1700 if(
false == ret_value) {
1701 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"Latitude",
"Longitude");
1702 if(
false == ret_value) {
1703 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"lat",
"lon");
1704 if(
false == ret_value)
1705 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"cell_lat",
"cell_lon");
1710 if(
true == ret_value)
1711 this->gproduct_pattern = GENERAL_LATLON2D;
1718 bool GMFile::Check_LatLon2D_General_Product_Pattern_Name_Size(
const string & latname,
const string & lonname) {
1720 BESDEBUG(
"h5",
"Coming to Check_LatLon2D_General_Product_Pattern_Name_Size()"<<endl);
1721 bool ret_value =
false;
1722 bool ll_flag =
false;
1724 vector<size_t>lat_size(2,0);
1725 vector<size_t>lon_size(2,0);
1727 const string designed_group1 =
"/";
1728 const string designed_group2 =
"/Geolocation/";
1730 bool lat_flag_g1 =
false;
1731 bool lon_flag_g1 =
false;
1732 bool lat_flag_g2 =
false;
1733 bool lon_flag_g2 =
false;
1739 lat_flag_g1 = is_var_under_group(latname,designed_group1,2,lat_size);
1740 lon_flag_g1 = is_var_under_group(lonname,designed_group1,2,lon_size);
1741 if(lat_flag_g1 ==
true && lon_flag_g1 ==
true) {
1744 lat_flag_g2 = is_var_under_group(latname,designed_group2,2,lat_size);
1745 if(lat_flag_g2 ==
false) {
1746 lon_flag_g2 = is_var_under_group(lonname,designed_group2,2,lon_size);
1747 if(lon_flag_g2 ==
false)
1751 else if(lat_flag_g1 ==
false && lon_flag_g1 ==
false) {
1752 lat_flag_g2 = is_var_under_group(latname,designed_group2,2,lat_size);
1753 if(lat_flag_g2 ==
true) {
1754 lon_flag_g2 = is_var_under_group(lonname,designed_group2,2,lon_size);
1755 if(lon_flag_g2 ==
true)
1764 if(
false == ll_flag) {
1766 const string designed_group3 =
"/GeolocationData/";
1767 if(is_var_under_group(latname,designed_group3,2,lat_size) &&
1768 is_var_under_group(lonname,designed_group3,2,lon_size))
1774 for (vector<Var *>::iterator irv = this->
vars.begin();
1775 irv != this->vars.end(); ++irv) {
1777 if((*irv)->rank == 2) {
1778 if((*irv)->name == latname) {
1781 string lat_path =HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1787 bool has_right_lat =
false;
1788 if(
"/" == lat_path ||
"/Geolocation/" == lat_path)
1789 if(
"/" == lat_path ||
"/Geolocation/" == lat_path) {
1791 lat_size[0] = (*irv)->getDimensions()[0]->size;
1792 lat_size[1] = (*irv)->getDimensions()[1]->size;
1796 else if((*irv)->name == lonname) {
1797 string lon_path = HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1798 if(
"/" == lon_path ||
"/Geolocation/" == lon_path) {
1800 lon_size[0] = (*irv)->getDimensions()[0]->size;
1801 lon_size[1] = (*irv)->getDimensions()[1]->size;
1814 if(
true == ll_flag) {
1816 bool latlon_size_match =
true;
1817 for (
unsigned int size_index = 0; size_index <lat_size.size();size_index++) {
1818 if(lat_size[size_index] != lon_size[size_index]){
1819 latlon_size_match =
false;
1823 if (
true == latlon_size_match) {
1825 gp_latname = latname;
1826 gp_lonname = lonname;
1839 bool GMFile::Check_LatLon1D_General_Product_Pattern() {
1841 BESDEBUG(
"h5",
"Coming to Check_LatLon1D_General_Product_Pattern()"<<endl);
1842 bool ret_value =
false;
1844 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"latitude",
"longitude");
1845 if(
false == ret_value) {
1846 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"Latitude",
"Longitude");
1847 if(
false == ret_value) {
1848 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"lat",
"lon");
1849 if(
false == ret_value)
1850 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"cell_lat",
"cell_lon");
1854 if(
true == ret_value)
1855 this->gproduct_pattern = GENERAL_LATLON1D;
1862 bool GMFile::Check_LatLon1D_General_Product_Pattern_Name_Size(
const string & latname,
const string & lonname) {
1864 BESDEBUG(
"h5",
"Coming to Check_LatLon1D_General_Product_Pattern_Name_Size()"<<endl);
1865 bool ret_value =
false;
1867 size_t lat_size = 0;
1868 size_t lon_size = 0;
1870 for (vector<Var *>::iterator irv = this->
vars.begin();
1871 irv != this->vars.end(); ++irv) {
1873 if((*irv)->rank == 1) {
1874 if((*irv)->name == latname) {
1876 string lat_path =HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1880 if(
"/" == lat_path ||
"/Geolocation/" == lat_path) {
1882 lat_size = (*irv)->getDimensions()[0]->size;
1885 else if((*irv)->name == lonname) {
1886 string lon_path = HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1887 if(
"/" == lon_path ||
"/Geolocation/" == lon_path) {
1889 lon_size = (*irv)->getDimensions()[0]->size;
1899 bool latlon_size_match_grid =
true;
1905 if(lat_size == lon_size) {
1908 latlon_size_match_grid =
false;
1912 for (vector<Var *>::iterator irv = this->
vars.begin();
1913 irv != this->vars.end(); ++irv) {
1914 if((*irv)->rank >=2) {
1915 short ll_size_flag = 0;
1916 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
1917 ird != (*irv)->dims.end(); ++ird) {
1918 if(lat_size == (*ird)->size) {
1920 if(2 == ll_size_flag){
1925 if(2 == ll_size_flag) {
1926 latlon_size_match_grid =
true;
1935 if (
true == latlon_size_match_grid) {
1936 gp_latname = latname;
1937 gp_lonname = lonname;
1947 bool GMFile::Check_LatLon_With_Coordinate_Attr_General_Product_Pattern() {
1949 BESDEBUG(
"h5",
"Coming to Check_LatLon_With_Coordinate_Attr_General_Product_Pattern()"<<endl);
1950 bool ret_value =
false;
1951 string co_attrname =
"coordinates";
1952 string co_attrvalue=
"";
1953 string unit_attrname =
"units";
1954 string lat_unit_attrvalue =
"degrees_north";
1955 string lon_unit_attrvalue =
"degrees_east";
1957 bool coor_has_lat_flag =
false;
1958 bool coor_has_lon_flag =
false;
1960 vector<Var*> tempvar_lat;
1961 vector<Var*> tempvar_lon;
1964 for (vector<Var *>::iterator irv = this->
vars.begin();
1965 irv != this->vars.end(); ++irv) {
1966 if((*irv)->rank >=2) {
1967 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
1968 ira !=(*irv)->attrs.end();++ira) {
1972 if((*ira)->name == co_attrname) {
1973 Retrieve_H5_Attr_Value((*ira),(*irv)->fullpath);
1974 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
1975 vector<string> coord_values;
1977 HDF5CFUtil::Split_helper(coord_values,orig_attr_value,sep);
1979 for(vector<string>::iterator irs=coord_values.begin();irs!=coord_values.end();++irs) {
1980 string coord_value_suffix1;
1981 string coord_value_suffix2;
1982 string coord_value_suffix3;
1984 if((*irs).size() >=3) {
1987 coord_value_suffix1 = (*irs).substr((*irs).size()-3,3);
1990 if((*irs).size() >=8){
1991 coord_value_suffix2 = (*irs).substr((*irs).size()-8,8);
1992 if((*irs).size() >=9)
1993 coord_value_suffix3 = (*irs).substr((*irs).size()-9,9);
1998 if(coord_value_suffix1==
"lat" || coord_value_suffix2 ==
"latitude" || coord_value_suffix2 ==
"Latitude")
1999 coor_has_lat_flag =
true;
2000 else if(coord_value_suffix1==
"lon" || coord_value_suffix3 ==
"longitude" || coord_value_suffix3 ==
"Longitude")
2001 coor_has_lon_flag =
true;
2004 if(
true == coor_has_lat_flag &&
true == coor_has_lon_flag)
2008 if(
true == coor_has_lat_flag &&
true == coor_has_lon_flag)
2011 coor_has_lat_flag =
false;
2012 coor_has_lon_flag =
false;
2018 if(
true == coor_has_lat_flag &&
true == coor_has_lon_flag) {
2020 for (vector<Var *>::iterator irv = this->
vars.begin();
2021 irv != this->vars.end(); ++irv) {
2022 bool var_is_lat =
false;
2023 bool var_is_lon =
false;
2025 string varname = (*irv)->name;
2029 if(varname.size() >=3) {
2030 ll_ssuffix = varname.substr(varname.size()-3,3);
2031 if(varname.size() >=8) {
2032 ll_lsuffix1 = varname.substr(varname.size()-8,8);
2033 if(varname.size() >=9)
2034 ll_lsuffix2 = varname.substr(varname.size()-9,9);
2037 if(ll_ssuffix==
"lat" || ll_lsuffix1 ==
"latitude" || ll_lsuffix1 ==
"Latitude")
2039 else if(ll_ssuffix==
"lon" || ll_lsuffix2 ==
"longitude" || ll_lsuffix2 ==
"Longitude")
2043 if(
true == var_is_lat) {
2044 if((*irv)->rank > 0) {
2045 Var * lat =
new Var(*irv);
2046 tempvar_lat.push_back(lat);
2049 else if(
true == var_is_lon) {
2050 if((*irv)->rank >0) {
2051 Var * lon =
new Var(*irv);
2052 tempvar_lon.push_back(lon);
2062 for(vector<Var*>:: iterator irlat = tempvar_lat.begin(); irlat!=tempvar_lat.end();++irlat) {
2065 if((*irlat)->rank == 1)
2066 Build_lat1D_latlon_candidate(*irlat,tempvar_lon);
2069 else if((*irlat)->rank >1)
2070 Build_latg1D_latlon_candidate(*irlat,tempvar_lon);
2074 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin(); ivs!=latloncv_candidate_pairs.end();++ivs) {
2075 cerr<<
"struct lat lon names are " <<(*ivs).name1 <<
" and " << (*ivs).name2 <<endl;
2082 Build_unique_latlon_candidate();
2096 if(latloncv_candidate_pairs.size() >0) {
2097 int num_1d_rank = 0;
2098 int num_2d_rank = 0;
2099 int num_g2d_rank = 0;
2100 vector<struct Name_Size_2Pairs> temp_1d_latlon_pairs;
2101 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin();
2102 ivs!=latloncv_candidate_pairs.end();++ivs) {
2103 if(1 == (*ivs).rank) {
2105 temp_1d_latlon_pairs.push_back(*ivs);
2107 else if(2 == (*ivs).rank)
2109 else if((*ivs).rank >2)
2114 if (num_2d_rank !=0)
2116 else if(num_1d_rank!=0) {
2120 for(vector<struct Name_Size_2Pairs>::iterator ivs=temp_1d_latlon_pairs.begin();
2121 ivs!=temp_1d_latlon_pairs.end();++ivs) {
2122 if((*ivs).size1 != (*ivs).size2) {
2133 for (vector<Var *>::iterator irv = this->
vars.begin();
2134 irv != this->vars.end(); ++irv) {
2135 if((*irv)->rank >=2) {
2136 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
2137 ira !=(*irv)->attrs.end();++ira) {
2139 if((*ira)->name == co_attrname) {
2140 Retrieve_H5_Attr_Value((*ira),(*irv)->fullpath);
2141 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
2142 vector<string> coord_values;
2144 HDF5CFUtil::Split_helper(coord_values,orig_attr_value,sep);
2145 bool has_lat_flag =
false;
2146 bool has_lon_flag =
false;
2147 for (vector<string>::iterator itcv=coord_values.begin();itcv!=coord_values.end();++itcv) {
2148 if((*ivs).name1 == (*itcv))
2149 has_lat_flag =
true;
2150 else if((*ivs).name2 == (*itcv))
2151 has_lon_flag =
true;
2154 if(
true == has_lat_flag &&
true == has_lon_flag) {
2155 short has_same_ll_size = 0;
2156 for(vector<Dimension *>::iterator ird = (*irv)->dims.begin();ird!=(*irv)->dims.end();++ird){
2157 if((*ird)->size == (*ivs).size1)
2160 if(has_same_ll_size!=2){
2167 if(
false == ret_value)
2172 if(
true == ret_value)
2179 release_standalone_var_vector(tempvar_lat);
2180 release_standalone_var_vector(tempvar_lon);
2184 if(
true == ret_value)
2185 cerr<<
"This product is the coordinate type "<<endl;
2188 if(
true == ret_value)
2189 this->gproduct_pattern = GENERAL_LATLON_COOR_ATTR;
2195 void GMFile::Build_lat1D_latlon_candidate(
Var *lat,
const vector<Var*> &lon_vec) {
2197 BESDEBUG(
"h5",
"Coming to Build_lat1D_latlon_candidate()"<<endl);
2198 set<string> lon_candidate_path;
2199 vector< pair<string,hsize_t> > lon_path_size_vec;
2202 for(vector<Var *>::const_iterator irlon = lon_vec.begin(); irlon!=lon_vec.end();++irlon) {
2204 if (lat->rank == (*irlon)->rank) {
2205 pair<string,hsize_t>lon_path_size;
2206 lon_path_size.first = (*irlon)->fullpath;
2207 lon_path_size.second = (*irlon)->getDimensions()[0]->size;
2208 lon_path_size_vec.push_back(lon_path_size);
2213 if(lon_path_size_vec.size() == 1) {
2216 latlon_pair.name1 = lat->fullpath;
2217 latlon_pair.name2 = lon_path_size_vec[0].first;
2219 latlon_pair.size2 = lon_path_size_vec[0].second;
2220 latlon_pair.rank = lat->rank;
2221 latloncv_candidate_pairs.push_back(latlon_pair);
2224 else if(lon_path_size_vec.size() >1) {
2228 string lat_path = HDF5CFUtil::obtain_string_before_lastslash(lat->fullpath);
2229 pair<string,hsize_t> lon_final_path_size;
2230 short num_lon_match = 0;
2231 for(vector <pair<string,hsize_t> >::iterator islon =lon_path_size_vec.begin();islon!=lon_path_size_vec.end();++islon) {
2233 if(HDF5CFUtil::obtain_string_before_lastslash((*islon).first)==lat_path) {
2235 if(1 == num_lon_match)
2236 lon_final_path_size = *islon;
2237 else if(num_lon_match > 1)
2241 if(num_lon_match ==1) {
2243 latlon_pair.name1 = lat->fullpath;
2244 latlon_pair.name2 = lon_final_path_size.first;
2246 latlon_pair.size2 = lon_final_path_size.second;
2247 latlon_pair.rank = lat->rank;
2248 latloncv_candidate_pairs.push_back(latlon_pair);
2255 void GMFile::Build_latg1D_latlon_candidate(
Var *lat,
const vector<Var*> & lon_vec) {
2257 BESDEBUG(
"h5",
"Coming to Build_latg1D_latlon_candidate()"<<endl);
2258 set<string> lon_candidate_path;
2261 for(vector<Var*>:: const_iterator irlon = lon_vec.begin(); irlon!=lon_vec.end();++irlon) {
2263 if (lat->rank == (*irlon)->rank) {
2266 bool same_dim =
true;
2267 for(
int dim_index = 0; dim_index <lat->rank; dim_index++) {
2269 (*irlon)->getDimensions()[dim_index]->size){
2274 if(
true == same_dim)
2275 lon_candidate_path.insert((*irlon)->fullpath);
2280 if(lon_candidate_path.size() > 1) {
2282 string lat_path = HDF5CFUtil::obtain_string_before_lastslash(lat->fullpath);
2283 vector <string> lon_final_candidate_path_vec;
2284 for(set<string>::iterator islon_path =lon_candidate_path.begin();islon_path!=lon_candidate_path.end();++islon_path) {
2287 if(HDF5CFUtil::obtain_string_before_lastslash(*islon_path)==lat_path)
2288 lon_final_candidate_path_vec.push_back(*islon_path);
2291 if(lon_final_candidate_path_vec.size() == 1) {
2295 latlon_pair.name1 = lat->fullpath;
2296 latlon_pair.name2 = lon_final_candidate_path_vec[0];
2299 latlon_pair.rank = lat->rank;
2300 latloncv_candidate_pairs.push_back(latlon_pair);
2302 else if(lon_final_candidate_path_vec.size() >1) {
2309 string lat_name = HDF5CFUtil::obtain_string_after_lastslash(lat->fullpath);
2310 string lat_name_prefix1;
2311 string lat_name_prefix2;
2314 if(lat_name.size() >3) {
2315 lat_name_prefix1 = lat_name.substr(0,lat_name.size()-3);
2316 if(lat_name.size() >8)
2317 lat_name_prefix2 = lat_name.substr(0,lat_name.size()-8);
2319 string lon_name_prefix1;
2320 string lon_name_prefix2;
2322 for(vector<string>::iterator ilon = lon_final_candidate_path_vec.begin(); ilon!=lon_final_candidate_path_vec.end();++ilon) {
2323 string lon_name = HDF5CFUtil::obtain_string_after_lastslash(*ilon);
2324 if(lon_name.size() >3) {
2325 lon_name_prefix1 = lon_name.substr(0,lon_name.size()-3);
2326 if(lon_name.size() >9)
2327 lon_name_prefix2 = lon_name.substr(0,lon_name.size()-9);
2329 if((lat_name_prefix1 !=
"" && lat_name_prefix1 == lon_name_prefix1) ||
2330 (lat_name_prefix2 !=
"" && lat_name_prefix2 == lon_name_prefix2)) {
2333 latlon_pair.name1 = lat->fullpath;
2334 latlon_pair.name2 = *ilon;
2337 latlon_pair.rank = lat->rank;
2338 latloncv_candidate_pairs.push_back(latlon_pair);
2345 else if(lon_candidate_path.size() == 1) {
2349 latlon_pair.name1 = lat->fullpath;
2350 latlon_pair.name2 = *(lon_candidate_path.begin());
2353 latlon_pair.rank = lat->rank;
2354 latloncv_candidate_pairs.push_back(latlon_pair);
2362 void GMFile::Build_unique_latlon_candidate() {
2364 BESDEBUG(
"h5",
"Coming to Build_unique_latlon_candidate()"<<endl);
2365 set<int> duplicate_index;
2366 for(
unsigned int i= 0; i<latloncv_candidate_pairs.size();i++) {
2367 for(
unsigned int j=i+1;j<latloncv_candidate_pairs.size();j++) {
2368 if(latloncv_candidate_pairs[i].name2 == latloncv_candidate_pairs[j].name2) {
2369 duplicate_index.insert(i);
2370 duplicate_index.insert(j);
2376 for(set<int>::reverse_iterator its= duplicate_index.rbegin();its!=duplicate_index.rend();++its) {
2377 latloncv_candidate_pairs[*its] = latloncv_candidate_pairs.back();
2378 latloncv_candidate_pairs.pop_back();
2385 bool GMFile::Check_LatLonName_General_Product(
int ll_rank) {
2387 if(ll_rank <1 || ll_rank >2)
2388 throw2(
"Only support rank = 1 or 2 lat/lon case for the general product. The current rank is ",ll_rank);
2389 bool ret_value =
false;
2390 size_t lat2D_dimsize0 = 0;
2391 size_t lat2D_dimsize1 = 0;
2392 size_t lon2D_dimsize0 = 0;
2393 size_t lon2D_dimsize1 = 0;
2396 vector<short>ll_flag(3,0);
2398 vector<size_t>lat_size;
2399 vector<size_t>lon_size;
2404 lat_size.assign(6,0);
2405 lon_size.assign(6,0);
2408 for (vector<Var *>::iterator irv = this->
vars.begin();
2409 irv != this->vars.end(); ++irv) {
2411 if((*irv)->rank == ll_rank) {
2412 if((*irv)->name ==
"lat") {
2415 lat_size[0] = (*irv)->getDimensions()[0]->size;
2416 lat_size[1] = (*irv)->getDimensions()[1]->size;
2421 else if((*irv)->name ==
"lon") {
2424 lon_size[0] = (*irv)->getDimensions()[0]->size;
2425 lon_size[1] = (*irv)->getDimensions()[1]->size;
2430 else if((*irv)->name ==
"latitude"){
2433 lat_size[2] = (*irv)->getDimensions()[0]->size;
2434 lat_size[3] = (*irv)->getDimensions()[1]->size;
2438 else if((*irv)->name ==
"longitude"){
2441 lon_size[2] = (*irv)->getDimensions()[0]->size;
2442 lon_size[3] = (*irv)->getDimensions()[1]->size;
2447 else if((*irv)->name ==
"Latitude"){
2450 lat_size[4] = (*irv)->getDimensions()[0]->size;
2451 lat_size[5] = (*irv)->getDimensions()[1]->size;
2456 else if((*irv)->name ==
"Longitude"){
2459 lon_size[4] = (*irv)->getDimensions()[0]->size;
2460 lon_size[5] = (*irv)->getDimensions()[1]->size;
2466 int total_llflag = 0;
2467 for (
int i = 0; i < ll_flag.size();i++)
2472 if(1 == total_llflag) {
2473 bool latlon_size_match =
true;
2475 for (
int size_index = 0; size_index <lat_size.size();size_index++) {
2476 if(lat_size[size_index] != lon_size[size_index]){
2477 latlon_size_match =
false;
2483 if(
true == latlon_size_match) {
2485 if(2 == ll_flag[0]) {
2489 else if ( 2 == ll_flag[1]) {
2490 gp_latname =
"latitude";
2491 gp_lonname =
"longitude";
2494 else if (2 == ll_flag[2]){
2495 gp_latname =
"Latitude";
2496 gp_lonname =
"Longitude";
2506 void GMFile::Add_Dim_Name_LatLon2D_General_Product() {
2508 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_LatLon2D_General_Product()"<<endl);
2511 size_t latdimsize0 = 0;
2512 size_t latdimsize1 = 0;
2515 for (vector<Var *>::iterator irv = this->
vars.begin();
2516 irv != this->vars.end(); ++irv) {
2518 set<hsize_t> fakedimsize;
2519 pair<set<hsize_t>::iterator,
bool> setsizeret;
2520 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2521 ird != (*irv)->dims.end(); ++ird) {
2522 Add_One_FakeDim_Name(*ird);
2523 setsizeret = fakedimsize.insert((*ird)->size);
2526 if (
false == setsizeret.second)
2527 Adjust_Duplicate_FakeDim_Name(*ird);
2532 if((*irv)->name == gp_latname) {
2533 if((*irv)->rank != 2) {
2534 throw4(
"coordinate variables ",gp_latname,
2535 " must have rank 2 for the 2-D latlon case , the current rank is ",
2538 latdimname0 = (*irv)->getDimensions()[0]->name;
2539 latdimsize0 = (*irv)->getDimensions()[0]->size;
2541 latdimname1 = (*irv)->getDimensions()[1]->name;
2542 latdimsize1 = (*irv)->getDimensions()[1]->size;
2549 for (vector<Var *>::iterator irv = this->
vars.begin();
2550 irv != this->vars.end(); ++irv) {
2551 int lat_dim0_index = 0;
2552 int lat_dim1_index = 0;
2553 bool has_lat_dims_size =
false;
2555 for (
unsigned int dim_index = 0; dim_index <(*irv)->dims.size(); dim_index++) {
2558 if(((*irv)->dims[dim_index])->size == latdimsize0) {
2561 lat_dim0_index = dim_index;
2562 for(
unsigned int dim_index2 = dim_index+1;dim_index2 < (*irv)->dims.size();dim_index2++) {
2563 if(((*irv)->dims[dim_index2])->size == latdimsize1) {
2564 lat_dim1_index = dim_index2;
2565 has_lat_dims_size =
true;
2570 if(
true == has_lat_dims_size)
2574 if(
true == has_lat_dims_size) {
2575 ((*irv)->dims[lat_dim0_index])->name = latdimname0;
2578 ((*irv)->dims[lat_dim1_index])->name = latdimname1;
2589 set<string>tempdimnamelist;
2591 for (vector<Var *>::iterator irv = this->
vars.begin();
2592 irv != this->
vars.end(); ++irv) {
2593 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2594 ird != (*irv)->dims.end(); ++ird)
2595 tempdimnamelist.insert((*ird)->name);
2600 set<string>finaldimnamelist;
2601 string finaldimname_base =
"FakeDim";
2603 for(
unsigned int i = 0; i<tempdimnamelist.size();i++) {
2604 stringstream sfakedimindex;
2606 string finaldimname = finaldimname_base + sfakedimindex.str();
2607 finaldimnamelist.insert(finaldimname);
2612 if(finaldimnamelist != tempdimnamelist) {
2613 map<string,string> tempdimname_to_finaldimname;
2614 set<string>:: iterator tempit = tempdimnamelist.begin();
2615 set<string>:: iterator finalit = finaldimnamelist.begin();
2616 while(tempit != tempdimnamelist.end()) {
2617 tempdimname_to_finaldimname[*tempit] = *finalit;
2623 for (vector<Var *>::iterator irv = this->
vars.begin();
2624 irv != this->
vars.end(); ++irv) {
2625 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2626 ird != (*irv)->dims.end(); ++ird) {
2627 if(tempdimname_to_finaldimname.find((*ird)->name) !=tempdimname_to_finaldimname.end()){
2628 (*ird)->name = tempdimname_to_finaldimname[(*ird)->name];
2631 throw3(
"The dimension names ",(*ird)->name,
"cannot be found in the dim. name list.");
2637 dimnamelist.clear();
2638 dimnamelist = finaldimnamelist;
2641 dimname_to_dimsize.clear();
2642 for (vector<Var *>::iterator irv = this->
vars.begin();
2643 irv != this->vars.end(); ++irv) {
2644 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2645 ird != (*irv)->dims.end(); ++ird) {
2646 if(finaldimnamelist.find((*ird)->name)!=finaldimnamelist.end()) {
2647 dimname_to_dimsize[(*ird)->name] = (*ird)->size;
2648 dimname_to_unlimited[(*ird)->name] = (*ird)->unlimited_dim;
2649 finaldimnamelist.erase((*ird)->name);
2653 if(
true == finaldimnamelist.empty())
2658 for (vector<Var *>::iterator irv = this->
vars.begin();
2659 irv != this->vars.end(); ++irv) {
2660 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2661 ird != (*irv)->dims.end(); ++ird) {
2662 (*ird)->newname = (*ird)->name;
2670 void GMFile::Add_Dim_Name_LatLon1D_Or_CoordAttr_General_Product() {
2672 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_LatLon1D_Or_CoordAttr_General_Product()"<<endl);
2674 for (vector<Var *>::iterator irv = this->
vars.begin();
2675 irv != this->vars.end(); ++irv) {
2677 set<hsize_t> fakedimsize;
2678 pair<set<hsize_t>::iterator,
bool> setsizeret;
2679 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2680 ird != (*irv)->dims.end(); ++ird) {
2681 Add_One_FakeDim_Name(*ird);
2682 setsizeret = fakedimsize.insert((*ird)->size);
2684 if (
false == setsizeret.second)
2685 Adjust_Duplicate_FakeDim_Name(*ird);
2691 void GMFile::Add_Dim_Name_Dimscale_General_Product() {
2693 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Dimscale_General_Product()"<<endl);
2695 pair<set<string>::iterator,
bool> setret;
2696 this->iscoard =
true;
2698 for (vector<Var *>::iterator irv = this->
vars.begin();
2699 irv != this->vars.end(); ++irv) {
2702 Handle_UseDimscale_Var_Dim_Names_General_Product((*irv));
2705 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
2706 ird !=(*irv)->dims.end();++ird) {
2707 setret = dimnamelist.insert((*ird)->name);
2708 if (
true == setret.second)
2709 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
2713 if (
true == dimnamelist.empty())
2714 throw1(
"This product should have the dimension names, but no dimension names are found");
2719 void GMFile::Handle_UseDimscale_Var_Dim_Names_General_Product(
Var *var) {
2721 BESDEBUG(
"h5",
"Coming to Handle_UseDimscale_Var_Dim_Names_General_Product()"<<endl);
2723 bool has_dimlist =
false;
2724 bool has_dimclass =
false;
2726 for(vector<Attribute *>::iterator ira = var->attrs.begin();
2727 ira != var->attrs.end();ira++) {
2728 if (
"DIMENSION_LIST" == (*ira)->name) {
2732 if (
"CLASS" == (*ira)->name) {
2734 Retrieve_H5_Attr_Value(*ira,var->fullpath);
2736 class_value.resize((*ira)->value.size());
2737 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
2741 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
2742 has_dimclass =
true;
2750 if (
true == has_dimlist)
2751 Add_UseDimscale_Var_Dim_Names_General_Product(var,dimlistattr);
2754 else if(
true == has_dimclass) {
2755 if (var->dims.size() !=1)
2756 throw2(
"Currently dimension scale dataset must be 1 dimension, this is not true for the dataset ",
2761 (var->dims)[0]->name = var->fullpath;
2762 (var->dims)[0]->newname = var->fullpath;
2763 pair<set<string>::iterator,
bool> setret;
2764 setret = dimnamelist.insert((var->dims)[0]->name);
2765 if (
true == setret.second)
2766 Insert_One_NameSizeMap_Element((var->dims)[0]->name,(var->dims)[0]->size,(var->dims)[0]->unlimited_dim);
2772 set<hsize_t> fakedimsize;
2773 pair<set<hsize_t>::iterator,
bool> setsizeret;
2774 for (vector<Dimension *>::iterator ird= var->dims.begin();
2775 ird != var->dims.end(); ++ird) {
2776 Add_One_FakeDim_Name(*ird);
2777 setsizeret = fakedimsize.insert((*ird)->size);
2779 if (
false == setsizeret.second)
2780 Adjust_Duplicate_FakeDim_Name(*ird);
2787 void GMFile::Add_UseDimscale_Var_Dim_Names_General_Product(
Var *var,
Attribute*dimlistattr)
2790 BESDEBUG(
"h5",
"Coming to Add_UseDimscale_Var_Dim_Names_General_Product()"<<endl);
2791 ssize_t objnamelen = -1;
2794 vector<hvl_t> vlbuf;
2798 hid_t atype_id = -1;
2799 hid_t amemtype_id = -1;
2800 hid_t aspace_id = -1;
2801 hid_t ref_dset = -1;
2803 if(NULL == dimlistattr)
2804 throw2(
"Cannot obtain the dimension list attribute for variable ",var->name);
2806 else if (0==var->rank)
2807 throw2(
"The number of dimension should NOT be 0 for the variable ",var->name);
2812 vlbuf.resize(var->rank);
2814 dset_id = H5Dopen(this->fileid,(var->fullpath).c_str(),H5P_DEFAULT);
2816 throw2(
"Cannot open the dataset ",var->fullpath);
2818 attr_id = H5Aopen(dset_id,(dimlistattr->name).c_str(),H5P_DEFAULT);
2820 throw4(
"Cannot open the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
2822 atype_id = H5Aget_type(attr_id);
2824 throw4(
"Cannot obtain the datatype of the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
2826 amemtype_id = H5Tget_native_type(atype_id, H5T_DIR_ASCEND);
2828 if (amemtype_id < 0)
2829 throw2(
"Cannot obtain the memory datatype for the attribute ",dimlistattr->name);
2832 if (H5Aread(attr_id,amemtype_id,&vlbuf[0]) <0)
2833 throw2(
"Cannot obtain the referenced object for the variable ",var->name);
2836 vector<char> objname;
2837 int vlbuf_index = 0;
2840 for (vector<Dimension *>::iterator ird = var->dims.begin();
2841 ird != var->dims.end(); ++ird) {
2843 if(vlbuf[vlbuf_index].p== NULL)
2844 throw4(
"The dimension doesn't exist. Var name is ",var->name,
"; the dimension index is ",vlbuf_index);
2845 rbuf =((hobj_ref_t*)vlbuf[vlbuf_index].p)[0];
2846 if ((ref_dset = H5RDEREFERENCE(attr_id, H5R_OBJECT, &rbuf)) < 0)
2847 throw2(
"Cannot dereference from the DIMENSION_LIST attribute for the variable ",var->name);
2849 if ((objnamelen= H5Iget_name(ref_dset,NULL,0))<=0)
2850 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
2851 objname.resize(objnamelen+1);
2852 if ((objnamelen= H5Iget_name(ref_dset,&objname[0],objnamelen+1))<=0)
2853 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
2855 string objname_str = string(objname.begin(),objname.end());
2861 string trim_objname = objname_str.substr(0,objnamelen);
2862 (*ird)->name = string(trim_objname.begin(),trim_objname.end());
2864 pair<set<string>::iterator,
bool> setret;
2865 setret = dimnamelist.insert((*ird)->name);
2866 if (
true == setret.second)
2867 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
2868 (*ird)->newname = (*ird)->name;
2876 if(vlbuf.size()!= 0) {
2878 if ((aspace_id = H5Aget_space(attr_id)) < 0)
2879 throw2(
"Cannot get hdf5 dataspace id for the attribute ",dimlistattr->name);
2881 if (H5Dvlen_reclaim(amemtype_id,aspace_id,H5P_DEFAULT,(
void*)&vlbuf[0])<0)
2882 throw2(
"Cannot successfully clean up the variable length memory for the variable ",var->name);
2884 H5Sclose(aspace_id);
2889 H5Tclose(amemtype_id);
2899 if(amemtype_id != -1)
2900 H5Tclose(amemtype_id);
2903 H5Sclose(aspace_id);
2920 BESDEBUG(
"h5",
"GMFile:: Coming to Handle_CVar()"<<endl);
2926 if (General_Product == this->product_type ||
2927 ACOS_L2S_OR_OCO2_L1B == this->product_type) {
2928 if (GENERAL_DIMSCALE == this->gproduct_pattern)
2929 Handle_CVar_Dimscale_General_Product();
2930 else if (GENERAL_LATLON1D == this->gproduct_pattern)
2931 Handle_CVar_LatLon1D_General_Product();
2932 else if (GENERAL_LATLON2D == this->gproduct_pattern)
2933 Handle_CVar_LatLon2D_General_Product();
2937 else if (Mea_SeaWiFS_L2 == this->product_type ||
2938 Mea_SeaWiFS_L3 == this->product_type)
2939 Handle_CVar_Mea_SeaWiFS();
2940 else if (Aqu_L3 == this->product_type)
2941 Handle_CVar_Aqu_L3();
2942 else if (OBPG_L3 == this->product_type)
2943 Handle_CVar_OBPG_L3();
2944 else if (OSMAPL2S == this->product_type)
2945 Handle_CVar_OSMAPL2S();
2946 else if (Mea_Ozone == this->product_type)
2947 Handle_CVar_Mea_Ozone();
2948 else if (GPMS_L3 == this->product_type || GPMM_L3 == this->product_type
2949 || GPM_L3_New == this->product_type )
2950 Handle_CVar_GPM_L3();
2951 else if (GPM_L1 == this->product_type)
2952 Handle_CVar_GPM_L1();
2956 void GMFile::Handle_CVar_GPM_L1() {
2958 BESDEBUG(
"h5",
"Coming to Handle_CVar_GPM_L1()"<<endl);
2961 for (vector<Var *>::iterator irv = this->
vars.begin();
2962 irv != this->vars.end(); ++irv) {
2963 if((*irv)->name==
"AlgorithmRuntimeInfo") {
2965 this->
vars.erase(irv);
2978 set<string> ll_dim_set;
2979 for (vector<Var *>::iterator irv = this->
vars.begin();
2980 irv != this->vars.end(); ) {
2981 if((*irv)->rank == 2 && (*irv)->name ==
"Latitude") {
2983 size_t lat_pos = (*irv)->fullpath.rfind(
"Latitude");
2984 string lat_path = (*irv)->fullpath.substr(0,lat_pos);
2985 GMcvar->cfdimname = lat_path + ((*irv)->dims)[0]->name;
2986 ll_dim_set.insert(((*irv)->dims)[0]->name);
2987 GMcvar->cvartype = CV_EXIST;
2988 GMcvar->product_type = product_type;
2989 this->cvars.push_back(GMcvar);
2991 irv = this->
vars.erase(irv);
2994 if((*irv)->rank == 2 && (*irv)->name ==
"Longitude") {
2996 size_t lon_pos = (*irv)->fullpath.rfind(
"Longitude");
2997 string lon_path = (*irv)->fullpath.substr(0,lon_pos);
2998 GMcvar->cfdimname = lon_path + ((*irv)->dims)[1]->name;
2999 ll_dim_set.insert(((*irv)->dims)[1]->name);
3000 GMcvar->cvartype = CV_EXIST;
3001 GMcvar->product_type = product_type;
3002 this->cvars.push_back(GMcvar);
3004 irv = this->
vars.erase(irv);
3013 set<string> cvdimset;
3014 pair<set<string>::iterator,
bool> setret;
3015 for (vector<Var *>::iterator irv = this->
vars.begin();
3016 irv != this->
vars.end(); ++irv) {
3017 for(vector<Dimension *>::iterator ird = (*irv)->dims.begin();
3018 ird != (*irv)->dims.end(); ++ird) {
3019 setret = cvdimset.insert((*ird)->name);
3020 cerr<<
"var name is "<<(*irv)->fullpath <<endl;
3021 if (
true == setret.second) {
3022 cerr<<
"dim name is "<<(*ird)->name <<endl;
3023 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size);
3032 for (map<string,hsize_t>::const_iterator itd = dimname_to_dimsize.begin();
3033 itd!=dimname_to_dimsize.end();++itd) {
3036 if((ll_dim_set.find(itd->first)) == ll_dim_set.end()) {
3038 Create_Missing_CV(GMcvar,itd->first);
3039 this->cvars.push_back(GMcvar);
3046 void GMFile::Handle_CVar_GPM_L3() {
3048 BESDEBUG(
"h5",
"Coming to Handle_CVar_GPM_L3()"<<endl);
3053 for (map<string,hsize_t>::const_iterator itd = dimname_to_dimsize.begin();
3054 itd!=dimname_to_dimsize.end();++itd) {
3057 if(
"nlon" == itd->first ||
"nlat" == itd->first
3058 ||
"lnH" == itd->first ||
"ltH" == itd->first
3059 ||
"lnL" == itd->first ||
"ltL" == itd->first) {
3060 GMcvar->name = itd->first;
3061 GMcvar->newname = GMcvar->name;
3062 GMcvar->fullpath = GMcvar->name;
3064 GMcvar->dtype = H5FLOAT32;
3066 gmcvar_dim->name = GMcvar->name;
3067 gmcvar_dim->newname = gmcvar_dim->name;
3068 GMcvar->dims.push_back(gmcvar_dim);
3069 GMcvar->cfdimname = gmcvar_dim->name;
3070 if (
"nlat" ==GMcvar->name ||
"ltH" == GMcvar->name
3071 ||
"ltL" == GMcvar->name)
3072 GMcvar->cvartype = CV_LAT_MISS;
3073 else if (
"nlon" == GMcvar->name ||
"lnH" == GMcvar->name
3074 ||
"lnL" == GMcvar->name)
3075 GMcvar->cvartype = CV_LON_MISS;
3076 GMcvar->product_type = product_type;
3078 else if ((
"nlayer" == itd->first && (28 == itd->second || 19 == itd->second)) ||
3079 (
"hgt" == itd->first && 5 == itd->second) ||
3080 (
"nalt" == itd->first && 5 == itd->second)){
3081 GMcvar->name = itd->first;
3082 GMcvar->newname = GMcvar->name;
3083 GMcvar->fullpath = GMcvar->name;
3085 GMcvar->dtype = H5FLOAT32;
3087 gmcvar_dim->name = GMcvar->name;
3088 gmcvar_dim->newname = gmcvar_dim->name;
3089 GMcvar->dims.push_back(gmcvar_dim);
3090 GMcvar->cfdimname = gmcvar_dim->name;
3091 GMcvar->cvartype = CV_SPECIAL;
3092 GMcvar->product_type = product_type;
3095 Create_Missing_CV(GMcvar,itd->first);
3096 this->cvars.push_back(GMcvar);
3101 void GMFile::Handle_CVar_Mea_SeaWiFS() {
3103 BESDEBUG(
"h5",
"Coming to Handle_CVar_Mea_SeaWiFS()"<<endl);
3104 pair<set<string>::iterator,
bool> setret;
3105 set<string>tempdimnamelist = dimnamelist;
3107 for (set<string>::iterator irs = dimnamelist.begin();
3108 irs != dimnamelist.end();++irs) {
3109 for (vector<Var *>::iterator irv = this->
vars.begin();
3110 irv != this->vars.end(); ) {
3111 if ((*irs)== (*irv)->fullpath) {
3113 if (!iscoard && ((
"/natrack" == (*irs))
3114 ||
"/nxtrack" == (*irs))) {
3119 if((*irv)->dims.size()!=1)
3120 throw3(
"Coard coordinate variable ",(*irv)->name,
"is not 1D");
3123 tempdimnamelist.erase(*irs);
3125 GMcvar->cfdimname = *irs;
3126 GMcvar->cvartype = CV_EXIST;
3127 GMcvar->product_type = product_type;
3128 this->cvars.push_back(GMcvar);
3130 irv = this->
vars.erase(irv);
3133 else if(
false == iscoard) {
3136 if ((((*irs) ==
"/natrack") && ((*irv)->fullpath ==
"/latitude"))
3137 ||(((*irs) ==
"/nxtrack") && ((*irv)->fullpath ==
"/longitude"))) {
3138 tempdimnamelist.erase(*irs);
3140 GMcvar->cfdimname = *irs;
3141 GMcvar->cvartype = CV_EXIST;
3142 GMcvar->product_type = product_type;
3143 this->cvars.push_back(GMcvar);
3145 irv = this->
vars.erase(irv);
3161 for (set<string>::iterator irs = tempdimnamelist.begin();
3162 irs != tempdimnamelist.end();++irs) {
3164 Create_Missing_CV(GMcvar,*irs);
3165 this->cvars.push_back(GMcvar);
3170 void GMFile::Handle_CVar_OSMAPL2S() {
3172 BESDEBUG(
"h5",
"Coming to Handle_CVar_OSMAPL2S()"<<endl);
3173 pair<set<string>::iterator,
bool> setret;
3174 set<string>tempdimnamelist = dimnamelist;
3176 string key0 =
"_lat";
3177 string key1 =
"_lon";
3178 string osmapl2sdim0 =
"YDim";
3179 string osmapl2sdim1 =
"XDim";
3181 bool foundkey0 =
false;
3182 bool foundkey1 =
false;
3186 for (vector<Var *>::iterator irv = this->
vars.begin();
3187 irv != this->vars.end(); ) {
3189 tempvarname = (*irv)->name;
3191 if ((tempvarname.size() > key0.size())&&
3192 (key0 == tempvarname.substr(tempvarname.size()-key0.size(),key0.size()))){
3196 if (dimnamelist.find(osmapl2sdim0)== dimnamelist.end())
3197 throw5(
"variable ",tempvarname,
" must have dimension ",osmapl2sdim0,
" , but not found ");
3199 tempdimnamelist.erase(osmapl2sdim0);
3201 GMcvar->newname = GMcvar->name;
3202 GMcvar->cfdimname = osmapl2sdim0;
3203 GMcvar->cvartype = CV_EXIST;
3204 GMcvar->product_type = product_type;
3205 this->cvars.push_back(GMcvar);
3207 irv = this->
vars.erase(irv);
3210 else if ((tempvarname.size() > key1.size())&&
3211 (key1 == tempvarname.substr(tempvarname.size()-key1.size(),key1.size()))){
3215 if (dimnamelist.find(osmapl2sdim1)== dimnamelist.end())
3216 throw5(
"variable ",tempvarname,
" must have dimension ",osmapl2sdim1,
" , but not found ");
3218 tempdimnamelist.erase(osmapl2sdim1);
3221 GMcvar->newname = GMcvar->name;
3222 GMcvar->cfdimname = osmapl2sdim1;
3223 GMcvar->cvartype = CV_EXIST;
3224 GMcvar->product_type = product_type;
3225 this->cvars.push_back(GMcvar);
3227 irv = this->
vars.erase(irv);
3232 if (
true == foundkey0 &&
true == foundkey1)
3236 for (set<string>::iterator irs = tempdimnamelist.begin();
3237 irs != tempdimnamelist.end();++irs) {
3240 Create_Missing_CV(GMcvar,*irs);
3241 this->cvars.push_back(GMcvar);
3247 void GMFile::Handle_CVar_Aqu_L3() {
3249 BESDEBUG(
"h5",
"Coming to Handle_CVar_Aqu_L3()"<<endl);
3251 for (vector<Var *>::iterator irv = this->
vars.begin();
3252 irv != this->vars.end(); ++irv) {
3254 if (
"l3m_data" == (*irv)->name) {
3255 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
3256 ird != (*irv)->dims.end(); ++ird) {
3258 GMcvar->name = (*ird)->name;
3259 GMcvar->newname = GMcvar->name;
3260 GMcvar->fullpath = GMcvar->name;
3262 GMcvar->dtype = H5FLOAT32;
3264 gmcvar_dim->name = GMcvar->name;
3265 gmcvar_dim->newname = gmcvar_dim->name;
3266 GMcvar->dims.push_back(gmcvar_dim);
3267 GMcvar->cfdimname = gmcvar_dim->name;
3268 if (
"lat" ==GMcvar->name ) GMcvar->cvartype = CV_LAT_MISS;
3269 if (
"lon" == GMcvar->name ) GMcvar->cvartype = CV_LON_MISS;
3270 GMcvar->product_type = product_type;
3271 this->cvars.push_back(GMcvar);
3279 void GMFile::Handle_CVar_Mea_Ozone() {
3281 BESDEBUG(
"h5",
"Coming to Handle_CVar_Mea_Ozone()"<<endl);
3282 pair<set<string>::iterator,
bool> setret;
3283 set<string>tempdimnamelist = dimnamelist;
3285 if(
false == iscoard)
3286 throw1(
"Measure Ozone level 3 zonal average product must follow COARDS conventions");
3288 for (set<string>::iterator irs = dimnamelist.begin();
3289 irs != dimnamelist.end();++irs) {
3290 for (vector<Var *>::iterator irv = this->
vars.begin();
3291 irv != this->vars.end(); ) {
3292 if ((*irs)== (*irv)->fullpath) {
3294 if((*irv)->dims.size()!=1)
3295 throw3(
"Coard coordinate variable",(*irv)->name,
"is not 1D");
3298 tempdimnamelist.erase(*irs);
3300 GMcvar->cfdimname = *irs;
3301 GMcvar->cvartype = CV_EXIST;
3302 GMcvar->product_type = product_type;
3303 this->cvars.push_back(GMcvar);
3305 irv = this->
vars.erase(irv);
3313 for (set<string>::iterator irs = tempdimnamelist.begin();
3314 irs != tempdimnamelist.end();irs++) {
3317 Create_Missing_CV(GMcvar,*irs);
3318 this->cvars.push_back(GMcvar);
3323 void GMFile::Handle_CVar_Dimscale_General_Product() {
3325 BESDEBUG(
"h5",
"Coming to Handle_CVar_Dimscale_General_Product"<<endl);
3326 pair<set<string>::iterator,
bool> setret;
3327 set<string>tempdimnamelist = dimnamelist;
3329 for (set<string>::iterator irs = dimnamelist.begin();
3330 irs != dimnamelist.end();++irs) {
3331 for (vector<Var *>::iterator irv = this->
vars.begin();
3332 irv != this->vars.end(); ) {
3335 if ((*irs)== (*irv)->fullpath) {
3336 if((*irv)->dims.size()!=1)
3337 throw3(
"COARDS coordinate variable",(*irv)->name,
"is not 1D");
3340 tempdimnamelist.erase(*irs);
3342 GMcvar->cfdimname = *irs;
3345 bool is_netcdf_dimension = Is_netCDF_Dimension(*irv);
3349 if (
true == is_netcdf_dimension)
3350 GMcvar->cvartype = CV_FILLINDEX;
3352 GMcvar->cvartype = CV_EXIST;
3353 GMcvar->product_type = product_type;
3354 this->cvars.push_back(GMcvar);
3356 irv = this->
vars.erase(irv);
3365 Update_M2DLatLon_Dimscale_CVs();
3368 for (set<string>::iterator irs = tempdimnamelist.begin();
3369 irs != tempdimnamelist.end();irs++) {
3371 Create_Missing_CV(GMcvar,*irs);
3372 this->cvars.push_back(GMcvar);
3378 for (set<string>::iterator irs = dimnamelist.begin();
3379 irs != dimnamelist.end();irs++) {
3380 cerr<<
"dimension name is "<<(*irs)<<endl;
3389 void GMFile::Update_M2DLatLon_Dimscale_CVs() {
3391 BESDEBUG(
"h5",
"Coming to Update_M2DLatLon_Dimscale_CVs()"<<endl);
3393 if(
false == Check_1DGeolocation_Dimscale()) {
3396 vector<GMCVar*> tempcvar_1dlat;
3397 vector<GMCVar*> tempcvar_1dlon;
3400 Obtain_1DLatLon_CVs(tempcvar_1dlat,tempcvar_1dlon);
3403 vector<Var*> tempcvar_2dlat;
3404 vector<Var*> tempcvar_2dlon;
3410 map<string,int> latlon2d_path_to_index;
3413 Obtain_2DLatLon_Vars(tempcvar_2dlat,tempcvar_2dlon,latlon2d_path_to_index);
3416 for(vector<GMCVar *>::iterator irv = tempcvar_1dlat.begin();irv != tempcvar_1dlat.end();++irv)
3417 cerr<<
"1-D lat variable full path is "<<(*irv)->fullpath <<endl;
3418 for(vector<GMCVar *>::iterator irv = tempcvar_1dlon.begin();irv != tempcvar_1dlon.end();++irv)
3419 cerr<<
"1-D lon variable full path is "<<(*irv)->fullpath <<endl;
3421 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv)
3422 cerr<<
"2-D lat variable full path is "<<(*irv)->fullpath <<endl;
3423 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv)
3424 cerr<<
"2-D lon variable full path is "<<(*irv)->fullpath <<endl;
3428 Obtain_2DLLVars_With_Dims_not_1DLLCVars(tempcvar_2dlat,tempcvar_2dlon,tempcvar_1dlat,tempcvar_1dlon,latlon2d_path_to_index);
3431 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv)
3432 cerr<<
"2-D Left lat variable full path is "<<(*irv)->fullpath <<endl;
3433 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv)
3434 cerr<<
"2-D Left lon variable full path is "<<(*irv)->fullpath <<endl;
3439 Obtain_2DLLCVar_Candidate(tempcvar_2dlat,tempcvar_2dlon,latlon2d_path_to_index);
3442 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv)
3443 cerr<<
"Final candidate 2-D Left lat variable full path is "<<(*irv)->fullpath <<endl;
3444 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv)
3445 cerr<<
"Final candidate 2-D Left lon variable full path is "<<(*irv)->fullpath <<endl;
3450 vector<int> var2d_index;
3451 for (map<string,int>::const_iterator it= latlon2d_path_to_index.begin();it!=latlon2d_path_to_index.end();++it)
3452 var2d_index.push_back(it->second);
3454 Remove_2DLLCVar_Final_Candidate_from_Vars(var2d_index);
3457 if(tempcvar_2dlat.size()>0)
3462 set<string>dim_names_2d_cvs;
3464 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv){
3468 dim_names_2d_cvs.insert(lat->cfdimname);
3469 lat->cvartype = CV_EXIST;
3470 lat->product_type = product_type;
3471 this->cvars.push_back(lat);
3473 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv){
3477 dim_names_2d_cvs.insert(lon->cfdimname);
3478 lon->cvartype = CV_EXIST;
3479 lon->product_type = product_type;
3480 this->cvars.push_back(lon);
3486 for(vector<GMCVar*>::iterator ircv= this->cvars.begin();ircv !=this->cvars.end();) {
3487 if(1 == (*ircv)->rank) {
3488 if(dim_names_2d_cvs.find((*ircv)->cfdimname)!=dim_names_2d_cvs.end()) {
3489 if(CV_FILLINDEX == (*ircv)->cvartype) {
3491 ircv = this->cvars.erase(ircv);
3493 else if(CV_EXIST == (*ircv)->cvartype) {
3496 Var *var =
new Var(*ircv);
3497 this->
vars.push_back(var);
3501 ircv = this->cvars.erase(ircv);
3505 if(CV_LAT_MISS == (*ircv)->cvartype)
3506 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_LAT_MISS");
3507 else if(CV_LON_MISS == (*ircv)->cvartype)
3508 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_LON_MISS");
3509 else if(CV_NONLATLON_MISS == (*ircv)->cvartype)
3510 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_NONLATLON_MISS");
3511 else if(CV_MODIFY == (*ircv)->cvartype)
3512 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_MODIFY");
3513 else if(CV_SPECIAL == (*ircv)->cvartype)
3514 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_SPECIAL");
3516 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_UNSUPPORTED");
3533 for(set<string>::iterator irs = grp_cv_paths.begin();irs != grp_cv_paths.end();++irs) {
3534 cerr<<
"group path is "<< (*irs)<<endl;
3541 cerr<<
"File name is "<< this->path <<endl;
3542 cerr<<
"CV names are the following "<<endl;
3543 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ++i)
3544 cerr<<(*i)->fullpath <<endl;
3549 release_standalone_GMCVar_vector(tempcvar_1dlat);
3550 release_standalone_GMCVar_vector(tempcvar_1dlon);
3551 release_standalone_var_vector(tempcvar_2dlat);
3552 release_standalone_var_vector(tempcvar_2dlon);
3555 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ++i)
3556 cerr<<(*i)->fullpath <<endl;
3563 bool GMFile::Check_1DGeolocation_Dimscale() {
3565 BESDEBUG(
"h5",
"Coming to Check_1DGeolocation_Dimscale()"<<endl);
3566 bool has_only_1d_geolocation_cv =
false;
3567 bool has_1d_lat_cv_flag =
false;
3568 bool has_1d_lon_cv_flag =
false;
3571 hsize_t lat_size = 0;
3574 hsize_t lon_size = 0;
3577 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
3578 ircv != this->cvars.end(); ++ircv) {
3580 if((*ircv)->cvartype == CV_EXIST) {
3581 string attr_name =
"units";
3582 string lat_unit_value =
"degrees_north";
3583 string lon_unit_value =
"degrees_east";
3585 for(vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
3586 ira != (*ircv)->attrs.end();ira++) {
3588 if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lat_unit_value)) {
3589 lat_size = (*ircv)->getDimensions()[0]->size;
3590 lat_dimname = (*ircv)->getDimensions()[0]->name;
3591 has_1d_lat_cv_flag =
true;
3594 else if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lon_unit_value)){
3595 lon_size = (*ircv)->getDimensions()[0]->size;
3596 lon_dimname = (*ircv)->getDimensions()[0]->name;
3597 has_1d_lon_cv_flag =
true;
3606 if(
true == has_1d_lat_cv_flag ) {
3608 if(
true == has_1d_lon_cv_flag) {
3611 if(0 == this->
groups.size()) {
3615 if(lat_size == lon_size) {
3616 bool var_has_latdim =
false;
3617 bool var_has_londim =
false;
3618 for (vector<Var *>::iterator irv = this->
vars.begin();
3619 irv != this->vars.end(); ++irv) {
3620 if((*irv)->rank >= 2) {
3621 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
3622 ird !=(*irv)->dims.end();++ird) {
3623 if((*ird)->name == lat_dimname)
3624 var_has_latdim =
true;
3625 else if((*ird)->name == lon_dimname)
3626 var_has_londim =
true;
3628 if(
true == var_has_latdim &&
true == var_has_londim) {
3629 has_only_1d_geolocation_cv =
true;
3633 var_has_latdim =
false;
3634 var_has_londim =
false;
3640 has_only_1d_geolocation_cv =
true;
3644 bool has_2d_latname_flag =
false;
3645 bool has_2d_lonname_flag =
false;
3646 for (vector<Var *>::iterator irv = this->
vars.begin();
3647 irv != this->vars.end(); ++irv) {
3648 if((*irv)->rank == 2) {
3651 if(
true == Is_geolatlon((*irv)->name,
true))
3652 has_2d_latname_flag =
true;
3655 else if(
true == Is_geolatlon((*irv)->name,
false))
3656 has_2d_lonname_flag =
true;
3658 if((
true == has_2d_latname_flag) && (
true == has_2d_lonname_flag))
3663 if(has_2d_latname_flag !=
true || has_2d_lonname_flag !=
true) {
3666 has_2d_latname_flag =
false;
3667 has_2d_lonname_flag =
false;
3669 for (vector<Var *>::iterator irv = this->
vars.begin();
3670 irv != this->vars.end(); ++irv) {
3671 if((*irv)->rank == 2) {
3672 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
3673 ira != (*irv)->attrs.end(); ++ira) {
3675 if (
false == has_2d_latname_flag) {
3678 has_2d_latname_flag = has_latlon_cf_units((*ira),(*irv)->fullpath,
true);
3679 if(
true == has_2d_latname_flag)
3681 else if(
false == has_2d_lonname_flag) {
3684 has_2d_lonname_flag = has_latlon_cf_units((*ira),(*irv)->fullpath,
false);
3685 if(
true == has_2d_lonname_flag)
3689 else if(
false == has_2d_lonname_flag) {
3693 has_2d_lonname_flag = has_latlon_cf_units((*ira),(*irv)->fullpath,
false);
3694 if(
true == has_2d_lonname_flag)
3698 if(
true == has_2d_latname_flag &&
true == has_2d_lonname_flag)
3705 if(has_2d_latname_flag !=
true || has_2d_lonname_flag !=
true)
3706 has_only_1d_geolocation_cv =
true;
3711 has_only_1d_geolocation_cv =
true;
3717 if(has_only_1d_geolocation_cv ==
true)
3718 cerr <<
"has only 1D lat/lon CVs. "<<endl;
3720 cerr<<
"Possibly has 2D lat/lon CVs. "<<endl;
3723 return has_only_1d_geolocation_cv;
3729 void GMFile::Obtain_1DLatLon_CVs(vector<GMCVar*> &cvar_1dlat,vector<GMCVar*> &cvar_1dlon) {
3731 BESDEBUG(
"h5",
"Coming to Obtain_1DLatLon_CVs()"<<endl);
3732 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
3733 ircv != this->cvars.end(); ++ircv) {
3735 if((*ircv)->cvartype == CV_EXIST) {
3737 string attr_name =
"units";
3738 string lat_unit_value =
"degrees_north";
3739 string lon_unit_value =
"degrees_east";
3741 for(vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
3742 ira != (*ircv)->attrs.end();ira++) {
3745 if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lat_unit_value)) {
3748 lat->cvartype = (*ircv)->cvartype;
3749 lat->product_type = (*ircv)->product_type;
3750 cvar_1dlat.push_back(lat);
3753 else if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lon_unit_value)){
3756 lon->cvartype = (*ircv)->cvartype;
3757 lon->product_type = (*ircv)->product_type;
3758 cvar_1dlon.push_back(lon);
3769 void GMFile::Obtain_2DLatLon_Vars(vector<Var*> &var_2dlat,vector<Var*> &var_2dlon,map<string,int> & latlon2d_path_to_index) {
3771 BESDEBUG(
"h5",
"Coming to Obtain_2DLatLon_Vars()"<<endl);
3772 for (vector<Var *>::iterator irv = this->
vars.begin();
3773 irv != this->vars.end(); ++irv) {
3774 if((*irv)->rank == 2) {
3777 if(
true == Is_geolatlon((*irv)->name,
true)) {
3778 Var *lat =
new Var(*irv);
3779 var_2dlat.push_back(lat);
3780 latlon2d_path_to_index[(*irv)->fullpath]= distance(this->
vars.begin(),irv);
3785 bool has_2dlat =
false;
3786 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
3787 ira != (*irv)->attrs.end(); ++ira) {
3790 if(
true == has_latlon_cf_units((*ira),(*irv)->fullpath,
true)) {
3791 Var *lat =
new Var(*irv);
3792 var_2dlat.push_back(lat);
3793 latlon2d_path_to_index[(*irv)->fullpath] = distance(this->
vars.begin(),irv);
3799 if(
true == has_2dlat)
3804 if(
true == Is_geolatlon((*irv)->name,
false)) {
3805 Var *lon =
new Var(*irv);
3806 latlon2d_path_to_index[(*irv)->fullpath] = distance(this->
vars.begin(),irv);
3807 var_2dlon.push_back(lon);
3810 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
3811 ira != (*irv)->attrs.end(); ++ira) {
3814 if(
true == has_latlon_cf_units((*ira),(*irv)->fullpath,
false)) {
3815 Var *lon =
new Var(*irv);
3816 latlon2d_path_to_index[(*irv)->fullpath] = distance(this->
vars.begin(),irv);
3817 var_2dlon.push_back(lon);
3828 void GMFile::Obtain_2DLLVars_With_Dims_not_1DLLCVars(vector<Var*> &var_2dlat,
3829 vector<Var*> &var_2dlon,
3830 vector<GMCVar*> &cvar_1dlat,
3831 vector<GMCVar*> &cvar_1dlon,
3832 map<string,int> &latlon2d_path_to_index) {
3834 BESDEBUG(
"h5",
"Coming to Obtain_2DLLVars_With_Dims_not_1DLLCVars()"<<endl);
3836 for(vector<Var *>::iterator irv = var_2dlat.begin();irv != var_2dlat.end();) {
3837 bool remove_2dlat =
false;
3838 for(vector<GMCVar *>::iterator ircv = cvar_1dlat.begin();ircv != cvar_1dlat.end();++ircv) {
3839 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
3840 ird!=(*irv)->dims.end(); ++ird) {
3841 if((*ird)->name == (*ircv)->getDimensions()[0]->name &&
3842 (*ird)->size == (*ircv)->getDimensions()[0]->size) {
3843 latlon2d_path_to_index.erase((*irv)->fullpath);
3845 irv = var_2dlat.erase(irv);
3846 remove_2dlat =
true;
3850 if(
true == remove_2dlat)
3854 if(
false == remove_2dlat)
3859 for(vector<Var *>::iterator irv = var_2dlon.begin();irv != var_2dlon.end();) {
3860 bool remove_2dlon =
false;
3861 for(vector<GMCVar *>::iterator ircv = cvar_1dlon.begin();ircv != cvar_1dlon.end();++ircv) {
3862 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
3863 ird!=(*irv)->dims.end(); ++ird) {
3864 if((*ird)->name == (*ircv)->getDimensions()[0]->name &&
3865 (*ird)->size == (*ircv)->getDimensions()[0]->size) {
3866 latlon2d_path_to_index.erase((*irv)->fullpath);
3868 irv = var_2dlon.erase(irv);
3869 remove_2dlon =
true;
3873 if(
true == remove_2dlon)
3877 if(
false == remove_2dlon)
3884 void GMFile::Obtain_2DLLCVar_Candidate(vector<Var*> &var_2dlat,
3885 vector<Var*> &var_2dlon,
3886 map<string,int>& latlon2d_path_to_index) {
3887 BESDEBUG(
"h5",
"Coming to Obtain_2DLLCVar_Candidate()"<<endl);
3890 vector<string> lon2d_group_paths;
3892 for(vector<Var *>::iterator irv_2dlat = var_2dlat.begin();irv_2dlat !=var_2dlat.end();) {
3893 for(vector<Var *>::iterator irv_2dlon = var_2dlon.begin();irv_2dlon != var_2dlon.end();++irv_2dlon) {
3894 if(((*irv_2dlat)->getDimensions()[0]->name == (*irv_2dlon)->getDimensions()[0]->name) &&
3895 ((*irv_2dlat)->getDimensions()[0]->size == (*irv_2dlon)->getDimensions()[0]->size) &&
3896 ((*irv_2dlat)->getDimensions()[1]->name == (*irv_2dlon)->getDimensions()[1]->name) &&
3897 ((*irv_2dlat)->getDimensions()[1]->size == (*irv_2dlon)->getDimensions()[1]->size))
3898 lon2d_group_paths.push_back(HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlon)->fullpath));
3902 if(0 == lon2d_group_paths.size()) {
3903 latlon2d_path_to_index.erase((*irv_2dlat)->fullpath);
3905 irv_2dlat = var_2dlat.erase(irv_2dlat);
3909 string lat2d_group_path = HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlat)->fullpath);
3912 short lon2d_has_lat2d_group_path_flag = 0;
3913 for(vector<string>::iterator ivs = lon2d_group_paths.begin();ivs!=lon2d_group_paths.end();++ivs) {
3914 if((*ivs)==lat2d_group_path)
3915 lon2d_has_lat2d_group_path_flag++;
3919 if(0 == lon2d_has_lat2d_group_path_flag) {
3920 latlon2d_path_to_index.erase((*irv_2dlat)->fullpath);
3922 irv_2dlat = var_2dlat.erase(irv_2dlat);
3925 else if (1== lon2d_has_lat2d_group_path_flag) {
3932 grp_cv_paths.insert(lat2d_group_path);
3933 latlon2d_path_to_index.erase((*irv_2dlat)->fullpath);
3935 irv_2dlat = var_2dlat.erase(irv_2dlat);
3940 lon2d_group_paths.clear();
3944 for(vector<Var *>::iterator irv_2dlat = var_2dlat.begin();irv_2dlat !=var_2dlat.end();++irv_2dlat)
3945 cerr<<
"2 left 2-D lat variable full path is: "<<(*irv_2dlat)->fullpath <<endl;
3951 vector<string> lat2d_group_paths;
3954 for(vector<Var *>::iterator irv_2dlon = var_2dlon.begin();irv_2dlon !=var_2dlon.end();) {
3955 for(vector<Var *>::iterator irv_2dlat = var_2dlat.begin();irv_2dlat != var_2dlat.end();++irv_2dlat) {
3956 if(((*irv_2dlat)->getDimensions()[0]->name == (*irv_2dlon)->getDimensions()[0]->name) &&
3957 ((*irv_2dlat)->getDimensions()[0]->size == (*irv_2dlon)->getDimensions()[0]->size) &&
3958 ((*irv_2dlat)->getDimensions()[1]->name == (*irv_2dlon)->getDimensions()[1]->name) &&
3959 ((*irv_2dlat)->getDimensions()[1]->size == (*irv_2dlon)->getDimensions()[1]->size))
3960 lat2d_group_paths.push_back(HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlat)->fullpath));
3964 if(0 == lat2d_group_paths.size()) {
3965 latlon2d_path_to_index.erase((*irv_2dlon)->fullpath);
3967 irv_2dlon = var_2dlon.erase(irv_2dlon);
3970 string lon2d_group_path = HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlon)->fullpath);
3973 short lat2d_has_lon2d_group_path_flag = 0;
3974 for(vector<string>::iterator ivs = lat2d_group_paths.begin();ivs!=lat2d_group_paths.end();++ivs) {
3975 if((*ivs)==lon2d_group_path)
3976 lat2d_has_lon2d_group_path_flag++;
3980 if(0 == lat2d_has_lon2d_group_path_flag) {
3981 latlon2d_path_to_index.erase((*irv_2dlon)->fullpath);
3983 irv_2dlon = var_2dlon.erase(irv_2dlon);
3986 else if (1== lat2d_has_lon2d_group_path_flag) {
3993 grp_cv_paths.insert(lon2d_group_path);
3994 latlon2d_path_to_index.erase((*irv_2dlon)->fullpath);
3996 irv_2dlon = var_2dlon.erase(irv_2dlon);
4000 lat2d_group_paths.clear();
4003 for(vector<Var*>::iterator itv = var_2dlat.begin(); itv!= var_2dlat.end();++itv) {
4004 cerr<<
"Before unique, 2-D CV latitude name is "<<(*itv)->fullpath <<endl;
4006 for(vector<Var*>::iterator itv = var_2dlon.begin(); itv!= var_2dlon.end();++itv) {
4007 cerr<<
"Before unique, 2-D CV longitude name is "<<(*itv)->fullpath <<endl;
4012 Obtain_unique_2dCV(var_2dlat,latlon2d_path_to_index);
4013 Obtain_unique_2dCV(var_2dlon,latlon2d_path_to_index);
4015 for(vector<Var*>::iterator itv = var_2dlat.begin(); itv!= var_2dlat.end();++itv) {
4016 cerr<<
"2-D CV latitude name is "<<(*itv)->fullpath <<endl;
4018 for(vector<Var*>::iterator itv = var_2dlon.begin(); itv!= var_2dlon.end();++itv) {
4019 cerr<<
"2-D CV longitude name is "<<(*itv)->fullpath <<endl;
4024 if(var_2dlat.size() != var_2dlon.size()) {
4025 throw1(
"Error in generating 2-D lat/lon CVs. The size of 2d-lat should be the same as that of 2d-lon.");
4031 void GMFile::Obtain_unique_2dCV(vector<Var*> &var_ll,map<string,int>&latlon2d_path_to_index){
4033 BESDEBUG(
"h5",
"Coming to Obtain_unique_2dCV()"<<endl);
4034 vector<bool> var_share_dims(var_ll.size(),
false);
4036 for(
unsigned int i = 0; i <var_ll.size();i++) {
4039 string var_ll_i_path = HDF5CFUtil::obtain_string_before_lastslash(var_ll[i]->fullpath);
4042 for(
unsigned int j = i+1; j<var_ll.size();j++) {
4043 if((var_ll[i]->getDimensions()[0]->name == var_ll[j]->getDimensions()[0]->name)
4044 ||(var_ll[i]->getDimensions()[0]->name == var_ll[j]->getDimensions()[1]->name)
4045 ||(var_ll[i]->getDimensions()[1]->name == var_ll[j]->getDimensions()[0]->name)
4046 ||(var_ll[i]->getDimensions()[1]->name == var_ll[j]->getDimensions()[1]->name)){
4047 string var_ll_j_path = HDF5CFUtil::obtain_string_before_lastslash(var_ll[j]->fullpath);
4054 if(var_ll_i_path.size() > var_ll_j_path.size()) {
4058 if(var_ll_i_path.compare(0,var_ll_j_path.size(),var_ll_j_path)==0) {
4059 var_share_dims[i] =
true;
4060 grp_cv_paths.insert(var_ll_i_path);
4063 var_share_dims[i] =
true;
4064 var_share_dims[j] =
true;
4066 grp_cv_paths.insert(var_ll_i_path);
4067 grp_cv_paths.insert(var_ll_j_path);
4070 else if (var_ll_i_path.size() == var_ll_j_path.size()) {
4071 var_share_dims[i] =
true;
4072 var_share_dims[j] =
true;
4073 if(var_ll_i_path == var_ll_j_path)
4074 grp_cv_paths.insert(var_ll_i_path);
4076 grp_cv_paths.insert(var_ll_i_path);
4077 grp_cv_paths.insert(var_ll_j_path);
4083 if(var_ll_j_path.compare(0,var_ll_i_path.size(),var_ll_i_path)==0) {
4084 var_share_dims[j] =
true;
4085 grp_cv_paths.insert(var_ll_j_path);
4088 var_share_dims[i] =
true;
4089 var_share_dims[j] =
true;
4091 grp_cv_paths.insert(var_ll_i_path);
4092 grp_cv_paths.insert(var_ll_j_path);
4102 for(vector<Var*>::iterator itv = var_ll.begin(); itv!= var_ll.end();) {
4103 if(
true == var_share_dims[var_index]) {
4104 latlon2d_path_to_index.erase((*itv)->fullpath);
4106 itv = var_ll.erase(itv);
4117 void GMFile::Remove_2DLLCVar_Final_Candidate_from_Vars(vector<int> &var2d_index) {
4119 BESDEBUG(
"h5",
"Coming to Remove_2DLLCVar_Final_Candidate_from_Vars()"<<endl);
4121 sort(var2d_index.begin(),var2d_index.end());
4122 vector<Var *>::iterator it = this->
vars.begin();
4128 for (
unsigned int i = 0; i <var2d_index.size();i++) {
4130 advance(it,var2d_index[i]);
4132 advance(it,var2d_index[i]-var2d_index[i-1]-1);
4134 if(it == this->
vars.end())
4135 throw1(
"Out of range to obtain 2D lat/lon variables");
4138 it = this->
vars.erase(it);
4146 bool GMFile::Check_Var_2D_CVars(
Var *var) {
4148 BESDEBUG(
"h5",
"Coming to Check_Var_2D_CVars()"<<endl);
4149 bool ret_value =
true;
4150 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4151 ircv != this->cvars.end(); ++ircv) {
4152 if((*ircv)->rank==2) {
4153 short first_dim_index = 0;
4154 short first_dim_times = 0;
4155 short second_dim_index = 0;
4156 short second_dim_times = 0;
4157 for (vector<Dimension *>::iterator ird = var->dims.begin();
4158 ird != var->dims.end(); ++ird) {
4159 if((*ird)->name == ((*ircv)->getDimensions()[0])->name) {
4160 first_dim_index = distance(var->dims.begin(),ird);
4163 else if((*ird)->name == ((*ircv)->getDimensions()[1])->name) {
4164 second_dim_index = distance(var->dims.begin(),ird);
4170 if(first_dim_times == 1 && second_dim_times == 1) {
4171 if(first_dim_index < second_dim_index) {
4184 bool GMFile::Flatten_VarPath_In_Coordinates_Attr(
Var *var) {
4186 BESDEBUG(
"h5",
"Coming to Flatten_VarPath_In_Coordinates_Attr()"<<endl);
4187 string co_attrname =
"coordinates";
4188 bool has_coor_attr =
false;
4189 string orig_coor_value;
4190 string flatten_coor_value;
4194 for (vector<Attribute *>:: iterator ira =var->attrs.begin(); ira !=var->attrs.end();) {
4198 if((*ira)->name == co_attrname) {
4199 Retrieve_H5_Attr_Value((*ira),var->fullpath);
4200 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
4201 orig_coor_value = orig_attr_value;
4202 has_coor_attr =
true;
4204 ira = var->attrs.erase(ira);
4211 if(
true == has_coor_attr) {
4214 size_t ele_start_pos = 0;
4215 size_t cur_pos = orig_coor_value.find_first_of(sc);
4216 while(cur_pos !=string::npos) {
4217 string tempstr = orig_coor_value.substr(ele_start_pos,cur_pos-ele_start_pos);
4218 tempstr = get_CF_string(tempstr);
4219 flatten_coor_value += tempstr + sc;
4220 ele_start_pos = cur_pos+1;
4221 cur_pos = orig_coor_value.find_first_of(sc,cur_pos+1);
4224 if(ele_start_pos == 0)
4225 flatten_coor_value = get_CF_string(orig_coor_value);
4227 flatten_coor_value += get_CF_string(orig_coor_value.substr(ele_start_pos));
4231 Add_Str_Attr(attr,co_attrname,flatten_coor_value);
4232 var->attrs.push_back(attr);
4233 var->coord_attr_add_path =
false;
4243 bool GMFile::Flatten_VarPath_In_Coordinates_Attr_EOS5(
Var *var) {
4245 BESDEBUG(
"h5",
"Coming to Flatten_VarPath_In_Coordinates_Attr_EOS5()"<<endl);
4246 string co_attrname =
"coordinates";
4247 bool has_coor_attr =
false;
4248 string orig_coor_value;
4249 string flatten_coor_value;
4253 for (vector<Attribute *>:: iterator ira =var->attrs.begin(); ira !=var->attrs.end();) {
4257 if((*ira)->name == co_attrname) {
4258 Retrieve_H5_Attr_Value((*ira),var->fullpath);
4260 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
4261 orig_coor_value = orig_attr_value;
4262 has_coor_attr =
true;
4264 ira = var->attrs.erase(ira);
4271 if(
true == has_coor_attr) {
4275 size_t ele_start_pos = 0;
4277 size_t cur_pos = orig_coor_value.find_first_of(sc);
4278 while(cur_pos !=string::npos) {
4279 string tempstr = orig_coor_value.substr(ele_start_pos,cur_pos-ele_start_pos);
4282 tempstr = get_CF_string(tempstr);
4283 flatten_coor_value += tempstr + sc;
4284 ele_start_pos = cur_pos+1;
4285 cur_pos = orig_coor_value.find_first_of(sc,cur_pos+1);
4288 if(ele_start_pos == 0) {
4291 flatten_coor_value = get_CF_string(tempstr);
4294 flatten_coor_value += get_CF_string(orig_coor_value.substr(ele_start_pos));
4298 Add_Str_Attr(attr,co_attrname,flatten_coor_value);
4299 var->attrs.push_back(attr);
4311 bool GMFile::Check_2DLatLon_Dimscale(
string & latname,
string &lonname) {
4329 bool latlon_2d_cv_check1 =
false;
4332 latlon_2d_cv_check1 =
true;
4335 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4336 ircv != this->cvars.end(); ++ircv) {
4337 if((*ircv)->cvartype == CV_FILLINDEX){
4338 latlon_2d_cv_check1 =
true;
4344 bool latlon_2d_cv_check2 =
true;
4347 if(
true == latlon_2d_cv_check1) {
4348 BESDEBUG(
"h5",
"Coming to check if having 2d latlon coordinates for a netCDF-4 like product. "<<endl);
4351 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4352 ircv != this->cvars.end(); ++ircv) {
4353 if((*ircv)->cvartype == CV_EXIST) {
4354 for(vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
4355 ira != (*ircv)->attrs.end();ira++) {
4356 string attr_name =
"units";
4357 string lat_unit_value =
"degrees_north";
4358 string lon_unit_value =
"degrees_east";
4361 if((
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lat_unit_value)) ||
4362 (
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lon_unit_value))) {
4363 latlon_2d_cv_check2=
false;
4369 if(
false == latlon_2d_cv_check2)
4374 bool latlon_2d_cv_check3 =
true;
4377 if(
true == latlon_2d_cv_check1 &&
true == latlon_2d_cv_check2) {
4379 short latlon_flag = 0;
4380 short LatLon_flag = 0;
4381 short latilong_flag = 0;
4383 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4384 ircv != this->cvars.end(); ++ircv) {
4385 if((*ircv)->cvartype == CV_EXIST) {
4386 if((*ircv)->name ==
"lat")
4388 else if((*ircv)->name ==
"lon")
4390 else if((*ircv)->name ==
"latitude")
4392 else if((*ircv)->name ==
"longitude")
4394 else if((*ircv)->name ==
"Latitude")
4396 else if((*ircv)->name ==
"Longitude")
4401 if((2== latlon_flag) || (2 == latilong_flag) || (2 == LatLon_flag ))
4402 latlon_2d_cv_check3 =
false;
4405 bool latlon_2d =
false;
4406 short latlon_flag = 0;
4407 string latdim1,latdim2,londim1,londim2;
4409 short LatLon_flag = 0;
4410 string Latdim1,Latdim2,Londim1,Londim2;
4412 short latilong_flag = 0;
4413 string latidim1,latidim2,longdim1,longdim2;
4420 if(
true == latlon_2d_cv_check1 &&
true == latlon_2d_cv_check2 &&
true == latlon_2d_cv_check3) {
4422 for (vector<Var *>::iterator irv = this->
vars.begin();
4423 irv != this->vars.end(); ++irv) {
4426 if((*irv)->rank == 2) {
4427 if((*irv)->name ==
"lat") {
4429 latdim1 = (*irv)->getDimensions()[0]->name;
4430 latdim2 = (*irv)->getDimensions()[1]->name;
4433 else if((*irv)->name ==
"lon") {
4435 londim1 = (*irv)->getDimensions()[0]->name;
4436 londim2 = (*irv)->getDimensions()[1]->name;
4438 else if((*irv)->name ==
"latitude"){
4440 latidim1 = (*irv)->getDimensions()[0]->name;
4441 latidim2 = (*irv)->getDimensions()[1]->name;
4443 else if((*irv)->name ==
"longitude"){
4445 longdim1 = (*irv)->getDimensions()[0]->name;
4446 longdim2 = (*irv)->getDimensions()[1]->name;
4449 else if((*irv)->name ==
"Latitude"){
4451 Latdim1 = (*irv)->getDimensions()[0]->name;
4452 Latdim2 = (*irv)->getDimensions()[1]->name;
4455 else if((*irv)->name ==
"Longitude"){
4457 Londim1 = (*irv)->getDimensions()[0]->name;
4458 Londim2 = (*irv)->getDimensions()[1]->name;
4468 if(2 == latlon_flag) {
4469 if((2 == latilong_flag) || ( 2 == LatLon_flag))
4471 else if((latdim1 == londim1) && (latdim2 == londim2)) {
4477 else if ( 2 == latilong_flag) {
4478 if( 2 == LatLon_flag)
4480 else if ((latidim1 == longdim1) ||(latidim2 == longdim2)) {
4481 latname =
"latitude";
4482 lonname =
"longitude";
4486 else if (2 == LatLon_flag){
4487 if ((Latdim1 == Londim1) ||(Latdim2 == Londim2)) {
4488 latname =
"Latitude";
4489 lonname =
"Longitude";
4500 void GMFile::Update_2DLatLon_Dimscale_CV(
const string &latname,
const string &lonname) {
4505 for (vector<Var *>::iterator irv = this->
vars.begin();
4506 irv != this->vars.end(); ++irv) {
4508 if((*irv)->rank == 2) {
4511 if((*irv)->name == latname) {
4514 string latdim0 = (*irv)->getDimensions()[0]->name;
4518 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ) {
4519 if((*i)->cfdimname == latdim0) {
4520 if(CV_FILLINDEX == (*i)->cvartype) {
4522 i = this->cvars.erase(i);
4524 else if(CV_EXIST == (*i)->cvartype) {
4527 this->
vars.push_back(var);
4530 i = this->cvars.erase(i);
4534 if(CV_LAT_MISS == (*i)->cvartype)
4535 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_LAT_MISS");
4536 else if(CV_LON_MISS == (*i)->cvartype)
4537 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_LON_MISS");
4538 else if(CV_NONLATLON_MISS == (*i)->cvartype)
4539 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_NONLATLON_MISS");
4540 else if(CV_MODIFY == (*i)->cvartype)
4541 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_MODIFY");
4542 else if(CV_SPECIAL == (*i)->cvartype)
4543 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_SPECIAL");
4545 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_UNSUPPORTED");
4554 GMcvar->cfdimname = latdim0;
4555 GMcvar->cvartype = CV_EXIST;
4556 GMcvar->product_type = product_type;
4557 this->cvars.push_back(GMcvar);
4559 this->
vars.erase(irv);
4566 for (vector<Var *>::iterator irv = this->
vars.begin();
4567 irv != this->vars.end(); ++irv) {
4569 if((*irv)->rank == 2) {
4572 if((*irv)->name == lonname) {
4575 string londim0 = (*irv)->getDimensions()[1]->name;
4578 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ) {
4580 if((*i)->cfdimname == londim0) {
4581 if(CV_FILLINDEX == (*i)->cvartype) {
4583 i= this->cvars.erase(i);
4585 else if(CV_EXIST == (*i)->cvartype) {
4588 this->
vars.push_back(var);
4591 i = this->cvars.erase(i);
4594 if(CV_LAT_MISS == (*i)->cvartype)
4595 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_LAT_MISS");
4596 else if(CV_LON_MISS == (*i)->cvartype)
4597 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_LON_MISS");
4598 else if(CV_NONLATLON_MISS == (*i)->cvartype)
4599 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_NONLATLON_MISS");
4600 else if(CV_MODIFY == (*i)->cvartype)
4601 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_MODIFY");
4602 else if(CV_SPECIAL == (*i)->cvartype)
4603 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_SPECIAL");
4605 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_UNSUPPORTED");
4614 GMcvar->cfdimname = londim0;
4615 GMcvar->cvartype = CV_EXIST;
4616 GMcvar->product_type = product_type;
4617 this->cvars.push_back(GMcvar);
4619 this->
vars.erase(irv);
4628 void GMFile::Handle_CVar_LatLon1D_General_Product() {
4630 BESDEBUG(
"h5",
"Coming to Handle_CVar_LatLon1D_General_Product()"<<endl);
4631 this->iscoard =
true;
4632 Handle_CVar_LatLon_General_Product();
4637 void GMFile::Handle_CVar_LatLon2D_General_Product() {
4639 BESDEBUG(
"h5",
"Coming to Handle_CVar_LatLon2D_General_Product()"<<endl);
4640 Handle_CVar_LatLon_General_Product();
4646 void GMFile::Handle_CVar_LatLon_General_Product() {
4648 BESDEBUG(
"h5",
"Coming to Handle_CVar_LatLon_General_Product()"<<endl);
4649 if((GENERAL_LATLON2D != this->gproduct_pattern)
4650 && GENERAL_LATLON1D != this->gproduct_pattern)
4651 throw1(
"This function only supports latlon 1D or latlon 2D general products");
4653 pair<set<string>::iterator,
bool> setret;
4654 set<string>tempdimnamelist = dimnamelist;
4656 for (vector<Var *>::iterator irv = this->
vars.begin();
4657 irv != this->vars.end(); ++irv) {
4660 if (gp_latname== (*irv)->name) {
4664 tempdimnamelist.erase(((*irv)->dims[0])->name);
4666 GMcvar->cfdimname = ((*irv)->dims[0])->name;
4667 GMcvar->cvartype = CV_EXIST;
4668 GMcvar->product_type = product_type;
4669 this->cvars.push_back(GMcvar);
4671 this->
vars.erase(irv);
4676 for (vector<Var *>::iterator irv = this->
vars.begin();
4677 irv != this->
vars.end(); ++irv) {
4680 if (gp_lonname== (*irv)->name) {
4686 if(GENERAL_LATLON2D == this->gproduct_pattern)
4687 londimname = ((*irv)->dims[1])->name;
4689 londimname = ((*irv)->dims[0])->name;
4691 tempdimnamelist.erase(londimname);
4693 GMcvar->cfdimname = londimname;
4694 GMcvar->cvartype = CV_EXIST;
4695 GMcvar->product_type = product_type;
4696 this->cvars.push_back(GMcvar);
4698 this->
vars.erase(irv);
4705 for (set<string>::iterator irs = tempdimnamelist.begin();
4706 irs != tempdimnamelist.end();irs++) {
4708 Create_Missing_CV(GMcvar,*irs);
4709 this->cvars.push_back(GMcvar);
4715 void GMFile::Handle_CVar_OBPG_L3() {
4717 BESDEBUG(
"h5",
"Coming to Handle_CVar_OBPG_L3()"<<endl);
4718 if (GENERAL_DIMSCALE == this->gproduct_pattern)
4719 Handle_CVar_Dimscale_General_Product();
4722 for (vector<Var *>::iterator irv = this->
vars.begin();
4723 irv != this->vars.end(); ++irv) {
4730 if((*irv)->rank == 2) {
4732 if(((*irv)->fullpath.find(
"/geophsical_data") == 0) || ((*irv)->dtype == H5FLOAT32)) {
4734 size_t lat_size = (*irv)->getDimensions()[0]->size;
4735 string lat_name = (*irv)->getDimensions()[0]->name;
4736 size_t lon_size = (*irv)->getDimensions()[1]->size;
4737 string lon_name = (*irv)->getDimensions()[1]->name;
4738 size_t temp_size = 0;
4740 H5DataType ll_dtype = (*irv)->dtype;
4743 if(lat_size >lon_size) {
4744 temp_size = lon_size;
4745 temp_name = lon_name;
4746 lon_size = lat_size;
4747 lon_name = lat_name;
4748 lat_size = temp_size;
4749 lat_name = temp_name;
4751 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4752 ircv != this->cvars.end(); ++ircv) {
4753 if((*ircv)->cvartype == CV_FILLINDEX) {
4754 if((*ircv)->getDimensions()[0]->size == lat_size &&
4755 (*ircv)->getDimensions()[0]->name == lat_name) {
4756 (*ircv)->cvartype = CV_LAT_MISS;
4757 (*ircv)->dtype = ll_dtype;
4758 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
4759 ira != (*ircv)->attrs.end(); ++ira) {
4760 if ((*ira)->name ==
"NAME") {
4762 (*ircv)->attrs.erase(ira);
4767 else if((*ircv)->getDimensions()[0]->size == lon_size &&
4768 (*ircv)->getDimensions()[0]->name == lon_name) {
4769 (*ircv)->cvartype = CV_LON_MISS;
4770 (*ircv)->dtype = ll_dtype;
4771 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
4772 ira != (*ircv)->attrs.end(); ++ira) {
4773 if ((*ira)->name ==
"NAME") {
4775 (*ircv)->attrs.erase(ira);
4794 BESDEBUG(
"h5",
"Coming to Handle_SpVar()"<<endl);
4795 if (ACOS_L2S_OR_OCO2_L1B == product_type)
4796 Handle_SpVar_ACOS_OCO2();
4797 else if(GPM_L1 == product_type) {
4800 for (vector<Var *>::iterator irv = this->
vars.begin();
4801 irv != this->vars.end(); ++irv) {
4802 if((*irv)->name==
"AlgorithmRuntimeInfo") {
4804 this->
vars.erase(irv);
4811 else if(GPMM_L3 == product_type || GPMS_L3 == product_type || GPM_L3_New==product_type) {
4813 for (vector<Var *>::iterator irv = this->
vars.begin();
4814 irv != this->vars.end(); ) {
4815 if((*irv)->name==
"InputFileNames") {
4817 irv = this->
vars.erase(irv);
4819 else if((*irv)->name==
"InputAlgorithmVersions") {
4821 irv = this->
vars.erase(irv);
4823 else if((*irv)->name==
"InputGenerationDateTimes") {
4825 irv = this->
vars.erase(irv);
4838 void GMFile::Handle_SpVar_ACOS_OCO2() {
4840 BESDEBUG(
"h5",
"Coming to Handle_SpVar_ACOS_OCO2()"<<endl);
4843 for (vector<Var *>::iterator irv = this->
vars.begin();
4844 irv != this->vars.end(); ) {
4845 if (H5INT64 == (*irv)->getType()) {
4849 spvar->name = (*irv)->name +
"_Time";
4850 spvar->newname = (*irv)->newname+
"_Time";
4851 spvar->dtype = H5INT32;
4852 spvar->otype = (*irv)->getType();
4856 spvar->numofdbits = 6;
4857 this->spvars.push_back(spvar);
4861 spvar2->name = (*irv)->name +
"_Date";
4862 spvar2->newname = (*irv)->newname+
"_Date";
4863 spvar2->dtype = H5INT32;
4864 spvar2->otype = (*irv)->getType();
4868 spvar2->numofdbits = 8;
4869 this->spvars.push_back(spvar2);
4872 irv = this->
vars.erase(irv);
4884 BESDEBUG(
"h5",
"Coming to Adjust_Obj_Name()"<<endl);
4885 if(Mea_Ozone == product_type)
4886 Adjust_Mea_Ozone_Obj_Name();
4888 if(GPMS_L3 == product_type || GPMM_L3 == product_type)
4889 Adjust_GPM_L3_Obj_Name();
4893 for (vector<Var*>::iterator irv2 = this->
vars.begin();
4894 irv2 != this->vars.end(); irv2++) {
4895 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
4896 ird !=(*irv2)->dims.end(); ird++) {
4897 cerr<<
"Dimension name afet Adjust_Obj_Name "<<(*ird)->newname <<endl;
4905 void GMFile:: Adjust_GPM_L3_Obj_Name() {
4907 BESDEBUG(
"h5",
"Coming to Adjust_GPM_L3_Obj_Name()"<<endl);
4910 if(this->
groups.size() <= 1) {
4911 for (vector<Var *>::iterator irv = this->
vars.begin();
4912 irv != this->vars.end(); ++irv) {
4913 objnewname = HDF5CFUtil::obtain_string_after_lastslash((*irv)->newname);
4914 if (objnewname !=
"")
4915 (*irv)->newname = objnewname;
4919 for (vector<Var *>::iterator irv = this->
vars.begin();
4920 irv != this->vars.end(); ++irv) {
4921 size_t grid_group_path_pos = ((*irv)->newname.substr(1)).find_first_of(
"/");
4922 objnewname = ((*irv)->newname).substr(grid_group_path_pos+2);
4923 (*irv)->newname = objnewname;
4929 void GMFile:: Adjust_Mea_Ozone_Obj_Name() {
4931 BESDEBUG(
"h5",
"Coming to Adjust_Mea_Ozone_Obj_Name()"<<endl);
4933 for (vector<Var *>::iterator irv = this->
vars.begin();
4934 irv != this->vars.end(); ++irv) {
4935 objnewname = HDF5CFUtil::obtain_string_after_lastslash((*irv)->newname);
4936 if (objnewname !=
"")
4937 (*irv)->newname = objnewname;
4941 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
4942 ird !=(*irv)->dims.end();++ird) {
4943 cerr<<
"Ozone dim. name "<<(*ird)->name <<endl;
4944 cerr<<
"Ozone dim. new name "<<(*ird)->newname <<endl;
4950 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
4951 irv != this->cvars.end(); ++irv) {
4952 objnewname = HDF5CFUtil::obtain_string_after_lastslash((*irv)->newname);
4953 if (objnewname !=
"")
4954 (*irv)->newname = objnewname;
4957 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
4958 ird !=(*irv)->dims.end();++ird) {
4959 cerr<<
"Ozone CV dim. name "<<(*ird)->name <<endl;
4960 cerr<<
"Ozone CV dim. new name "<<(*ird)->newname <<endl;
4969 BESDEBUG(
"h5",
"GMFile::Coming to Flatten_Obj_Name()"<<endl);
4974 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
4975 irv != this->cvars.end(); ++irv) {
4976 (*irv)->newname = get_CF_string((*irv)->newname);
4978 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
4979 ird != (*irv)->dims.end(); ++ird) {
4980 (*ird)->newname = get_CF_string((*ird)->newname);
4983 if (
true == include_attr) {
4984 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
4985 ira != (*irv)->attrs.end(); ++ira)
4986 (*ira)->newname = File::get_CF_string((*ira)->newname);
4993 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
4994 irv != this->spvars.end(); ++irv) {
4995 (*irv)->newname = get_CF_string((*irv)->newname);
4997 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
4998 ird != (*irv)->dims.end(); ++ird)
4999 (*ird)->newname = get_CF_string((*ird)->newname);
5001 if (
true == include_attr) {
5002 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
5003 ira != (*irv)->attrs.end(); ++ira)
5004 (*ira)->newname = File::get_CF_string((*ira)->newname);
5011 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5012 irv2 != this->vars.end(); irv2++) {
5013 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5014 ird !=(*irv2)->dims.end(); ird++) {
5015 cerr<<
"Dimension name afet Flatten_Obj_Name "<<(*ird)->newname <<endl;
5027 BESDEBUG(
"h5",
"GMFile::Coming to Handle_Obj_NameClashing()"<<endl);
5031 set<string>objnameset;
5032 Handle_GMCVar_NameClashing(objnameset);
5033 Handle_GMSPVar_NameClashing(objnameset);
5034 File::Handle_GeneralObj_NameClashing(include_attr,objnameset);
5035 if (
true == include_attr) {
5036 Handle_GMCVar_AttrNameClashing();
5037 Handle_GMSPVar_AttrNameClashing();
5044 void GMFile::Handle_GMCVar_NameClashing(set<string> &objnameset ) {
5046 GMHandle_General_NameClashing(objnameset,this->cvars);
5050 void GMFile::Handle_GMSPVar_NameClashing(set<string> &objnameset ) {
5052 GMHandle_General_NameClashing(objnameset,this->spvars);
5056 void GMFile::Handle_GMCVar_AttrNameClashing() {
5058 BESDEBUG(
"h5",
"Coming to Handle_GMCVar_AttrNameClashing()"<<endl);
5059 set<string> objnameset;
5061 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5062 irv != this->cvars.end(); ++irv) {
5063 Handle_General_NameClashing(objnameset,(*irv)->attrs);
5069 void GMFile::Handle_GMSPVar_AttrNameClashing() {
5071 BESDEBUG(
"h5",
"Coming to Handle_GMSPVar_AttrNameClashing()"<<endl);
5072 set<string> objnameset;
5074 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5075 irv != this->spvars.end(); ++irv) {
5076 Handle_General_NameClashing(objnameset,(*irv)->attrs);
5084 template<
class T>
void
5085 GMFile::GMHandle_General_NameClashing(set <string>&objnameset, vector<T*>& objvec) {
5087 BESDEBUG(
"h5",
"Coming to GMHandle_General_NameClashing()"<<endl);
5088 pair<set<string>::iterator,
bool> setret;
5089 set<string>::iterator iss;
5091 vector<string> clashnamelist;
5092 vector<string>::iterator ivs;
5094 map<int,int> cl_to_ol;
5098 typename vector<T*>::iterator irv;
5100 for (irv = objvec.begin();
5101 irv != objvec.end(); ++irv) {
5103 setret = objnameset.insert((*irv)->newname);
5104 if (
false == setret.second ) {
5105 clashnamelist.insert(clashnamelist.end(),(*irv)->newname);
5106 cl_to_ol[cl_index] = ol_index;
5115 for (ivs=clashnamelist.begin(); ivs!=clashnamelist.end(); ++ivs) {
5116 int clash_index = 1;
5117 string temp_clashname = *ivs +
'_';
5118 HDF5CFUtil::gen_unique_name(temp_clashname,objnameset,clash_index);
5119 *ivs = temp_clashname;
5124 for (
unsigned int i =0; i <clashnamelist.size(); i++)
5125 objvec[cl_to_ol[i]]->newname = clashnamelist[i];
5133 BESDEBUG(
"h5",
"GMFile: Coming to Handle_DimNameClashing()"<<endl);
5135 if (ACOS_L2S_OR_OCO2_L1B == product_type)
5138 map<string,string>dimname_to_dimnewname;
5139 pair<map<string,string>::iterator,
bool>mapret;
5140 set<string> dimnameset;
5141 vector<Dimension*>vdims;
5142 set<string> dimnewnameset;
5143 pair<set<string>::iterator,
bool> setret;
5146 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5147 irv !=this->cvars.end(); ++irv) {
5148 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5149 ird !=(*irv)->dims.end();++ird) {
5150 setret = dimnameset.insert((*ird)->name);
5151 if (
true == setret.second)
5152 vdims.push_back(*ird);
5159 for(vector<Var *>::iterator irv= this->
vars.begin();
5160 irv != this->vars.end();++irv) {
5161 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5162 ird !=(*irv)->dims.end();++ird) {
5164 setret = dimnameset.insert((*ird)->name);
5165 if (setret.second) vdims.push_back(*ird);
5169 GMHandle_General_NameClashing(dimnewnameset,vdims);
5172 for (vector<Dimension*>::iterator ird = vdims.begin();ird!=vdims.end();++ird) {
5173 mapret = dimname_to_dimnewname.insert(pair<string,string>((*ird)->name,(*ird)->newname));
5174 if (
false == mapret.second)
5175 throw4(
"The dimension name ",(*ird)->name,
" should map to ",
5180 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5181 irv !=this->cvars.end(); ++irv)
5182 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5183 ird!=(*irv)->dims.end();++ird)
5184 (*ird)->newname = dimname_to_dimnewname[(*ird)->name];
5186 for (vector<Var *>::iterator irv = this->
vars.begin();
5187 irv != this->vars.end(); ++irv)
5188 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5189 ird !=(*irv)->dims.end();++ird)
5190 (*ird)->newname = dimname_to_dimnewname[(*ird)->name];
5197 BESDEBUG(
"h5",
"GMFile:Coming to Adjust_Dim_Name()"<<endl);
5200 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5201 irv2 != this->vars.end(); irv2++) {
5202 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5203 ird !=(*irv2)->dims.end(); ird++) {
5204 cerr<<
"Dimension new name "<<(*ird)->newname <<endl;
5210 if(
true == iscoard) {
5211 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5212 irv !=this->cvars.end(); ++irv) {
5214 cerr<<
"1D Cvariable name is "<<(*irv)->name <<endl;
5215 cerr<<
"1D Cvariable new name is "<<(*irv)->newname <<endl;
5216 cerr<<
"1D Cvariable dim name is "<<((*irv)->dims)[0]->name <<endl;
5217 cerr<<
"1D Cvariable dim new name is "<<((*irv)->dims)[0]->newname <<endl;
5219 if ((*irv)->dims.size()!=1)
5220 throw3(
"Coard coordinate variable ",(*irv)->name,
"is not 1D");
5221 if ((*irv)->newname != (((*irv)->dims)[0]->newname)) {
5222 ((*irv)->dims)[0]->newname = (*irv)->newname;
5225 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5226 irv2 != this->
vars.end(); ++irv2) {
5227 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5228 ird !=(*irv2)->dims.end(); ++ird) {
5233 if ((*ird)->name == ((*irv)->dims)[0]->name)
5234 (*ird)->newname = ((*irv)->dims)[0]->newname;
5243 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5244 irv2 != this->
vars.end(); irv2++) {
5245 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5246 ird !=(*irv2)->dims.end(); ird++) {
5247 cerr<<
"Dimension name afet Adjust_Dim_Name "<<(*ird)->newname <<endl;
5259 BESDEBUG(
"h5",
"GMFile::Coming to Add_Supplement_Attrs()"<<endl);
5260 if (General_Product == product_type ||
true == add_path) {
5263 if(
true == add_path) {
5265 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5266 irv != this->cvars.end(); ++irv) {
5267 if (((*irv)->cvartype == CV_EXIST) || ((*irv)->cvartype == CV_MODIFY)) {
5269 const string varname = (*irv)->name;
5270 const string attrname =
"origname";
5271 Add_Str_Attr(attr,attrname,varname);
5272 (*irv)->attrs.push_back(attr);
5276 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5277 irv != this->cvars.end(); ++irv) {
5281 if((*irv)->zero_storage_size ==
false
5282 || HDF5RequestHandler::get_no_zero_size_fullnameattr() ==
false) {
5283 if (((*irv)->cvartype == CV_EXIST) || ((*irv)->cvartype == CV_MODIFY)) {
5285 const string varname = (*irv)->fullpath;
5286 const string attrname =
"fullnamepath";
5287 Add_Str_Attr(attr,attrname,varname);
5288 (*irv)->attrs.push_back(attr);
5293 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5294 irv != this->spvars.end(); ++irv) {
5296 const string varname = (*irv)->name;
5297 const string attrname =
"origname";
5298 Add_Str_Attr(attr,attrname,varname);
5299 (*irv)->attrs.push_back(attr);
5302 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5303 irv != this->spvars.end(); ++irv) {
5307 if((*irv)->zero_storage_size ==
false
5308 || HDF5RequestHandler::get_no_zero_size_fullnameattr() ==
false) {
5310 const string varname = (*irv)->fullpath;
5311 const string attrname =
"fullnamepath";
5312 Add_Str_Attr(attr,attrname,varname);
5313 (*irv)->attrs.push_back(attr);
5319 if(GPM_L1 == product_type || GPMS_L3 == product_type || GPMM_L3 == product_type)
5321 else if (Aqu_L3 == product_type)
5323 else if (Mea_SeaWiFS_L2 == product_type || Mea_SeaWiFS_L3 == product_type)
5324 Add_SeaWiFS_Attrs();
5330 GMFile:: Add_GPM_Attrs() {
5332 BESDEBUG(
"h5",
"Coming to Add_GPM_Attrs()"<<endl);
5333 vector<HDF5CF::Var *>::const_iterator it_v;
5334 vector<HDF5CF::Attribute *>::const_iterator ira;
5335 const string attr_name_be_replaced =
"CodeMissingValue";
5336 const string attr_new_name =
"_FillValue";
5337 const string attr2_name_be_replaced =
"Units";
5338 const string attr2_new_name =
"units";
5343 for (it_v =
vars.begin(); it_v !=
vars.end(); ++it_v) {
5344 bool has_fvalue_attr =
false;
5345 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5346 if(attr_new_name == (*ira)->name) {
5347 has_fvalue_attr =
true;
5352 if(
false == has_fvalue_attr) {
5353 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5354 if(attr_name_be_replaced == (*ira)->name) {
5355 if((*ira)->dtype == H5FSTRING)
5356 Change_Attr_One_Str_to_Others((*ira),(*it_v));
5357 (*ira)->name = attr_new_name;
5358 (*ira)->newname = attr_new_name;
5366 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5367 irv != this->cvars.end(); ++irv) {
5368 bool has_fvalue_attr =
false;
5370 for(ira = (*irv)->attrs.begin(); ira!= (*irv)->attrs.end();ira++) {
5372 if(attr_new_name == (*ira)->name) {
5373 has_fvalue_attr =
true;
5377 if(
false == has_fvalue_attr) {
5378 for(ira = (*irv)->attrs.begin(); ira!= (*irv)->attrs.end();ira++) {
5380 if(attr_name_be_replaced == (*ira)->name) {
5381 if((*ira)->dtype == H5FSTRING)
5382 Change_Attr_One_Str_to_Others((*ira),(*irv));
5383 (*ira)->name = attr_new_name;
5384 (*ira)->newname = attr_new_name;
5391 if(product_type == GPM_L1) {
5393 if ((*irv)->cvartype == CV_EXIST) {
5394 if((*irv)->name.find(
"Latitude") !=string::npos) {
5395 string unit_value =
"degrees_north";
5396 Correct_GPM_L1_LatLon_units(*irv,unit_value);
5399 else if((*irv)->name.find(
"Longitude") !=string::npos) {
5400 string unit_value =
"degrees_east";
5401 Correct_GPM_L1_LatLon_units(*irv,unit_value);
5406 else if ((*irv)->cvartype == CV_NONLATLON_MISS) {
5409 const string attrname =
"comment";
5413 if((*irv)->name ==
"nchannel1")
5414 comment =
"Number of Swath S1 channels (10V 10H 19V 19H 23V 37V 37H 89V 89H).";
5415 else if((*irv)->name ==
"nchannel2")
5416 comment =
"Number of Swath S2 channels (166V 166H 183+/-3V 183+/-8V).";
5417 else if((*irv)->name ==
"nchan1")
5418 comment =
"Number of channels in Swath 1.";
5419 else if((*irv)->name ==
"nchan2")
5420 comment =
"Number of channels in Swath 2.";
5421 else if((*irv)->name ==
"VH")
5422 comment =
"Number of polarizations.";
5423 else if((*irv)->name ==
"GMIxyz")
5424 comment =
"x, y, z components in GMI instrument coordinate system.";
5425 else if((*irv)->name ==
"LNL")
5426 comment =
"Linear and non-linear.";
5427 else if((*irv)->name ==
"nscan")
5428 comment =
"Number of scans in the granule.";
5429 else if((*irv)->name ==
"nscan1")
5430 comment =
"Typical number of Swath S1 scans in the granule.";
5431 else if((*irv)->name ==
"nscan2")
5432 comment =
"Typical number of Swath S2 scans in the granule.";
5433 else if((*irv)->name ==
"npixelev")
5434 comment =
"Number of earth view pixels in one scan.";
5435 else if((*irv)->name ==
"npixelht")
5436 comment =
"Number of hot load pixels in one scan.";
5437 else if((*irv)->name ==
"npixelcs")
5438 comment =
"Number of cold sky pixels in one scan.";
5439 else if((*irv)->name ==
"npixelfr")
5440 comment =
"Number of full rotation earth view pixels in one scan.";
5441 else if((*irv)->name ==
"nfreq1")
5442 comment =
"Number of frequencies in Swath 1.";
5443 else if((*irv)->name ==
"nfreq2")
5444 comment =
"Number of frequencies in Swath 2.";
5445 else if((*irv)->name ==
"npix1")
5446 comment =
"Number of pixels in Swath 1.";
5447 else if((*irv)->name ==
"npix2")
5448 comment =
"Number of pixels in Swath 2.";
5449 else if((*irv)->name ==
"npix3")
5450 comment =
"Number of pixels in Swath 3.";
5451 else if((*irv)->name ==
"npix4")
5452 comment =
"Number of pixels in Swath 4.";
5453 else if((*irv)->name ==
"ncolds1")
5454 comment =
"Maximum number of cold samples in Swath 1.";
5455 else if((*irv)->name ==
"ncolds2")
5456 comment =
"Maximum number of cold samples in Swath 2.";
5457 else if((*irv)->name ==
"nhots1")
5458 comment =
"Maximum number of hot samples in Swath 1.";
5459 else if((*irv)->name ==
"nhots2")
5460 comment =
"Maximum number of hot samples in Swath 2.";
5461 else if((*irv)->name ==
"ntherm")
5462 comment =
"Number of hot load thermisters.";
5463 else if((*irv)->name ==
"ntach")
5464 comment =
"Number of tachometer readings.";
5465 else if((*irv)->name ==
"nsamt"){
5466 comment =
"Number of sample types. ";
5467 comment = +
"The types are: total science GSDR, earthview,hot load, cold sky.";
5469 else if((*irv)->name ==
"nndiode")
5470 comment =
"Number of noise diodes.";
5471 else if((*irv)->name ==
"n7")
5472 comment =
"Number seven.";
5473 else if((*irv)->name ==
"nray")
5474 comment =
"Number of angle bins in each NS scan.";
5475 else if((*irv)->name ==
"nrayMS")
5476 comment =
"Number of angle bins in each MS scan.";
5477 else if((*irv)->name ==
"nrayHS")
5478 comment =
"Number of angle bins in each HS scan.";
5479 else if((*irv)->name ==
"nbin")
5480 comment =
"Number of range bins in each NS and MS ray. Bin interval is 125m.";
5481 else if((*irv)->name ==
"nbinHS")
5482 comment =
"Number of range bins in each HS ray. Bin interval is 250m.";
5483 else if((*irv)->name ==
"nbinSZP")
5484 comment =
"Number of range bins for sigmaZeroProfile.";
5485 else if((*irv)->name ==
"nbinSZPHS")
5486 comment =
"Number of range bins for sigmaZeroProfile in each HS scan.";
5487 else if((*irv)->name ==
"nNP")
5488 comment =
"Number of NP kinds.";
5489 else if((*irv)->name ==
"nearFar")
5490 comment =
"Near reference, Far reference.";
5491 else if((*irv)->name ==
"foreBack")
5492 comment =
"Forward, Backward.";
5493 else if((*irv)->name ==
"method")
5494 comment =
"Number of SRT methods.";
5495 else if((*irv)->name ==
"nNode")
5496 comment =
"Number of binNode.";
5497 else if((*irv)->name ==
"nDSD")
5498 comment =
"Number of DSD parameters. Parameters are N0 and D0";
5499 else if((*irv)->name ==
"LS")
5500 comment =
"Liquid, solid.";
5506 Add_Str_Attr(attr,attrname,comment);
5507 (*irv)->attrs.push_back(attr);
5513 if(product_type == GPMS_L3 || product_type == GPMM_L3) {
5514 if ((*irv)->cvartype == CV_NONLATLON_MISS) {
5517 const string attrname =
"comment";
5521 if((*irv)->name ==
"chn")
5522 comment =
"Number of channels:Ku,Ka,KaHS,DPR.";
5523 else if((*irv)->name ==
"inst")
5524 comment =
"Number of instruments:Ku,Ka,KaHS.";
5525 else if((*irv)->name ==
"tim")
5526 comment =
"Number of hours(local time).";
5527 else if((*irv)->name ==
"ang"){
5528 comment =
"Number of angles.The meaning of ang is different for each channel.";
5530 "For Ku channel all indices are used with the meaning 0,1,2,..6 =angle bins 24,";
5532 "(20,28),(16,32),(12,36),(8,40),(3,44),and (0,48).";
5534 "For Ka channel 4 indices are used with the meaning 0,1,2,3 = angle bins 12,(8,16),";
5536 "(4,20),and (0,24). For KaHS channel 4 indices are used with the meaning 0,1,2,3 =";
5537 comment +=
"angle bins(11,2),(7,16),(3,20),and (0.23).";
5540 else if((*irv)->name ==
"rt")
5541 comment =
"Number of rain types: stratiform, convective,all.";
5542 else if((*irv)->name ==
"st")
5543 comment =
"Number of surface types:ocean,land,all.";
5544 else if((*irv)->name ==
"bin"){
5545 comment =
"Number of bins in histogram. The thresholds are different for different";
5546 comment +=
" variables. see the file specification for this algorithm.";
5548 else if((*irv)->name ==
"nvar") {
5549 comment =
"Number of phase bins. Bins are counts of phase less than 100, ";
5550 comment +=
"counts of phase greater than or equal to 100 and less than 200, ";
5551 comment +=
"counts of phase greater than or equal to 200.";
5553 else if((*irv)->name ==
"AD")
5554 comment =
"Ascending or descending half of the orbit.";
5560 Add_Str_Attr(attr,attrname,comment);
5561 (*irv)->attrs.push_back(attr);
5568 if ((*irv)->cvartype == CV_SPECIAL) {
5569 if((*irv)->name ==
"nlayer" || (*irv)->name ==
"hgt"
5570 || (*irv)->name ==
"nalt") {
5572 string unit_value =
"km";
5573 Add_Str_Attr(attr,attr2_new_name,unit_value);
5574 (*irv)->attrs.push_back(attr);
5577 string attr1_axis=
"axis";
5578 string attr1_value =
"Z";
5579 Add_Str_Attr(attr1,attr1_axis,attr1_value);
5580 (*irv)->attrs.push_back(attr1);
5583 string attr2_positive=
"positive";
5584 string attr2_value =
"up";
5585 Add_Str_Attr(attr2,attr2_positive,attr2_value);
5586 (*irv)->attrs.push_back(attr2);
5589 if((*irv)->name ==
"hgt" || (*irv)->name ==
"nalt"){
5591 string comment =
"Number of heights above the earth ellipsoid";
5592 Add_Str_Attr(attr1,
"comment",comment);
5593 (*irv)->attrs.push_back(attr1);
5603 const string fill_value_attr_name =
"_FillValue";
5604 vector<HDF5CF::Var *>::const_iterator it_v;
5605 vector<HDF5CF::Attribute *>::const_iterator ira;
5607 for (it_v =
vars.begin();
5608 it_v !=
vars.end(); ++it_v) {
5610 bool has_fillvalue =
false;
5611 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5612 if (fill_value_attr_name == (*ira)->name){
5613 has_fillvalue =
true;
5620 if (has_fillvalue !=
true ) {
5622 if(H5FLOAT32 == (*it_v)->dtype) {
5624 float _FillValue = -9999.9;
5625 Add_One_Float_Attr(attr,fill_value_attr_name,_FillValue);
5626 (*it_v)->attrs.push_back(attr);
5636 GMFile:: Correct_GPM_L1_LatLon_units(
Var *var,
const string unit_value) {
5638 BESDEBUG(
"h5",
"Coming to Correct_GPM_L1_LatLon_units()"<<endl);
5639 const string Unit_name =
"Units";
5640 const string unit_name =
"units";
5642 vector<HDF5CF::Attribute *>::iterator ira;
5645 for(ira = var->attrs.begin(); ira!= var->attrs.end();) {
5646 if(unit_name == (*ira)->name) {
5648 ira = var->attrs.erase(ira);
5650 else if(Unit_name == (*ira)->name) {
5652 ira = var->attrs.erase(ira);
5661 Add_Str_Attr(attr,unit_name,unit_value);
5662 var->attrs.push_back(attr);
5669 GMFile:: Add_Aqu_Attrs() {
5671 BESDEBUG(
"h5",
"Coming to Add_Aqu_Attrs()"<<endl);
5672 vector<HDF5CF::Var *>::const_iterator it_v;
5673 vector<HDF5CF::Attribute *>::const_iterator ira;
5675 const string orig_longname_attr_name =
"Parameter";
5676 const string longname_attr_name =
"long_name";
5677 string longname_value;
5680 const string orig_units_attr_name =
"Units";
5681 const string units_attr_name =
"units";
5684 const string orig_valid_min_attr_name =
"Data Minimum";
5685 const string valid_min_attr_name =
"valid_min";
5686 float valid_min_value = 0;
5688 const string orig_valid_max_attr_name =
"Data Maximum";
5689 const string valid_max_attr_name =
"valid_max";
5690 float valid_max_value = 0;
5695 const string fill_value_attr_name =
"_FillValue";
5696 float _FillValue = -32767.0;
5698 for (ira = this->
root_attrs.begin(); ira != this->root_attrs.end(); ++ira) {
5699 if (orig_longname_attr_name == (*ira)->name) {
5700 Retrieve_H5_Attr_Value(*ira,
"/");
5701 longname_value.resize((*ira)->value.size());
5702 copy((*ira)->value.begin(),(*ira)->value.end(),longname_value.begin());
5705 else if (orig_units_attr_name == (*ira)->name) {
5706 Retrieve_H5_Attr_Value(*ira,
"/");
5707 units_value.resize((*ira)->value.size());
5708 copy((*ira)->value.begin(),(*ira)->value.end(),units_value.begin());
5711 else if (orig_valid_min_attr_name == (*ira)->name) {
5712 Retrieve_H5_Attr_Value(*ira,
"/");
5713 memcpy(&valid_min_value,(
void*)(&((*ira)->value[0])),(*ira)->value.size());
5716 else if (orig_valid_max_attr_name == (*ira)->name) {
5717 Retrieve_H5_Attr_Value(*ira,
"/");
5718 memcpy(&valid_max_value,(
void*)(&((*ira)->value[0])),(*ira)->value.size());
5725 bool has_long_name =
false;
5726 bool has_units =
false;
5727 bool has_valid_min =
false;
5728 bool has_valid_max =
false;
5729 bool has_fillvalue =
false;
5731 for (it_v =
vars.begin();
5732 it_v !=
vars.end(); ++it_v) {
5733 if (
"l3m_data" == (*it_v)->name) {
5734 for (ira = (*it_v)->attrs.begin(); ira != (*it_v)->attrs.end(); ++ira) {
5735 if (longname_attr_name == (*ira)->name)
5736 has_long_name =
true;
5737 else if(units_attr_name == (*ira)->name)
5739 else if(valid_min_attr_name == (*ira)->name)
5740 has_valid_min =
true;
5741 else if(valid_max_attr_name == (*ira)->name)
5742 has_valid_max =
true;
5743 else if(fill_value_attr_name == (*ira)->name)
5744 has_fillvalue =
true;
5752 for (it_v =
vars.begin();
5753 it_v !=
vars.end(); ++it_v) {
5754 if (
"l3m_data" == (*it_v)->name) {
5758 if(
false == has_long_name) {
5760 Add_Str_Attr(attr,longname_attr_name,longname_value);
5761 (*it_v)->attrs.push_back(attr);
5765 if(
false == has_units) {
5767 Add_Str_Attr(attr,units_attr_name,units_value);
5768 (*it_v)->attrs.push_back(attr);
5772 if(
false == has_valid_min) {
5774 Add_One_Float_Attr(attr,valid_min_attr_name,valid_min_value);
5775 (*it_v)->attrs.push_back(attr);
5779 if(
false == has_valid_max) {
5781 Add_One_Float_Attr(attr,valid_max_attr_name,valid_max_value);
5782 (*it_v)->attrs.push_back(attr);
5786 if(
false == has_fillvalue) {
5788 Add_One_Float_Attr(attr,fill_value_attr_name,_FillValue);
5789 (*it_v)->attrs.push_back(attr);
5799 GMFile:: Add_SeaWiFS_Attrs() {
5801 BESDEBUG(
"h5",
"Coming to Add_SeaWiFS_Attrs()"<<endl);
5804 const string fill_value_attr_name =
"_FillValue";
5805 float _FillValue = -999.0;
5806 const string valid_range_attr_name =
"valid_range";
5807 vector<HDF5CF::Var *>::const_iterator it_v;
5808 vector<HDF5CF::Attribute *>::const_iterator ira;
5811 for (it_v =
vars.begin();
5812 it_v !=
vars.end(); ++it_v) {
5813 if (H5FLOAT32 == (*it_v)->dtype) {
5814 bool has_fillvalue =
false;
5815 bool has_validrange =
false;
5816 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5817 if (fill_value_attr_name == (*ira)->name){
5818 has_fillvalue =
true;
5822 else if(valid_range_attr_name == (*ira)->name) {
5823 has_validrange =
true;
5829 if (has_fillvalue !=
true && has_validrange !=
true ) {
5831 Add_One_Float_Attr(attr,fill_value_attr_name,_FillValue);
5832 (*it_v)->attrs.push_back(attr);
5843 string co_attrname =
"coordinates";
5844 string co_attrvalue=
"";
5845 string unit_attrname =
"units";
5846 string nonll_unit_attrvalue =
"level";
5847 string lat_unit_attrvalue =
"degrees_north";
5848 string lon_unit_attrvalue =
"degrees_east";
5850 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5851 ircv != this->cvars.end(); ++ircv) {
5854 if ((*ircv)->cvartype == CV_NONLATLON_MISS) {
5856 Add_Str_Attr(attr,unit_attrname,nonll_unit_attrvalue);
5857 (*ircv)->attrs.push_back(attr);
5860 else if ((*ircv)->cvartype == CV_LAT_MISS) {
5865 Add_Str_Attr(attr,unit_attrname,lat_unit_attrvalue);
5866 (*ircv)->attrs.push_back(attr);
5870 else if ((*ircv)->cvartype == CV_LON_MISS) {
5872 Add_Str_Attr(attr,unit_attrname,lon_unit_attrvalue);
5873 (*ircv)->attrs.push_back(attr);
5878 if(product_type == Mea_SeaWiFS_L2)
5882 else if(product_type == GPM_L1) {
5883 Handle_GPM_l1_Coor_Attr();
5887 else if (
true == iscoard) {
5894 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5895 ircv != this->cvars.end(); ++ircv) {
5896 if((*ircv)->rank == 2) {
5899 if(gp_latname == (*ircv)->name)
5900 Replace_Var_Str_Attr((*ircv),unit_attrname,lat_unit_attrvalue);
5901 else if(gp_lonname ==(*ircv)->name)
5902 Replace_Var_Str_Attr((*ircv),unit_attrname,lon_unit_attrvalue);
5907 string ll2d_dimname0,ll2d_dimname1;
5908 bool has_ll2d_coords =
false;
5909 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5910 ircv != this->cvars.end(); ++ircv) {
5911 if((*ircv)->rank == 2) {
5913 ll2d_dimname0 = (*ircv)->getDimensions()[0]->name;
5914 ll2d_dimname1 = (*ircv)->getDimensions()[1]->name;
5915 if(ll2d_dimname0 !=
"" && ll2d_dimname1 !=
"")
5916 has_ll2d_coords =
true;
5921 if(
true == has_ll2d_coords) {
5923 for (vector<Var *>::iterator irv = this->
vars.begin();
5924 irv != this->vars.end(); ++irv) {
5926 bool coor_attr_keep_exist =
false;
5929 if(((*irv)->rank >=2)) {
5931 short ll2dim_flag = 0;
5932 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
5933 ird != (*irv)->dims.end(); ++ ird) {
5934 if((*ird)->name == ll2d_dimname0)
5936 else if((*ird)->name == ll2d_dimname1)
5940 if(ll2dim_flag != 2)
5941 coor_attr_keep_exist =
true;
5944 if(product_type == OSMAPL2S)
5945 coor_attr_keep_exist =
true;
5947 if (
false == coor_attr_keep_exist) {
5948 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
5949 ira !=(*irv)->attrs.end();) {
5950 if ((*ira)->newname == co_attrname) {
5952 ira = (*irv)->attrs.erase(ira);
5960 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
5961 ird != (*irv)->dims.end(); ++ ird) {
5962 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5963 ircv != this->cvars.end(); ++ircv) {
5964 if ((*ird)->name == (*ircv)->cfdimname)
5965 co_attrvalue = (co_attrvalue.empty())
5966 ?(*ircv)->newname:co_attrvalue +
" "+(*ircv)->newname;
5970 if (
false == co_attrvalue.empty()) {
5972 Add_Str_Attr(attr,co_attrname,co_attrvalue);
5973 (*irv)->attrs.push_back(attr);
5976 co_attrvalue.clear();
5988 BESDEBUG(
"h5",
"GMFile::Coming to Handle_Coor_Attr()"<<endl);
5989 string co_attrname =
"coordinates";
5990 string co_attrvalue=
"";
5991 string unit_attrname =
"units";
5992 string nonll_unit_attrvalue =
"level";
5993 string lat_unit_attrvalue =
"degrees_north";
5994 string lon_unit_attrvalue =
"degrees_east";
5998 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5999 ircv != this->cvars.end(); ++ircv) {
6001 if ((*ircv)->cvartype == CV_NONLATLON_MISS) {
6003 Add_Str_Attr(attr,unit_attrname,nonll_unit_attrvalue);
6004 (*ircv)->attrs.push_back(attr);
6006 else if ((*ircv)->cvartype == CV_LAT_MISS) {
6008 Add_Str_Attr(attr,unit_attrname,lat_unit_attrvalue);
6009 (*ircv)->attrs.push_back(attr);
6011 else if ((*ircv)->cvartype == CV_LON_MISS) {
6013 Add_Str_Attr(attr,unit_attrname,lon_unit_attrvalue);
6014 (*ircv)->attrs.push_back(attr);
6019 if(product_type == Mea_SeaWiFS_L2)
6023 else if(product_type == GPM_L1) {
6024 Handle_GPM_l1_Coor_Attr();
6029 else if(product_type == General_Product && gproduct_pattern == GENERAL_LATLON_COOR_ATTR){
6030 Handle_LatLon_With_CoordinateAttr_Coor_Attr();
6034 else if (
true == iscoard) {
6038 if(grp_cv_paths.size() >0) {
6039 for (vector<Var *>::iterator irv = this->
vars.begin();
6040 irv != this->vars.end(); ++irv) {
6041 if(grp_cv_paths.find(HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) != grp_cv_paths.end()){
6044 Flatten_VarPath_In_Coordinates_Attr(*irv);
6052 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6053 ircv != this->cvars.end(); ++ircv) {
6055 if((*ircv)->rank == 2 && (*ircv)->cvartype == CV_EXIST) {
6064 if(gp_latname == (*ircv)->name) {
6066 if(
false == Is_geolatlon(gp_latname,
true))
6067 Replace_Var_Str_Attr((*ircv),unit_attrname,lat_unit_attrvalue);
6069 else if(gp_lonname ==(*ircv)->name) {
6071 if(
false == Is_geolatlon(gp_lonname,
false))
6072 Replace_Var_Str_Attr((*ircv),unit_attrname,lon_unit_attrvalue);
6080 if(
true == Is_geolatlon((*ircv)->name,
true))
6081 Replace_Var_Str_Attr((*ircv),unit_attrname,lat_unit_attrvalue);
6083 else if(
true == Is_geolatlon((*ircv)->name,
false))
6084 Replace_Var_Str_Attr((*ircv),unit_attrname,lon_unit_attrvalue);
6090 if(grp_cv_paths.size() >0) {
6091 for (vector<Var *>::iterator irv = this->
vars.begin();
6092 irv != this->vars.end(); ++irv) {
6093 if(grp_cv_paths.find(HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) != grp_cv_paths.end()){
6096 Flatten_VarPath_In_Coordinates_Attr(*irv);
6102 bool has_ll2d_coords =
false;
6105 if(General_Product == this->product_type && GENERAL_DIMSCALE == this->gproduct_pattern)
6106 has_ll2d_coords =
true;
6108 string ll2d_dimname0;
6109 string ll2d_dimname1;
6110 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6111 ircv != this->cvars.end(); ++ircv) {
6112 if((*ircv)->rank == 2) {
6114 ll2d_dimname0 = (*ircv)->getDimensions()[0]->name;
6115 ll2d_dimname1 = (*ircv)->getDimensions()[1]->name;
6116 if(ll2d_dimname0 !=
"" && ll2d_dimname1 !=
"")
6117 has_ll2d_coords =
true;
6124 if(
true == has_ll2d_coords) {
6132 bool force_flatten_coor_attr = HDF5RequestHandler::get_force_flatten_coor_attr();
6136 bool has_coor_attr_ge_2d_vars =
false;
6137 for (vector<Var *>::iterator irv = this->
vars.begin();
6138 irv != this->vars.end(); ++irv) {
6139 if((*irv)->rank >=2){
6140 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end();++ira) {
6142 if((*ira)->name == co_attrname) {
6143 has_coor_attr_ge_2d_vars =
true;
6147 if(has_coor_attr_ge_2d_vars ==
true)
6154 bool is_hybrid_eos5=
false;
6155 if(force_flatten_coor_attr ==
true && has_coor_attr_ge_2d_vars ==
true)
6156 is_hybrid_eos5 = Is_Hybrid_EOS5();
6158 for (vector<Var *>::iterator irv = this->
vars.begin();
6159 irv != this->vars.end(); ++irv) {
6161 bool has_coor =
false;
6162 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end();++ira) {
6164 if((*ira)->name == co_attrname) {
6171 if(
true == force_flatten_coor_attr &&
true == has_coor) {
6173 if(is_hybrid_eos5 ==
true) {
6174 Flatten_VarPath_In_Coordinates_Attr_EOS5((*irv));
6178 Flatten_VarPath_In_Coordinates_Attr((*irv));
6181 else if(((*irv)->rank >=2) && (has_coor_attr_ge_2d_vars ==
false ||
false == force_flatten_coor_attr)) {
6183 bool coor_attr_keep_exist =
false;
6186 if(grp_cv_paths.find(HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) == grp_cv_paths.end())
6189 coor_attr_keep_exist = Check_Var_2D_CVars(*irv);
6191 coor_attr_keep_exist =
true;
6195 if(product_type == OSMAPL2S)
6196 coor_attr_keep_exist =
true;
6199 if (
false == coor_attr_keep_exist) {
6200 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
6201 ira !=(*irv)->attrs.end();) {
6202 if ((*ira)->newname == co_attrname) {
6204 ira = (*irv)->attrs.erase(ira);
6212 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6213 ird != (*irv)->dims.end(); ++ ird) {
6214 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6215 ircv != this->cvars.end(); ++ircv) {
6216 if ((*ird)->name == (*ircv)->cfdimname)
6217 co_attrvalue = (co_attrvalue.empty())
6218 ?(*ircv)->newname:co_attrvalue +
" "+(*ircv)->newname;
6222 if (
false == co_attrvalue.empty()) {
6224 Add_Str_Attr(attr,co_attrname,co_attrvalue);
6225 (*irv)->attrs.push_back(attr);
6228 co_attrvalue.clear();
6229 (*irv)->coord_attr_add_path =
false;
6237 void GMFile:: Handle_GPM_l1_Coor_Attr() {
6239 BESDEBUG(
"h5",
"Coming to Handle_GPM_l1_Coor_Attr()"<<endl);
6253 string co_attrname =
"coordinates";
6254 string co_attrvalue=
"";
6257 set<string> cvar_2d_dimset;
6259 pair<map<string,string>::iterator,
bool>mapret;
6262 map<string,string>cfdimname_to_cvar2dname;
6265 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
6266 irv != this->cvars.end(); ++irv) {
6269 if((*irv)->rank == 2) {
6275 for(vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6276 ird != (*irv)->dims.end(); ++ird) {
6277 cvar_2d_dimset.insert((*ird)->name);
6281 mapret = cfdimname_to_cvar2dname.insert(pair<string,string>((*irv)->cfdimname,(*irv)->newname));
6282 if (
false == mapret.second)
6283 throw4(
"The cf dimension name ",(*irv)->cfdimname,
" should map to 2-D coordinate variable",
6289 for (vector<Var *>::iterator irv = this->
vars.begin();
6290 irv != this->vars.end(); ++irv) {
6293 if((*irv)->rank >=2) {
6297 short have_2d_dimnames_flag = 0;
6298 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6299 ird !=(*irv)->dims.end();++ird) {
6300 if (cvar_2d_dimset.find((*ird)->name)!=cvar_2d_dimset.end())
6301 have_2d_dimnames_flag++;
6305 if(have_2d_dimnames_flag >=2) {
6309 if((*irv)->fullpath.size() > (*irv)->name.size())
6310 var_path=(*irv)->fullpath.substr(0,(*irv)->fullpath.size()-(*irv)->name.size());
6312 throw4(
"The variable full path ",(*irv)->fullpath,
" doesn't contain the variable name ",
6316 short cv_2d_flag = 0;
6319 vector<string> cv_2d_names;
6322 set<string> cv_2d_dimnames;
6325 for(map<string,string>::const_iterator itm = cfdimname_to_cvar2dname.begin();
6326 itm != cfdimname_to_cvar2dname.end();++itm) {
6329 string reduced_dimname = HDF5CFUtil::obtain_string_after_lastslash(itm->first);
6331 if(itm->first.size() <= reduced_dimname.size())
6332 throw2(
"The cf dim. name of this dimension is not right.",itm->first);
6334 cfdim_path= itm->first.substr(0,itm->first.size() - reduced_dimname.size());
6343 if(var_path == cfdim_path) {
6344 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6345 ird!=(*irv)->dims.end();++ird) {
6346 if(reduced_dimname == (*ird)->name) {
6348 cv_2d_names.push_back(itm->second);
6349 cv_2d_dimnames.insert((*ird)->name);
6361 if(cv_2d_flag != 2) {
6364 for(map<string,string>::const_iterator itm = cfdimname_to_cvar2dname.begin();
6365 itm != cfdimname_to_cvar2dname.end();++itm) {
6367 string reduced_dimname = HDF5CFUtil::obtain_string_after_lastslash(itm->first);
6369 if(itm->first.size() <= reduced_dimname.size())
6370 throw2(
"The cf dim. name of this dimension is not right.",itm->first);
6372 cfdim_path= itm->first.substr(0,itm->first.size() - reduced_dimname.size());
6381 if(var_path.find(cfdim_path)!=string::npos) {
6382 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6383 ird!=(*irv)->dims.end();++ird) {
6384 if(reduced_dimname == (*ird)->name) {
6386 cv_2d_names.push_back(itm->second);
6387 cv_2d_dimnames.insert((*ird)->name);
6396 if(2 == cv_2d_flag) {
6399 co_attrvalue = cv_2d_names[0] +
" " + cv_2d_names[1];
6400 if((*irv)->rank >2) {
6401 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6402 ird !=(*irv)->dims.end();++ird) {
6405 if(cv_2d_dimnames.find((*ird)->name) == cv_2d_dimnames.end())
6406 co_attrvalue = co_attrvalue +
" " +(*ird)->newname;
6410 Add_Str_Attr(attr,co_attrname,co_attrvalue);
6411 (*irv)->attrs.push_back(attr);
6412 (*irv)->coord_attr_add_path =
false;
6420 void GMFile::Handle_LatLon_With_CoordinateAttr_Coor_Attr() {
6422 BESDEBUG(
"h5",
"Coming to Handle_LatLon_With_CoordinateAttr_Coor_Attr()"<<endl);
6423 string co_attrname =
"coordinates";
6426 for (vector<Var *>::iterator irv = this->
vars.begin();
6427 irv != this->vars.end(); ++irv) {
6428 if((*irv)->rank >= 2) {
6429 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end(); ++ira) {
6430 if((*ira)->name == co_attrname) {
6433 string coor_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
6434 if(Coord_Match_LatLon_NameSize(coor_value) ==
true)
6435 Flatten_VarPath_In_Coordinates_Attr(*irv);
6439 else if(Coord_Match_LatLon_NameSize_Same_Group(coor_value,HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) ==
true)
6440 Add_VarPath_In_Coordinates_Attr(*irv,coor_value);
6452 bool GMFile::Coord_Match_LatLon_NameSize(
const string & coord_values) {
6454 BESDEBUG(
"h5",
"Coming to Coord_Match_LatLon_NameSize()"<<endl);
6455 bool ret_value =
false;
6456 vector<string> coord_values_vec;
6458 int match_lat_name_pair_index = -1;
6459 int match_lon_name_pair_index = -2;
6460 int num_match_lat = 0;
6461 int num_match_lon = 0;
6465 HDF5CFUtil::Split_helper(coord_values_vec,coord_values,sep);
6468 if((coord_values_vec[0])[0] !=
'/') {
6469 for(vector<string>::iterator irs=coord_values_vec.begin();irs!=coord_values_vec.end();++irs){
6470 if(((*irs).find_first_of(
'/'))!=string::npos) {
6471 *irs =
'/' + (*irs);
6477 for(vector<string>::iterator irs=coord_values_vec.begin();irs!=coord_values_vec.end();++irs){
6481 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin(); ivs!=latloncv_candidate_pairs.end();++ivs) {
6482 if((*irs) == (*ivs).name1){
6483 match_lat_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6486 else if ((*irs) == (*ivs).name2) {
6487 match_lon_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6493 if((match_lat_name_pair_index == match_lon_name_pair_index) && (num_match_lat ==1) && (num_match_lon ==1))
6502 bool GMFile::Coord_Match_LatLon_NameSize_Same_Group(
const string &coord_values,
const string &var_path) {
6504 BESDEBUG(
"h5",
"Coming to Coord_Match_LatLon_NameSize_Same_Group()"<<endl);
6505 bool ret_value =
false;
6506 vector<string> coord_values_vec;
6508 int match_lat_name_pair_index = -1;
6509 int match_lon_name_pair_index = -2;
6510 int num_match_lat = 0;
6511 int num_match_lon = 0;
6513 HDF5CFUtil::Split_helper(coord_values_vec,coord_values,sep);
6516 for(vector<string>::iterator irs=coord_values_vec.begin();irs!=coord_values_vec.end();++irs){
6518 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin(); ivs!=latloncv_candidate_pairs.end();++ivs) {
6519 string lat_name = HDF5CFUtil::obtain_string_after_lastslash((*ivs).name1);
6520 string lat_path = HDF5CFUtil::obtain_string_before_lastslash((*ivs).name1);
6521 string lon_name = HDF5CFUtil::obtain_string_after_lastslash((*ivs).name2);
6522 string lon_path = HDF5CFUtil::obtain_string_before_lastslash((*ivs).name2);
6523 if((*irs) == lat_name && lat_path == var_path){
6524 match_lat_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6527 else if ((*irs) == lon_name && lon_path == var_path) {
6528 match_lon_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6534 if((match_lat_name_pair_index == match_lon_name_pair_index) && (num_match_lat ==1) && (num_match_lon ==1))
6541 void GMFile::Add_VarPath_In_Coordinates_Attr(
Var *var,
const string &coor_value) {
6543 BESDEBUG(
"h5",
"Coming to Add_VarPath_In_Coordinates_Attr()"<<endl);
6544 string new_coor_value;
6546 string var_path = HDF5CFUtil::obtain_string_before_lastslash(var->fullpath) ;
6547 string var_flatten_path = get_CF_string(var_path);
6550 size_t ele_start_pos = 0;
6551 size_t cur_pos = coor_value.find_first_of(sep);
6552 while(cur_pos !=string::npos) {
6553 string tempstr = coor_value.substr(ele_start_pos,cur_pos-ele_start_pos);
6554 tempstr = var_flatten_path + tempstr;
6555 new_coor_value += tempstr + sep;
6556 ele_start_pos = cur_pos+1;
6557 cur_pos = coor_value.find_first_of(sep,cur_pos+1);
6560 if(ele_start_pos == 0)
6561 new_coor_value = var_flatten_path + coor_value;
6563 new_coor_value += var_flatten_path + coor_value.substr(ele_start_pos);
6565 string coor_attr_name =
"coordinates";
6566 Replace_Var_Str_Attr(var,coor_attr_name,new_coor_value);
6567 var->coord_attr_add_path =
false;
6572 void GMFile:: Create_Missing_CV(
GMCVar *GMcvar,
const string& dimname) {
6574 BESDEBUG(
"h5",
"GMFile::Coming to Create_Missing_CV()"<<endl);
6576 GMcvar->name = dimname;
6577 GMcvar->newname = GMcvar->name;
6578 GMcvar->fullpath = GMcvar->name;
6580 GMcvar->dtype = H5INT32;
6581 hsize_t gmcvar_dimsize = dimname_to_dimsize[dimname];
6582 bool unlimited_flag = dimname_to_unlimited[dimname];
6584 gmcvar_dim->unlimited_dim = unlimited_flag;
6585 gmcvar_dim->name = dimname;
6586 gmcvar_dim->newname = dimname;
6587 GMcvar->dims.push_back(gmcvar_dim);
6588 GMcvar->cfdimname = dimname;
6589 GMcvar->cvartype = CV_NONLATLON_MISS;
6590 GMcvar->product_type = product_type;
6595 bool GMFile::Is_netCDF_Dimension(
Var *var) {
6597 string netcdf_dim_mark =
"This is a netCDF dimension but not a netCDF variable";
6599 bool is_only_dimension =
false;
6601 for(vector<Attribute *>::iterator ira = var->attrs.begin();
6602 ira != var->attrs.end();ira++) {
6604 if (
"NAME" == (*ira)->name) {
6606 Retrieve_H5_Attr_Value(*ira,var->fullpath);
6608 name_value.resize((*ira)->value.size());
6609 copy((*ira)->value.begin(),(*ira)->value.end(),name_value.begin());
6612 if (0 == name_value.compare(0,netcdf_dim_mark.size(),netcdf_dim_mark))
6613 is_only_dimension =
true;
6619 return is_only_dimension;
6629 GMFile::Is_Hybrid_EOS5() {
6631 bool has_group_hdfeos =
false;
6632 bool has_group_hdfeos_info =
false;
6638 for (vector<Group *>::iterator irg = this->
groups.begin();
6639 irg != this->groups.end(); ++ irg) {
6640 if (
"/HDFEOS" == (*irg)->path)
6641 has_group_hdfeos =
true;
6642 else if(
"/HDFEOS INFORMATION" == (*irg)->path) {
6643 for(vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
6644 ira != (*irg)->attrs.end();ira++) {
6645 if(
"HDFEOSVersion" == (*ira)->name)
6646 has_group_hdfeos_info =
true;
6649 if(
true == has_group_hdfeos &&
true == has_group_hdfeos_info)
6654 if(
true == has_group_hdfeos &&
true == has_group_hdfeos_info)
6660 void GMFile::Handle_Hybrid_EOS5() {
6662 string eos_str=
"HDFEOS_";
6663 string eos_info_str=
"HDFEOS_INFORMATION_";
6664 string grid_str=
"GRIDS_";
6665 string swath_str=
"SWATHS_";
6666 string zas_str=
"ZAS_";
6667 string df_str=
"Data_Fields_";
6668 string gf_str=
"Geolocation_Fields_";
6669 for (vector<Var *>::iterator irv = this->
vars.begin();
6670 irv != this->vars.end(); irv++) {
6671 string temp_var_name = (*irv)->newname;
6673 bool remove_eos = Remove_EOS5_Strings(temp_var_name);
6675 if(
true == remove_eos)
6676 (*irv)->newname = get_CF_string(temp_var_name);
6678 string::size_type eos_info_pos = temp_var_name.find(eos_info_str);
6679 if(eos_info_pos !=string::npos)
6680 (*irv)->newname = temp_var_name.erase(eos_info_pos,eos_info_str.size());
6682 if(Remove_EOS5_Strings_NonEOS_Fields(temp_var_name)==
true)
6683 (*irv)->newname = get_CF_string(temp_var_name);
6689 for (vector<Var *>::iterator irv = this->
vars.begin();
6690 irv != this->vars.end(); irv++) {
6691 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6692 ird!=(*irv)->dims.end(); ++ird) {
6693 string temp_dim_name = (*ird)->newname;
6694 bool remove_eos = Remove_EOS5_Strings(temp_dim_name);
6696 if(
true == remove_eos)
6697 (*ird)->newname = get_CF_string(temp_dim_name);
6699 string::size_type eos_info_pos = temp_dim_name.find(eos_info_str);
6700 if(eos_info_pos !=string::npos)
6701 (*ird)->newname = temp_dim_name.erase(eos_info_pos,eos_info_str.size());
6703 if(Remove_EOS5_Strings_NonEOS_Fields(temp_dim_name)==
true)
6704 (*ird)->newname = get_CF_string(temp_dim_name);
6711 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
6712 irv != this->cvars.end(); ++irv) {
6713 string temp_var_name = (*irv)->newname;
6715 bool remove_eos = Remove_EOS5_Strings(temp_var_name);
6717 if(
true == remove_eos)
6718 (*irv)->newname = get_CF_string(temp_var_name);
6720 string::size_type eos_info_pos = temp_var_name.find(eos_info_str);
6721 if(eos_info_pos !=string::npos)
6722 (*irv)->newname = temp_var_name.erase(eos_info_pos,eos_info_str.size());
6724 if(Remove_EOS5_Strings_NonEOS_Fields(temp_var_name)==
true)
6725 (*irv)->newname = get_CF_string(temp_var_name);
6730 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
6731 irv != this->cvars.end(); irv++) {
6732 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6733 ird!=(*irv)->dims.end(); ++ird) {
6734 string temp_dim_name = (*ird)->newname;
6735 bool remove_eos = Remove_EOS5_Strings(temp_dim_name);
6737 if(
true == remove_eos)
6738 (*ird)->newname = get_CF_string(temp_dim_name);
6740 string::size_type eos_info_pos = temp_dim_name.find(eos_info_str);
6741 if(eos_info_pos !=string::npos)
6742 (*ird)->newname = temp_dim_name.erase(eos_info_pos,eos_info_str.size());
6744 if(Remove_EOS5_Strings_NonEOS_Fields(temp_dim_name)==
true)
6745 (*ird)->newname = get_CF_string(temp_dim_name);
6754 for (vector<Var *>::iterator irv = this->
vars.begin();
6755 irv != this->vars.end(); irv++) {
6756 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
6757 ira != (*irv)->attrs.end();ira++) {
6760 if((*ira)->name ==
"coordinates") {
6761 string cor_values((*ira)->value.begin(),(*ira)->value.end()) ;
6762 bool change_cor_values =
false;
6764 if(cor_values.find(eos_str)==0) {
6765 if(cor_values.find(grid_str)!=string::npos) {
6766 cor_values = HDF5CFUtil::remove_substrings(cor_values,eos_str);
6767 cor_values = HDF5CFUtil::remove_substrings(cor_values,grid_str);
6768 string new_cor_values = HDF5CFUtil::remove_substrings(cor_values,df_str);
6769 if(new_cor_values.size() < cor_values.size()){
6770 change_cor_values =
true;
6771 cor_values = new_cor_values;
6774 else if(cor_values.find(zas_str)!=string::npos) {
6775 cor_values = HDF5CFUtil::remove_substrings(cor_values,eos_str);
6776 cor_values = HDF5CFUtil::remove_substrings(cor_values,zas_str);
6777 string new_cor_values = HDF5CFUtil::remove_substrings(cor_values,df_str);
6778 if(new_cor_values.size() < cor_values.size()){
6779 change_cor_values =
true;
6780 cor_values = new_cor_values;
6783 else if(cor_values.find(swath_str)!=string::npos) {
6784 cor_values = HDF5CFUtil::remove_substrings(cor_values,eos_str);
6785 cor_values = HDF5CFUtil::remove_substrings(cor_values,swath_str);
6786 string new_cor_values = HDF5CFUtil::remove_substrings(cor_values,df_str);
6787 if(new_cor_values.size() < cor_values.size()){
6788 change_cor_values =
true;
6789 cor_values = new_cor_values;
6792 new_cor_values = HDF5CFUtil::remove_substrings(cor_values,gf_str);
6793 if(new_cor_values.size() < cor_values.size()){
6794 change_cor_values =
true;
6795 cor_values = new_cor_values;
6800 if(
true == change_cor_values) {
6801 (*ira)->value.resize(cor_values.size());
6802 (*ira)->fstrsize=cor_values.size();
6803 (*ira)->strsize[0] = cor_values.size();
6804 copy(cor_values.begin(), cor_values.end(), (*ira)->value.begin());
6805 (*irv)->coord_attr_add_path =
false;
6816 bool GMFile:: Remove_EOS5_Strings(
string &var_name) {
6818 string eos_str=
"HDFEOS_";
6819 string grid_str=
"GRIDS_";
6820 string swath_str=
"SWATHS_";
6821 string zas_str=
"ZAS_";
6822 string df_str=
"Data_Fields_";
6823 string gf_str=
"Geolocation_Fields_";
6824 string temp_var_name = var_name;
6826 bool remove_eos =
false;
6828 string::size_type eos_pos = temp_var_name.find(eos_str);
6829 if(eos_pos!=string::npos) {
6830 temp_var_name.erase(eos_pos,eos_str.size());
6832 string::size_type grid_pos=temp_var_name.find(grid_str);
6833 string::size_type grid_df_pos=string::npos;
6834 if(grid_pos!=string::npos)
6835 grid_df_pos = temp_var_name.find(df_str,grid_pos);
6836 string::size_type zas_pos = string::npos;
6837 string::size_type zas_df_pos=string::npos;
6838 if(grid_pos==string::npos || grid_df_pos ==string::npos)
6839 zas_pos=temp_var_name.find(zas_str);
6840 if(zas_pos!=string::npos)
6841 zas_df_pos=temp_var_name.find(df_str,zas_pos);
6843 if(grid_pos !=string::npos && grid_df_pos!=string::npos) {
6844 temp_var_name.erase(grid_pos,grid_str.size());
6845 grid_df_pos = temp_var_name.find(df_str);
6846 temp_var_name.erase(grid_df_pos,df_str.size());
6849 else if(zas_pos!=string::npos && zas_df_pos!=string::npos){
6850 temp_var_name.erase(zas_pos,zas_str.size());
6851 zas_df_pos = temp_var_name.find(df_str);
6852 temp_var_name.erase(zas_df_pos,df_str.size());
6857 string::size_type swath_pos=temp_var_name.find(swath_str);
6858 string::size_type swath_df_pos=string::npos;
6859 if(swath_pos!=string::npos)
6860 swath_df_pos=temp_var_name.find(df_str,swath_pos);
6862 string::size_type swath_gf_pos=string::npos;
6863 if(swath_pos!=string::npos && swath_df_pos == string::npos)
6864 swath_gf_pos=temp_var_name.find(gf_str,swath_pos);
6866 if(swath_pos !=string::npos) {
6868 if(swath_df_pos!=string::npos) {
6869 temp_var_name.erase(swath_pos,swath_str.size());
6870 swath_df_pos = temp_var_name.find(df_str);
6871 temp_var_name.erase(swath_df_pos,df_str.size());
6874 else if(swath_gf_pos!=string::npos) {
6875 temp_var_name.erase(swath_pos,swath_str.size());
6876 swath_gf_pos = temp_var_name.find(gf_str);
6877 temp_var_name.erase(swath_gf_pos,gf_str.size());
6883 if(
true == remove_eos)
6884 var_name = temp_var_name;
6889 bool GMFile:: Remove_EOS5_Strings_NonEOS_Fields(
string &var_name) {
6891 string eos_str=
"HDFEOS_";
6892 string grid_str=
"GRIDS_";
6893 string swath_str=
"SWATHS_";
6894 string zas_str=
"ZAS_";
6895 string temp_var_name = var_name;
6897 bool remove_eos =
false;
6899 string::size_type eos_pos = temp_var_name.find(eos_str);
6900 if(eos_pos!=string::npos) {
6901 temp_var_name.erase(eos_pos,eos_str.size());
6905 if(temp_var_name.find(grid_str)==0)
6906 temp_var_name.erase(0,grid_str.size());
6907 else if(temp_var_name.find(swath_str)==0)
6908 temp_var_name.erase(0,swath_str.size());
6909 else if(temp_var_name.find(zas_str)==0)
6910 temp_var_name.erase(0,zas_str.size());
6912 if(
true == remove_eos)
6913 var_name = temp_var_name;
6934 if(this->unsupported_var_dtype ==
true) {
6937 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6938 ircv != this->cvars.end();) {
6939 if((*ircv)->newname.find(
"FakeDim")==0) {
6940 bool var_has_fakedim =
false;
6941 for (vector<Var*>::iterator irv2 = this->
vars.begin();
6942 irv2 != this->vars.end(); irv2++) {
6943 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
6944 ird !=(*irv2)->dims.end(); ird++) {
6945 if((*ird)->newname == (*ircv)->newname){
6946 var_has_fakedim =
true;
6950 if(var_has_fakedim ==
true)
6953 if(var_has_fakedim ==
false) {
6956 ircv = this->cvars.erase(ircv);
6978 if(
true == this->have_nc4_non_coord) {
6979 string nc4_non_coord=
"_nc4_non_coord_";
6980 size_t nc4_non_coord_size= nc4_non_coord.size();
6981 for (vector<Var*>::iterator irv = this->
vars.begin();
6982 irv != this->vars.end(); irv++) {
6983 if((*irv)->name.find(nc4_non_coord)==0)
6984 (*irv)->newname = (*irv)->newname.substr(nc4_non_coord_size,(*irv)->newname.size()-nc4_non_coord_size);
6987 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6988 ircv != this->cvars.end();++ircv) {
6989 if((*ircv)->name.find(nc4_non_coord)==0)
6990 (*ircv)->newname = (*ircv)->newname.substr(nc4_non_coord_size,(*ircv)->newname.size()-nc4_non_coord_size);
6998 BESDEBUG(
"h5",
"GMFile::Coming to Add_Path_Coor_Attr()"<<endl);
6999 string co_attrname =
"coordinates";
7000 for (vector<Var *>::iterator irv = this->
vars.begin();
7001 irv != this->vars.end(); ++irv) {
7002 if((*irv)->coord_attr_add_path ==
true) {
7003 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end();++ira) {
7005 if((*ira)->name == co_attrname) {
7006 string coor_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
7008 vector<string>cvalue_vec;
7009 HDF5CFUtil::Split_helper(cvalue_vec,coor_value,sep);
7010 string new_coor_value;
7011 for (
int i = 0; i<cvalue_vec.size();i++) {
7012 HDF5CFUtil::cha_co(cvalue_vec[i],(*irv)->fullpath);
7013 cvalue_vec[i] = get_CF_string(cvalue_vec[i]);
7015 new_coor_value = cvalue_vec[i];
7017 new_coor_value += sep+cvalue_vec[i];
7022 Replace_Var_Str_Attr((*irv),co_attrname,new_coor_value);
7037 GMFile::release_standalone_GMCVar_vector(vector<GMCVar*>&tempgc_vars){
7039 for (vector<GMCVar *>::iterator i = tempgc_vars.begin();
7040 i != tempgc_vars.end(); ) {
7042 i = tempgc_vars.erase(i);
7049 GMFile::add_ignored_info_attrs(
bool is_grp,
bool is_first){
7053 GMFile::add_ignored_info_objs(
bool is_dim_related,
bool is_first) {
7060 GMFile::ignored_dimscale_ref_list(
Var *var) {
7062 bool ignored_dimscale =
true;
7063 if(General_Product == this->product_type && GENERAL_DIMSCALE== this->gproduct_pattern) {
7065 bool has_dimscale =
false;
7066 bool has_reference_list =
false;
7067 for(vector<Attribute *>::iterator ira = var->attrs.begin();
7068 ira != var->attrs.end();ira++) {
7069 if((*ira)->name ==
"REFERENCE_LIST" &&
7070 false == HDF5CFUtil::cf_strict_support_type((*ira)->getType()))
7071 has_reference_list =
true;
7072 if((*ira)->name ==
"CLASS") {
7073 Retrieve_H5_Attr_Value(*ira,var->fullpath);
7075 class_value.resize((*ira)->value.size());
7076 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
7080 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
7081 has_dimscale =
true;
7085 if(
true == has_dimscale &&
true == has_reference_list) {
7086 ignored_dimscale=
false;
7092 return ignored_dimscale;
This class specifies the core engineering of mapping HDF5 to DAP by following CF.
#define throw1(a1)
The followings are convenient functions to throw exceptions with different.
include the entry functions to execute the handlers
This class represents one attribute.
This class repersents one dimension of an HDF5 dataset(variable).
This class retrieves all information from an HDF5 file.
std::vector< Group * > groups
Non-root group vectors.
virtual void Handle_Unsupported_Dspace(bool)
Handle unsupported HDF5 dataspaces for datasets.
virtual void Handle_Grid_Mapping_Vars()
Handle Grid Mapping Vars.
virtual void Handle_Unsupported_Others(bool)
Handle other unmapped objects/attributes.
virtual void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes.
std::vector< Var * > vars
Var vectors.
virtual void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name.
virtual void Retrieve_H5_Info(const char *path, hid_t file_id, bool)
std::vector< Attribute * > root_attrs
Root attribute vectors.
virtual void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes.
virtual void Flatten_Obj_Name(bool)
Flatten the object name.
virtual bool Have_Grid_Mapping_Attrs()
Check if having Grid Mapping Attrs.
This class is a derived class of CVar. It represents a coordinate variable for general HDF5 files.
virtual void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes for general HDF5 products.
virtual void Adjust_Obj_Name()
Adjust object names based on different general NASA HDF5 products.
virtual void Retrieve_H5_CVar_Supported_Attr_Values()
Retrieve coordinate variable attributes.
void Add_Path_Coord_Attr()
Update the coordinate attribute to include path and also flatten.
virtual bool Have_Grid_Mapping_Attrs()
Check if having Grid Mapping Attrs.
virtual void Adjust_Dim_Name()
Adjust dimension name for general NASA HDF5 products.
void Handle_Obj_NameClashing(bool)
Handle object name clashing for general NASA HDF5 products.
void Remove_Unused_FakeDimVars()
Unsupported datatype array may generate FakeDim. Remove them.
void Update_Product_Type()
Update "product type" attributes for general HDF5 products.
virtual void Retrieve_H5_Info(const char *path, hid_t file_id, bool include_attr)
Retrieve DDS information from the HDF5 file; real implementation for general HDF5 products.
virtual void Handle_SpVar()
Handle special variables for general NASA HDF5 products.
void Adjust_H5_Attr_Value(Attribute *attr)
Adjust attribute values for general HDF5 products.
virtual void Handle_Unsupported_Dspace(bool)
Handle unsupported HDF5 dataspaces for general HDF5 products.
virtual void Handle_SpVar_Attr()
Handle special variable attributes for general NASA HDF5 products.
virtual void Handle_Unsupported_Others(bool)
Handle other unmapped objects/attributes for general HDF5 products.
void Remove_Unneeded_Objects()
Remove unneeded objects.
void Add_Dim_Name()
Add dimension name.
virtual void Flatten_Obj_Name(bool include_attr)
Flatten the object name for general NASA HDF5 products.
virtual void Handle_Grid_Mapping_Vars()
Handle Grid Mapping Vars.
virtual void Handle_DimNameClashing()
virtual void Handle_Coor_Attr()
Handle "coordinates" attributes for general HDF5 products.
void Rename_NC4_NonCoordVars()
Remove the _nc4_non_coord from the variable new names.
virtual void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes for general HDF5 products.
virtual void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name for general NASA HDF5 products.
virtual void Handle_CVar()
Handle coordinate variables for general NASA HDF5 products.
This class is a derived class of Var. It represents a special general HDF5 product(currently ACOS and...
This class represents one HDF5 dataset(CF variable)
const std::vector< Dimension * > & getDimensions() const
Get the list of the dimensions.
static void Split(const char *s, int len, char sep, std::vector< std::string > &names)