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,_is_dap4)) {
422 ira = (*ircv)->attrs.erase(ira);
429 H5DataType temp_dtype = (*ircv)->getType();
430 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)) {
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,_is_dap4)) {
454 ira = (*ircv)->attrs.erase(ira);
461 H5DataType temp_dtype = (*ircv)->getType();
462 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)) {
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();
523 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
527 if ((
"DIMENSION_LIST" !=(*ira)->name) &&
528 (
"REFERENCE_LIST" != (*ira)->name ||
true == is_ignored))
529 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
535 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
536 irv != this->spvars.end(); ++irv) {
539 bool is_ignored = ignored_dimscale_ref_list((*irv));
540 if (
false == (*irv)->attrs.empty()) {
542 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
543 ira != (*irv)->attrs.end(); ++ira) {
544 H5DataType temp_dtype = (*ira)->getType();
546 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
550 if ((
"DIMENSION_LIST" !=(*ira)->name) &&
551 (
"REFERENCE_LIST" != (*ira)->name ||
true == is_ignored))
552 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
560 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
561 irv != this->cvars.end(); ++irv) {
562 if (
false == (*irv)->attrs.empty()) {
564 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
565 ira != (*irv)->attrs.end(); ++ira) {
566 H5DataType temp_dtype = (*ira)->getType();
568 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
569 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
576 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
577 irv != this->spvars.end(); ++irv) {
578 if (
false == (*irv)->attrs.empty()) {
580 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
581 ira != (*irv)->attrs.end(); ++ira) {
582 H5DataType temp_dtype = (*ira)->getType();
584 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4) || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
585 this->add_ignored_info_attrs(
false,(*irv)->fullpath,(*ira)->name);
599 BESDEBUG(
"h5",
"Coming to GMFile:Handle_Unsupported_Dspace()"<<endl);
600 if(
true == check_ignored)
601 Gen_Unsupported_Dspace_Info();
604 Handle_GM_Unsupported_Dspace(include_attr);
609 void GMFile:: Handle_GM_Unsupported_Dspace(
bool include_attr) {
611 BESDEBUG(
"h5",
"Coming to GMFile:Handle_GM_Unsupported_Dspace()"<<endl);
612 if(
true == this->unsupported_var_dspace) {
613 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
614 ircv != this->cvars.end(); ) {
615 if (
true == (*ircv)->unsupported_dspace ) {
623 ircv = this->cvars.erase(ircv);
630 for (vector<GMSPVar *>::iterator ircv = this->spvars.begin();
631 ircv != this->spvars.end(); ) {
633 if (
true == (*ircv)->unsupported_dspace) {
635 ircv = this->spvars.erase(ircv);
644 if(
true == include_attr) {
645 if(
true == this->unsupported_var_attr_dspace) {
646 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
647 ircv != this->cvars.end(); ++ircv) {
648 if (
false == (*ircv)->attrs.empty()) {
649 if (
true == (*ircv)->unsupported_attr_dspace) {
650 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
651 ira != (*ircv)->attrs.end(); ) {
652 if (0 == (*ira)->count) {
654 ira = (*ircv)->attrs.erase(ira);
664 for (vector<GMSPVar *>::iterator ircv = this->spvars.begin();
665 ircv != this->spvars.end(); ++ircv) {
666 if (
false == (*ircv)->attrs.empty()) {
667 if (
true == (*ircv)->unsupported_attr_dspace) {
668 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
669 ira != (*ircv)->attrs.end(); ) {
670 if (0 == (*ira)->count) {
672 ira = (*ircv)->attrs.erase(ira);
687 void GMFile:: Gen_Unsupported_Dspace_Info() {
689 File::Gen_Unsupported_Dspace_Info();
696 BESDEBUG(
"h5",
"Coming to GMFile:Handle_Unsupported_Others()"<<endl);
701 if(General_Product != this->product_type
702 || (General_Product == this->product_type && OTHERGMS != this->gproduct_pattern)){
705 if((General_Product == this->product_type && GENERAL_DIMSCALE== this->gproduct_pattern)
706 || (Mea_Ozone == this->product_type) || (Mea_SeaWiFS_L2 == this->product_type)
707 || (Mea_SeaWiFS_L3 == this->product_type)
708 || (OBPG_L3 == this->product_type))
710 remove_netCDF_internal_attributes(include_attr);
711 if(include_attr ==
true) {
713 for (vector<Attribute *>::iterator ira = this->
root_attrs.begin(); ira != this->root_attrs.end();) {
715 if((*ira)->name ==
"_nc3_strict") {
720 else if((*ira)->name ==
"_NCProperties") {
724 else if((*ira)->name ==
"_Netcdf4Coordinates") {
733 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
734 irv != this->cvars.end(); ++irv) {
735 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
736 ira != (*irv)->attrs.end();) {
737 if((*ira)->name ==
"CLASS") {
738 string class_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
742 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
744 ira = (*irv)->attrs.erase(ira);
751 else if((*ira)->name ==
"NAME") {
753 ira =(*irv)->attrs.erase(ira);
757 string name_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
758 if( 0 == name_value.compare(0,(*irv)->name.size(),(*irv)->name)) {
760 ira =(*irv)->attrs.erase(ira);
763 string netcdf_dim_mark=
"This is a netCDF dimension but not a netCDF variable";
764 if( 0 == name_value.compare(0,netcdf_dim_mark.size(),netcdf_dim_mark)) {
766 ira =(*irv)->attrs.erase(ira);
774 else if((*ira)->name ==
"_Netcdf4Dimid") {
776 ira =(*irv)->attrs.erase(ira);
778 else if((*ira)->name ==
"_Netcdf4Coordinates") {
780 ira =(*irv)->attrs.erase(ira);
784 else if((*ira)->name ==
"_nc3_strict") {
786 ira =(*irv)->attrs.erase(ira);
799 if(
true == this->check_ignored &&
true == include_attr) {
800 if(
true == HDF5RequestHandler::get_drop_long_string()){
801 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
802 irv != this->cvars.end(); ++irv) {
803 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
804 ira != (*irv)->attrs.end();++ira) {
805 if(
true == Check_DropLongStr((*irv),(*ira))) {
806 this->add_ignored_droplongstr_hdr();
807 this->add_ignored_var_longstr_info((*irv),(*ira));
812 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
813 irv != this->spvars.end(); ++irv) {
814 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
815 ira != (*irv)->attrs.end();++ira) {
816 if(
true == Check_DropLongStr((*irv),(*ira))) {
817 this->add_ignored_droplongstr_hdr();
818 this->add_ignored_var_longstr_info((*irv),(*ira));
827 if(
false == this->have_ignored)
828 this->add_no_ignored_info();
835 BESDEBUG(
"h5",
"Coming to GMFile:Add_Dim_Name()"<<endl);
836 switch(product_type) {
839 Add_Dim_Name_Mea_SeaWiFS();
842 Add_Dim_Name_Aqu_L3();
845 Add_Dim_Name_OSMAPL2S();
847 case ACOS_L2S_OR_OCO2_L1B:
848 Add_Dim_Name_ACOS_L2S_OCO2_L1B();
851 Add_Dim_Name_Mea_Ozonel3z();
860 Add_Dim_Name_OBPG_L3();
862 case General_Product:
863 Add_Dim_Name_General_Product();
866 throw1(
"Cannot generate dim. names for unsupported datatype");
871 for (vector<Var*>::iterator irv2 = this->
vars.begin();
872 irv2 != this->vars.end(); irv2++) {
873 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
874 ird !=(*irv2)->dims.end(); ird++) {
875 cerr<<
"Dimension name afet Add_Dim_Name "<<(*ird)->newname <<endl;
883 void GMFile::Add_Dim_Name_OBPG_L3() {
885 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_OBPG_L3()"<<endl);
888 Check_General_Product_Pattern();
889 Add_Dim_Name_General_Product();
893 void GMFile::Add_Dim_Name_Mea_SeaWiFS() {
895 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Mea_SeaWiFS()"<<endl);
896 pair<set<string>::iterator,
bool> setret;
897 if (Mea_SeaWiFS_L3 == product_type)
899 for (vector<Var *>::iterator irv = this->
vars.begin();
900 irv != this->vars.end(); ++irv) {
901 Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone((*irv));
902 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
903 ird !=(*irv)->dims.end();++ird) {
904 setret = dimnamelist.insert((*ird)->name);
905 if (
true == setret.second)
906 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
910 if (
true == dimnamelist.empty())
911 throw1(
"This product should have the dimension names, but no dimension names are found");
915 void GMFile::Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(
Var* var)
918 BESDEBUG(
"h5",
"Coming to Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone()"<<endl);
920 bool has_dimlist =
false;
921 bool has_class =
false;
922 bool has_reflist =
false;
924 for(vector<Attribute *>::iterator ira = var->attrs.begin();
925 ira != var->attrs.end();ira++) {
926 if (
"DIMENSION_LIST" == (*ira)->name) {
930 if (
"CLASS" == (*ira)->name)
932 if (
"REFERENCE_LIST" == (*ira)->name)
935 if (
true == has_dimlist)
937 if (
true == has_class &&
true == has_reflist)
941 if (
true == has_dimlist)
942 Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(var,dimlistattr);
945 else if(
true == has_class &&
true == has_reflist) {
946 if (var->dims.size() !=1)
947 throw2(
"dimension scale dataset must be 1 dimension, this is not true for variable ",
952 (var->dims)[0]->name = var->fullpath;
953 (var->dims)[0]->newname = var->fullpath;
954 pair<set<string>::iterator,
bool> setret;
955 setret = dimnamelist.insert((var->dims)[0]->name);
956 if (
true == setret.second)
957 Insert_One_NameSizeMap_Element((var->dims)[0]->name,(var->dims)[0]->size,(var->dims)[0]->unlimited_dim);
965 set<hsize_t> fakedimsize;
966 pair<set<hsize_t>::iterator,
bool> setsizeret;
967 for (vector<Dimension *>::iterator ird= var->dims.begin();
968 ird != var->dims.end(); ++ird) {
969 Add_One_FakeDim_Name(*ird);
970 setsizeret = fakedimsize.insert((*ird)->size);
971 if (
false == setsizeret.second)
972 Adjust_Duplicate_FakeDim_Name(*ird);
976 for (
int i = 0; i < var->dims.size(); ++i) {
977 Add_One_FakeDim_Name((var->dims)[i]);
978 bool gotoMainLoop =
false;
979 for (
int j =i-1; j>=0 && !gotoMainLoop; --j) {
980 if (((var->dims)[i])->size == ((var->dims)[j])->size){
981 Adjust_Duplicate_FakeDim_Name((var->dims)[i]);
992 void GMFile::Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(
Var *var,
Attribute*dimlistattr)
995 BESDEBUG(
"h5",
"Coming to Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone()"<<endl);
996 ssize_t objnamelen = -1;
1003 hid_t atype_id = -1;
1004 hid_t amemtype_id = -1;
1005 hid_t aspace_id = -1;
1006 hid_t ref_dset = -1;
1009 if(NULL == dimlistattr)
1010 throw2(
"Cannot obtain the dimension list attribute for variable ",var->name);
1013 throw2(
"The number of dimension should NOT be 0 for the variable ",var->name);
1017 vlbuf.resize(var->rank);
1019 dset_id = H5Dopen(this->fileid,(var->fullpath).c_str(),H5P_DEFAULT);
1021 throw2(
"Cannot open the dataset ",var->fullpath);
1023 attr_id = H5Aopen(dset_id,(dimlistattr->name).c_str(),H5P_DEFAULT);
1025 throw4(
"Cannot open the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
1027 atype_id = H5Aget_type(attr_id);
1029 throw4(
"Cannot obtain the datatype of the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
1031 amemtype_id = H5Tget_native_type(atype_id, H5T_DIR_ASCEND);
1033 if (amemtype_id < 0)
1034 throw2(
"Cannot obtain the memory datatype for the attribute ",dimlistattr->name);
1037 if (H5Aread(attr_id,amemtype_id,&vlbuf[0]) <0)
1038 throw2(
"Cannot obtain the referenced object for the variable ",var->name);
1041 vector<char> objname;
1042 int vlbuf_index = 0;
1045 for (vector<Dimension *>::iterator ird = var->dims.begin();
1046 ird != var->dims.end(); ++ird) {
1048 if(vlbuf[vlbuf_index].p== NULL)
1049 throw4(
"The dimension doesn't exist. Var name is ",var->name,
"; the dimension index is ",vlbuf_index);
1051 rbuf =((hobj_ref_t*)vlbuf[vlbuf_index].p)[0];
1052 if ((ref_dset = H5RDEREFERENCE(attr_id, H5R_OBJECT, &rbuf)) < 0)
1053 throw2(
"Cannot dereference from the DIMENSION_LIST attribute for the variable ",var->name);
1059 rbuf =((hobj_ref_t*)vl_ref[0].p)[0];
1061 dset1 = H5Rdereference2(attr_id,H5P_DEFAULT,H5R_OBJECT,&ds_ref_buf);
1064 H5R_ref_t new_rbuf =((H5R_ref_t*)vlbuf[vlbuf_index].p)[0];
1065 if ((ref_dset = H5Ropen_object((H5R_ref_t *)&new_rbuf, H5P_DEFAULT, H5P_DEFAULT))<0)
1066 throw2(
"Cannot dereference from the DIMENSION_LIST attribute for the variable ",var->name);
1067 H5Rdestroy(&new_rbuf);
1070 if ((objnamelen= H5Iget_name(ref_dset,NULL,0))<=0)
1071 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
1072 objname.resize(objnamelen+1);
1073 if ((objnamelen= H5Iget_name(ref_dset,&objname[0],objnamelen+1))<=0)
1074 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
1076 string objname_str = string(objname.begin(),objname.end());
1077 string trim_objname = objname_str.substr(0,objnamelen);
1078 (*ird)->name = string(trim_objname.begin(),trim_objname.end());
1080 pair<set<string>::iterator,
bool> setret;
1081 setret = dimnamelist.insert((*ird)->name);
1082 if (
true == setret.second)
1083 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1084 (*ird)->newname = (*ird)->name;
1090 if(vlbuf.size()!= 0) {
1092 if ((aspace_id = H5Aget_space(attr_id)) < 0)
1093 throw2(
"Cannot get hdf5 dataspace id for the attribute ",dimlistattr->name);
1095 if (H5Dvlen_reclaim(amemtype_id,aspace_id,H5P_DEFAULT,(
void*)&vlbuf[0])<0)
1096 throw2(
"Cannot successfully clean up the variable length memory for the variable ",var->name);
1098 H5Sclose(aspace_id);
1103 H5Tclose(amemtype_id);
1114 if(amemtype_id != -1)
1115 H5Tclose(amemtype_id);
1118 H5Sclose(aspace_id);
1132 void GMFile::Add_Dim_Name_Mea_Ozonel3z() {
1134 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Mea_Ozonel3z()"<<endl);
1136 bool use_dimscale =
false;
1138 for (vector<Group *>::iterator irg = this->
groups.begin();
1139 irg != this->groups.end(); ++ irg) {
1140 if (
"/Dimensions" == (*irg)->path) {
1141 use_dimscale =
true;
1146 if (
false == use_dimscale) {
1148 bool has_dimlist =
false;
1149 bool has_class =
false;
1150 bool has_reflist =
false;
1152 for (vector<Var *>::iterator irv = this->
vars.begin();
1153 irv != this->vars.end(); irv++) {
1155 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1156 ira != (*irv)->attrs.end();ira++) {
1157 if (
"DIMENSION_LIST" == (*ira)->name)
1160 if (
true == has_dimlist)
1164 if (
true == has_dimlist) {
1165 for (vector<Var *>::iterator irv = this->
vars.begin();
1166 irv != this->vars.end(); irv++) {
1168 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1169 ira != (*irv)->attrs.end();ira++) {
1170 if (
"CLASS" == (*ira)->name)
1172 if (
"REFERENCE_LIST" == (*ira)->name)
1174 if (
true == has_class &&
true == has_reflist)
1178 if (
true == has_class &&
1179 true == has_reflist)
1183 if (
true == has_class &&
true == has_reflist)
1184 use_dimscale =
true;
1188 if (
true == use_dimscale) {
1190 pair<set<string>::iterator,
bool> setret;
1191 for (vector<Var *>::iterator irv = this->
vars.begin();
1192 irv != this->vars.end(); ++irv) {
1193 Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone((*irv));
1194 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
1195 ird !=(*irv)->dims.end();++ird) {
1196 setret = dimnamelist.insert((*ird)->name);
1197 if(
true == setret.second)
1198 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1202 if (
true == dimnamelist.empty())
1203 throw1(
"This product should have the dimension names, but no dimension names are found");
1209 multimap<hsize_t,string> ozonedimsize_to_dimname;
1210 pair<multimap<hsize_t,string>::iterator,multimap<hsize_t,string>::iterator> mm_er_ret;
1211 multimap<hsize_t,string>::iterator irmm;
1213 for (vector<Var *>::iterator irv = this->
vars.begin();
1214 irv != this->vars.end(); ++irv) {
1215 bool is_cv = check_cv((*irv)->name);
1216 if (
true == is_cv) {
1217 if ((*irv)->dims.size() != 1)
1218 throw3(
"The coordinate variable", (*irv)->name,
" must be one dimension for the zonal average product");
1219 ozonedimsize_to_dimname.insert(pair<hsize_t,string>(((*irv)->dims)[0]->size,(*irv)->fullpath));
1223 set<hsize_t> fakedimsize;
1224 pair<set<hsize_t>::iterator,
bool> setsizeret;
1225 pair<set<string>::iterator,
bool> setret;
1226 pair<set<string>::iterator,
bool> tempsetret;
1227 set<string> tempdimnamelist;
1228 bool fakedimflag =
false;
1230 for (vector<Var *>::iterator irv = this->
vars.begin();
1231 irv != this->vars.end(); ++irv) {
1233 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
1234 ird != (*irv)->dims.end(); ++ird) {
1237 mm_er_ret = ozonedimsize_to_dimname.equal_range((*ird)->size);
1238 for (irmm = mm_er_ret.first; irmm!=mm_er_ret.second;irmm++) {
1239 setret = tempdimnamelist.insert(irmm->second);
1240 if (
true == setret.second) {
1241 (*ird)->name = irmm->second;
1242 (*ird)->newname = (*ird)->name;
1243 setret = dimnamelist.insert((*ird)->name);
1244 if(setret.second) Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1245 fakedimflag =
false;
1250 if (
true == fakedimflag) {
1251 Add_One_FakeDim_Name(*ird);
1252 setsizeret = fakedimsize.insert((*ird)->size);
1253 if (
false == setsizeret.second)
1254 Adjust_Duplicate_FakeDim_Name(*ird);
1258 tempdimnamelist.clear();
1259 fakedimsize.clear();
1265 bool GMFile::check_cv(
const string & varname)
const {
1267 BESDEBUG(
"h5",
"Coming to check_cv()"<<endl);
1268 const string lat_name =
"Latitude";
1269 const string time_name =
"Time";
1270 const string ratio_pressure_name =
"MixingRatioPressureLevels";
1271 const string profile_pressure_name =
"ProfilePressureLevels";
1272 const string wave_length_name =
"Wavelength";
1274 if (lat_name == varname)
1276 else if (time_name == varname)
1278 else if (ratio_pressure_name == varname)
1280 else if (profile_pressure_name == varname)
1282 else if (wave_length_name == varname)
1289 void GMFile::Add_Dim_Name_GPM()
1292 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_GPM()"<<endl);
1294 pair<set<string>::iterator,
bool> setret;
1306 for (vector<Var *>::iterator irv = this->
vars.begin();
1307 irv != this->vars.end(); irv++) {
1309 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1310 ira != (*irv)->attrs.end(); ++ira) {
1312 if(
"DimensionNames" == (*ira)->name) {
1314 Retrieve_H5_Attr_Value(*ira,(*irv)->fullpath);
1315 string dimname_value((*ira)->value.begin(),(*ira)->value.end());
1317 vector<string> ind_elems;
1321 if(ind_elems.size() != (
size_t)((*irv)->getRank())) {
1322 throw2(
"The number of dims obtained from the <DimensionNames> attribute is not equal to the rank ",
1326 for(
unsigned int i = 0; i<ind_elems.size(); ++i) {
1328 ((*irv)->dims)[i]->name = ind_elems[i];
1332 if(((*irv)->dims)[i]->name==
""){
1333 Add_One_FakeDim_Name(((*irv)->dims)[i]);
1336 string fakedim =
"FakeDim";
1337 stringstream sdim_count;
1338 sdim_count << dim_count;
1339 fakedim = fakedim + sdim_count.str();
1341 ((*irv)->dims)[i]->name = fakedim;
1342 ((*irv)->dims)[i]->newname = fakedim;
1343 ind_elems[i] = fakedim;
1348 ((*irv)->dims)[i]->newname = ind_elems[i];
1349 setret = dimnamelist.insert(((*irv)->dims)[i]->name);
1351 if (
true == setret.second) {
1352 Insert_One_NameSizeMap_Element(((*irv)->dims)[i]->name,
1353 ((*irv)->dims)[i]->size,
1354 ((*irv)->dims)[i]->unlimited_dim);
1357 if(dimname_to_dimsize[((*irv)->dims)[i]->name] !=((*irv)->dims)[i]->size)
1358 throw5(
"Dimension ",((*irv)->dims)[i]->name,
"has two sizes",
1359 ((*irv)->dims)[i]->size,dimname_to_dimsize[((*irv)->dims)[i]->name]);
1371 if(
false == has_dim_name_attr) {
1373 throw4(
"The variable ", (*irv)->name,
" doesn't have the DimensionNames attribute.",
1374 "We currently don't support this case. Please report to the NASA data center.");
1383 void GMFile::Add_Dim_Name_Aqu_L3()
1385 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Aqu_L3()"<<endl);
1386 for (vector<Var *>::iterator irv = this->
vars.begin();
1387 irv != this->vars.end(); irv++) {
1388 if (
"l3m_data" == (*irv)->name) {
1389 ((*irv)->dims)[0]->name =
"lat";
1390 ((*irv)->dims)[0]->newname =
"lat";
1391 ((*irv)->dims)[1]->name =
"lon";
1392 ((*irv)->dims)[1]->newname =
"lon";
1399 if (
"palette" == (*irv)->name) {
1401 ((*irv)->dims)[0]->name =
"paldim0";
1402 ((*irv)->dims)[0]->newname =
"paldim0";
1403 ((*irv)->dims)[1]->name =
"paldim1";
1404 ((*irv)->dims)[1]->newname =
"paldim1";
1412 void GMFile::Add_Dim_Name_OSMAPL2S(){
1414 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_OSMAPL2S()"<<endl);
1415 string tempvarname =
"";
1416 string key =
"_lat";
1417 string osmapl2sdim0 =
"YDim";
1418 string osmapl2sdim1 =
"XDim";
1421 multimap<hsize_t,string> osmapl2sdimsize_to_dimname;
1422 pair<multimap<hsize_t,string>::iterator,multimap<hsize_t,string>::iterator> mm_er_ret;
1423 multimap<hsize_t,string>::iterator irmm;
1426 for (vector<Var *>::iterator irv = this->
vars.begin();
1427 irv != this->vars.end(); ++irv) {
1428 tempvarname = (*irv)->name;
1429 if ((tempvarname.size() > key.size())&&
1430 (key == tempvarname.substr(tempvarname.size()-key.size(),key.size()))){
1431 if ((*irv)->dims.size() !=2)
1432 throw1(
"Currently only 2D lat/lon is supported for OSMAPL2S");
1433 osmapl2sdimsize_to_dimname.insert(pair<hsize_t,string>(((*irv)->dims)[0]->size,osmapl2sdim0));
1434 osmapl2sdimsize_to_dimname.insert(pair<hsize_t,string>(((*irv)->dims)[1]->size,osmapl2sdim1));
1439 set<hsize_t> fakedimsize;
1440 pair<set<hsize_t>::iterator,
bool> setsizeret;
1441 pair<set<string>::iterator,
bool> setret;
1442 pair<set<string>::iterator,
bool> tempsetret;
1443 set<string> tempdimnamelist;
1444 bool fakedimflag =
false;
1447 for (vector<Var *>::iterator irv = this->
vars.begin();
1448 irv != this->vars.end(); ++irv) {
1450 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
1451 ird != (*irv)->dims.end(); ++ird) {
1454 mm_er_ret = osmapl2sdimsize_to_dimname.equal_range((*ird)->size);
1455 for (irmm = mm_er_ret.first; irmm!=mm_er_ret.second;irmm++) {
1456 setret = tempdimnamelist.insert(irmm->second);
1457 if (setret.second) {
1458 (*ird)->name = irmm->second;
1459 (*ird)->newname = (*ird)->name;
1460 setret = dimnamelist.insert((*ird)->name);
1461 if(setret.second) Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
1462 fakedimflag =
false;
1467 if (
true == fakedimflag) {
1468 Add_One_FakeDim_Name(*ird);
1469 setsizeret = fakedimsize.insert((*ird)->size);
1470 if (!setsizeret.second)
1471 Adjust_Duplicate_FakeDim_Name(*ird);
1474 tempdimnamelist.clear();
1475 fakedimsize.clear();
1480 void GMFile::Add_Dim_Name_ACOS_L2S_OCO2_L1B(){
1482 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_ACOS_L2S_OCO2_L1B()"<<endl);
1483 for (vector<Var *>::iterator irv = this->
vars.begin();
1484 irv != this->vars.end(); ++irv) {
1486 set<hsize_t> fakedimsize;
1487 pair<set<hsize_t>::iterator,
bool> setsizeret;
1488 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
1489 ird != (*irv)->dims.end(); ++ird) {
1490 Add_One_FakeDim_Name(*ird);
1491 setsizeret = fakedimsize.insert((*ird)->size);
1492 if (
false == setsizeret.second)
1493 Adjust_Duplicate_FakeDim_Name(*ird);
1499 void GMFile::Add_Dim_Name_General_Product(){
1501 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_General_Product()"<<endl);
1504 if (GENERAL_DIMSCALE == this->gproduct_pattern){
1505 Add_Dim_Name_Dimscale_General_Product();
1508 else if (GENERAL_LATLON2D == this->gproduct_pattern)
1509 Add_Dim_Name_LatLon2D_General_Product();
1511 else if (GENERAL_LATLON1D == this->gproduct_pattern || GENERAL_LATLON_COOR_ATTR == this->gproduct_pattern)
1512 Add_Dim_Name_LatLon1D_Or_CoordAttr_General_Product();
1525 void GMFile::Check_General_Product_Pattern() {
1527 BESDEBUG(
"h5",
"Coming to Check_General_Product_Pattern()"<<endl);
1528 if(
false == Check_Dimscale_General_Product_Pattern()) {
1530 if(
false == Check_And_Update_New_GPM_L3())
1531 if(
false == Check_LatLon2D_General_Product_Pattern())
1532 if(
false == Check_LatLon1D_General_Product_Pattern())
1533 Check_LatLon_With_Coordinate_Attr_General_Product_Pattern();
1540 bool GMFile::Check_Dimscale_General_Product_Pattern() {
1542 BESDEBUG(
"h5",
"Coming to Check_Dimscale_General_Product_Pattern()"<<endl);
1543 bool ret_value =
false;
1544 bool has_dimlist =
false;
1545 bool has_dimscalelist =
false;
1548 for (vector<Var *>::iterator irv = this->
vars.begin();
1549 irv != this->vars.end(); ++irv) {
1550 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1551 ira != (*irv)->attrs.end();ira++) {
1552 if (
"DIMENSION_LIST" == (*ira)->name) {
1557 if (
true == has_dimlist)
1566 for (vector<Var *>::iterator irv = this->
vars.begin();
1567 irv != this->vars.end(); ++irv) {
1570 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1571 ira != (*irv)->attrs.end();ira++) {
1572 if (
"CLASS" == (*ira)->name) {
1574 Retrieve_H5_Attr_Value(*ira,(*irv)->fullpath);
1576 class_value.resize((*ira)->value.size());
1577 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
1581 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
1582 has_dimscalelist =
true;
1588 if (
true == has_dimscalelist)
1593 if (
true == has_dimscalelist) {
1594 if (
true == has_dimlist ) {
1595 this->gproduct_pattern = GENERAL_DIMSCALE;
1603 bool is_general_dimscale =
false;
1605 for (vector<Var *>::iterator irv = this->
vars.begin();
1606 irv != this->vars.end(); ++irv) {
1608 bool has_class_dscale =
false;
1609 bool has_name =
false;
1610 bool has_netcdf4_id =
false;
1612 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1613 ira != (*irv)->attrs.end();ira++) {
1614 if (
"CLASS" == (*ira)->name) {
1616 Retrieve_H5_Attr_Value(*ira,(*irv)->fullpath);
1618 class_value.resize((*ira)->value.size());
1619 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
1623 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE"))
1624 has_class_dscale=
true;
1626 else if (
"NAME" == (*ira)->name)
1628 else if (
"_Netcdf4Dimid" == (*ira)->name)
1629 has_netcdf4_id =
true;
1630 if(
true == has_class_dscale &&
true == has_name &&
true == has_netcdf4_id)
1631 is_general_dimscale =
true;
1634 if(
true == is_general_dimscale)
1639 if (
true == is_general_dimscale) {
1640 this->gproduct_pattern = GENERAL_DIMSCALE;
1649 bool GMFile::Check_And_Update_New_GPM_L3() {
1651 bool is_new_gpm_l3 =
false;
1652 unsigned int num_vars = this->
vars.size();
1653 unsigned sel_steps = num_vars/5;
1654 string dim_name=
"DimensionNames";
1655 bool has_dim_name =
false;
1662 vector<Var *>::iterator it_var_end;
1665 it_var_end = this->
vars.end();
1667 it_var_end = this->
vars.begin()+5*sel_steps;
1669 for (vector<Var *>::iterator irv = this->
vars.begin();
1670 irv != it_var_end; irv+=sel_steps) {
1672 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
1673 ira != (*irv)->attrs.end();ira++) {
1674 if(H5FSTRING == (*ira)->getType()) {
1675 if((*ira)->name == dim_name){
1676 has_dim_name =
true;
1681 if(
true == has_dim_name)
1690 if(
true == has_dim_name) {
1691 string attr_name_subset =
"GridHeader";
1692 BESDEBUG(
"h5",
"GMFile::Check_And_Update_New_GPM_L3() has attribute <DimensionNames>. "<<endl);
1693 for (vector<Group *>::iterator irg = this->
groups.begin();
1694 irg != this->groups.end(); ++ irg) {
1695 for(vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
1696 ira != (*irg)->attrs.end();ira++) {
1697 string attr_name = (*ira)->name;
1699 if(attr_name.find(attr_name_subset)!=string::npos) {
1700 this->product_type = GPM_L3_New;
1701 is_new_gpm_l3 =
true;
1705 if(
true == is_new_gpm_l3)
1709 return is_new_gpm_l3;
1715 bool GMFile::Check_LatLon2D_General_Product_Pattern() {
1717 BESDEBUG(
"h5",
"Coming to Check_LatLon2D_General_Product_Pattern()"<<endl);
1718 bool ret_value =
false;
1720 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"latitude",
"longitude");
1721 if(
false == ret_value) {
1722 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"Latitude",
"Longitude");
1723 if(
false == ret_value) {
1724 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"lat",
"lon");
1725 if(
false == ret_value)
1726 ret_value = Check_LatLon2D_General_Product_Pattern_Name_Size(
"cell_lat",
"cell_lon");
1731 if(
true == ret_value)
1732 this->gproduct_pattern = GENERAL_LATLON2D;
1739 bool GMFile::Check_LatLon2D_General_Product_Pattern_Name_Size(
const string & latname,
const string & lonname) {
1741 BESDEBUG(
"h5",
"Coming to Check_LatLon2D_General_Product_Pattern_Name_Size()"<<endl);
1742 bool ret_value =
false;
1743 bool ll_flag =
false;
1745 vector<size_t>lat_size(2,0);
1746 vector<size_t>lon_size(2,0);
1748 const string designed_group1 =
"/";
1749 const string designed_group2 =
"/Geolocation/";
1751 bool lat_flag_g1 =
false;
1752 bool lon_flag_g1 =
false;
1753 bool lat_flag_g2 =
false;
1754 bool lon_flag_g2 =
false;
1760 lat_flag_g1 = is_var_under_group(latname,designed_group1,2,lat_size);
1761 lon_flag_g1 = is_var_under_group(lonname,designed_group1,2,lon_size);
1762 if(lat_flag_g1 ==
true && lon_flag_g1 ==
true) {
1765 lat_flag_g2 = is_var_under_group(latname,designed_group2,2,lat_size);
1766 if(lat_flag_g2 ==
false) {
1767 lon_flag_g2 = is_var_under_group(lonname,designed_group2,2,lon_size);
1768 if(lon_flag_g2 ==
false)
1772 else if(lat_flag_g1 ==
false && lon_flag_g1 ==
false) {
1773 lat_flag_g2 = is_var_under_group(latname,designed_group2,2,lat_size);
1774 if(lat_flag_g2 ==
true) {
1775 lon_flag_g2 = is_var_under_group(lonname,designed_group2,2,lon_size);
1776 if(lon_flag_g2 ==
true)
1785 if(
false == ll_flag) {
1787 const string designed_group3 =
"/GeolocationData/";
1788 if(is_var_under_group(latname,designed_group3,2,lat_size) &&
1789 is_var_under_group(lonname,designed_group3,2,lon_size))
1795 for (vector<Var *>::iterator irv = this->
vars.begin();
1796 irv != this->vars.end(); ++irv) {
1798 if((*irv)->rank == 2) {
1799 if((*irv)->name == latname) {
1802 string lat_path =HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1808 bool has_right_lat =
false;
1809 if(
"/" == lat_path ||
"/Geolocation/" == lat_path)
1810 if(
"/" == lat_path ||
"/Geolocation/" == lat_path) {
1812 lat_size[0] = (*irv)->getDimensions()[0]->size;
1813 lat_size[1] = (*irv)->getDimensions()[1]->size;
1817 else if((*irv)->name == lonname) {
1818 string lon_path = HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1819 if(
"/" == lon_path ||
"/Geolocation/" == lon_path) {
1821 lon_size[0] = (*irv)->getDimensions()[0]->size;
1822 lon_size[1] = (*irv)->getDimensions()[1]->size;
1835 if(
true == ll_flag) {
1837 bool latlon_size_match =
true;
1838 for (
unsigned int size_index = 0; size_index <lat_size.size();size_index++) {
1839 if(lat_size[size_index] != lon_size[size_index]){
1840 latlon_size_match =
false;
1844 if (
true == latlon_size_match) {
1846 gp_latname = latname;
1847 gp_lonname = lonname;
1860 bool GMFile::Check_LatLon1D_General_Product_Pattern() {
1862 BESDEBUG(
"h5",
"Coming to Check_LatLon1D_General_Product_Pattern()"<<endl);
1863 bool ret_value =
false;
1865 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"latitude",
"longitude");
1866 if(
false == ret_value) {
1867 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"Latitude",
"Longitude");
1868 if(
false == ret_value) {
1869 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"lat",
"lon");
1870 if(
false == ret_value)
1871 ret_value = Check_LatLon1D_General_Product_Pattern_Name_Size(
"cell_lat",
"cell_lon");
1875 if(
true == ret_value)
1876 this->gproduct_pattern = GENERAL_LATLON1D;
1883 bool GMFile::Check_LatLon1D_General_Product_Pattern_Name_Size(
const string & latname,
const string & lonname) {
1885 BESDEBUG(
"h5",
"Coming to Check_LatLon1D_General_Product_Pattern_Name_Size()"<<endl);
1886 bool ret_value =
false;
1888 size_t lat_size = 0;
1889 size_t lon_size = 0;
1891 for (vector<Var *>::iterator irv = this->
vars.begin();
1892 irv != this->vars.end(); ++irv) {
1894 if((*irv)->rank == 1) {
1895 if((*irv)->name == latname) {
1897 string lat_path =HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1901 if(
"/" == lat_path ||
"/Geolocation/" == lat_path) {
1903 lat_size = (*irv)->getDimensions()[0]->size;
1906 else if((*irv)->name == lonname) {
1907 string lon_path = HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath);
1908 if(
"/" == lon_path ||
"/Geolocation/" == lon_path) {
1910 lon_size = (*irv)->getDimensions()[0]->size;
1920 bool latlon_size_match_grid =
true;
1926 if(lat_size == lon_size) {
1929 latlon_size_match_grid =
false;
1933 for (vector<Var *>::iterator irv = this->
vars.begin();
1934 irv != this->vars.end(); ++irv) {
1935 if((*irv)->rank >=2) {
1936 short ll_size_flag = 0;
1937 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
1938 ird != (*irv)->dims.end(); ++ird) {
1939 if(lat_size == (*ird)->size) {
1941 if(2 == ll_size_flag){
1946 if(2 == ll_size_flag) {
1947 latlon_size_match_grid =
true;
1956 if (
true == latlon_size_match_grid) {
1957 gp_latname = latname;
1958 gp_lonname = lonname;
1968 bool GMFile::Check_LatLon_With_Coordinate_Attr_General_Product_Pattern() {
1970 BESDEBUG(
"h5",
"Coming to Check_LatLon_With_Coordinate_Attr_General_Product_Pattern()"<<endl);
1971 bool ret_value =
false;
1972 string co_attrname =
"coordinates";
1973 string co_attrvalue=
"";
1974 string unit_attrname =
"units";
1975 string lat_unit_attrvalue =
"degrees_north";
1976 string lon_unit_attrvalue =
"degrees_east";
1978 bool coor_has_lat_flag =
false;
1979 bool coor_has_lon_flag =
false;
1981 vector<Var*> tempvar_lat;
1982 vector<Var*> tempvar_lon;
1985 for (vector<Var *>::iterator irv = this->
vars.begin();
1986 irv != this->vars.end(); ++irv) {
1987 if((*irv)->rank >=2) {
1988 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
1989 ira !=(*irv)->attrs.end();++ira) {
1993 if((*ira)->name == co_attrname) {
1994 Retrieve_H5_Attr_Value((*ira),(*irv)->fullpath);
1995 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
1996 vector<string> coord_values;
1998 HDF5CFUtil::Split_helper(coord_values,orig_attr_value,sep);
2000 for(vector<string>::iterator irs=coord_values.begin();irs!=coord_values.end();++irs) {
2001 string coord_value_suffix1;
2002 string coord_value_suffix2;
2003 string coord_value_suffix3;
2005 if((*irs).size() >=3) {
2008 coord_value_suffix1 = (*irs).substr((*irs).size()-3,3);
2011 if((*irs).size() >=8){
2012 coord_value_suffix2 = (*irs).substr((*irs).size()-8,8);
2013 if((*irs).size() >=9)
2014 coord_value_suffix3 = (*irs).substr((*irs).size()-9,9);
2019 if(coord_value_suffix1==
"lat" || coord_value_suffix2 ==
"latitude" || coord_value_suffix2 ==
"Latitude")
2020 coor_has_lat_flag =
true;
2021 else if(coord_value_suffix1==
"lon" || coord_value_suffix3 ==
"longitude" || coord_value_suffix3 ==
"Longitude")
2022 coor_has_lon_flag =
true;
2025 if(
true == coor_has_lat_flag &&
true == coor_has_lon_flag)
2029 if(
true == coor_has_lat_flag &&
true == coor_has_lon_flag)
2032 coor_has_lat_flag =
false;
2033 coor_has_lon_flag =
false;
2039 if(
true == coor_has_lat_flag &&
true == coor_has_lon_flag) {
2041 for (vector<Var *>::iterator irv = this->
vars.begin();
2042 irv != this->vars.end(); ++irv) {
2043 bool var_is_lat =
false;
2044 bool var_is_lon =
false;
2046 string varname = (*irv)->name;
2050 if(varname.size() >=3) {
2051 ll_ssuffix = varname.substr(varname.size()-3,3);
2052 if(varname.size() >=8) {
2053 ll_lsuffix1 = varname.substr(varname.size()-8,8);
2054 if(varname.size() >=9)
2055 ll_lsuffix2 = varname.substr(varname.size()-9,9);
2058 if(ll_ssuffix==
"lat" || ll_lsuffix1 ==
"latitude" || ll_lsuffix1 ==
"Latitude")
2060 else if(ll_ssuffix==
"lon" || ll_lsuffix2 ==
"longitude" || ll_lsuffix2 ==
"Longitude")
2064 if(
true == var_is_lat) {
2065 if((*irv)->rank > 0) {
2066 Var * lat =
new Var(*irv);
2067 tempvar_lat.push_back(lat);
2070 else if(
true == var_is_lon) {
2071 if((*irv)->rank >0) {
2072 Var * lon =
new Var(*irv);
2073 tempvar_lon.push_back(lon);
2083 for(vector<Var*>:: iterator irlat = tempvar_lat.begin(); irlat!=tempvar_lat.end();++irlat) {
2086 if((*irlat)->rank == 1)
2087 Build_lat1D_latlon_candidate(*irlat,tempvar_lon);
2090 else if((*irlat)->rank >1)
2091 Build_latg1D_latlon_candidate(*irlat,tempvar_lon);
2095 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin(); ivs!=latloncv_candidate_pairs.end();++ivs) {
2096 cerr<<
"struct lat lon names are " <<(*ivs).name1 <<
" and " << (*ivs).name2 <<endl;
2103 Build_unique_latlon_candidate();
2117 if(latloncv_candidate_pairs.size() >0) {
2118 int num_1d_rank = 0;
2119 int num_2d_rank = 0;
2120 int num_g2d_rank = 0;
2121 vector<struct Name_Size_2Pairs> temp_1d_latlon_pairs;
2122 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin();
2123 ivs!=latloncv_candidate_pairs.end();++ivs) {
2124 if(1 == (*ivs).rank) {
2126 temp_1d_latlon_pairs.push_back(*ivs);
2128 else if(2 == (*ivs).rank)
2130 else if((*ivs).rank >2)
2135 if (num_2d_rank !=0)
2137 else if(num_1d_rank!=0) {
2141 for(vector<struct Name_Size_2Pairs>::iterator ivs=temp_1d_latlon_pairs.begin();
2142 ivs!=temp_1d_latlon_pairs.end();++ivs) {
2143 if((*ivs).size1 != (*ivs).size2) {
2154 for (vector<Var *>::iterator irv = this->
vars.begin();
2155 irv != this->vars.end(); ++irv) {
2156 if((*irv)->rank >=2) {
2157 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
2158 ira !=(*irv)->attrs.end();++ira) {
2160 if((*ira)->name == co_attrname) {
2161 Retrieve_H5_Attr_Value((*ira),(*irv)->fullpath);
2162 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
2163 vector<string> coord_values;
2165 HDF5CFUtil::Split_helper(coord_values,orig_attr_value,sep);
2166 bool has_lat_flag =
false;
2167 bool has_lon_flag =
false;
2168 for (vector<string>::iterator itcv=coord_values.begin();itcv!=coord_values.end();++itcv) {
2169 if((*ivs).name1 == (*itcv))
2170 has_lat_flag =
true;
2171 else if((*ivs).name2 == (*itcv))
2172 has_lon_flag =
true;
2175 if(
true == has_lat_flag &&
true == has_lon_flag) {
2176 short has_same_ll_size = 0;
2177 for(vector<Dimension *>::iterator ird = (*irv)->dims.begin();ird!=(*irv)->dims.end();++ird){
2178 if((*ird)->size == (*ivs).size1)
2181 if(has_same_ll_size!=2){
2188 if(
false == ret_value)
2193 if(
true == ret_value)
2200 release_standalone_var_vector(tempvar_lat);
2201 release_standalone_var_vector(tempvar_lon);
2205 if(
true == ret_value)
2206 cerr<<
"This product is the coordinate type "<<endl;
2209 if(
true == ret_value)
2210 this->gproduct_pattern = GENERAL_LATLON_COOR_ATTR;
2216 void GMFile::Build_lat1D_latlon_candidate(
Var *lat,
const vector<Var*> &lon_vec) {
2218 BESDEBUG(
"h5",
"Coming to Build_lat1D_latlon_candidate()"<<endl);
2219 set<string> lon_candidate_path;
2220 vector< pair<string,hsize_t> > lon_path_size_vec;
2223 for(vector<Var *>::const_iterator irlon = lon_vec.begin(); irlon!=lon_vec.end();++irlon) {
2225 if (lat->rank == (*irlon)->rank) {
2226 pair<string,hsize_t>lon_path_size;
2227 lon_path_size.first = (*irlon)->fullpath;
2228 lon_path_size.second = (*irlon)->getDimensions()[0]->size;
2229 lon_path_size_vec.push_back(lon_path_size);
2234 if(lon_path_size_vec.size() == 1) {
2237 latlon_pair.name1 = lat->fullpath;
2238 latlon_pair.name2 = lon_path_size_vec[0].first;
2240 latlon_pair.size2 = lon_path_size_vec[0].second;
2241 latlon_pair.rank = lat->rank;
2242 latloncv_candidate_pairs.push_back(latlon_pair);
2245 else if(lon_path_size_vec.size() >1) {
2249 string lat_path = HDF5CFUtil::obtain_string_before_lastslash(lat->fullpath);
2250 pair<string,hsize_t> lon_final_path_size;
2251 short num_lon_match = 0;
2252 for(vector <pair<string,hsize_t> >::iterator islon =lon_path_size_vec.begin();islon!=lon_path_size_vec.end();++islon) {
2254 if(HDF5CFUtil::obtain_string_before_lastslash((*islon).first)==lat_path) {
2256 if(1 == num_lon_match)
2257 lon_final_path_size = *islon;
2258 else if(num_lon_match > 1)
2262 if(num_lon_match ==1) {
2264 latlon_pair.name1 = lat->fullpath;
2265 latlon_pair.name2 = lon_final_path_size.first;
2267 latlon_pair.size2 = lon_final_path_size.second;
2268 latlon_pair.rank = lat->rank;
2269 latloncv_candidate_pairs.push_back(latlon_pair);
2276 void GMFile::Build_latg1D_latlon_candidate(
Var *lat,
const vector<Var*> & lon_vec) {
2278 BESDEBUG(
"h5",
"Coming to Build_latg1D_latlon_candidate()"<<endl);
2279 set<string> lon_candidate_path;
2282 for(vector<Var*>:: const_iterator irlon = lon_vec.begin(); irlon!=lon_vec.end();++irlon) {
2284 if (lat->rank == (*irlon)->rank) {
2287 bool same_dim =
true;
2288 for(
int dim_index = 0; dim_index <lat->rank; dim_index++) {
2290 (*irlon)->getDimensions()[dim_index]->size){
2295 if(
true == same_dim)
2296 lon_candidate_path.insert((*irlon)->fullpath);
2301 if(lon_candidate_path.size() > 1) {
2303 string lat_path = HDF5CFUtil::obtain_string_before_lastslash(lat->fullpath);
2304 vector <string> lon_final_candidate_path_vec;
2305 for(set<string>::iterator islon_path =lon_candidate_path.begin();islon_path!=lon_candidate_path.end();++islon_path) {
2308 if(HDF5CFUtil::obtain_string_before_lastslash(*islon_path)==lat_path)
2309 lon_final_candidate_path_vec.push_back(*islon_path);
2312 if(lon_final_candidate_path_vec.size() == 1) {
2316 latlon_pair.name1 = lat->fullpath;
2317 latlon_pair.name2 = lon_final_candidate_path_vec[0];
2320 latlon_pair.rank = lat->rank;
2321 latloncv_candidate_pairs.push_back(latlon_pair);
2323 else if(lon_final_candidate_path_vec.size() >1) {
2330 string lat_name = HDF5CFUtil::obtain_string_after_lastslash(lat->fullpath);
2331 string lat_name_prefix1;
2332 string lat_name_prefix2;
2335 if(lat_name.size() >3) {
2336 lat_name_prefix1 = lat_name.substr(0,lat_name.size()-3);
2337 if(lat_name.size() >8)
2338 lat_name_prefix2 = lat_name.substr(0,lat_name.size()-8);
2340 string lon_name_prefix1;
2341 string lon_name_prefix2;
2343 for(vector<string>::iterator ilon = lon_final_candidate_path_vec.begin(); ilon!=lon_final_candidate_path_vec.end();++ilon) {
2344 string lon_name = HDF5CFUtil::obtain_string_after_lastslash(*ilon);
2345 if(lon_name.size() >3) {
2346 lon_name_prefix1 = lon_name.substr(0,lon_name.size()-3);
2347 if(lon_name.size() >9)
2348 lon_name_prefix2 = lon_name.substr(0,lon_name.size()-9);
2350 if((lat_name_prefix1 !=
"" && lat_name_prefix1 == lon_name_prefix1) ||
2351 (lat_name_prefix2 !=
"" && lat_name_prefix2 == lon_name_prefix2)) {
2354 latlon_pair.name1 = lat->fullpath;
2355 latlon_pair.name2 = *ilon;
2358 latlon_pair.rank = lat->rank;
2359 latloncv_candidate_pairs.push_back(latlon_pair);
2366 else if(lon_candidate_path.size() == 1) {
2370 latlon_pair.name1 = lat->fullpath;
2371 latlon_pair.name2 = *(lon_candidate_path.begin());
2374 latlon_pair.rank = lat->rank;
2375 latloncv_candidate_pairs.push_back(latlon_pair);
2383 void GMFile::Build_unique_latlon_candidate() {
2385 BESDEBUG(
"h5",
"Coming to Build_unique_latlon_candidate()"<<endl);
2386 set<int> duplicate_index;
2387 for(
unsigned int i= 0; i<latloncv_candidate_pairs.size();i++) {
2388 for(
unsigned int j=i+1;j<latloncv_candidate_pairs.size();j++) {
2389 if(latloncv_candidate_pairs[i].name2 == latloncv_candidate_pairs[j].name2) {
2390 duplicate_index.insert(i);
2391 duplicate_index.insert(j);
2397 for(set<int>::reverse_iterator its= duplicate_index.rbegin();its!=duplicate_index.rend();++its) {
2398 latloncv_candidate_pairs[*its] = latloncv_candidate_pairs.back();
2399 latloncv_candidate_pairs.pop_back();
2406 bool GMFile::Check_LatLonName_General_Product(
int ll_rank) {
2408 if(ll_rank <1 || ll_rank >2)
2409 throw2(
"Only support rank = 1 or 2 lat/lon case for the general product. The current rank is ",ll_rank);
2410 bool ret_value =
false;
2411 size_t lat2D_dimsize0 = 0;
2412 size_t lat2D_dimsize1 = 0;
2413 size_t lon2D_dimsize0 = 0;
2414 size_t lon2D_dimsize1 = 0;
2417 vector<short>ll_flag(3,0);
2419 vector<size_t>lat_size;
2420 vector<size_t>lon_size;
2425 lat_size.assign(6,0);
2426 lon_size.assign(6,0);
2429 for (vector<Var *>::iterator irv = this->
vars.begin();
2430 irv != this->vars.end(); ++irv) {
2432 if((*irv)->rank == ll_rank) {
2433 if((*irv)->name ==
"lat") {
2436 lat_size[0] = (*irv)->getDimensions()[0]->size;
2437 lat_size[1] = (*irv)->getDimensions()[1]->size;
2442 else if((*irv)->name ==
"lon") {
2445 lon_size[0] = (*irv)->getDimensions()[0]->size;
2446 lon_size[1] = (*irv)->getDimensions()[1]->size;
2451 else if((*irv)->name ==
"latitude"){
2454 lat_size[2] = (*irv)->getDimensions()[0]->size;
2455 lat_size[3] = (*irv)->getDimensions()[1]->size;
2459 else if((*irv)->name ==
"longitude"){
2462 lon_size[2] = (*irv)->getDimensions()[0]->size;
2463 lon_size[3] = (*irv)->getDimensions()[1]->size;
2468 else if((*irv)->name ==
"Latitude"){
2471 lat_size[4] = (*irv)->getDimensions()[0]->size;
2472 lat_size[5] = (*irv)->getDimensions()[1]->size;
2477 else if((*irv)->name ==
"Longitude"){
2480 lon_size[4] = (*irv)->getDimensions()[0]->size;
2481 lon_size[5] = (*irv)->getDimensions()[1]->size;
2487 int total_llflag = 0;
2488 for (
int i = 0; i < ll_flag.size();i++)
2493 if(1 == total_llflag) {
2494 bool latlon_size_match =
true;
2496 for (
int size_index = 0; size_index <lat_size.size();size_index++) {
2497 if(lat_size[size_index] != lon_size[size_index]){
2498 latlon_size_match =
false;
2504 if(
true == latlon_size_match) {
2506 if(2 == ll_flag[0]) {
2510 else if ( 2 == ll_flag[1]) {
2511 gp_latname =
"latitude";
2512 gp_lonname =
"longitude";
2515 else if (2 == ll_flag[2]){
2516 gp_latname =
"Latitude";
2517 gp_lonname =
"Longitude";
2527 void GMFile::Add_Dim_Name_LatLon2D_General_Product() {
2529 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_LatLon2D_General_Product()"<<endl);
2532 size_t latdimsize0 = 0;
2533 size_t latdimsize1 = 0;
2536 for (vector<Var *>::iterator irv = this->
vars.begin();
2537 irv != this->vars.end(); ++irv) {
2539 set<hsize_t> fakedimsize;
2540 pair<set<hsize_t>::iterator,
bool> setsizeret;
2541 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2542 ird != (*irv)->dims.end(); ++ird) {
2543 Add_One_FakeDim_Name(*ird);
2544 setsizeret = fakedimsize.insert((*ird)->size);
2547 if (
false == setsizeret.second)
2548 Adjust_Duplicate_FakeDim_Name(*ird);
2553 if((*irv)->name == gp_latname) {
2554 if((*irv)->rank != 2) {
2555 throw4(
"coordinate variables ",gp_latname,
2556 " must have rank 2 for the 2-D latlon case , the current rank is ",
2559 latdimname0 = (*irv)->getDimensions()[0]->name;
2560 latdimsize0 = (*irv)->getDimensions()[0]->size;
2562 latdimname1 = (*irv)->getDimensions()[1]->name;
2563 latdimsize1 = (*irv)->getDimensions()[1]->size;
2570 for (vector<Var *>::iterator irv = this->
vars.begin();
2571 irv != this->vars.end(); ++irv) {
2572 int lat_dim0_index = 0;
2573 int lat_dim1_index = 0;
2574 bool has_lat_dims_size =
false;
2576 for (
unsigned int dim_index = 0; dim_index <(*irv)->dims.size(); dim_index++) {
2579 if(((*irv)->dims[dim_index])->size == latdimsize0) {
2582 lat_dim0_index = dim_index;
2583 for(
unsigned int dim_index2 = dim_index+1;dim_index2 < (*irv)->dims.size();dim_index2++) {
2584 if(((*irv)->dims[dim_index2])->size == latdimsize1) {
2585 lat_dim1_index = dim_index2;
2586 has_lat_dims_size =
true;
2591 if(
true == has_lat_dims_size)
2595 if(
true == has_lat_dims_size) {
2596 ((*irv)->dims[lat_dim0_index])->name = latdimname0;
2599 ((*irv)->dims[lat_dim1_index])->name = latdimname1;
2610 set<string>tempdimnamelist;
2612 for (vector<Var *>::iterator irv = this->
vars.begin();
2613 irv != this->
vars.end(); ++irv) {
2614 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2615 ird != (*irv)->dims.end(); ++ird)
2616 tempdimnamelist.insert((*ird)->name);
2621 set<string>finaldimnamelist;
2622 string finaldimname_base =
"FakeDim";
2624 for(
unsigned int i = 0; i<tempdimnamelist.size();i++) {
2625 stringstream sfakedimindex;
2627 string finaldimname = finaldimname_base + sfakedimindex.str();
2628 finaldimnamelist.insert(finaldimname);
2633 if(finaldimnamelist != tempdimnamelist) {
2634 map<string,string> tempdimname_to_finaldimname;
2635 set<string>:: iterator tempit = tempdimnamelist.begin();
2636 set<string>:: iterator finalit = finaldimnamelist.begin();
2637 while(tempit != tempdimnamelist.end()) {
2638 tempdimname_to_finaldimname[*tempit] = *finalit;
2644 for (vector<Var *>::iterator irv = this->
vars.begin();
2645 irv != this->
vars.end(); ++irv) {
2646 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2647 ird != (*irv)->dims.end(); ++ird) {
2648 if(tempdimname_to_finaldimname.find((*ird)->name) !=tempdimname_to_finaldimname.end()){
2649 (*ird)->name = tempdimname_to_finaldimname[(*ird)->name];
2652 throw3(
"The dimension names ",(*ird)->name,
"cannot be found in the dim. name list.");
2658 dimnamelist.clear();
2659 dimnamelist = finaldimnamelist;
2662 dimname_to_dimsize.clear();
2663 for (vector<Var *>::iterator irv = this->
vars.begin();
2664 irv != this->vars.end(); ++irv) {
2665 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2666 ird != (*irv)->dims.end(); ++ird) {
2667 if(finaldimnamelist.find((*ird)->name)!=finaldimnamelist.end()) {
2668 dimname_to_dimsize[(*ird)->name] = (*ird)->size;
2669 dimname_to_unlimited[(*ird)->name] = (*ird)->unlimited_dim;
2670 finaldimnamelist.erase((*ird)->name);
2674 if(
true == finaldimnamelist.empty())
2679 for (vector<Var *>::iterator irv = this->
vars.begin();
2680 irv != this->vars.end(); ++irv) {
2681 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2682 ird != (*irv)->dims.end(); ++ird) {
2683 (*ird)->newname = (*ird)->name;
2691 void GMFile::Add_Dim_Name_LatLon1D_Or_CoordAttr_General_Product() {
2693 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_LatLon1D_Or_CoordAttr_General_Product()"<<endl);
2695 for (vector<Var *>::iterator irv = this->
vars.begin();
2696 irv != this->vars.end(); ++irv) {
2698 set<hsize_t> fakedimsize;
2699 pair<set<hsize_t>::iterator,
bool> setsizeret;
2700 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
2701 ird != (*irv)->dims.end(); ++ird) {
2702 Add_One_FakeDim_Name(*ird);
2703 setsizeret = fakedimsize.insert((*ird)->size);
2705 if (
false == setsizeret.second)
2706 Adjust_Duplicate_FakeDim_Name(*ird);
2712 void GMFile::Add_Dim_Name_Dimscale_General_Product() {
2714 BESDEBUG(
"h5",
"Coming to Add_Dim_Name_Dimscale_General_Product()"<<endl);
2716 pair<set<string>::iterator,
bool> setret;
2717 this->iscoard =
true;
2719 for (vector<Var *>::iterator irv = this->
vars.begin();
2720 irv != this->vars.end(); ++irv) {
2723 Handle_UseDimscale_Var_Dim_Names_General_Product((*irv));
2726 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
2727 ird !=(*irv)->dims.end();++ird) {
2728 setret = dimnamelist.insert((*ird)->name);
2729 if (
true == setret.second)
2730 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
2734 if (
true == dimnamelist.empty())
2735 throw1(
"This product should have the dimension names, but no dimension names are found");
2740 void GMFile::Handle_UseDimscale_Var_Dim_Names_General_Product(
Var *var) {
2742 BESDEBUG(
"h5",
"Coming to Handle_UseDimscale_Var_Dim_Names_General_Product()"<<endl);
2744 bool has_dimlist =
false;
2745 bool has_dimclass =
false;
2747 for(vector<Attribute *>::iterator ira = var->attrs.begin();
2748 ira != var->attrs.end();ira++) {
2749 if (
"DIMENSION_LIST" == (*ira)->name) {
2753 if (
"CLASS" == (*ira)->name) {
2755 Retrieve_H5_Attr_Value(*ira,var->fullpath);
2757 class_value.resize((*ira)->value.size());
2758 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
2762 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
2763 has_dimclass =
true;
2771 if (
true == has_dimlist)
2772 Add_UseDimscale_Var_Dim_Names_General_Product(var,dimlistattr);
2775 else if(
true == has_dimclass) {
2776 if (var->dims.size() !=1)
2777 throw2(
"Currently dimension scale dataset must be 1 dimension, this is not true for the dataset ",
2782 (var->dims)[0]->name = var->fullpath;
2783 (var->dims)[0]->newname = var->fullpath;
2784 pair<set<string>::iterator,
bool> setret;
2785 setret = dimnamelist.insert((var->dims)[0]->name);
2786 if (
true == setret.second)
2787 Insert_One_NameSizeMap_Element((var->dims)[0]->name,(var->dims)[0]->size,(var->dims)[0]->unlimited_dim);
2793 set<hsize_t> fakedimsize;
2794 pair<set<hsize_t>::iterator,
bool> setsizeret;
2795 for (vector<Dimension *>::iterator ird= var->dims.begin();
2796 ird != var->dims.end(); ++ird) {
2797 Add_One_FakeDim_Name(*ird);
2798 setsizeret = fakedimsize.insert((*ird)->size);
2800 if (
false == setsizeret.second)
2801 Adjust_Duplicate_FakeDim_Name(*ird);
2808 void GMFile::Add_UseDimscale_Var_Dim_Names_General_Product(
Var *var,
Attribute*dimlistattr)
2811 BESDEBUG(
"h5",
"Coming to Add_UseDimscale_Var_Dim_Names_General_Product()"<<endl);
2812 ssize_t objnamelen = -1;
2815 vector<hvl_t> vlbuf;
2819 hid_t atype_id = -1;
2820 hid_t amemtype_id = -1;
2821 hid_t aspace_id = -1;
2822 hid_t ref_dset = -1;
2824 if(NULL == dimlistattr)
2825 throw2(
"Cannot obtain the dimension list attribute for variable ",var->name);
2827 else if (0==var->rank)
2828 throw2(
"The number of dimension should NOT be 0 for the variable ",var->name);
2833 vlbuf.resize(var->rank);
2835 dset_id = H5Dopen(this->fileid,(var->fullpath).c_str(),H5P_DEFAULT);
2837 throw2(
"Cannot open the dataset ",var->fullpath);
2839 attr_id = H5Aopen(dset_id,(dimlistattr->name).c_str(),H5P_DEFAULT);
2841 throw4(
"Cannot open the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
2843 atype_id = H5Aget_type(attr_id);
2845 throw4(
"Cannot obtain the datatype of the attribute ",dimlistattr->name,
" of HDF5 dataset ",var->fullpath);
2847 amemtype_id = H5Tget_native_type(atype_id, H5T_DIR_ASCEND);
2849 if (amemtype_id < 0)
2850 throw2(
"Cannot obtain the memory datatype for the attribute ",dimlistattr->name);
2853 if (H5Aread(attr_id,amemtype_id,&vlbuf[0]) <0)
2854 throw2(
"Cannot obtain the referenced object for the variable ",var->name);
2857 vector<char> objname;
2858 int vlbuf_index = 0;
2861 for (vector<Dimension *>::iterator ird = var->dims.begin();
2862 ird != var->dims.end(); ++ird) {
2864 if(vlbuf[vlbuf_index].p== NULL)
2865 throw4(
"The dimension doesn't exist. Var name is ",var->name,
"; the dimension index is ",vlbuf_index);
2866 rbuf =((hobj_ref_t*)vlbuf[vlbuf_index].p)[0];
2867 if ((ref_dset = H5RDEREFERENCE(attr_id, H5R_OBJECT, &rbuf)) < 0)
2868 throw2(
"Cannot dereference from the DIMENSION_LIST attribute for the variable ",var->name);
2870 if ((objnamelen= H5Iget_name(ref_dset,NULL,0))<=0)
2871 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
2872 objname.resize(objnamelen+1);
2873 if ((objnamelen= H5Iget_name(ref_dset,&objname[0],objnamelen+1))<=0)
2874 throw2(
"Cannot obtain the dataset name dereferenced from the DIMENSION_LIST attribute for the variable ",var->name);
2876 string objname_str = string(objname.begin(),objname.end());
2882 string trim_objname = objname_str.substr(0,objnamelen);
2883 (*ird)->name = string(trim_objname.begin(),trim_objname.end());
2885 pair<set<string>::iterator,
bool> setret;
2886 setret = dimnamelist.insert((*ird)->name);
2887 if (
true == setret.second)
2888 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size,(*ird)->unlimited_dim);
2889 (*ird)->newname = (*ird)->name;
2897 if(vlbuf.size()!= 0) {
2899 if ((aspace_id = H5Aget_space(attr_id)) < 0)
2900 throw2(
"Cannot get hdf5 dataspace id for the attribute ",dimlistattr->name);
2902 if (H5Dvlen_reclaim(amemtype_id,aspace_id,H5P_DEFAULT,(
void*)&vlbuf[0])<0)
2903 throw2(
"Cannot successfully clean up the variable length memory for the variable ",var->name);
2905 H5Sclose(aspace_id);
2910 H5Tclose(amemtype_id);
2920 if(amemtype_id != -1)
2921 H5Tclose(amemtype_id);
2924 H5Sclose(aspace_id);
2941 BESDEBUG(
"h5",
"GMFile:: Coming to Handle_CVar()"<<endl);
2947 if (General_Product == this->product_type ||
2948 ACOS_L2S_OR_OCO2_L1B == this->product_type) {
2949 if (GENERAL_DIMSCALE == this->gproduct_pattern)
2950 Handle_CVar_Dimscale_General_Product();
2951 else if (GENERAL_LATLON1D == this->gproduct_pattern)
2952 Handle_CVar_LatLon1D_General_Product();
2953 else if (GENERAL_LATLON2D == this->gproduct_pattern)
2954 Handle_CVar_LatLon2D_General_Product();
2958 else if (Mea_SeaWiFS_L2 == this->product_type ||
2959 Mea_SeaWiFS_L3 == this->product_type)
2960 Handle_CVar_Mea_SeaWiFS();
2961 else if (Aqu_L3 == this->product_type)
2962 Handle_CVar_Aqu_L3();
2963 else if (OBPG_L3 == this->product_type)
2964 Handle_CVar_OBPG_L3();
2965 else if (OSMAPL2S == this->product_type)
2966 Handle_CVar_OSMAPL2S();
2967 else if (Mea_Ozone == this->product_type)
2968 Handle_CVar_Mea_Ozone();
2969 else if (GPMS_L3 == this->product_type || GPMM_L3 == this->product_type
2970 || GPM_L3_New == this->product_type )
2971 Handle_CVar_GPM_L3();
2972 else if (GPM_L1 == this->product_type)
2973 Handle_CVar_GPM_L1();
2977 void GMFile::Handle_CVar_GPM_L1() {
2979 BESDEBUG(
"h5",
"Coming to Handle_CVar_GPM_L1()"<<endl);
2982 for (vector<Var *>::iterator irv = this->
vars.begin();
2983 irv != this->vars.end(); ++irv) {
2984 if((*irv)->name==
"AlgorithmRuntimeInfo") {
2986 this->
vars.erase(irv);
2999 set<string> ll_dim_set;
3000 for (vector<Var *>::iterator irv = this->
vars.begin();
3001 irv != this->vars.end(); ) {
3002 if((*irv)->rank == 2 && (*irv)->name ==
"Latitude") {
3004 size_t lat_pos = (*irv)->fullpath.rfind(
"Latitude");
3005 string lat_path = (*irv)->fullpath.substr(0,lat_pos);
3006 GMcvar->cfdimname = lat_path + ((*irv)->dims)[0]->name;
3007 ll_dim_set.insert(((*irv)->dims)[0]->name);
3008 GMcvar->cvartype = CV_EXIST;
3009 GMcvar->product_type = product_type;
3010 this->cvars.push_back(GMcvar);
3012 irv = this->
vars.erase(irv);
3015 if((*irv)->rank == 2 && (*irv)->name ==
"Longitude") {
3017 size_t lon_pos = (*irv)->fullpath.rfind(
"Longitude");
3018 string lon_path = (*irv)->fullpath.substr(0,lon_pos);
3019 GMcvar->cfdimname = lon_path + ((*irv)->dims)[1]->name;
3020 ll_dim_set.insert(((*irv)->dims)[1]->name);
3021 GMcvar->cvartype = CV_EXIST;
3022 GMcvar->product_type = product_type;
3023 this->cvars.push_back(GMcvar);
3025 irv = this->
vars.erase(irv);
3034 set<string> cvdimset;
3035 pair<set<string>::iterator,
bool> setret;
3036 for (vector<Var *>::iterator irv = this->
vars.begin();
3037 irv != this->
vars.end(); ++irv) {
3038 for(vector<Dimension *>::iterator ird = (*irv)->dims.begin();
3039 ird != (*irv)->dims.end(); ++ird) {
3040 setret = cvdimset.insert((*ird)->name);
3041 cerr<<
"var name is "<<(*irv)->fullpath <<endl;
3042 if (
true == setret.second) {
3043 cerr<<
"dim name is "<<(*ird)->name <<endl;
3044 Insert_One_NameSizeMap_Element((*ird)->name,(*ird)->size);
3053 for (map<string,hsize_t>::const_iterator itd = dimname_to_dimsize.begin();
3054 itd!=dimname_to_dimsize.end();++itd) {
3057 if((ll_dim_set.find(itd->first)) == ll_dim_set.end()) {
3059 Create_Missing_CV(GMcvar,itd->first);
3060 this->cvars.push_back(GMcvar);
3067 void GMFile::Handle_CVar_GPM_L3() {
3069 BESDEBUG(
"h5",
"Coming to Handle_CVar_GPM_L3()"<<endl);
3074 for (map<string,hsize_t>::const_iterator itd = dimname_to_dimsize.begin();
3075 itd!=dimname_to_dimsize.end();++itd) {
3078 if(
"nlon" == itd->first ||
"nlat" == itd->first
3079 ||
"lnH" == itd->first ||
"ltH" == itd->first
3080 ||
"lnL" == itd->first ||
"ltL" == itd->first) {
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 if (
"nlat" ==GMcvar->name ||
"ltH" == GMcvar->name
3092 ||
"ltL" == GMcvar->name)
3093 GMcvar->cvartype = CV_LAT_MISS;
3094 else if (
"nlon" == GMcvar->name ||
"lnH" == GMcvar->name
3095 ||
"lnL" == GMcvar->name)
3096 GMcvar->cvartype = CV_LON_MISS;
3097 GMcvar->product_type = product_type;
3099 else if ((
"nlayer" == itd->first && (28 == itd->second || 19 == itd->second)) ||
3100 (
"hgt" == itd->first && 5 == itd->second) ||
3101 (
"nalt" == itd->first && 5 == itd->second)){
3102 GMcvar->name = itd->first;
3103 GMcvar->newname = GMcvar->name;
3104 GMcvar->fullpath = GMcvar->name;
3106 GMcvar->dtype = H5FLOAT32;
3108 gmcvar_dim->name = GMcvar->name;
3109 gmcvar_dim->newname = gmcvar_dim->name;
3110 GMcvar->dims.push_back(gmcvar_dim);
3111 GMcvar->cfdimname = gmcvar_dim->name;
3112 GMcvar->cvartype = CV_SPECIAL;
3113 GMcvar->product_type = product_type;
3116 Create_Missing_CV(GMcvar,itd->first);
3117 this->cvars.push_back(GMcvar);
3122 void GMFile::Handle_CVar_Mea_SeaWiFS() {
3124 BESDEBUG(
"h5",
"Coming to Handle_CVar_Mea_SeaWiFS()"<<endl);
3125 pair<set<string>::iterator,
bool> setret;
3126 set<string>tempdimnamelist = dimnamelist;
3128 for (set<string>::iterator irs = dimnamelist.begin();
3129 irs != dimnamelist.end();++irs) {
3130 for (vector<Var *>::iterator irv = this->
vars.begin();
3131 irv != this->vars.end(); ) {
3132 if ((*irs)== (*irv)->fullpath) {
3134 if (!iscoard && ((
"/natrack" == (*irs))
3135 ||
"/nxtrack" == (*irs))) {
3140 if((*irv)->dims.size()!=1)
3141 throw3(
"Coard coordinate variable ",(*irv)->name,
"is not 1D");
3144 tempdimnamelist.erase(*irs);
3146 GMcvar->cfdimname = *irs;
3147 GMcvar->cvartype = CV_EXIST;
3148 GMcvar->product_type = product_type;
3149 this->cvars.push_back(GMcvar);
3151 irv = this->
vars.erase(irv);
3154 else if(
false == iscoard) {
3157 if ((((*irs) ==
"/natrack") && ((*irv)->fullpath ==
"/latitude"))
3158 ||(((*irs) ==
"/nxtrack") && ((*irv)->fullpath ==
"/longitude"))) {
3159 tempdimnamelist.erase(*irs);
3161 GMcvar->cfdimname = *irs;
3162 GMcvar->cvartype = CV_EXIST;
3163 GMcvar->product_type = product_type;
3164 this->cvars.push_back(GMcvar);
3166 irv = this->
vars.erase(irv);
3182 for (set<string>::iterator irs = tempdimnamelist.begin();
3183 irs != tempdimnamelist.end();++irs) {
3185 Create_Missing_CV(GMcvar,*irs);
3186 this->cvars.push_back(GMcvar);
3191 void GMFile::Handle_CVar_OSMAPL2S() {
3193 BESDEBUG(
"h5",
"Coming to Handle_CVar_OSMAPL2S()"<<endl);
3194 pair<set<string>::iterator,
bool> setret;
3195 set<string>tempdimnamelist = dimnamelist;
3197 string key0 =
"_lat";
3198 string key1 =
"_lon";
3199 string osmapl2sdim0 =
"YDim";
3200 string osmapl2sdim1 =
"XDim";
3202 bool foundkey0 =
false;
3203 bool foundkey1 =
false;
3207 for (vector<Var *>::iterator irv = this->
vars.begin();
3208 irv != this->vars.end(); ) {
3210 tempvarname = (*irv)->name;
3212 if ((tempvarname.size() > key0.size())&&
3213 (key0 == tempvarname.substr(tempvarname.size()-key0.size(),key0.size()))){
3217 if (dimnamelist.find(osmapl2sdim0)== dimnamelist.end())
3218 throw5(
"variable ",tempvarname,
" must have dimension ",osmapl2sdim0,
" , but not found ");
3220 tempdimnamelist.erase(osmapl2sdim0);
3222 GMcvar->newname = GMcvar->name;
3223 GMcvar->cfdimname = osmapl2sdim0;
3224 GMcvar->cvartype = CV_EXIST;
3225 GMcvar->product_type = product_type;
3226 this->cvars.push_back(GMcvar);
3228 irv = this->
vars.erase(irv);
3231 else if ((tempvarname.size() > key1.size())&&
3232 (key1 == tempvarname.substr(tempvarname.size()-key1.size(),key1.size()))){
3236 if (dimnamelist.find(osmapl2sdim1)== dimnamelist.end())
3237 throw5(
"variable ",tempvarname,
" must have dimension ",osmapl2sdim1,
" , but not found ");
3239 tempdimnamelist.erase(osmapl2sdim1);
3242 GMcvar->newname = GMcvar->name;
3243 GMcvar->cfdimname = osmapl2sdim1;
3244 GMcvar->cvartype = CV_EXIST;
3245 GMcvar->product_type = product_type;
3246 this->cvars.push_back(GMcvar);
3248 irv = this->
vars.erase(irv);
3253 if (
true == foundkey0 &&
true == foundkey1)
3257 for (set<string>::iterator irs = tempdimnamelist.begin();
3258 irs != tempdimnamelist.end();++irs) {
3261 Create_Missing_CV(GMcvar,*irs);
3262 this->cvars.push_back(GMcvar);
3268 void GMFile::Handle_CVar_Aqu_L3() {
3270 BESDEBUG(
"h5",
"Coming to Handle_CVar_Aqu_L3()"<<endl);
3272 for (vector<Var *>::iterator irv = this->
vars.begin();
3273 irv != this->vars.end(); ++irv) {
3275 if (
"l3m_data" == (*irv)->name) {
3276 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
3277 ird != (*irv)->dims.end(); ++ird) {
3279 GMcvar->name = (*ird)->name;
3280 GMcvar->newname = GMcvar->name;
3281 GMcvar->fullpath = GMcvar->name;
3283 GMcvar->dtype = H5FLOAT32;
3285 gmcvar_dim->name = GMcvar->name;
3286 gmcvar_dim->newname = gmcvar_dim->name;
3287 GMcvar->dims.push_back(gmcvar_dim);
3288 GMcvar->cfdimname = gmcvar_dim->name;
3289 if (
"lat" ==GMcvar->name ) GMcvar->cvartype = CV_LAT_MISS;
3290 if (
"lon" == GMcvar->name ) GMcvar->cvartype = CV_LON_MISS;
3291 GMcvar->product_type = product_type;
3292 this->cvars.push_back(GMcvar);
3300 void GMFile::Handle_CVar_Mea_Ozone() {
3302 BESDEBUG(
"h5",
"Coming to Handle_CVar_Mea_Ozone()"<<endl);
3303 pair<set<string>::iterator,
bool> setret;
3304 set<string>tempdimnamelist = dimnamelist;
3306 if(
false == iscoard)
3307 throw1(
"Measure Ozone level 3 zonal average product must follow COARDS conventions");
3309 for (set<string>::iterator irs = dimnamelist.begin();
3310 irs != dimnamelist.end();++irs) {
3311 for (vector<Var *>::iterator irv = this->
vars.begin();
3312 irv != this->vars.end(); ) {
3313 if ((*irs)== (*irv)->fullpath) {
3315 if((*irv)->dims.size()!=1)
3316 throw3(
"Coard coordinate variable",(*irv)->name,
"is not 1D");
3319 tempdimnamelist.erase(*irs);
3321 GMcvar->cfdimname = *irs;
3322 GMcvar->cvartype = CV_EXIST;
3323 GMcvar->product_type = product_type;
3324 this->cvars.push_back(GMcvar);
3326 irv = this->
vars.erase(irv);
3334 for (set<string>::iterator irs = tempdimnamelist.begin();
3335 irs != tempdimnamelist.end();irs++) {
3338 Create_Missing_CV(GMcvar,*irs);
3339 this->cvars.push_back(GMcvar);
3344 void GMFile::Handle_CVar_Dimscale_General_Product() {
3346 BESDEBUG(
"h5",
"Coming to Handle_CVar_Dimscale_General_Product"<<endl);
3347 pair<set<string>::iterator,
bool> setret;
3348 set<string>tempdimnamelist = dimnamelist;
3350 for (set<string>::iterator irs = dimnamelist.begin();
3351 irs != dimnamelist.end();++irs) {
3352 for (vector<Var *>::iterator irv = this->
vars.begin();
3353 irv != this->vars.end(); ) {
3356 if ((*irs)== (*irv)->fullpath) {
3357 if((*irv)->dims.size()!=1)
3358 throw3(
"COARDS coordinate variable",(*irv)->name,
"is not 1D");
3361 tempdimnamelist.erase(*irs);
3363 GMcvar->cfdimname = *irs;
3366 bool is_netcdf_dimension = Is_netCDF_Dimension(*irv);
3370 if (
true == is_netcdf_dimension)
3371 GMcvar->cvartype = CV_FILLINDEX;
3373 GMcvar->cvartype = CV_EXIST;
3374 GMcvar->product_type = product_type;
3375 this->cvars.push_back(GMcvar);
3377 irv = this->
vars.erase(irv);
3386 Update_M2DLatLon_Dimscale_CVs();
3389 for (set<string>::iterator irs = tempdimnamelist.begin();
3390 irs != tempdimnamelist.end();irs++) {
3392 Create_Missing_CV(GMcvar,*irs);
3393 this->cvars.push_back(GMcvar);
3399 for (set<string>::iterator irs = dimnamelist.begin();
3400 irs != dimnamelist.end();irs++) {
3401 cerr<<
"dimension name is "<<(*irs)<<endl;
3410 void GMFile::Update_M2DLatLon_Dimscale_CVs() {
3412 BESDEBUG(
"h5",
"Coming to Update_M2DLatLon_Dimscale_CVs()"<<endl);
3414 if(
false == Check_1DGeolocation_Dimscale()) {
3417 vector<GMCVar*> tempcvar_1dlat;
3418 vector<GMCVar*> tempcvar_1dlon;
3421 Obtain_1DLatLon_CVs(tempcvar_1dlat,tempcvar_1dlon);
3424 vector<Var*> tempcvar_2dlat;
3425 vector<Var*> tempcvar_2dlon;
3431 map<string,int> latlon2d_path_to_index;
3434 Obtain_2DLatLon_Vars(tempcvar_2dlat,tempcvar_2dlon,latlon2d_path_to_index);
3437 for(vector<GMCVar *>::iterator irv = tempcvar_1dlat.begin();irv != tempcvar_1dlat.end();++irv)
3438 cerr<<
"1-D lat variable full path is "<<(*irv)->fullpath <<endl;
3439 for(vector<GMCVar *>::iterator irv = tempcvar_1dlon.begin();irv != tempcvar_1dlon.end();++irv)
3440 cerr<<
"1-D lon variable full path is "<<(*irv)->fullpath <<endl;
3442 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv)
3443 cerr<<
"2-D lat variable full path is "<<(*irv)->fullpath <<endl;
3444 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv)
3445 cerr<<
"2-D lon variable full path is "<<(*irv)->fullpath <<endl;
3449 Obtain_2DLLVars_With_Dims_not_1DLLCVars(tempcvar_2dlat,tempcvar_2dlon,tempcvar_1dlat,tempcvar_1dlon,latlon2d_path_to_index);
3452 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv)
3453 cerr<<
"2-D Left lat variable full path is "<<(*irv)->fullpath <<endl;
3454 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv)
3455 cerr<<
"2-D Left lon variable full path is "<<(*irv)->fullpath <<endl;
3460 Obtain_2DLLCVar_Candidate(tempcvar_2dlat,tempcvar_2dlon,latlon2d_path_to_index);
3463 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv)
3464 cerr<<
"Final candidate 2-D Left lat variable full path is "<<(*irv)->fullpath <<endl;
3465 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv)
3466 cerr<<
"Final candidate 2-D Left lon variable full path is "<<(*irv)->fullpath <<endl;
3471 vector<int> var2d_index;
3472 for (map<string,int>::const_iterator it= latlon2d_path_to_index.begin();it!=latlon2d_path_to_index.end();++it)
3473 var2d_index.push_back(it->second);
3475 Remove_2DLLCVar_Final_Candidate_from_Vars(var2d_index);
3478 if(tempcvar_2dlat.size()>0)
3483 set<string>dim_names_2d_cvs;
3485 for(vector<Var *>::iterator irv = tempcvar_2dlat.begin();irv != tempcvar_2dlat.end();++irv){
3489 dim_names_2d_cvs.insert(lat->cfdimname);
3490 lat->cvartype = CV_EXIST;
3491 lat->product_type = product_type;
3492 this->cvars.push_back(lat);
3494 for(vector<Var *>::iterator irv = tempcvar_2dlon.begin();irv != tempcvar_2dlon.end();++irv){
3498 dim_names_2d_cvs.insert(lon->cfdimname);
3499 lon->cvartype = CV_EXIST;
3500 lon->product_type = product_type;
3501 this->cvars.push_back(lon);
3507 for(vector<GMCVar*>::iterator ircv= this->cvars.begin();ircv !=this->cvars.end();) {
3508 if(1 == (*ircv)->rank) {
3509 if(dim_names_2d_cvs.find((*ircv)->cfdimname)!=dim_names_2d_cvs.end()) {
3510 if(CV_FILLINDEX == (*ircv)->cvartype) {
3512 ircv = this->cvars.erase(ircv);
3514 else if(CV_EXIST == (*ircv)->cvartype) {
3517 Var *var =
new Var(*ircv);
3518 this->
vars.push_back(var);
3522 ircv = this->cvars.erase(ircv);
3526 if(CV_LAT_MISS == (*ircv)->cvartype)
3527 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_LAT_MISS");
3528 else if(CV_LON_MISS == (*ircv)->cvartype)
3529 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_LON_MISS");
3530 else if(CV_NONLATLON_MISS == (*ircv)->cvartype)
3531 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_NONLATLON_MISS");
3532 else if(CV_MODIFY == (*ircv)->cvartype)
3533 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_MODIFY");
3534 else if(CV_SPECIAL == (*ircv)->cvartype)
3535 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_SPECIAL");
3537 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",(*ircv)->cfdimname,
"is a coordinate variable of type CV_UNSUPPORTED");
3554 for(set<string>::iterator irs = grp_cv_paths.begin();irs != grp_cv_paths.end();++irs) {
3555 cerr<<
"group path is "<< (*irs)<<endl;
3562 cerr<<
"File name is "<< this->path <<endl;
3563 cerr<<
"CV names are the following "<<endl;
3564 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ++i)
3565 cerr<<(*i)->fullpath <<endl;
3570 release_standalone_GMCVar_vector(tempcvar_1dlat);
3571 release_standalone_GMCVar_vector(tempcvar_1dlon);
3572 release_standalone_var_vector(tempcvar_2dlat);
3573 release_standalone_var_vector(tempcvar_2dlon);
3576 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ++i)
3577 cerr<<(*i)->fullpath <<endl;
3584 bool GMFile::Check_1DGeolocation_Dimscale() {
3586 BESDEBUG(
"h5",
"Coming to Check_1DGeolocation_Dimscale()"<<endl);
3587 bool has_only_1d_geolocation_cv =
false;
3588 bool has_1d_lat_cv_flag =
false;
3589 bool has_1d_lon_cv_flag =
false;
3592 hsize_t lat_size = 0;
3595 hsize_t lon_size = 0;
3598 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
3599 ircv != this->cvars.end(); ++ircv) {
3600 if((*ircv)->cvartype == CV_EXIST) {
3601 string attr_name =
"units";
3602 string lat_unit_value =
"degrees_north";
3603 string lon_unit_value =
"degrees_east";
3605 for(vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
3606 ira != (*ircv)->attrs.end();ira++) {
3608 if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lat_unit_value)) {
3609 lat_size = (*ircv)->getDimensions()[0]->size;
3610 lat_dimname = (*ircv)->getDimensions()[0]->name;
3611 has_1d_lat_cv_flag =
true;
3614 else if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lon_unit_value)){
3615 lon_size = (*ircv)->getDimensions()[0]->size;
3616 lon_dimname = (*ircv)->getDimensions()[0]->name;
3617 has_1d_lon_cv_flag =
true;
3626 if(
true == has_1d_lat_cv_flag ) {
3628 if(
true == has_1d_lon_cv_flag) {
3631 if(0 == this->
groups.size()) {
3635 if(lat_size == lon_size) {
3636 bool var_has_latdim =
false;
3637 bool var_has_londim =
false;
3638 for (vector<Var *>::iterator irv = this->
vars.begin();
3639 irv != this->vars.end(); ++irv) {
3640 if((*irv)->rank >= 2) {
3641 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
3642 ird !=(*irv)->dims.end();++ird) {
3643 if((*ird)->name == lat_dimname)
3644 var_has_latdim =
true;
3645 else if((*ird)->name == lon_dimname)
3646 var_has_londim =
true;
3648 if(
true == var_has_latdim &&
true == var_has_londim) {
3649 has_only_1d_geolocation_cv =
true;
3653 var_has_latdim =
false;
3654 var_has_londim =
false;
3660 has_only_1d_geolocation_cv =
true;
3664 bool has_2d_latname_flag =
false;
3665 bool has_2d_lonname_flag =
false;
3666 for (vector<Var *>::iterator irv = this->
vars.begin();
3667 irv != this->vars.end(); ++irv) {
3668 if((*irv)->rank == 2) {
3671 if(
true == Is_geolatlon((*irv)->name,
true))
3672 has_2d_latname_flag =
true;
3675 else if(
true == Is_geolatlon((*irv)->name,
false))
3676 has_2d_lonname_flag =
true;
3678 if((
true == has_2d_latname_flag) && (
true == has_2d_lonname_flag))
3683 if(has_2d_latname_flag !=
true || has_2d_lonname_flag !=
true) {
3686 has_2d_latname_flag =
false;
3687 has_2d_lonname_flag =
false;
3689 for (vector<Var *>::iterator irv = this->
vars.begin();
3690 irv != this->vars.end(); ++irv) {
3691 if((*irv)->rank == 2) {
3692 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
3693 ira != (*irv)->attrs.end(); ++ira) {
3695 if (
false == has_2d_latname_flag) {
3698 has_2d_latname_flag = has_latlon_cf_units((*ira),(*irv)->fullpath,
true);
3699 if(
true == has_2d_latname_flag)
3701 else if(
false == has_2d_lonname_flag) {
3704 has_2d_lonname_flag = has_latlon_cf_units((*ira),(*irv)->fullpath,
false);
3705 if(
true == has_2d_lonname_flag)
3709 else if(
false == has_2d_lonname_flag) {
3713 has_2d_lonname_flag = has_latlon_cf_units((*ira),(*irv)->fullpath,
false);
3714 if(
true == has_2d_lonname_flag)
3718 if(
true == has_2d_latname_flag &&
true == has_2d_lonname_flag)
3725 if(has_2d_latname_flag !=
true || has_2d_lonname_flag !=
true)
3726 has_only_1d_geolocation_cv =
true;
3731 has_only_1d_geolocation_cv =
true;
3737 if(has_only_1d_geolocation_cv ==
true)
3738 cerr <<
"has only 1D lat/lon CVs. "<<endl;
3740 cerr<<
"Possibly has 2D lat/lon CVs. "<<endl;
3743 return has_only_1d_geolocation_cv;
3749 void GMFile::Obtain_1DLatLon_CVs(vector<GMCVar*> &cvar_1dlat,vector<GMCVar*> &cvar_1dlon) {
3751 BESDEBUG(
"h5",
"Coming to Obtain_1DLatLon_CVs()"<<endl);
3752 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
3753 ircv != this->cvars.end(); ++ircv) {
3755 if((*ircv)->cvartype == CV_EXIST) {
3757 string attr_name =
"units";
3758 string lat_unit_value =
"degrees_north";
3759 string lon_unit_value =
"degrees_east";
3761 for(vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
3762 ira != (*ircv)->attrs.end();ira++) {
3765 if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lat_unit_value)) {
3768 lat->cvartype = (*ircv)->cvartype;
3769 lat->product_type = (*ircv)->product_type;
3770 cvar_1dlat.push_back(lat);
3773 else if(
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lon_unit_value)){
3776 lon->cvartype = (*ircv)->cvartype;
3777 lon->product_type = (*ircv)->product_type;
3778 cvar_1dlon.push_back(lon);
3789 void GMFile::Obtain_2DLatLon_Vars(vector<Var*> &var_2dlat,vector<Var*> &var_2dlon,map<string,int> & latlon2d_path_to_index) {
3791 BESDEBUG(
"h5",
"Coming to Obtain_2DLatLon_Vars()"<<endl);
3792 for (vector<Var *>::iterator irv = this->
vars.begin();
3793 irv != this->vars.end(); ++irv) {
3794 if((*irv)->rank == 2) {
3797 if(
true == Is_geolatlon((*irv)->name,
true)) {
3798 Var *lat =
new Var(*irv);
3799 var_2dlat.push_back(lat);
3800 latlon2d_path_to_index[(*irv)->fullpath]= distance(this->
vars.begin(),irv);
3805 bool has_2dlat =
false;
3806 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
3807 ira != (*irv)->attrs.end(); ++ira) {
3810 if(
true == has_latlon_cf_units((*ira),(*irv)->fullpath,
true)) {
3811 Var *lat =
new Var(*irv);
3812 var_2dlat.push_back(lat);
3813 latlon2d_path_to_index[(*irv)->fullpath] = distance(this->
vars.begin(),irv);
3819 if(
true == has_2dlat)
3824 if(
true == Is_geolatlon((*irv)->name,
false)) {
3825 Var *lon =
new Var(*irv);
3826 latlon2d_path_to_index[(*irv)->fullpath] = distance(this->
vars.begin(),irv);
3827 var_2dlon.push_back(lon);
3830 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
3831 ira != (*irv)->attrs.end(); ++ira) {
3834 if(
true == has_latlon_cf_units((*ira),(*irv)->fullpath,
false)) {
3835 Var *lon =
new Var(*irv);
3836 latlon2d_path_to_index[(*irv)->fullpath] = distance(this->
vars.begin(),irv);
3837 var_2dlon.push_back(lon);
3848 void GMFile::Obtain_2DLLVars_With_Dims_not_1DLLCVars(vector<Var*> &var_2dlat,
3849 vector<Var*> &var_2dlon,
3850 vector<GMCVar*> &cvar_1dlat,
3851 vector<GMCVar*> &cvar_1dlon,
3852 map<string,int> &latlon2d_path_to_index) {
3854 BESDEBUG(
"h5",
"Coming to Obtain_2DLLVars_With_Dims_not_1DLLCVars()"<<endl);
3856 for(vector<Var *>::iterator irv = var_2dlat.begin();irv != var_2dlat.end();) {
3857 bool remove_2dlat =
false;
3858 for(vector<GMCVar *>::iterator ircv = cvar_1dlat.begin();ircv != cvar_1dlat.end();++ircv) {
3859 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
3860 ird!=(*irv)->dims.end(); ++ird) {
3861 if((*ird)->name == (*ircv)->getDimensions()[0]->name &&
3862 (*ird)->size == (*ircv)->getDimensions()[0]->size) {
3863 latlon2d_path_to_index.erase((*irv)->fullpath);
3865 irv = var_2dlat.erase(irv);
3866 remove_2dlat =
true;
3870 if(
true == remove_2dlat)
3874 if(
false == remove_2dlat)
3879 for(vector<Var *>::iterator irv = var_2dlon.begin();irv != var_2dlon.end();) {
3880 bool remove_2dlon =
false;
3881 for(vector<GMCVar *>::iterator ircv = cvar_1dlon.begin();ircv != cvar_1dlon.end();++ircv) {
3882 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
3883 ird!=(*irv)->dims.end(); ++ird) {
3884 if((*ird)->name == (*ircv)->getDimensions()[0]->name &&
3885 (*ird)->size == (*ircv)->getDimensions()[0]->size) {
3886 latlon2d_path_to_index.erase((*irv)->fullpath);
3888 irv = var_2dlon.erase(irv);
3889 remove_2dlon =
true;
3893 if(
true == remove_2dlon)
3897 if(
false == remove_2dlon)
3904 void GMFile::Obtain_2DLLCVar_Candidate(vector<Var*> &var_2dlat,
3905 vector<Var*> &var_2dlon,
3906 map<string,int>& latlon2d_path_to_index) {
3907 BESDEBUG(
"h5",
"Coming to Obtain_2DLLCVar_Candidate()"<<endl);
3910 vector<string> lon2d_group_paths;
3912 for(vector<Var *>::iterator irv_2dlat = var_2dlat.begin();irv_2dlat !=var_2dlat.end();) {
3913 for(vector<Var *>::iterator irv_2dlon = var_2dlon.begin();irv_2dlon != var_2dlon.end();++irv_2dlon) {
3914 if(((*irv_2dlat)->getDimensions()[0]->name == (*irv_2dlon)->getDimensions()[0]->name) &&
3915 ((*irv_2dlat)->getDimensions()[0]->size == (*irv_2dlon)->getDimensions()[0]->size) &&
3916 ((*irv_2dlat)->getDimensions()[1]->name == (*irv_2dlon)->getDimensions()[1]->name) &&
3917 ((*irv_2dlat)->getDimensions()[1]->size == (*irv_2dlon)->getDimensions()[1]->size))
3918 lon2d_group_paths.push_back(HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlon)->fullpath));
3922 if(0 == lon2d_group_paths.size()) {
3923 latlon2d_path_to_index.erase((*irv_2dlat)->fullpath);
3925 irv_2dlat = var_2dlat.erase(irv_2dlat);
3929 string lat2d_group_path = HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlat)->fullpath);
3932 short lon2d_has_lat2d_group_path_flag = 0;
3933 for(vector<string>::iterator ivs = lon2d_group_paths.begin();ivs!=lon2d_group_paths.end();++ivs) {
3934 if((*ivs)==lat2d_group_path)
3935 lon2d_has_lat2d_group_path_flag++;
3939 if(0 == lon2d_has_lat2d_group_path_flag) {
3940 latlon2d_path_to_index.erase((*irv_2dlat)->fullpath);
3942 irv_2dlat = var_2dlat.erase(irv_2dlat);
3945 else if (1== lon2d_has_lat2d_group_path_flag) {
3952 grp_cv_paths.insert(lat2d_group_path);
3953 latlon2d_path_to_index.erase((*irv_2dlat)->fullpath);
3955 irv_2dlat = var_2dlat.erase(irv_2dlat);
3960 lon2d_group_paths.clear();
3964 for(vector<Var *>::iterator irv_2dlat = var_2dlat.begin();irv_2dlat !=var_2dlat.end();++irv_2dlat)
3965 cerr<<
"2 left 2-D lat variable full path is: "<<(*irv_2dlat)->fullpath <<endl;
3971 vector<string> lat2d_group_paths;
3974 for(vector<Var *>::iterator irv_2dlon = var_2dlon.begin();irv_2dlon !=var_2dlon.end();) {
3975 for(vector<Var *>::iterator irv_2dlat = var_2dlat.begin();irv_2dlat != var_2dlat.end();++irv_2dlat) {
3976 if(((*irv_2dlat)->getDimensions()[0]->name == (*irv_2dlon)->getDimensions()[0]->name) &&
3977 ((*irv_2dlat)->getDimensions()[0]->size == (*irv_2dlon)->getDimensions()[0]->size) &&
3978 ((*irv_2dlat)->getDimensions()[1]->name == (*irv_2dlon)->getDimensions()[1]->name) &&
3979 ((*irv_2dlat)->getDimensions()[1]->size == (*irv_2dlon)->getDimensions()[1]->size))
3980 lat2d_group_paths.push_back(HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlat)->fullpath));
3984 if(0 == lat2d_group_paths.size()) {
3985 latlon2d_path_to_index.erase((*irv_2dlon)->fullpath);
3987 irv_2dlon = var_2dlon.erase(irv_2dlon);
3990 string lon2d_group_path = HDF5CFUtil::obtain_string_before_lastslash((*irv_2dlon)->fullpath);
3993 short lat2d_has_lon2d_group_path_flag = 0;
3994 for(vector<string>::iterator ivs = lat2d_group_paths.begin();ivs!=lat2d_group_paths.end();++ivs) {
3995 if((*ivs)==lon2d_group_path)
3996 lat2d_has_lon2d_group_path_flag++;
4000 if(0 == lat2d_has_lon2d_group_path_flag) {
4001 latlon2d_path_to_index.erase((*irv_2dlon)->fullpath);
4003 irv_2dlon = var_2dlon.erase(irv_2dlon);
4006 else if (1== lat2d_has_lon2d_group_path_flag) {
4013 grp_cv_paths.insert(lon2d_group_path);
4014 latlon2d_path_to_index.erase((*irv_2dlon)->fullpath);
4016 irv_2dlon = var_2dlon.erase(irv_2dlon);
4020 lat2d_group_paths.clear();
4023 for(vector<Var*>::iterator itv = var_2dlat.begin(); itv!= var_2dlat.end();++itv) {
4024 cerr<<
"Before unique, 2-D CV latitude name is "<<(*itv)->fullpath <<endl;
4026 for(vector<Var*>::iterator itv = var_2dlon.begin(); itv!= var_2dlon.end();++itv) {
4027 cerr<<
"Before unique, 2-D CV longitude name is "<<(*itv)->fullpath <<endl;
4032 Obtain_unique_2dCV(var_2dlat,latlon2d_path_to_index);
4033 Obtain_unique_2dCV(var_2dlon,latlon2d_path_to_index);
4035 for(vector<Var*>::iterator itv = var_2dlat.begin(); itv!= var_2dlat.end();++itv) {
4036 cerr<<
"2-D CV latitude name is "<<(*itv)->fullpath <<endl;
4038 for(vector<Var*>::iterator itv = var_2dlon.begin(); itv!= var_2dlon.end();++itv) {
4039 cerr<<
"2-D CV longitude name is "<<(*itv)->fullpath <<endl;
4044 if(var_2dlat.size() != var_2dlon.size()) {
4045 throw1(
"Error in generating 2-D lat/lon CVs. The size of 2d-lat should be the same as that of 2d-lon.");
4051 void GMFile::Obtain_unique_2dCV(vector<Var*> &var_ll,map<string,int>&latlon2d_path_to_index){
4053 BESDEBUG(
"h5",
"Coming to Obtain_unique_2dCV()"<<endl);
4054 vector<bool> var_share_dims(var_ll.size(),
false);
4056 for(
unsigned int i = 0; i <var_ll.size();i++) {
4059 string var_ll_i_path = HDF5CFUtil::obtain_string_before_lastslash(var_ll[i]->fullpath);
4062 for(
unsigned int j = i+1; j<var_ll.size();j++) {
4063 if((var_ll[i]->getDimensions()[0]->name == var_ll[j]->getDimensions()[0]->name)
4064 ||(var_ll[i]->getDimensions()[0]->name == var_ll[j]->getDimensions()[1]->name)
4065 ||(var_ll[i]->getDimensions()[1]->name == var_ll[j]->getDimensions()[0]->name)
4066 ||(var_ll[i]->getDimensions()[1]->name == var_ll[j]->getDimensions()[1]->name)){
4067 string var_ll_j_path = HDF5CFUtil::obtain_string_before_lastslash(var_ll[j]->fullpath);
4074 if(var_ll_i_path.size() > var_ll_j_path.size()) {
4078 if(var_ll_i_path.compare(0,var_ll_j_path.size(),var_ll_j_path)==0) {
4079 var_share_dims[i] =
true;
4080 grp_cv_paths.insert(var_ll_i_path);
4083 var_share_dims[i] =
true;
4084 var_share_dims[j] =
true;
4086 grp_cv_paths.insert(var_ll_i_path);
4087 grp_cv_paths.insert(var_ll_j_path);
4090 else if (var_ll_i_path.size() == var_ll_j_path.size()) {
4091 var_share_dims[i] =
true;
4092 var_share_dims[j] =
true;
4093 if(var_ll_i_path == var_ll_j_path)
4094 grp_cv_paths.insert(var_ll_i_path);
4096 grp_cv_paths.insert(var_ll_i_path);
4097 grp_cv_paths.insert(var_ll_j_path);
4103 if(var_ll_j_path.compare(0,var_ll_i_path.size(),var_ll_i_path)==0) {
4104 var_share_dims[j] =
true;
4105 grp_cv_paths.insert(var_ll_j_path);
4108 var_share_dims[i] =
true;
4109 var_share_dims[j] =
true;
4111 grp_cv_paths.insert(var_ll_i_path);
4112 grp_cv_paths.insert(var_ll_j_path);
4122 for(vector<Var*>::iterator itv = var_ll.begin(); itv!= var_ll.end();) {
4123 if(
true == var_share_dims[var_index]) {
4124 latlon2d_path_to_index.erase((*itv)->fullpath);
4126 itv = var_ll.erase(itv);
4137 void GMFile::Remove_2DLLCVar_Final_Candidate_from_Vars(vector<int> &var2d_index) {
4139 BESDEBUG(
"h5",
"Coming to Remove_2DLLCVar_Final_Candidate_from_Vars()"<<endl);
4141 sort(var2d_index.begin(),var2d_index.end());
4142 vector<Var *>::iterator it = this->
vars.begin();
4148 for (
unsigned int i = 0; i <var2d_index.size();i++) {
4150 advance(it,var2d_index[i]);
4152 advance(it,var2d_index[i]-var2d_index[i-1]-1);
4154 if(it == this->
vars.end())
4155 throw1(
"Out of range to obtain 2D lat/lon variables");
4158 it = this->
vars.erase(it);
4166 bool GMFile::Check_Var_2D_CVars(
Var *var) {
4168 BESDEBUG(
"h5",
"Coming to Check_Var_2D_CVars()"<<endl);
4169 bool ret_value =
true;
4170 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4171 ircv != this->cvars.end(); ++ircv) {
4172 if((*ircv)->rank==2) {
4173 short first_dim_index = 0;
4174 short first_dim_times = 0;
4175 short second_dim_index = 0;
4176 short second_dim_times = 0;
4177 for (vector<Dimension *>::iterator ird = var->dims.begin();
4178 ird != var->dims.end(); ++ird) {
4179 if((*ird)->name == ((*ircv)->getDimensions()[0])->name) {
4180 first_dim_index = distance(var->dims.begin(),ird);
4183 else if((*ird)->name == ((*ircv)->getDimensions()[1])->name) {
4184 second_dim_index = distance(var->dims.begin(),ird);
4190 if(first_dim_times == 1 && second_dim_times == 1) {
4191 if(first_dim_index < second_dim_index) {
4204 bool GMFile::Flatten_VarPath_In_Coordinates_Attr(
Var *var) {
4206 BESDEBUG(
"h5",
"Coming to Flatten_VarPath_In_Coordinates_Attr()"<<endl);
4207 string co_attrname =
"coordinates";
4208 bool need_flatten_coor_attr =
false;
4209 string orig_coor_value;
4210 string flatten_coor_value;
4213 char backslash =
'/';
4215 for (vector<Attribute *>:: iterator ira =var->attrs.begin(); ira !=var->attrs.end();) {
4225 if((*ira)->name == co_attrname) {
4226 Retrieve_H5_Attr_Value((*ira),var->fullpath);
4227 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
4228 if(orig_attr_value.find_first_of(backslash)!=string::npos){
4229 orig_coor_value = orig_attr_value;
4230 need_flatten_coor_attr =
true;
4232 ira = var->attrs.erase(ira);
4240 if(
true == need_flatten_coor_attr) {
4243 size_t ele_start_pos = 0;
4244 size_t cur_pos = orig_coor_value.find_first_of(sc);
4245 while(cur_pos !=string::npos) {
4246 string tempstr = orig_coor_value.substr(ele_start_pos,cur_pos-ele_start_pos);
4247 tempstr = get_CF_string(tempstr);
4248 flatten_coor_value += tempstr + sc;
4249 ele_start_pos = cur_pos+1;
4250 cur_pos = orig_coor_value.find_first_of(sc,cur_pos+1);
4253 if(ele_start_pos == 0)
4254 flatten_coor_value = get_CF_string(orig_coor_value);
4256 flatten_coor_value += get_CF_string(orig_coor_value.substr(ele_start_pos));
4260 Add_Str_Attr(attr,co_attrname,flatten_coor_value);
4261 var->attrs.push_back(attr);
4262 var->coord_attr_add_path =
false;
4273 bool GMFile::Flatten_VarPath_In_Coordinates_Attr_EOS5(
Var *var) {
4275 BESDEBUG(
"h5",
"Coming to Flatten_VarPath_In_Coordinates_Attr_EOS5()"<<endl);
4276 string co_attrname =
"coordinates";
4277 bool has_coor_attr =
false;
4278 string orig_coor_value;
4279 string flatten_coor_value;
4283 for (vector<Attribute *>:: iterator ira =var->attrs.begin(); ira !=var->attrs.end();) {
4287 if((*ira)->name == co_attrname) {
4288 Retrieve_H5_Attr_Value((*ira),var->fullpath);
4290 string orig_attr_value((*ira)->value.begin(),(*ira)->value.end());
4291 orig_coor_value = orig_attr_value;
4292 has_coor_attr =
true;
4294 ira = var->attrs.erase(ira);
4301 if(
true == has_coor_attr) {
4305 size_t ele_start_pos = 0;
4307 size_t cur_pos = orig_coor_value.find_first_of(sc);
4308 while(cur_pos !=string::npos) {
4309 string tempstr = orig_coor_value.substr(ele_start_pos,cur_pos-ele_start_pos);
4312 tempstr = get_CF_string(tempstr);
4313 flatten_coor_value += tempstr + sc;
4314 ele_start_pos = cur_pos+1;
4315 cur_pos = orig_coor_value.find_first_of(sc,cur_pos+1);
4318 if(ele_start_pos == 0) {
4321 flatten_coor_value = get_CF_string(tempstr);
4324 flatten_coor_value += get_CF_string(orig_coor_value.substr(ele_start_pos));
4328 Add_Str_Attr(attr,co_attrname,flatten_coor_value);
4329 var->attrs.push_back(attr);
4341 bool GMFile::Check_2DLatLon_Dimscale(
string & latname,
string &lonname) {
4359 bool latlon_2d_cv_check1 =
false;
4362 latlon_2d_cv_check1 =
true;
4365 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4366 ircv != this->cvars.end(); ++ircv) {
4367 if((*ircv)->cvartype == CV_FILLINDEX){
4368 latlon_2d_cv_check1 =
true;
4374 bool latlon_2d_cv_check2 =
true;
4377 if(
true == latlon_2d_cv_check1) {
4378 BESDEBUG(
"h5",
"Coming to check if having 2d latlon coordinates for a netCDF-4 like product. "<<endl);
4381 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4382 ircv != this->cvars.end(); ++ircv) {
4383 if((*ircv)->cvartype == CV_EXIST) {
4384 for(vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
4385 ira != (*ircv)->attrs.end();ira++) {
4386 string attr_name =
"units";
4387 string lat_unit_value =
"degrees_north";
4388 string lon_unit_value =
"degrees_east";
4391 if((
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lat_unit_value)) ||
4392 (
true == Is_Str_Attr(*ira,(*ircv)->fullpath,attr_name,lon_unit_value))) {
4393 latlon_2d_cv_check2=
false;
4399 if(
false == latlon_2d_cv_check2)
4404 bool latlon_2d_cv_check3 =
true;
4407 if(
true == latlon_2d_cv_check1 &&
true == latlon_2d_cv_check2) {
4409 short latlon_flag = 0;
4410 short LatLon_flag = 0;
4411 short latilong_flag = 0;
4413 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4414 ircv != this->cvars.end(); ++ircv) {
4415 if((*ircv)->cvartype == CV_EXIST) {
4416 if((*ircv)->name ==
"lat")
4418 else if((*ircv)->name ==
"lon")
4420 else if((*ircv)->name ==
"latitude")
4422 else if((*ircv)->name ==
"longitude")
4424 else if((*ircv)->name ==
"Latitude")
4426 else if((*ircv)->name ==
"Longitude")
4431 if((2== latlon_flag) || (2 == latilong_flag) || (2 == LatLon_flag ))
4432 latlon_2d_cv_check3 =
false;
4435 bool latlon_2d =
false;
4436 short latlon_flag = 0;
4437 string latdim1,latdim2,londim1,londim2;
4439 short LatLon_flag = 0;
4440 string Latdim1,Latdim2,Londim1,Londim2;
4442 short latilong_flag = 0;
4443 string latidim1,latidim2,longdim1,longdim2;
4450 if(
true == latlon_2d_cv_check1 &&
true == latlon_2d_cv_check2 &&
true == latlon_2d_cv_check3) {
4452 for (vector<Var *>::iterator irv = this->
vars.begin();
4453 irv != this->vars.end(); ++irv) {
4456 if((*irv)->rank == 2) {
4457 if((*irv)->name ==
"lat") {
4459 latdim1 = (*irv)->getDimensions()[0]->name;
4460 latdim2 = (*irv)->getDimensions()[1]->name;
4463 else if((*irv)->name ==
"lon") {
4465 londim1 = (*irv)->getDimensions()[0]->name;
4466 londim2 = (*irv)->getDimensions()[1]->name;
4468 else if((*irv)->name ==
"latitude"){
4470 latidim1 = (*irv)->getDimensions()[0]->name;
4471 latidim2 = (*irv)->getDimensions()[1]->name;
4473 else if((*irv)->name ==
"longitude"){
4475 longdim1 = (*irv)->getDimensions()[0]->name;
4476 longdim2 = (*irv)->getDimensions()[1]->name;
4479 else if((*irv)->name ==
"Latitude"){
4481 Latdim1 = (*irv)->getDimensions()[0]->name;
4482 Latdim2 = (*irv)->getDimensions()[1]->name;
4485 else if((*irv)->name ==
"Longitude"){
4487 Londim1 = (*irv)->getDimensions()[0]->name;
4488 Londim2 = (*irv)->getDimensions()[1]->name;
4498 if(2 == latlon_flag) {
4499 if((2 == latilong_flag) || ( 2 == LatLon_flag))
4501 else if((latdim1 == londim1) && (latdim2 == londim2)) {
4507 else if ( 2 == latilong_flag) {
4508 if( 2 == LatLon_flag)
4510 else if ((latidim1 == longdim1) ||(latidim2 == longdim2)) {
4511 latname =
"latitude";
4512 lonname =
"longitude";
4516 else if (2 == LatLon_flag){
4517 if ((Latdim1 == Londim1) ||(Latdim2 == Londim2)) {
4518 latname =
"Latitude";
4519 lonname =
"Longitude";
4530 void GMFile::Update_2DLatLon_Dimscale_CV(
const string &latname,
const string &lonname) {
4535 for (vector<Var *>::iterator irv = this->
vars.begin();
4536 irv != this->vars.end(); ++irv) {
4538 if((*irv)->rank == 2) {
4541 if((*irv)->name == latname) {
4544 string latdim0 = (*irv)->getDimensions()[0]->name;
4548 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ) {
4549 if((*i)->cfdimname == latdim0) {
4550 if(CV_FILLINDEX == (*i)->cvartype) {
4552 i = this->cvars.erase(i);
4554 else if(CV_EXIST == (*i)->cvartype) {
4557 this->
vars.push_back(var);
4560 i = this->cvars.erase(i);
4564 if(CV_LAT_MISS == (*i)->cvartype)
4565 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_LAT_MISS");
4566 else if(CV_LON_MISS == (*i)->cvartype)
4567 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_LON_MISS");
4568 else if(CV_NONLATLON_MISS == (*i)->cvartype)
4569 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_NONLATLON_MISS");
4570 else if(CV_MODIFY == (*i)->cvartype)
4571 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_MODIFY");
4572 else if(CV_SPECIAL == (*i)->cvartype)
4573 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_SPECIAL");
4575 throw3(
"For the 2-D lat/lon case, the latitude dimension name ",latdim0,
"is a coordinate variable of type CV_UNSUPPORTED");
4584 GMcvar->cfdimname = latdim0;
4585 GMcvar->cvartype = CV_EXIST;
4586 GMcvar->product_type = product_type;
4587 this->cvars.push_back(GMcvar);
4589 this->
vars.erase(irv);
4596 for (vector<Var *>::iterator irv = this->
vars.begin();
4597 irv != this->vars.end(); ++irv) {
4599 if((*irv)->rank == 2) {
4602 if((*irv)->name == lonname) {
4605 string londim0 = (*irv)->getDimensions()[1]->name;
4608 for (vector<GMCVar *>:: iterator i= this->cvars.begin(); i!=this->cvars.end(); ) {
4610 if((*i)->cfdimname == londim0) {
4611 if(CV_FILLINDEX == (*i)->cvartype) {
4613 i= this->cvars.erase(i);
4615 else if(CV_EXIST == (*i)->cvartype) {
4618 this->
vars.push_back(var);
4621 i = this->cvars.erase(i);
4624 if(CV_LAT_MISS == (*i)->cvartype)
4625 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_LAT_MISS");
4626 else if(CV_LON_MISS == (*i)->cvartype)
4627 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_LON_MISS");
4628 else if(CV_NONLATLON_MISS == (*i)->cvartype)
4629 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_NONLATLON_MISS");
4630 else if(CV_MODIFY == (*i)->cvartype)
4631 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_MODIFY");
4632 else if(CV_SPECIAL == (*i)->cvartype)
4633 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_SPECIAL");
4635 throw3(
"For the 2-D lat/lon case, the longitude dimension name ",londim0,
"is a coordinate variable of type CV_UNSUPPORTED");
4644 GMcvar->cfdimname = londim0;
4645 GMcvar->cvartype = CV_EXIST;
4646 GMcvar->product_type = product_type;
4647 this->cvars.push_back(GMcvar);
4649 this->
vars.erase(irv);
4658 void GMFile::Handle_CVar_LatLon1D_General_Product() {
4660 BESDEBUG(
"h5",
"Coming to Handle_CVar_LatLon1D_General_Product()"<<endl);
4661 this->iscoard =
true;
4662 Handle_CVar_LatLon_General_Product();
4667 void GMFile::Handle_CVar_LatLon2D_General_Product() {
4669 BESDEBUG(
"h5",
"Coming to Handle_CVar_LatLon2D_General_Product()"<<endl);
4670 Handle_CVar_LatLon_General_Product();
4676 void GMFile::Handle_CVar_LatLon_General_Product() {
4678 BESDEBUG(
"h5",
"Coming to Handle_CVar_LatLon_General_Product()"<<endl);
4679 if((GENERAL_LATLON2D != this->gproduct_pattern)
4680 && GENERAL_LATLON1D != this->gproduct_pattern)
4681 throw1(
"This function only supports latlon 1D or latlon 2D general products");
4683 pair<set<string>::iterator,
bool> setret;
4684 set<string>tempdimnamelist = dimnamelist;
4686 for (vector<Var *>::iterator irv = this->
vars.begin();
4687 irv != this->vars.end(); ++irv) {
4690 if (gp_latname== (*irv)->name) {
4694 tempdimnamelist.erase(((*irv)->dims[0])->name);
4696 GMcvar->cfdimname = ((*irv)->dims[0])->name;
4697 GMcvar->cvartype = CV_EXIST;
4698 GMcvar->product_type = product_type;
4699 this->cvars.push_back(GMcvar);
4701 this->
vars.erase(irv);
4706 for (vector<Var *>::iterator irv = this->
vars.begin();
4707 irv != this->
vars.end(); ++irv) {
4710 if (gp_lonname== (*irv)->name) {
4716 if(GENERAL_LATLON2D == this->gproduct_pattern)
4717 londimname = ((*irv)->dims[1])->name;
4719 londimname = ((*irv)->dims[0])->name;
4721 tempdimnamelist.erase(londimname);
4723 GMcvar->cfdimname = londimname;
4724 GMcvar->cvartype = CV_EXIST;
4725 GMcvar->product_type = product_type;
4726 this->cvars.push_back(GMcvar);
4728 this->
vars.erase(irv);
4735 for (set<string>::iterator irs = tempdimnamelist.begin();
4736 irs != tempdimnamelist.end();irs++) {
4738 Create_Missing_CV(GMcvar,*irs);
4739 this->cvars.push_back(GMcvar);
4745 void GMFile::Handle_CVar_OBPG_L3() {
4747 BESDEBUG(
"h5",
"Coming to Handle_CVar_OBPG_L3()"<<endl);
4748 if (GENERAL_DIMSCALE == this->gproduct_pattern)
4749 Handle_CVar_Dimscale_General_Product();
4752 for (vector<Var *>::iterator irv = this->
vars.begin();
4753 irv != this->vars.end(); ++irv) {
4760 if((*irv)->rank == 2) {
4762 if(((*irv)->fullpath.find(
"/geophsical_data") == 0) || ((*irv)->dtype == H5FLOAT32)) {
4764 size_t lat_size = (*irv)->getDimensions()[0]->size;
4765 string lat_name = (*irv)->getDimensions()[0]->name;
4766 size_t lon_size = (*irv)->getDimensions()[1]->size;
4767 string lon_name = (*irv)->getDimensions()[1]->name;
4768 size_t temp_size = 0;
4770 H5DataType ll_dtype = (*irv)->dtype;
4773 if(lat_size >lon_size) {
4774 temp_size = lon_size;
4775 temp_name = lon_name;
4776 lon_size = lat_size;
4777 lon_name = lat_name;
4778 lat_size = temp_size;
4779 lat_name = temp_name;
4781 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
4782 ircv != this->cvars.end(); ++ircv) {
4783 if((*ircv)->cvartype == CV_FILLINDEX) {
4784 if((*ircv)->getDimensions()[0]->size == lat_size &&
4785 (*ircv)->getDimensions()[0]->name == lat_name) {
4786 (*ircv)->cvartype = CV_LAT_MISS;
4787 (*ircv)->dtype = ll_dtype;
4788 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
4789 ira != (*ircv)->attrs.end(); ++ira) {
4790 if ((*ira)->name ==
"NAME") {
4792 (*ircv)->attrs.erase(ira);
4797 else if((*ircv)->getDimensions()[0]->size == lon_size &&
4798 (*ircv)->getDimensions()[0]->name == lon_name) {
4799 (*ircv)->cvartype = CV_LON_MISS;
4800 (*ircv)->dtype = ll_dtype;
4801 for (vector<Attribute *>::iterator ira = (*ircv)->attrs.begin();
4802 ira != (*ircv)->attrs.end(); ++ira) {
4803 if ((*ira)->name ==
"NAME") {
4805 (*ircv)->attrs.erase(ira);
4824 BESDEBUG(
"h5",
"Coming to Handle_SpVar()"<<endl);
4825 if (ACOS_L2S_OR_OCO2_L1B == product_type)
4826 Handle_SpVar_ACOS_OCO2();
4827 else if(GPM_L1 == product_type) {
4830 for (vector<Var *>::iterator irv = this->
vars.begin();
4831 irv != this->vars.end(); ++irv) {
4832 if((*irv)->name==
"AlgorithmRuntimeInfo") {
4834 this->
vars.erase(irv);
4841 else if(GPMM_L3 == product_type || GPMS_L3 == product_type || GPM_L3_New==product_type) {
4843 for (vector<Var *>::iterator irv = this->
vars.begin();
4844 irv != this->vars.end(); ) {
4845 if((*irv)->name==
"InputFileNames") {
4847 irv = this->
vars.erase(irv);
4849 else if((*irv)->name==
"InputAlgorithmVersions") {
4851 irv = this->
vars.erase(irv);
4853 else if((*irv)->name==
"InputGenerationDateTimes") {
4855 irv = this->
vars.erase(irv);
4868 void GMFile::Handle_SpVar_ACOS_OCO2() {
4870 BESDEBUG(
"h5",
"Coming to Handle_SpVar_ACOS_OCO2()"<<endl);
4873 for (vector<Var *>::iterator irv = this->
vars.begin();
4874 irv != this->vars.end(); ) {
4875 if (H5INT64 == (*irv)->getType()) {
4879 spvar->name = (*irv)->name +
"_Time";
4880 spvar->newname = (*irv)->newname+
"_Time";
4881 spvar->dtype = H5INT32;
4882 spvar->otype = (*irv)->getType();
4886 spvar->numofdbits = 6;
4887 this->spvars.push_back(spvar);
4891 spvar2->name = (*irv)->name +
"_Date";
4892 spvar2->newname = (*irv)->newname+
"_Date";
4893 spvar2->dtype = H5INT32;
4894 spvar2->otype = (*irv)->getType();
4898 spvar2->numofdbits = 8;
4899 this->spvars.push_back(spvar2);
4902 irv = this->
vars.erase(irv);
4914 BESDEBUG(
"h5",
"Coming to Adjust_Obj_Name()"<<endl);
4915 if(Mea_Ozone == product_type)
4916 Adjust_Mea_Ozone_Obj_Name();
4918 if(GPMS_L3 == product_type || GPMM_L3 == product_type)
4919 Adjust_GPM_L3_Obj_Name();
4923 for (vector<Var*>::iterator irv2 = this->
vars.begin();
4924 irv2 != this->vars.end(); irv2++) {
4925 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
4926 ird !=(*irv2)->dims.end(); ird++) {
4927 cerr<<
"Dimension name afet Adjust_Obj_Name "<<(*ird)->newname <<endl;
4935 void GMFile:: Adjust_GPM_L3_Obj_Name() {
4937 BESDEBUG(
"h5",
"Coming to Adjust_GPM_L3_Obj_Name()"<<endl);
4940 if(this->
groups.size() <= 1) {
4941 for (vector<Var *>::iterator irv = this->
vars.begin();
4942 irv != this->vars.end(); ++irv) {
4943 objnewname = HDF5CFUtil::obtain_string_after_lastslash((*irv)->newname);
4944 if (objnewname !=
"")
4945 (*irv)->newname = objnewname;
4949 for (vector<Var *>::iterator irv = this->
vars.begin();
4950 irv != this->vars.end(); ++irv) {
4951 size_t grid_group_path_pos = ((*irv)->newname.substr(1)).find_first_of(
"/");
4952 objnewname = ((*irv)->newname).substr(grid_group_path_pos+2);
4953 (*irv)->newname = objnewname;
4959 void GMFile:: Adjust_Mea_Ozone_Obj_Name() {
4961 BESDEBUG(
"h5",
"Coming to Adjust_Mea_Ozone_Obj_Name()"<<endl);
4963 for (vector<Var *>::iterator irv = this->
vars.begin();
4964 irv != this->vars.end(); ++irv) {
4965 objnewname = HDF5CFUtil::obtain_string_after_lastslash((*irv)->newname);
4966 if (objnewname !=
"")
4967 (*irv)->newname = objnewname;
4971 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
4972 ird !=(*irv)->dims.end();++ird) {
4973 cerr<<
"Ozone dim. name "<<(*ird)->name <<endl;
4974 cerr<<
"Ozone dim. new name "<<(*ird)->newname <<endl;
4980 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
4981 irv != this->cvars.end(); ++irv) {
4982 objnewname = HDF5CFUtil::obtain_string_after_lastslash((*irv)->newname);
4983 if (objnewname !=
"")
4984 (*irv)->newname = objnewname;
4987 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
4988 ird !=(*irv)->dims.end();++ird) {
4989 cerr<<
"Ozone CV dim. name "<<(*ird)->name <<endl;
4990 cerr<<
"Ozone CV dim. new name "<<(*ird)->newname <<endl;
4999 BESDEBUG(
"h5",
"GMFile::Coming to Flatten_Obj_Name()"<<endl);
5004 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5005 irv != this->cvars.end(); ++irv) {
5006 (*irv)->newname = get_CF_string((*irv)->newname);
5008 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
5009 ird != (*irv)->dims.end(); ++ird) {
5010 (*ird)->newname = get_CF_string((*ird)->newname);
5013 if (
true == include_attr) {
5014 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
5015 ira != (*irv)->attrs.end(); ++ira)
5016 (*ira)->newname = File::get_CF_string((*ira)->newname);
5023 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5024 irv != this->spvars.end(); ++irv) {
5025 (*irv)->newname = get_CF_string((*irv)->newname);
5027 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
5028 ird != (*irv)->dims.end(); ++ird)
5029 (*ird)->newname = get_CF_string((*ird)->newname);
5031 if (
true == include_attr) {
5032 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
5033 ira != (*irv)->attrs.end(); ++ira)
5034 (*ira)->newname = File::get_CF_string((*ira)->newname);
5041 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5042 irv2 != this->vars.end(); irv2++) {
5043 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5044 ird !=(*irv2)->dims.end(); ird++) {
5045 cerr<<
"Dimension name afet Flatten_Obj_Name "<<(*ird)->newname <<endl;
5057 BESDEBUG(
"h5",
"GMFile::Coming to Handle_Obj_NameClashing()"<<endl);
5061 set<string>objnameset;
5062 Handle_GMCVar_NameClashing(objnameset);
5063 Handle_GMSPVar_NameClashing(objnameset);
5064 File::Handle_GeneralObj_NameClashing(include_attr,objnameset);
5065 if (
true == include_attr) {
5066 Handle_GMCVar_AttrNameClashing();
5067 Handle_GMSPVar_AttrNameClashing();
5074 void GMFile::Handle_GMCVar_NameClashing(set<string> &objnameset ) {
5076 GMHandle_General_NameClashing(objnameset,this->cvars);
5080 void GMFile::Handle_GMSPVar_NameClashing(set<string> &objnameset ) {
5082 GMHandle_General_NameClashing(objnameset,this->spvars);
5086 void GMFile::Handle_GMCVar_AttrNameClashing() {
5088 BESDEBUG(
"h5",
"Coming to Handle_GMCVar_AttrNameClashing()"<<endl);
5089 set<string> objnameset;
5091 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5092 irv != this->cvars.end(); ++irv) {
5093 Handle_General_NameClashing(objnameset,(*irv)->attrs);
5099 void GMFile::Handle_GMSPVar_AttrNameClashing() {
5101 BESDEBUG(
"h5",
"Coming to Handle_GMSPVar_AttrNameClashing()"<<endl);
5102 set<string> objnameset;
5104 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5105 irv != this->spvars.end(); ++irv) {
5106 Handle_General_NameClashing(objnameset,(*irv)->attrs);
5114 template<
class T>
void
5115 GMFile::GMHandle_General_NameClashing(set <string>&objnameset, vector<T*>& objvec) {
5117 BESDEBUG(
"h5",
"Coming to GMHandle_General_NameClashing()"<<endl);
5118 pair<set<string>::iterator,
bool> setret;
5119 set<string>::iterator iss;
5121 vector<string> clashnamelist;
5122 vector<string>::iterator ivs;
5124 map<int,int> cl_to_ol;
5128 typename vector<T*>::iterator irv;
5130 for (irv = objvec.begin();
5131 irv != objvec.end(); ++irv) {
5133 setret = objnameset.insert((*irv)->newname);
5134 if (
false == setret.second ) {
5135 clashnamelist.insert(clashnamelist.end(),(*irv)->newname);
5136 cl_to_ol[cl_index] = ol_index;
5145 for (ivs=clashnamelist.begin(); ivs!=clashnamelist.end(); ++ivs) {
5146 int clash_index = 1;
5147 string temp_clashname = *ivs +
'_';
5148 HDF5CFUtil::gen_unique_name(temp_clashname,objnameset,clash_index);
5149 *ivs = temp_clashname;
5154 for (
unsigned int i =0; i <clashnamelist.size(); i++)
5155 objvec[cl_to_ol[i]]->newname = clashnamelist[i];
5163 BESDEBUG(
"h5",
"GMFile: Coming to Handle_DimNameClashing()"<<endl);
5165 if (ACOS_L2S_OR_OCO2_L1B == product_type)
5168 map<string,string>dimname_to_dimnewname;
5169 pair<map<string,string>::iterator,
bool>mapret;
5170 set<string> dimnameset;
5171 vector<Dimension*>vdims;
5172 set<string> dimnewnameset;
5173 pair<set<string>::iterator,
bool> setret;
5176 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5177 irv !=this->cvars.end(); ++irv) {
5178 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5179 ird !=(*irv)->dims.end();++ird) {
5180 setret = dimnameset.insert((*ird)->name);
5181 if (
true == setret.second)
5182 vdims.push_back(*ird);
5189 for(vector<Var *>::iterator irv= this->
vars.begin();
5190 irv != this->vars.end();++irv) {
5191 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5192 ird !=(*irv)->dims.end();++ird) {
5194 setret = dimnameset.insert((*ird)->name);
5195 if (setret.second) vdims.push_back(*ird);
5199 GMHandle_General_NameClashing(dimnewnameset,vdims);
5202 for (vector<Dimension*>::iterator ird = vdims.begin();ird!=vdims.end();++ird) {
5203 mapret = dimname_to_dimnewname.insert(pair<string,string>((*ird)->name,(*ird)->newname));
5204 if (
false == mapret.second)
5205 throw4(
"The dimension name ",(*ird)->name,
" should map to ",
5210 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5211 irv !=this->cvars.end(); ++irv)
5212 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5213 ird!=(*irv)->dims.end();++ird)
5214 (*ird)->newname = dimname_to_dimnewname[(*ird)->name];
5216 for (vector<Var *>::iterator irv = this->
vars.begin();
5217 irv != this->vars.end(); ++irv)
5218 for (vector <Dimension *>:: iterator ird = (*irv)->dims.begin();
5219 ird !=(*irv)->dims.end();++ird)
5220 (*ird)->newname = dimname_to_dimnewname[(*ird)->name];
5227 BESDEBUG(
"h5",
"GMFile:Coming to Adjust_Dim_Name()"<<endl);
5230 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5231 irv2 != this->vars.end(); irv2++) {
5232 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5233 ird !=(*irv2)->dims.end(); ird++) {
5234 cerr<<
"Dimension new name "<<(*ird)->newname <<endl;
5240 if(
true == iscoard) {
5241 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5242 irv !=this->cvars.end(); ++irv) {
5244 cerr<<
"1D Cvariable name is "<<(*irv)->name <<endl;
5245 cerr<<
"1D Cvariable new name is "<<(*irv)->newname <<endl;
5246 cerr<<
"1D Cvariable dim name is "<<((*irv)->dims)[0]->name <<endl;
5247 cerr<<
"1D Cvariable dim new name is "<<((*irv)->dims)[0]->newname <<endl;
5249 if ((*irv)->dims.size()!=1)
5250 throw3(
"Coard coordinate variable ",(*irv)->name,
"is not 1D");
5251 if ((*irv)->newname != (((*irv)->dims)[0]->newname)) {
5252 ((*irv)->dims)[0]->newname = (*irv)->newname;
5255 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5256 irv2 != this->
vars.end(); ++irv2) {
5257 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5258 ird !=(*irv2)->dims.end(); ++ird) {
5263 if ((*ird)->name == ((*irv)->dims)[0]->name)
5264 (*ird)->newname = ((*irv)->dims)[0]->newname;
5273 for (vector<Var*>::iterator irv2 = this->
vars.begin();
5274 irv2 != this->
vars.end(); irv2++) {
5275 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
5276 ird !=(*irv2)->dims.end(); ird++) {
5277 cerr<<
"Dimension name afet Adjust_Dim_Name "<<(*ird)->newname <<endl;
5289 BESDEBUG(
"h5",
"GMFile::Coming to Add_Supplement_Attrs()"<<endl);
5290 if (General_Product == product_type ||
true == add_path) {
5293 if(
true == add_path) {
5295 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5296 irv != this->cvars.end(); ++irv) {
5297 if (((*irv)->cvartype == CV_EXIST) || ((*irv)->cvartype == CV_MODIFY)) {
5299 const string varname = (*irv)->name;
5300 const string attrname =
"origname";
5301 Add_Str_Attr(attr,attrname,varname);
5302 (*irv)->attrs.push_back(attr);
5306 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5307 irv != this->cvars.end(); ++irv) {
5311 if((*irv)->zero_storage_size ==
false
5312 || HDF5RequestHandler::get_no_zero_size_fullnameattr() ==
false) {
5313 if (((*irv)->cvartype == CV_EXIST) || ((*irv)->cvartype == CV_MODIFY)) {
5315 const string varname = (*irv)->fullpath;
5316 const string attrname =
"fullnamepath";
5317 Add_Str_Attr(attr,attrname,varname);
5318 (*irv)->attrs.push_back(attr);
5323 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5324 irv != this->spvars.end(); ++irv) {
5326 const string varname = (*irv)->name;
5327 const string attrname =
"origname";
5328 Add_Str_Attr(attr,attrname,varname);
5329 (*irv)->attrs.push_back(attr);
5332 for (vector<GMSPVar *>::iterator irv = this->spvars.begin();
5333 irv != this->spvars.end(); ++irv) {
5337 if((*irv)->zero_storage_size ==
false
5338 || HDF5RequestHandler::get_no_zero_size_fullnameattr() ==
false) {
5340 const string varname = (*irv)->fullpath;
5341 const string attrname =
"fullnamepath";
5342 Add_Str_Attr(attr,attrname,varname);
5343 (*irv)->attrs.push_back(attr);
5349 if(GPM_L1 == product_type || GPMS_L3 == product_type || GPMM_L3 == product_type)
5351 else if (Aqu_L3 == product_type)
5353 else if (Mea_SeaWiFS_L2 == product_type || Mea_SeaWiFS_L3 == product_type)
5354 Add_SeaWiFS_Attrs();
5360 GMFile:: Add_GPM_Attrs() {
5362 BESDEBUG(
"h5",
"Coming to Add_GPM_Attrs()"<<endl);
5363 vector<HDF5CF::Var *>::const_iterator it_v;
5364 vector<HDF5CF::Attribute *>::const_iterator ira;
5365 const string attr_name_be_replaced =
"CodeMissingValue";
5366 const string attr_new_name =
"_FillValue";
5367 const string attr2_name_be_replaced =
"Units";
5368 const string attr2_new_name =
"units";
5373 for (it_v =
vars.begin(); it_v !=
vars.end(); ++it_v) {
5374 bool has_fvalue_attr =
false;
5375 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5376 if(attr_new_name == (*ira)->name) {
5377 has_fvalue_attr =
true;
5382 if(
false == has_fvalue_attr) {
5383 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5384 if(attr_name_be_replaced == (*ira)->name) {
5385 if((*ira)->dtype == H5FSTRING)
5386 Change_Attr_One_Str_to_Others((*ira),(*it_v));
5387 (*ira)->name = attr_new_name;
5388 (*ira)->newname = attr_new_name;
5396 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
5397 irv != this->cvars.end(); ++irv) {
5398 bool has_fvalue_attr =
false;
5400 for(ira = (*irv)->attrs.begin(); ira!= (*irv)->attrs.end();ira++) {
5402 if(attr_new_name == (*ira)->name) {
5403 has_fvalue_attr =
true;
5407 if(
false == has_fvalue_attr) {
5408 for(ira = (*irv)->attrs.begin(); ira!= (*irv)->attrs.end();ira++) {
5410 if(attr_name_be_replaced == (*ira)->name) {
5411 if((*ira)->dtype == H5FSTRING)
5412 Change_Attr_One_Str_to_Others((*ira),(*irv));
5413 (*ira)->name = attr_new_name;
5414 (*ira)->newname = attr_new_name;
5421 if(product_type == GPM_L1) {
5423 if ((*irv)->cvartype == CV_EXIST) {
5424 if((*irv)->name.find(
"Latitude") !=string::npos) {
5425 string unit_value =
"degrees_north";
5426 Correct_GPM_L1_LatLon_units(*irv,unit_value);
5429 else if((*irv)->name.find(
"Longitude") !=string::npos) {
5430 string unit_value =
"degrees_east";
5431 Correct_GPM_L1_LatLon_units(*irv,unit_value);
5436 else if ((*irv)->cvartype == CV_NONLATLON_MISS) {
5439 const string attrname =
"comment";
5443 if((*irv)->name ==
"nchannel1")
5444 comment =
"Number of Swath S1 channels (10V 10H 19V 19H 23V 37V 37H 89V 89H).";
5445 else if((*irv)->name ==
"nchannel2")
5446 comment =
"Number of Swath S2 channels (166V 166H 183+/-3V 183+/-8V).";
5447 else if((*irv)->name ==
"nchan1")
5448 comment =
"Number of channels in Swath 1.";
5449 else if((*irv)->name ==
"nchan2")
5450 comment =
"Number of channels in Swath 2.";
5451 else if((*irv)->name ==
"VH")
5452 comment =
"Number of polarizations.";
5453 else if((*irv)->name ==
"GMIxyz")
5454 comment =
"x, y, z components in GMI instrument coordinate system.";
5455 else if((*irv)->name ==
"LNL")
5456 comment =
"Linear and non-linear.";
5457 else if((*irv)->name ==
"nscan")
5458 comment =
"Number of scans in the granule.";
5459 else if((*irv)->name ==
"nscan1")
5460 comment =
"Typical number of Swath S1 scans in the granule.";
5461 else if((*irv)->name ==
"nscan2")
5462 comment =
"Typical number of Swath S2 scans in the granule.";
5463 else if((*irv)->name ==
"npixelev")
5464 comment =
"Number of earth view pixels in one scan.";
5465 else if((*irv)->name ==
"npixelht")
5466 comment =
"Number of hot load pixels in one scan.";
5467 else if((*irv)->name ==
"npixelcs")
5468 comment =
"Number of cold sky pixels in one scan.";
5469 else if((*irv)->name ==
"npixelfr")
5470 comment =
"Number of full rotation earth view pixels in one scan.";
5471 else if((*irv)->name ==
"nfreq1")
5472 comment =
"Number of frequencies in Swath 1.";
5473 else if((*irv)->name ==
"nfreq2")
5474 comment =
"Number of frequencies in Swath 2.";
5475 else if((*irv)->name ==
"npix1")
5476 comment =
"Number of pixels in Swath 1.";
5477 else if((*irv)->name ==
"npix2")
5478 comment =
"Number of pixels in Swath 2.";
5479 else if((*irv)->name ==
"npix3")
5480 comment =
"Number of pixels in Swath 3.";
5481 else if((*irv)->name ==
"npix4")
5482 comment =
"Number of pixels in Swath 4.";
5483 else if((*irv)->name ==
"ncolds1")
5484 comment =
"Maximum number of cold samples in Swath 1.";
5485 else if((*irv)->name ==
"ncolds2")
5486 comment =
"Maximum number of cold samples in Swath 2.";
5487 else if((*irv)->name ==
"nhots1")
5488 comment =
"Maximum number of hot samples in Swath 1.";
5489 else if((*irv)->name ==
"nhots2")
5490 comment =
"Maximum number of hot samples in Swath 2.";
5491 else if((*irv)->name ==
"ntherm")
5492 comment =
"Number of hot load thermisters.";
5493 else if((*irv)->name ==
"ntach")
5494 comment =
"Number of tachometer readings.";
5495 else if((*irv)->name ==
"nsamt"){
5496 comment =
"Number of sample types. ";
5497 comment = +
"The types are: total science GSDR, earthview,hot load, cold sky.";
5499 else if((*irv)->name ==
"nndiode")
5500 comment =
"Number of noise diodes.";
5501 else if((*irv)->name ==
"n7")
5502 comment =
"Number seven.";
5503 else if((*irv)->name ==
"nray")
5504 comment =
"Number of angle bins in each NS scan.";
5505 else if((*irv)->name ==
"nrayMS")
5506 comment =
"Number of angle bins in each MS scan.";
5507 else if((*irv)->name ==
"nrayHS")
5508 comment =
"Number of angle bins in each HS scan.";
5509 else if((*irv)->name ==
"nbin")
5510 comment =
"Number of range bins in each NS and MS ray. Bin interval is 125m.";
5511 else if((*irv)->name ==
"nbinHS")
5512 comment =
"Number of range bins in each HS ray. Bin interval is 250m.";
5513 else if((*irv)->name ==
"nbinSZP")
5514 comment =
"Number of range bins for sigmaZeroProfile.";
5515 else if((*irv)->name ==
"nbinSZPHS")
5516 comment =
"Number of range bins for sigmaZeroProfile in each HS scan.";
5517 else if((*irv)->name ==
"nNP")
5518 comment =
"Number of NP kinds.";
5519 else if((*irv)->name ==
"nearFar")
5520 comment =
"Near reference, Far reference.";
5521 else if((*irv)->name ==
"foreBack")
5522 comment =
"Forward, Backward.";
5523 else if((*irv)->name ==
"method")
5524 comment =
"Number of SRT methods.";
5525 else if((*irv)->name ==
"nNode")
5526 comment =
"Number of binNode.";
5527 else if((*irv)->name ==
"nDSD")
5528 comment =
"Number of DSD parameters. Parameters are N0 and D0";
5529 else if((*irv)->name ==
"LS")
5530 comment =
"Liquid, solid.";
5536 Add_Str_Attr(attr,attrname,comment);
5537 (*irv)->attrs.push_back(attr);
5543 if(product_type == GPMS_L3 || product_type == GPMM_L3) {
5544 if ((*irv)->cvartype == CV_NONLATLON_MISS) {
5547 const string attrname =
"comment";
5551 if((*irv)->name ==
"chn")
5552 comment =
"Number of channels:Ku,Ka,KaHS,DPR.";
5553 else if((*irv)->name ==
"inst")
5554 comment =
"Number of instruments:Ku,Ka,KaHS.";
5555 else if((*irv)->name ==
"tim")
5556 comment =
"Number of hours(local time).";
5557 else if((*irv)->name ==
"ang"){
5558 comment =
"Number of angles.The meaning of ang is different for each channel.";
5560 "For Ku channel all indices are used with the meaning 0,1,2,..6 =angle bins 24,";
5562 "(20,28),(16,32),(12,36),(8,40),(3,44),and (0,48).";
5564 "For Ka channel 4 indices are used with the meaning 0,1,2,3 = angle bins 12,(8,16),";
5566 "(4,20),and (0,24). For KaHS channel 4 indices are used with the meaning 0,1,2,3 =";
5567 comment +=
"angle bins(11,2),(7,16),(3,20),and (0.23).";
5570 else if((*irv)->name ==
"rt")
5571 comment =
"Number of rain types: stratiform, convective,all.";
5572 else if((*irv)->name ==
"st")
5573 comment =
"Number of surface types:ocean,land,all.";
5574 else if((*irv)->name ==
"bin"){
5575 comment =
"Number of bins in histogram. The thresholds are different for different";
5576 comment +=
" variables. see the file specification for this algorithm.";
5578 else if((*irv)->name ==
"nvar") {
5579 comment =
"Number of phase bins. Bins are counts of phase less than 100, ";
5580 comment +=
"counts of phase greater than or equal to 100 and less than 200, ";
5581 comment +=
"counts of phase greater than or equal to 200.";
5583 else if((*irv)->name ==
"AD")
5584 comment =
"Ascending or descending half of the orbit.";
5590 Add_Str_Attr(attr,attrname,comment);
5591 (*irv)->attrs.push_back(attr);
5598 if ((*irv)->cvartype == CV_SPECIAL) {
5599 if((*irv)->name ==
"nlayer" || (*irv)->name ==
"hgt"
5600 || (*irv)->name ==
"nalt") {
5602 string unit_value =
"km";
5603 Add_Str_Attr(attr,attr2_new_name,unit_value);
5604 (*irv)->attrs.push_back(attr);
5607 string attr1_axis=
"axis";
5608 string attr1_value =
"Z";
5609 Add_Str_Attr(attr1,attr1_axis,attr1_value);
5610 (*irv)->attrs.push_back(attr1);
5613 string attr2_positive=
"positive";
5614 string attr2_value =
"up";
5615 Add_Str_Attr(attr2,attr2_positive,attr2_value);
5616 (*irv)->attrs.push_back(attr2);
5619 if((*irv)->name ==
"hgt" || (*irv)->name ==
"nalt"){
5621 string comment =
"Number of heights above the earth ellipsoid";
5622 Add_Str_Attr(attr1,
"comment",comment);
5623 (*irv)->attrs.push_back(attr1);
5633 const string fill_value_attr_name =
"_FillValue";
5634 vector<HDF5CF::Var *>::const_iterator it_v;
5635 vector<HDF5CF::Attribute *>::const_iterator ira;
5637 for (it_v =
vars.begin();
5638 it_v !=
vars.end(); ++it_v) {
5640 bool has_fillvalue =
false;
5641 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5642 if (fill_value_attr_name == (*ira)->name){
5643 has_fillvalue =
true;
5650 if (has_fillvalue !=
true ) {
5652 if(H5FLOAT32 == (*it_v)->dtype) {
5654 float _FillValue = -9999.9;
5655 Add_One_Float_Attr(attr,fill_value_attr_name,_FillValue);
5656 (*it_v)->attrs.push_back(attr);
5666 GMFile:: Correct_GPM_L1_LatLon_units(
Var *var,
const string unit_value) {
5668 BESDEBUG(
"h5",
"Coming to Correct_GPM_L1_LatLon_units()"<<endl);
5669 const string Unit_name =
"Units";
5670 const string unit_name =
"units";
5672 vector<HDF5CF::Attribute *>::iterator ira;
5675 for(ira = var->attrs.begin(); ira!= var->attrs.end();) {
5676 if(unit_name == (*ira)->name) {
5678 ira = var->attrs.erase(ira);
5680 else if(Unit_name == (*ira)->name) {
5682 ira = var->attrs.erase(ira);
5691 Add_Str_Attr(attr,unit_name,unit_value);
5692 var->attrs.push_back(attr);
5699 GMFile:: Add_Aqu_Attrs() {
5701 BESDEBUG(
"h5",
"Coming to Add_Aqu_Attrs()"<<endl);
5702 vector<HDF5CF::Var *>::const_iterator it_v;
5703 vector<HDF5CF::Attribute *>::const_iterator ira;
5705 const string orig_longname_attr_name =
"Parameter";
5706 const string longname_attr_name =
"long_name";
5707 string longname_value;
5710 const string orig_units_attr_name =
"Units";
5711 const string units_attr_name =
"units";
5714 const string orig_valid_min_attr_name =
"Data Minimum";
5715 const string valid_min_attr_name =
"valid_min";
5716 float valid_min_value = 0;
5718 const string orig_valid_max_attr_name =
"Data Maximum";
5719 const string valid_max_attr_name =
"valid_max";
5720 float valid_max_value = 0;
5725 const string fill_value_attr_name =
"_FillValue";
5726 float _FillValue = -32767.0;
5728 for (ira = this->
root_attrs.begin(); ira != this->root_attrs.end(); ++ira) {
5729 if (orig_longname_attr_name == (*ira)->name) {
5730 Retrieve_H5_Attr_Value(*ira,
"/");
5731 longname_value.resize((*ira)->value.size());
5732 copy((*ira)->value.begin(),(*ira)->value.end(),longname_value.begin());
5735 else if (orig_units_attr_name == (*ira)->name) {
5736 Retrieve_H5_Attr_Value(*ira,
"/");
5737 units_value.resize((*ira)->value.size());
5738 copy((*ira)->value.begin(),(*ira)->value.end(),units_value.begin());
5741 else if (orig_valid_min_attr_name == (*ira)->name) {
5742 Retrieve_H5_Attr_Value(*ira,
"/");
5743 memcpy(&valid_min_value,(
void*)(&((*ira)->value[0])),(*ira)->value.size());
5746 else if (orig_valid_max_attr_name == (*ira)->name) {
5747 Retrieve_H5_Attr_Value(*ira,
"/");
5748 memcpy(&valid_max_value,(
void*)(&((*ira)->value[0])),(*ira)->value.size());
5755 bool has_long_name =
false;
5756 bool has_units =
false;
5757 bool has_valid_min =
false;
5758 bool has_valid_max =
false;
5759 bool has_fillvalue =
false;
5761 for (it_v =
vars.begin();
5762 it_v !=
vars.end(); ++it_v) {
5763 if (
"l3m_data" == (*it_v)->name) {
5764 for (ira = (*it_v)->attrs.begin(); ira != (*it_v)->attrs.end(); ++ira) {
5765 if (longname_attr_name == (*ira)->name)
5766 has_long_name =
true;
5767 else if(units_attr_name == (*ira)->name)
5769 else if(valid_min_attr_name == (*ira)->name)
5770 has_valid_min =
true;
5771 else if(valid_max_attr_name == (*ira)->name)
5772 has_valid_max =
true;
5773 else if(fill_value_attr_name == (*ira)->name)
5774 has_fillvalue =
true;
5782 for (it_v =
vars.begin();
5783 it_v !=
vars.end(); ++it_v) {
5784 if (
"l3m_data" == (*it_v)->name) {
5788 if(
false == has_long_name) {
5790 Add_Str_Attr(attr,longname_attr_name,longname_value);
5791 (*it_v)->attrs.push_back(attr);
5795 if(
false == has_units) {
5797 Add_Str_Attr(attr,units_attr_name,units_value);
5798 (*it_v)->attrs.push_back(attr);
5802 if(
false == has_valid_min) {
5804 Add_One_Float_Attr(attr,valid_min_attr_name,valid_min_value);
5805 (*it_v)->attrs.push_back(attr);
5809 if(
false == has_valid_max) {
5811 Add_One_Float_Attr(attr,valid_max_attr_name,valid_max_value);
5812 (*it_v)->attrs.push_back(attr);
5816 if(
false == has_fillvalue) {
5818 Add_One_Float_Attr(attr,fill_value_attr_name,_FillValue);
5819 (*it_v)->attrs.push_back(attr);
5829 GMFile:: Add_SeaWiFS_Attrs() {
5831 BESDEBUG(
"h5",
"Coming to Add_SeaWiFS_Attrs()"<<endl);
5834 const string fill_value_attr_name =
"_FillValue";
5835 float _FillValue = -999.0;
5836 const string valid_range_attr_name =
"valid_range";
5837 vector<HDF5CF::Var *>::const_iterator it_v;
5838 vector<HDF5CF::Attribute *>::const_iterator ira;
5841 for (it_v =
vars.begin();
5842 it_v !=
vars.end(); ++it_v) {
5843 if (H5FLOAT32 == (*it_v)->dtype) {
5844 bool has_fillvalue =
false;
5845 bool has_validrange =
false;
5846 for(ira = (*it_v)->attrs.begin(); ira!= (*it_v)->attrs.end();ira++) {
5847 if (fill_value_attr_name == (*ira)->name){
5848 has_fillvalue =
true;
5852 else if(valid_range_attr_name == (*ira)->name) {
5853 has_validrange =
true;
5859 if (has_fillvalue !=
true && has_validrange !=
true ) {
5861 Add_One_Float_Attr(attr,fill_value_attr_name,_FillValue);
5862 (*it_v)->attrs.push_back(attr);
5873 string co_attrname =
"coordinates";
5874 string co_attrvalue=
"";
5875 string unit_attrname =
"units";
5876 string nonll_unit_attrvalue =
"level";
5877 string lat_unit_attrvalue =
"degrees_north";
5878 string lon_unit_attrvalue =
"degrees_east";
5880 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5881 ircv != this->cvars.end(); ++ircv) {
5884 if ((*ircv)->cvartype == CV_NONLATLON_MISS) {
5886 Add_Str_Attr(attr,unit_attrname,nonll_unit_attrvalue);
5887 (*ircv)->attrs.push_back(attr);
5890 else if ((*ircv)->cvartype == CV_LAT_MISS) {
5895 Add_Str_Attr(attr,unit_attrname,lat_unit_attrvalue);
5896 (*ircv)->attrs.push_back(attr);
5900 else if ((*ircv)->cvartype == CV_LON_MISS) {
5902 Add_Str_Attr(attr,unit_attrname,lon_unit_attrvalue);
5903 (*ircv)->attrs.push_back(attr);
5908 if(product_type == Mea_SeaWiFS_L2)
5912 else if(product_type == GPM_L1) {
5913 Handle_GPM_l1_Coor_Attr();
5917 else if (
true == iscoard) {
5924 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5925 ircv != this->cvars.end(); ++ircv) {
5926 if((*ircv)->rank == 2) {
5929 if(gp_latname == (*ircv)->name)
5930 Replace_Var_Str_Attr((*ircv),unit_attrname,lat_unit_attrvalue);
5931 else if(gp_lonname ==(*ircv)->name)
5932 Replace_Var_Str_Attr((*ircv),unit_attrname,lon_unit_attrvalue);
5937 string ll2d_dimname0,ll2d_dimname1;
5938 bool has_ll2d_coords =
false;
5939 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5940 ircv != this->cvars.end(); ++ircv) {
5941 if((*ircv)->rank == 2) {
5943 ll2d_dimname0 = (*ircv)->getDimensions()[0]->name;
5944 ll2d_dimname1 = (*ircv)->getDimensions()[1]->name;
5945 if(ll2d_dimname0 !=
"" && ll2d_dimname1 !=
"")
5946 has_ll2d_coords =
true;
5951 if(
true == has_ll2d_coords) {
5953 for (vector<Var *>::iterator irv = this->
vars.begin();
5954 irv != this->vars.end(); ++irv) {
5956 bool coor_attr_keep_exist =
false;
5959 if(((*irv)->rank >=2)) {
5961 short ll2dim_flag = 0;
5962 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
5963 ird != (*irv)->dims.end(); ++ ird) {
5964 if((*ird)->name == ll2d_dimname0)
5966 else if((*ird)->name == ll2d_dimname1)
5970 if(ll2dim_flag != 2)
5971 coor_attr_keep_exist =
true;
5974 if(product_type == OSMAPL2S)
5975 coor_attr_keep_exist =
true;
5977 if (
false == coor_attr_keep_exist) {
5978 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
5979 ira !=(*irv)->attrs.end();) {
5980 if ((*ira)->newname == co_attrname) {
5982 ira = (*irv)->attrs.erase(ira);
5990 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
5991 ird != (*irv)->dims.end(); ++ ird) {
5992 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
5993 ircv != this->cvars.end(); ++ircv) {
5994 if ((*ird)->name == (*ircv)->cfdimname)
5995 co_attrvalue = (co_attrvalue.empty())
5996 ?(*ircv)->newname:co_attrvalue +
" "+(*ircv)->newname;
6000 if (
false == co_attrvalue.empty()) {
6002 Add_Str_Attr(attr,co_attrname,co_attrvalue);
6003 (*irv)->attrs.push_back(attr);
6006 co_attrvalue.clear();
6018 BESDEBUG(
"h5",
"GMFile::Coming to Handle_Coor_Attr()"<<endl);
6019 string co_attrname =
"coordinates";
6020 string co_attrvalue=
"";
6021 string unit_attrname =
"units";
6022 string nonll_unit_attrvalue =
"level";
6023 string lat_unit_attrvalue =
"degrees_north";
6024 string lon_unit_attrvalue =
"degrees_east";
6028 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6029 ircv != this->cvars.end(); ++ircv) {
6031 if ((*ircv)->cvartype == CV_NONLATLON_MISS) {
6033 Add_Str_Attr(attr,unit_attrname,nonll_unit_attrvalue);
6034 (*ircv)->attrs.push_back(attr);
6036 else if ((*ircv)->cvartype == CV_LAT_MISS) {
6038 Add_Str_Attr(attr,unit_attrname,lat_unit_attrvalue);
6039 (*ircv)->attrs.push_back(attr);
6041 else if ((*ircv)->cvartype == CV_LON_MISS) {
6043 Add_Str_Attr(attr,unit_attrname,lon_unit_attrvalue);
6044 (*ircv)->attrs.push_back(attr);
6049 if(product_type == Mea_SeaWiFS_L2)
6053 else if(product_type == GPM_L1) {
6054 Handle_GPM_l1_Coor_Attr();
6059 else if(product_type == General_Product && gproduct_pattern == GENERAL_LATLON_COOR_ATTR){
6060 Handle_LatLon_With_CoordinateAttr_Coor_Attr();
6064 else if (
true == iscoard) {
6068 if(grp_cv_paths.size() >0) {
6069 for (vector<Var *>::iterator irv = this->
vars.begin();
6070 irv != this->vars.end(); ++irv) {
6071 if(grp_cv_paths.find(HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) != grp_cv_paths.end()){
6074 Flatten_VarPath_In_Coordinates_Attr(*irv);
6082 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6083 ircv != this->cvars.end(); ++ircv) {
6085 if((*ircv)->rank == 2 && (*ircv)->cvartype == CV_EXIST) {
6094 if(gp_latname == (*ircv)->name) {
6096 if(
false == Is_geolatlon(gp_latname,
true))
6097 Replace_Var_Str_Attr((*ircv),unit_attrname,lat_unit_attrvalue);
6099 else if(gp_lonname ==(*ircv)->name) {
6101 if(
false == Is_geolatlon(gp_lonname,
false))
6102 Replace_Var_Str_Attr((*ircv),unit_attrname,lon_unit_attrvalue);
6110 if(
true == Is_geolatlon((*ircv)->name,
true))
6111 Replace_Var_Str_Attr((*ircv),unit_attrname,lat_unit_attrvalue);
6113 else if(
true == Is_geolatlon((*ircv)->name,
false))
6114 Replace_Var_Str_Attr((*ircv),unit_attrname,lon_unit_attrvalue);
6120 if(grp_cv_paths.size() >0) {
6121 for (vector<Var *>::iterator irv = this->
vars.begin();
6122 irv != this->vars.end(); ++irv) {
6123 if(grp_cv_paths.find(HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) != grp_cv_paths.end()){
6126 Flatten_VarPath_In_Coordinates_Attr(*irv);
6132 bool has_ll2d_coords =
false;
6135 if(General_Product == this->product_type && GENERAL_DIMSCALE == this->gproduct_pattern)
6136 has_ll2d_coords =
true;
6138 string ll2d_dimname0;
6139 string ll2d_dimname1;
6140 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6141 ircv != this->cvars.end(); ++ircv) {
6142 if((*ircv)->rank == 2) {
6144 ll2d_dimname0 = (*ircv)->getDimensions()[0]->name;
6145 ll2d_dimname1 = (*ircv)->getDimensions()[1]->name;
6146 if(ll2d_dimname0 !=
"" && ll2d_dimname1 !=
"")
6147 has_ll2d_coords =
true;
6154 if(
true == has_ll2d_coords) {
6162 bool force_flatten_coor_attr = HDF5RequestHandler::get_force_flatten_coor_attr();
6166 bool has_coor_attr_ge_2d_vars =
false;
6167 for (vector<Var *>::iterator irv = this->
vars.begin();
6168 irv != this->vars.end(); ++irv) {
6169 if((*irv)->rank >=2){
6170 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end();++ira) {
6172 if((*ira)->name == co_attrname) {
6173 has_coor_attr_ge_2d_vars =
true;
6177 if(has_coor_attr_ge_2d_vars ==
true)
6184 bool is_hybrid_eos5=
false;
6185 if(force_flatten_coor_attr ==
true && has_coor_attr_ge_2d_vars ==
true)
6186 is_hybrid_eos5 = Is_Hybrid_EOS5();
6188 for (vector<Var *>::iterator irv = this->
vars.begin();
6189 irv != this->vars.end(); ++irv) {
6191 bool has_coor =
false;
6192 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end();++ira) {
6194 if((*ira)->name == co_attrname) {
6201 if(
true == force_flatten_coor_attr &&
true == has_coor) {
6203 if(is_hybrid_eos5 ==
true) {
6204 Flatten_VarPath_In_Coordinates_Attr_EOS5((*irv));
6208 Flatten_VarPath_In_Coordinates_Attr((*irv));
6211 else if(((*irv)->rank >=2) && (has_coor_attr_ge_2d_vars ==
false ||
false == force_flatten_coor_attr)) {
6213 bool coor_attr_keep_exist =
false;
6216 if(grp_cv_paths.find(HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) == grp_cv_paths.end())
6219 coor_attr_keep_exist = Check_Var_2D_CVars(*irv);
6221 coor_attr_keep_exist =
true;
6225 if(product_type == OSMAPL2S)
6226 coor_attr_keep_exist =
true;
6229 if (
false == coor_attr_keep_exist) {
6230 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin();
6231 ira !=(*irv)->attrs.end();) {
6232 if ((*ira)->newname == co_attrname) {
6234 ira = (*irv)->attrs.erase(ira);
6242 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6243 ird != (*irv)->dims.end(); ++ ird) {
6244 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6245 ircv != this->cvars.end(); ++ircv) {
6246 if ((*ird)->name == (*ircv)->cfdimname)
6247 co_attrvalue = (co_attrvalue.empty())
6248 ?(*ircv)->newname:co_attrvalue +
" "+(*ircv)->newname;
6252 if (
false == co_attrvalue.empty()) {
6254 Add_Str_Attr(attr,co_attrname,co_attrvalue);
6255 (*irv)->attrs.push_back(attr);
6258 co_attrvalue.clear();
6259 (*irv)->coord_attr_add_path =
false;
6267 void GMFile:: Handle_GPM_l1_Coor_Attr() {
6269 BESDEBUG(
"h5",
"Coming to Handle_GPM_l1_Coor_Attr()"<<endl);
6283 string co_attrname =
"coordinates";
6284 string co_attrvalue=
"";
6287 set<string> cvar_2d_dimset;
6289 pair<map<string,string>::iterator,
bool>mapret;
6292 map<string,string>cfdimname_to_cvar2dname;
6295 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
6296 irv != this->cvars.end(); ++irv) {
6299 if((*irv)->rank == 2) {
6305 for(vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6306 ird != (*irv)->dims.end(); ++ird) {
6307 cvar_2d_dimset.insert((*ird)->name);
6311 mapret = cfdimname_to_cvar2dname.insert(pair<string,string>((*irv)->cfdimname,(*irv)->newname));
6312 if (
false == mapret.second)
6313 throw4(
"The cf dimension name ",(*irv)->cfdimname,
" should map to 2-D coordinate variable",
6319 for (vector<Var *>::iterator irv = this->
vars.begin();
6320 irv != this->vars.end(); ++irv) {
6323 if((*irv)->rank >=2) {
6327 short have_2d_dimnames_flag = 0;
6328 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6329 ird !=(*irv)->dims.end();++ird) {
6330 if (cvar_2d_dimset.find((*ird)->name)!=cvar_2d_dimset.end())
6331 have_2d_dimnames_flag++;
6335 if(have_2d_dimnames_flag >=2) {
6339 if((*irv)->fullpath.size() > (*irv)->name.size())
6340 var_path=(*irv)->fullpath.substr(0,(*irv)->fullpath.size()-(*irv)->name.size());
6342 throw4(
"The variable full path ",(*irv)->fullpath,
" doesn't contain the variable name ",
6346 short cv_2d_flag = 0;
6349 vector<string> cv_2d_names;
6352 set<string> cv_2d_dimnames;
6355 for(map<string,string>::const_iterator itm = cfdimname_to_cvar2dname.begin();
6356 itm != cfdimname_to_cvar2dname.end();++itm) {
6359 string reduced_dimname = HDF5CFUtil::obtain_string_after_lastslash(itm->first);
6361 if(itm->first.size() <= reduced_dimname.size())
6362 throw2(
"The cf dim. name of this dimension is not right.",itm->first);
6364 cfdim_path= itm->first.substr(0,itm->first.size() - reduced_dimname.size());
6373 if(var_path == cfdim_path) {
6374 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6375 ird!=(*irv)->dims.end();++ird) {
6376 if(reduced_dimname == (*ird)->name) {
6378 cv_2d_names.push_back(itm->second);
6379 cv_2d_dimnames.insert((*ird)->name);
6391 if(cv_2d_flag != 2) {
6394 for(map<string,string>::const_iterator itm = cfdimname_to_cvar2dname.begin();
6395 itm != cfdimname_to_cvar2dname.end();++itm) {
6397 string reduced_dimname = HDF5CFUtil::obtain_string_after_lastslash(itm->first);
6399 if(itm->first.size() <= reduced_dimname.size())
6400 throw2(
"The cf dim. name of this dimension is not right.",itm->first);
6402 cfdim_path= itm->first.substr(0,itm->first.size() - reduced_dimname.size());
6411 if(var_path.find(cfdim_path)!=string::npos) {
6412 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6413 ird!=(*irv)->dims.end();++ird) {
6414 if(reduced_dimname == (*ird)->name) {
6416 cv_2d_names.push_back(itm->second);
6417 cv_2d_dimnames.insert((*ird)->name);
6426 if(2 == cv_2d_flag) {
6429 co_attrvalue = cv_2d_names[0] +
" " + cv_2d_names[1];
6430 if((*irv)->rank >2) {
6431 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
6432 ird !=(*irv)->dims.end();++ird) {
6435 if(cv_2d_dimnames.find((*ird)->name) == cv_2d_dimnames.end())
6436 co_attrvalue = co_attrvalue +
" " +(*ird)->newname;
6440 Add_Str_Attr(attr,co_attrname,co_attrvalue);
6441 (*irv)->attrs.push_back(attr);
6442 (*irv)->coord_attr_add_path =
false;
6450 void GMFile::Handle_LatLon_With_CoordinateAttr_Coor_Attr() {
6452 BESDEBUG(
"h5",
"Coming to Handle_LatLon_With_CoordinateAttr_Coor_Attr()"<<endl);
6453 string co_attrname =
"coordinates";
6456 for (vector<Var *>::iterator irv = this->
vars.begin();
6457 irv != this->vars.end(); ++irv) {
6458 if((*irv)->rank >= 2) {
6459 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end(); ++ira) {
6460 if((*ira)->name == co_attrname) {
6463 string coor_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
6464 if(Coord_Match_LatLon_NameSize(coor_value) ==
true)
6465 Flatten_VarPath_In_Coordinates_Attr(*irv);
6469 else if(Coord_Match_LatLon_NameSize_Same_Group(coor_value,HDF5CFUtil::obtain_string_before_lastslash((*irv)->fullpath)) ==
true)
6470 Add_VarPath_In_Coordinates_Attr(*irv,coor_value);
6482 bool GMFile::Coord_Match_LatLon_NameSize(
const string & coord_values) {
6484 BESDEBUG(
"h5",
"Coming to Coord_Match_LatLon_NameSize()"<<endl);
6485 bool ret_value =
false;
6486 vector<string> coord_values_vec;
6488 int match_lat_name_pair_index = -1;
6489 int match_lon_name_pair_index = -2;
6490 int num_match_lat = 0;
6491 int num_match_lon = 0;
6495 HDF5CFUtil::Split_helper(coord_values_vec,coord_values,sep);
6498 if((coord_values_vec[0])[0] !=
'/') {
6499 for(vector<string>::iterator irs=coord_values_vec.begin();irs!=coord_values_vec.end();++irs){
6500 if(((*irs).find_first_of(
'/'))!=string::npos) {
6501 *irs =
'/' + (*irs);
6507 for(vector<string>::iterator irs=coord_values_vec.begin();irs!=coord_values_vec.end();++irs){
6511 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin(); ivs!=latloncv_candidate_pairs.end();++ivs) {
6512 if((*irs) == (*ivs).name1){
6513 match_lat_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6516 else if ((*irs) == (*ivs).name2) {
6517 match_lon_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6523 if((match_lat_name_pair_index == match_lon_name_pair_index) && (num_match_lat ==1) && (num_match_lon ==1))
6532 bool GMFile::Coord_Match_LatLon_NameSize_Same_Group(
const string &coord_values,
const string &var_path) {
6534 BESDEBUG(
"h5",
"Coming to Coord_Match_LatLon_NameSize_Same_Group()"<<endl);
6535 bool ret_value =
false;
6536 vector<string> coord_values_vec;
6538 int match_lat_name_pair_index = -1;
6539 int match_lon_name_pair_index = -2;
6540 int num_match_lat = 0;
6541 int num_match_lon = 0;
6543 HDF5CFUtil::Split_helper(coord_values_vec,coord_values,sep);
6546 for(vector<string>::iterator irs=coord_values_vec.begin();irs!=coord_values_vec.end();++irs){
6548 for(vector<struct Name_Size_2Pairs>::iterator ivs=latloncv_candidate_pairs.begin(); ivs!=latloncv_candidate_pairs.end();++ivs) {
6549 string lat_name = HDF5CFUtil::obtain_string_after_lastslash((*ivs).name1);
6550 string lat_path = HDF5CFUtil::obtain_string_before_lastslash((*ivs).name1);
6551 string lon_name = HDF5CFUtil::obtain_string_after_lastslash((*ivs).name2);
6552 string lon_path = HDF5CFUtil::obtain_string_before_lastslash((*ivs).name2);
6553 if((*irs) == lat_name && lat_path == var_path){
6554 match_lat_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6557 else if ((*irs) == lon_name && lon_path == var_path) {
6558 match_lon_name_pair_index = distance(latloncv_candidate_pairs.begin(),ivs);
6564 if((match_lat_name_pair_index == match_lon_name_pair_index) && (num_match_lat ==1) && (num_match_lon ==1))
6571 void GMFile::Add_VarPath_In_Coordinates_Attr(
Var *var,
const string &coor_value) {
6573 BESDEBUG(
"h5",
"Coming to Add_VarPath_In_Coordinates_Attr()"<<endl);
6574 string new_coor_value;
6576 string var_path = HDF5CFUtil::obtain_string_before_lastslash(var->fullpath) ;
6577 string var_flatten_path = get_CF_string(var_path);
6580 size_t ele_start_pos = 0;
6581 size_t cur_pos = coor_value.find_first_of(sep);
6582 while(cur_pos !=string::npos) {
6583 string tempstr = coor_value.substr(ele_start_pos,cur_pos-ele_start_pos);
6584 tempstr = var_flatten_path + tempstr;
6585 new_coor_value += tempstr + sep;
6586 ele_start_pos = cur_pos+1;
6587 cur_pos = coor_value.find_first_of(sep,cur_pos+1);
6590 if(ele_start_pos == 0)
6591 new_coor_value = var_flatten_path + coor_value;
6593 new_coor_value += var_flatten_path + coor_value.substr(ele_start_pos);
6595 string coor_attr_name =
"coordinates";
6596 Replace_Var_Str_Attr(var,coor_attr_name,new_coor_value);
6597 var->coord_attr_add_path =
false;
6602 void GMFile:: Create_Missing_CV(
GMCVar *GMcvar,
const string& dimname) {
6604 BESDEBUG(
"h5",
"GMFile::Coming to Create_Missing_CV()"<<endl);
6606 GMcvar->name = dimname;
6607 GMcvar->newname = GMcvar->name;
6608 GMcvar->fullpath = GMcvar->name;
6610 GMcvar->dtype = H5INT32;
6611 hsize_t gmcvar_dimsize = dimname_to_dimsize[dimname];
6612 bool unlimited_flag = dimname_to_unlimited[dimname];
6614 gmcvar_dim->unlimited_dim = unlimited_flag;
6615 gmcvar_dim->name = dimname;
6616 gmcvar_dim->newname = dimname;
6617 GMcvar->dims.push_back(gmcvar_dim);
6618 GMcvar->cfdimname = dimname;
6619 GMcvar->cvartype = CV_NONLATLON_MISS;
6620 GMcvar->product_type = product_type;
6625 bool GMFile::Is_netCDF_Dimension(
Var *var) {
6627 string netcdf_dim_mark =
"This is a netCDF dimension but not a netCDF variable";
6629 bool is_only_dimension =
false;
6631 for(vector<Attribute *>::iterator ira = var->attrs.begin();
6632 ira != var->attrs.end();ira++) {
6634 if (
"NAME" == (*ira)->name) {
6636 Retrieve_H5_Attr_Value(*ira,var->fullpath);
6638 name_value.resize((*ira)->value.size());
6639 copy((*ira)->value.begin(),(*ira)->value.end(),name_value.begin());
6642 if (0 == name_value.compare(0,netcdf_dim_mark.size(),netcdf_dim_mark))
6643 is_only_dimension =
true;
6649 return is_only_dimension;
6659 GMFile::Is_Hybrid_EOS5() {
6661 bool has_group_hdfeos =
false;
6662 bool has_group_hdfeos_info =
false;
6668 for (vector<Group *>::iterator irg = this->
groups.begin();
6669 irg != this->groups.end(); ++ irg) {
6670 if (
"/HDFEOS" == (*irg)->path)
6671 has_group_hdfeos =
true;
6672 else if(
"/HDFEOS INFORMATION" == (*irg)->path) {
6673 for(vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
6674 ira != (*irg)->attrs.end();ira++) {
6675 if(
"HDFEOSVersion" == (*ira)->name)
6676 has_group_hdfeos_info =
true;
6679 if(
true == has_group_hdfeos &&
true == has_group_hdfeos_info)
6684 if(
true == has_group_hdfeos &&
true == has_group_hdfeos_info)
6690 void GMFile::Handle_Hybrid_EOS5() {
6692 string eos_str=
"HDFEOS_";
6693 string eos_info_str=
"HDFEOS_INFORMATION_";
6694 string grid_str=
"GRIDS_";
6695 string swath_str=
"SWATHS_";
6696 string zas_str=
"ZAS_";
6697 string df_str=
"Data_Fields_";
6698 string gf_str=
"Geolocation_Fields_";
6699 for (vector<Var *>::iterator irv = this->
vars.begin();
6700 irv != this->vars.end(); irv++) {
6701 string temp_var_name = (*irv)->newname;
6703 bool remove_eos = Remove_EOS5_Strings(temp_var_name);
6705 if(
true == remove_eos)
6706 (*irv)->newname = get_CF_string(temp_var_name);
6708 string::size_type eos_info_pos = temp_var_name.find(eos_info_str);
6709 if(eos_info_pos !=string::npos)
6710 (*irv)->newname = temp_var_name.erase(eos_info_pos,eos_info_str.size());
6712 if(Remove_EOS5_Strings_NonEOS_Fields(temp_var_name)==
true)
6713 (*irv)->newname = get_CF_string(temp_var_name);
6719 for (vector<Var *>::iterator irv = this->
vars.begin();
6720 irv != this->vars.end(); irv++) {
6721 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6722 ird!=(*irv)->dims.end(); ++ird) {
6723 string temp_dim_name = (*ird)->newname;
6724 bool remove_eos = Remove_EOS5_Strings(temp_dim_name);
6726 if(
true == remove_eos)
6727 (*ird)->newname = get_CF_string(temp_dim_name);
6729 string::size_type eos_info_pos = temp_dim_name.find(eos_info_str);
6730 if(eos_info_pos !=string::npos)
6731 (*ird)->newname = temp_dim_name.erase(eos_info_pos,eos_info_str.size());
6733 if(Remove_EOS5_Strings_NonEOS_Fields(temp_dim_name)==
true)
6734 (*ird)->newname = get_CF_string(temp_dim_name);
6741 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
6742 irv != this->cvars.end(); ++irv) {
6743 string temp_var_name = (*irv)->newname;
6745 bool remove_eos = Remove_EOS5_Strings(temp_var_name);
6747 if(
true == remove_eos)
6748 (*irv)->newname = get_CF_string(temp_var_name);
6750 string::size_type eos_info_pos = temp_var_name.find(eos_info_str);
6751 if(eos_info_pos !=string::npos)
6752 (*irv)->newname = temp_var_name.erase(eos_info_pos,eos_info_str.size());
6754 if(Remove_EOS5_Strings_NonEOS_Fields(temp_var_name)==
true)
6755 (*irv)->newname = get_CF_string(temp_var_name);
6760 for (vector<GMCVar *>::iterator irv = this->cvars.begin();
6761 irv != this->cvars.end(); irv++) {
6762 for (vector<Dimension*>::iterator ird = (*irv)->dims.begin();
6763 ird!=(*irv)->dims.end(); ++ird) {
6764 string temp_dim_name = (*ird)->newname;
6765 bool remove_eos = Remove_EOS5_Strings(temp_dim_name);
6767 if(
true == remove_eos)
6768 (*ird)->newname = get_CF_string(temp_dim_name);
6770 string::size_type eos_info_pos = temp_dim_name.find(eos_info_str);
6771 if(eos_info_pos !=string::npos)
6772 (*ird)->newname = temp_dim_name.erase(eos_info_pos,eos_info_str.size());
6774 if(Remove_EOS5_Strings_NonEOS_Fields(temp_dim_name)==
true)
6775 (*ird)->newname = get_CF_string(temp_dim_name);
6784 for (vector<Var *>::iterator irv = this->
vars.begin();
6785 irv != this->vars.end(); irv++) {
6786 for(vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
6787 ira != (*irv)->attrs.end();ira++) {
6790 if((*ira)->name ==
"coordinates") {
6791 string cor_values((*ira)->value.begin(),(*ira)->value.end()) ;
6792 bool change_cor_values =
false;
6794 if(cor_values.find(eos_str)==0) {
6795 if(cor_values.find(grid_str)!=string::npos) {
6796 cor_values = HDF5CFUtil::remove_substrings(cor_values,eos_str);
6797 cor_values = HDF5CFUtil::remove_substrings(cor_values,grid_str);
6798 string new_cor_values = HDF5CFUtil::remove_substrings(cor_values,df_str);
6799 if(new_cor_values.size() < cor_values.size()){
6800 change_cor_values =
true;
6801 cor_values = new_cor_values;
6804 else if(cor_values.find(zas_str)!=string::npos) {
6805 cor_values = HDF5CFUtil::remove_substrings(cor_values,eos_str);
6806 cor_values = HDF5CFUtil::remove_substrings(cor_values,zas_str);
6807 string new_cor_values = HDF5CFUtil::remove_substrings(cor_values,df_str);
6808 if(new_cor_values.size() < cor_values.size()){
6809 change_cor_values =
true;
6810 cor_values = new_cor_values;
6813 else if(cor_values.find(swath_str)!=string::npos) {
6814 cor_values = HDF5CFUtil::remove_substrings(cor_values,eos_str);
6815 cor_values = HDF5CFUtil::remove_substrings(cor_values,swath_str);
6816 string new_cor_values = HDF5CFUtil::remove_substrings(cor_values,df_str);
6817 if(new_cor_values.size() < cor_values.size()){
6818 change_cor_values =
true;
6819 cor_values = new_cor_values;
6822 new_cor_values = HDF5CFUtil::remove_substrings(cor_values,gf_str);
6823 if(new_cor_values.size() < cor_values.size()){
6824 change_cor_values =
true;
6825 cor_values = new_cor_values;
6830 if(
true == change_cor_values) {
6831 (*ira)->value.resize(cor_values.size());
6832 (*ira)->fstrsize=cor_values.size();
6833 (*ira)->strsize[0] = cor_values.size();
6834 copy(cor_values.begin(), cor_values.end(), (*ira)->value.begin());
6835 (*irv)->coord_attr_add_path =
false;
6846 bool GMFile:: Remove_EOS5_Strings(
string &var_name) {
6848 string eos_str=
"HDFEOS_";
6849 string grid_str=
"GRIDS_";
6850 string swath_str=
"SWATHS_";
6851 string zas_str=
"ZAS_";
6852 string df_str=
"Data_Fields_";
6853 string gf_str=
"Geolocation_Fields_";
6854 string temp_var_name = var_name;
6856 bool remove_eos =
false;
6858 string::size_type eos_pos = temp_var_name.find(eos_str);
6859 if(eos_pos!=string::npos) {
6860 temp_var_name.erase(eos_pos,eos_str.size());
6862 string::size_type grid_pos=temp_var_name.find(grid_str);
6863 string::size_type grid_df_pos=string::npos;
6864 if(grid_pos!=string::npos)
6865 grid_df_pos = temp_var_name.find(df_str,grid_pos);
6866 string::size_type zas_pos = string::npos;
6867 string::size_type zas_df_pos=string::npos;
6868 if(grid_pos==string::npos || grid_df_pos ==string::npos)
6869 zas_pos=temp_var_name.find(zas_str);
6870 if(zas_pos!=string::npos)
6871 zas_df_pos=temp_var_name.find(df_str,zas_pos);
6873 if(grid_pos !=string::npos && grid_df_pos!=string::npos) {
6874 temp_var_name.erase(grid_pos,grid_str.size());
6875 grid_df_pos = temp_var_name.find(df_str);
6876 temp_var_name.erase(grid_df_pos,df_str.size());
6879 else if(zas_pos!=string::npos && zas_df_pos!=string::npos){
6880 temp_var_name.erase(zas_pos,zas_str.size());
6881 zas_df_pos = temp_var_name.find(df_str);
6882 temp_var_name.erase(zas_df_pos,df_str.size());
6887 string::size_type swath_pos=temp_var_name.find(swath_str);
6888 string::size_type swath_df_pos=string::npos;
6889 if(swath_pos!=string::npos)
6890 swath_df_pos=temp_var_name.find(df_str,swath_pos);
6892 string::size_type swath_gf_pos=string::npos;
6893 if(swath_pos!=string::npos && swath_df_pos == string::npos)
6894 swath_gf_pos=temp_var_name.find(gf_str,swath_pos);
6896 if(swath_pos !=string::npos) {
6898 if(swath_df_pos!=string::npos) {
6899 temp_var_name.erase(swath_pos,swath_str.size());
6900 swath_df_pos = temp_var_name.find(df_str);
6901 temp_var_name.erase(swath_df_pos,df_str.size());
6904 else if(swath_gf_pos!=string::npos) {
6905 temp_var_name.erase(swath_pos,swath_str.size());
6906 swath_gf_pos = temp_var_name.find(gf_str);
6907 temp_var_name.erase(swath_gf_pos,gf_str.size());
6913 if(
true == remove_eos)
6914 var_name = temp_var_name;
6919 bool GMFile:: Remove_EOS5_Strings_NonEOS_Fields(
string &var_name) {
6921 string eos_str=
"HDFEOS_";
6922 string grid_str=
"GRIDS_";
6923 string swath_str=
"SWATHS_";
6924 string zas_str=
"ZAS_";
6925 string temp_var_name = var_name;
6927 bool remove_eos =
false;
6929 string::size_type eos_pos = temp_var_name.find(eos_str);
6930 if(eos_pos!=string::npos) {
6931 temp_var_name.erase(eos_pos,eos_str.size());
6935 if(temp_var_name.find(grid_str)==0)
6936 temp_var_name.erase(0,grid_str.size());
6937 else if(temp_var_name.find(swath_str)==0)
6938 temp_var_name.erase(0,swath_str.size());
6939 else if(temp_var_name.find(zas_str)==0)
6940 temp_var_name.erase(0,zas_str.size());
6942 if(
true == remove_eos)
6943 var_name = temp_var_name;
6964 if(this->unsupported_var_dtype ==
true) {
6967 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
6968 ircv != this->cvars.end();) {
6969 if((*ircv)->newname.find(
"FakeDim")==0) {
6970 bool var_has_fakedim =
false;
6971 for (vector<Var*>::iterator irv2 = this->
vars.begin();
6972 irv2 != this->vars.end(); irv2++) {
6973 for (vector<Dimension *>::iterator ird = (*irv2)->dims.begin();
6974 ird !=(*irv2)->dims.end(); ird++) {
6975 if((*ird)->newname == (*ircv)->newname){
6976 var_has_fakedim =
true;
6980 if(var_has_fakedim ==
true)
6983 if(var_has_fakedim ==
false) {
6986 ircv = this->cvars.erase(ircv);
7008 if(
true == this->have_nc4_non_coord) {
7009 string nc4_non_coord=
"_nc4_non_coord_";
7010 size_t nc4_non_coord_size= nc4_non_coord.size();
7011 for (vector<Var*>::iterator irv = this->
vars.begin();
7012 irv != this->vars.end(); irv++) {
7013 if((*irv)->name.find(nc4_non_coord)==0)
7014 (*irv)->newname = (*irv)->newname.substr(nc4_non_coord_size,(*irv)->newname.size()-nc4_non_coord_size);
7017 for (vector<GMCVar *>::iterator ircv = this->cvars.begin();
7018 ircv != this->cvars.end();++ircv) {
7019 if((*ircv)->name.find(nc4_non_coord)==0)
7020 (*ircv)->newname = (*ircv)->newname.substr(nc4_non_coord_size,(*ircv)->newname.size()-nc4_non_coord_size);
7028 BESDEBUG(
"h5",
"GMFile::Coming to Add_Path_Coor_Attr()"<<endl);
7029 string co_attrname =
"coordinates";
7030 for (vector<Var *>::iterator irv = this->
vars.begin();
7031 irv != this->vars.end(); ++irv) {
7032 if((*irv)->coord_attr_add_path ==
true) {
7033 for (vector<Attribute *>:: iterator ira =(*irv)->attrs.begin(); ira !=(*irv)->attrs.end();++ira) {
7035 if((*ira)->name == co_attrname) {
7036 string coor_value = Retrieve_Str_Attr_Value(*ira,(*irv)->fullpath);
7038 vector<string>cvalue_vec;
7039 HDF5CFUtil::Split_helper(cvalue_vec,coor_value,sep);
7040 string new_coor_value;
7041 for (
int i = 0; i<cvalue_vec.size();i++) {
7042 HDF5CFUtil::cha_co(cvalue_vec[i],(*irv)->fullpath);
7043 cvalue_vec[i] = get_CF_string(cvalue_vec[i]);
7045 new_coor_value = cvalue_vec[i];
7047 new_coor_value += sep+cvalue_vec[i];
7052 Replace_Var_Str_Attr((*irv),co_attrname,new_coor_value);
7067 GMFile::release_standalone_GMCVar_vector(vector<GMCVar*>&tempgc_vars){
7069 for (vector<GMCVar *>::iterator i = tempgc_vars.begin();
7070 i != tempgc_vars.end(); ) {
7072 i = tempgc_vars.erase(i);
7079 GMFile::add_ignored_info_attrs(
bool is_grp,
bool is_first){
7083 GMFile::add_ignored_info_objs(
bool is_dim_related,
bool is_first) {
7090 GMFile::ignored_dimscale_ref_list(
Var *var) {
7092 bool ignored_dimscale =
true;
7093 if(General_Product == this->product_type && GENERAL_DIMSCALE== this->gproduct_pattern) {
7095 bool has_dimscale =
false;
7096 bool has_reference_list =
false;
7097 for(vector<Attribute *>::iterator ira = var->attrs.begin();
7098 ira != var->attrs.end();ira++) {
7099 if((*ira)->name ==
"REFERENCE_LIST" &&
7100 false == HDF5CFUtil::cf_strict_support_type((*ira)->getType()))
7101 has_reference_list =
true;
7102 if((*ira)->name ==
"CLASS") {
7103 Retrieve_H5_Attr_Value(*ira,var->fullpath);
7105 class_value.resize((*ira)->value.size());
7106 copy((*ira)->value.begin(),(*ira)->value.end(),class_value.begin());
7110 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
7111 has_dimscale =
true;
7115 if(
true == has_dimscale &&
true == has_reference_list) {
7116 ignored_dimscale=
false;
7122 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)