41#include <libdap/InternalErr.h>
66using namespace HDF5CF;
69void map_gmh5_cfdds(DDS &dds, hid_t file_id,
const string& filename){
71 BESDEBUG(
"h5",
"Coming to GM products DDS mapping function map_gmh5_cfdds() "<<endl);
73 H5GCFProduct product_type = check_product(file_id);
75 GMPattern gproduct_pattern = OTHERGMS;
80 f =
new GMFile(filename.c_str(),file_id,product_type,gproduct_pattern);
83 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate memory for GMFile ");
86 bool include_attr =
false;
121 if((HDF5RequestHandler::get_lrdata_mem_cache() != NULL) ||
122 (HDF5RequestHandler::get_srdata_mem_cache() != NULL)){
145 if((HDF5RequestHandler::get_lrdata_mem_cache() != NULL) ||
146 (HDF5RequestHandler::get_srdata_mem_cache() != NULL))
158 if(General_Product == product_type ||
159 true == HDF5RequestHandler::get_check_name_clashing())
164 if(General_Product == product_type ||
165 true == HDF5RequestHandler::get_check_name_clashing())
168 f->Handle_Hybrid_EOS5();
172 if((HDF5RequestHandler::get_lrdata_mem_cache() != NULL) ||
173 (HDF5RequestHandler::get_srdata_mem_cache() != NULL))
182 throw InternalErr(e.what());
187 gen_gmh5_cfdds(dds,f);
200void map_gmh5_cfdas(DAS &das, hid_t file_id,
const string& filename){
202 BESDEBUG(
"h5",
"Coming to GM products DAS mapping function map_gmh5_cfdas() "<<endl);
204 H5GCFProduct product_type = check_product(file_id);
205 GMPattern gproduct_pattern = OTHERGMS;
210 f =
new GMFile(filename.c_str(),file_id,product_type,gproduct_pattern);
213 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate memory for GMFile ");
216 bool include_attr =
true;
250 if(General_Product == product_type ||
251 true == HDF5RequestHandler::get_check_name_clashing())
258 f->Handle_Hybrid_EOS5();
266 if(
true == HDF5RequestHandler::get_enable_coord_attr_add_path())
272 throw InternalErr(e.what());
277 gen_gmh5_cfdas(das,f);
291void map_gmh5_cfdmr(D4Group *d4_root, hid_t file_id,
const string& filename){
293 BESDEBUG(
"h5",
"Coming to GM products DMR mapping function map_gmh5_cfdmr() "<<endl);
295 H5GCFProduct product_type = check_product(file_id);
297 GMPattern gproduct_pattern = OTHERGMS;
302 f =
new GMFile(filename.c_str(),file_id,product_type,gproduct_pattern);
305 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate memory for GMFile ");
309 bool include_attr =
true;
386 if(General_Product == product_type ||
387 true == HDF5RequestHandler::get_check_name_clashing())
392 if(General_Product == product_type ||
393 true == HDF5RequestHandler::get_check_name_clashing())
399 f->Handle_Hybrid_EOS5();
404 if((HDF5RequestHandler::get_lrdata_mem_cache() != NULL) ||
405 (HDF5RequestHandler::get_srdata_mem_cache() != NULL))
412 if(
true == HDF5RequestHandler::get_enable_coord_attr_add_path())
419 throw InternalErr(e.what());
424 gen_gmh5_cfdmr(d4_root,f);
440 BESDEBUG(
"h5",
"Coming to GM DDS generation function gen_gmh5_cfdds() "<<endl);
442 const vector<HDF5CF::Var *>& vars = f->
getVars();
443 const vector<HDF5CF::GMCVar *>& cvars = f->getCVars();
444 const vector<HDF5CF::GMSPVar *>& spvars = f->getSPVars();
445 const string filename = f->
getPath();
450 vector<HDF5CF::Var *>::const_iterator it_v;
451 vector<HDF5CF::GMCVar *>::const_iterator it_cv;
452 vector<HDF5CF::GMSPVar *>::const_iterator it_spv;
456 bool dmr_64bit_support =
false;
457 if(HDF5RequestHandler::get_dmr_long_int()==
true &&
458 HDF5RequestHandler::get_dmr_64bit_int()!=NULL) {
459 for (it_v = vars.begin(); it_v !=vars.end();++it_v) {
460 if (H5INT64 == (*it_v)->getType() || H5UINT64 == (*it_v)->getType()){
461 dmr_64bit_support =
true;
468 if(
true == dmr_64bit_support) {
477 for (it_v = vars.begin(); it_v !=vars.end();++it_v) {
478 BESDEBUG(
"h5",
"variable full path= "<< (*it_v)->getFullPath() <<endl);
480 if(need_attr_values_for_dap4(*it_v) ==
true)
482 gen_dap_onevar_dds(dds,*it_v,fileid, filename);
484 for (it_cv = cvars.begin(); it_cv !=cvars.end();++it_cv) {
485 BESDEBUG(
"h5",
"variable full path= "<< (*it_cv)->getFullPath() <<endl);
486 gen_dap_onegmcvar_dds(dds,*it_cv,fileid, filename);
489 for (it_spv = spvars.begin(); it_spv !=spvars.end();it_spv++) {
490 BESDEBUG(
"h5",
"variable full path= "<< (*it_spv)->getFullPath() <<endl);
491 gen_dap_onegmspvar_dds(dds,*it_spv,fileid, filename);
499 BESDEBUG(
"h5",
"Coming to GM DAS generation function gen_gmh5_cfdas() "<<endl);
503 gen_gmh5_cf_ignored_obj_info(das, f);
507 const vector<HDF5CF::Var *>& vars = f->
getVars();
508 const vector<HDF5CF::GMCVar *>& cvars = f->getCVars();
509 const vector<HDF5CF::GMSPVar *>& spvars = f->getSPVars();
510 const vector<HDF5CF::Group *>& grps = f->
getGroups();
511 const vector<HDF5CF::Attribute *>& root_attrs = f->
getAttributes();
514 vector<HDF5CF::Var *>::const_iterator it_v;
515 vector<HDF5CF::GMCVar *>::const_iterator it_cv;
516 vector<HDF5CF::GMSPVar *>::const_iterator it_spv;
517 vector<HDF5CF::Group *>::const_iterator it_g;
518 vector<HDF5CF::Attribute *>::const_iterator it_ra;
523 if (
false == root_attrs.empty()) {
525 AttrTable *at = das.get_table(FILE_ATTR_TABLE_NAME);
527 at = das.add_table(FILE_ATTR_TABLE_NAME,
new AttrTable);
529 for (it_ra = root_attrs.begin(); it_ra != root_attrs.end(); ++it_ra) {
531 check_update_int64_attr(
"",*it_ra);
532 gen_dap_oneobj_das(at,*it_ra,NULL);
536 if (
false == grps.empty()) {
537 for (it_g = grps.begin();
538 it_g != grps.end(); ++it_g) {
539 AttrTable *at = das.get_table((*it_g)->getNewName());
541 at = das.add_table((*it_g)->getNewName(),
new AttrTable);
543 for (it_ra = (*it_g)->getAttributes().begin();
544 it_ra != (*it_g)->getAttributes().end(); ++it_ra) {
545 check_update_int64_attr((*it_g)->getNewName(),*it_ra);
546 gen_dap_oneobj_das(at,*it_ra,NULL);
551 for (it_v = vars.begin();
552 it_v != vars.end(); ++it_v) {
553 if (
false == ((*it_v)->getAttributes().empty())) {
559 if(H5INT64 == (*it_v)->getType() || H5UINT64 == (*it_v)->getType()){
563 AttrTable *at = das.get_table((*it_v)->getNewName());
565 at = das.add_table((*it_v)->getNewName(),
new AttrTable);
567 for (it_ra = (*it_v)->getAttributes().begin();
568 it_ra != (*it_v)->getAttributes().end(); ++it_ra) {
569 gen_dap_oneobj_das(at,*it_ra,*it_v);
579 if(GPMS_L3 == f->getProductType() || GPMM_L3 == f->getProductType()
580 || GPM_L1 == f->getProductType())
581 update_GPM_special_attrs(das,*it_v,
false);
585 for (it_cv = cvars.begin();
586 it_cv != cvars.end(); ++it_cv) {
587 if (
false == ((*it_cv)->getAttributes().empty())) {
590 if(H5INT64 == (*it_cv)->getType() || H5UINT64 == (*it_cv)->getType()){
594 AttrTable *at = das.get_table((*it_cv)->getNewName());
596 at = das.add_table((*it_cv)->getNewName(),
new AttrTable);
598 for (it_ra = (*it_cv)->getAttributes().begin();
599 it_ra != (*it_cv)->getAttributes().end(); ++it_ra){
600 gen_dap_oneobj_das(at,*it_ra,*it_cv);
605 if(GPMS_L3 == f->getProductType() || GPMM_L3 == f->getProductType()
606 || GPM_L1 == f->getProductType())
607 update_GPM_special_attrs(das,*it_cv,
true);
612 for (it_spv = spvars.begin();
613 it_spv != spvars.end(); ++it_spv) {
614 if (
false == ((*it_spv)->getAttributes().empty())) {
616 AttrTable *at = das.get_table((*it_spv)->getNewName());
618 at = das.add_table((*it_spv)->getNewName(),
new AttrTable);
623 for (it_ra = (*it_spv)->getAttributes().begin();
624 it_ra != (*it_spv)->getAttributes().end(); ++it_ra)
625 gen_dap_oneobj_das(at,*it_ra,*it_spv);
632 BESDEBUG(
"h5",
"Find unlimited dimension in the GM DAS generation function gen_gmh5_cfdas() "<<endl);
637 if(cvars.empty()==
false ){
641 bool still_has_unlimited =
false;
642 for (it_cv = cvars.begin();
643 it_cv != cvars.end(); ++it_cv) {
645 for (vector<Dimension*>::const_iterator ird = (*it_cv)->getDimensions().begin();
646 ird != (*it_cv)->getDimensions().end(); ++ird) {
651 if((*ird)->HaveUnlimitedDim() ==
true) {
652 still_has_unlimited =
true;
656 if(
true == still_has_unlimited)
660 if(
true == still_has_unlimited) {
661 AttrTable* at = das.get_table(
"DODS_EXTRA");
663 at = das.add_table(
"DODS_EXTRA",
new AttrTable);
665 string unlimited_names;
667 for (it_cv = cvars.begin();
668 it_cv != cvars.end(); ++it_cv) {
670 bool has_unlimited_dim =
false;
673 for (vector<Dimension*>::const_iterator ird = (*it_cv)->getDimensions().begin();
674 ird != (*it_cv)->getDimensions().end(); ++ird) {
679 if((*ird)->HaveUnlimitedDim() ==
true) {
680 if(unlimited_names==
"") {
681 unlimited_names = (*ird)->getNewName();
683 at->append_attr(
"Unlimited_Dimension",
"String",unlimited_names);
686 if(unlimited_names.rfind((*ird)->getNewName()) == string::npos) {
687 unlimited_names = unlimited_names+
" "+(*ird)->getNewName();
689 at->append_attr(
"Unlimited_Dimension",
"String",(*ird)->getNewName());
708 BESDEBUG(
"h5",
"Coming to GM DDS generation function gen_gmh5_cfdmr() "<<endl);
710 const vector<HDF5CF::Var *>& vars = f->
getVars();
711 const vector<HDF5CF::GMCVar *>& cvars = f->getCVars();
712 const vector<HDF5CF::GMSPVar *>& spvars = f->getSPVars();
713 const string filename = f->
getPath();
715 const vector<HDF5CF::Group *>& grps = f->
getGroups();
716 const vector<HDF5CF::Attribute *>& root_attrs = f->
getAttributes();
718 vector<HDF5CF::Var *>::const_iterator it_v;
719 vector<HDF5CF::GMCVar *>::const_iterator it_cv;
720 vector<HDF5CF::GMSPVar *>::const_iterator it_spv;
721 vector<HDF5CF::Group *>::const_iterator it_g;
722 vector<HDF5CF::Attribute *>::const_iterator it_ra;
725 if (
false == root_attrs.empty()) {
726 for (it_ra = root_attrs.begin(); it_ra != root_attrs.end(); ++it_ra)
727 map_cfh5_grp_attr_to_dap4(d4_root,*it_ra);
731 for (it_v = vars.begin(); it_v !=vars.end();++it_v) {
732 BESDEBUG(
"h5",
"variable full path= "<< (*it_v)->getFullPath() <<endl);
733 gen_dap_onevar_dmr(d4_root,*it_v,fileid, filename);
736 for (it_cv = cvars.begin(); it_cv !=cvars.end();++it_cv) {
737 BESDEBUG(
"h5",
"variable full path= "<< (*it_cv)->getFullPath() <<endl);
738 gen_dap_onegmcvar_dmr(d4_root,*it_cv,fileid, filename);
741 for (it_spv = spvars.begin(); it_spv !=spvars.end();it_spv++) {
742 BESDEBUG(
"h5",
"variable full path= "<< (*it_spv)->getFullPath() <<endl);
743 gen_dap_onegmspvar_dmr(d4_root,*it_spv,fileid, filename);
747 if (
false == grps.empty()) {
748 for (it_g = grps.begin();
749 it_g != grps.end(); ++it_g) {
751 D4Attribute *tmp_grp =
new D4Attribute;
752 tmp_grp->set_name((*it_g)->getNewName());
755 tmp_grp->set_type(attr_container_c);
757 for (it_ra = (*it_g)->getAttributes().begin();
758 it_ra != (*it_g)->getAttributes().end(); ++it_ra) {
759 map_cfh5_attr_container_to_dap4(tmp_grp,(*it_ra));
762 d4_root->attributes()->add_attribute_nocopy(tmp_grp);
769 BESDEBUG(
"h5",
"Find unlimited dimension in the GM DMR generation function gen_gmh5_cfdmr() "<<endl);
774 if(cvars.empty()==
false ){
778 bool still_has_unlimited =
false;
779 for (it_cv = cvars.begin();
780 it_cv != cvars.end(); ++it_cv) {
782 for (vector<Dimension*>::const_iterator ird = (*it_cv)->getDimensions().begin();
783 ird != (*it_cv)->getDimensions().end(); ++ird) {
788 if((*ird)->HaveUnlimitedDim() ==
true) {
789 still_has_unlimited =
true;
793 if(
true == still_has_unlimited)
797 if(
true == still_has_unlimited) {
799 string dods_extra =
"DODS_EXTRA";
802 if(d4_root->attributes() != NULL) {
806 string unlimited_dim_names =
"";
808 for (it_cv = cvars.begin();
809 it_cv != cvars.end(); it_cv++) {
812 for (vector<Dimension*>::const_iterator ird = (*it_cv)->getDimensions().begin();
813 ird != (*it_cv)->getDimensions().end(); ++ird) {
818 if((*ird)->HaveUnlimitedDim() ==
true) {
820 string unlimited_dim_name = (*ird)->getNewName();
821 if(unlimited_dim_names==
"")
822 unlimited_dim_names = unlimited_dim_name;
824 if(unlimited_dim_names.rfind(unlimited_dim_name) == string::npos)
825 unlimited_dim_names = unlimited_dim_names+
" "+unlimited_dim_name;
831 if(unlimited_dim_names !=
"") {
832 D4Attribute *dods_extra_attr =
new D4Attribute(dods_extra,attr_container_c);
833 D4Attribute *unlimited_dim_attr =
new D4Attribute(
"Unlimited_Dimension",attr_str_c);
834 unlimited_dim_attr->add_value(unlimited_dim_names);
835 dods_extra_attr->attributes()->add_attribute_nocopy(unlimited_dim_attr);
836 d4_root->attributes()->add_attribute_nocopy(dods_extra_attr);
840 throw InternalErr(__FILE__, __LINE__,
"Unlimited dimension should exist.");
853 BESDEBUG(
"h5",
"Coming to gen_gmh5_cf_ignored_obj_info() "<<endl);
854 AttrTable *at = das.get_table(
"Ignored_Object_Info");
856 at = das.add_table(
"Ignored_Object_Info",
new AttrTable);
863void gen_dap_onegmcvar_dds(DDS &dds,
const HDF5CF::GMCVar* cvar,
const hid_t file_id,
const string & filename) {
865 BESDEBUG(
"h5",
"Coming to gen_dap_onegmcvar_dds() "<<endl);
872#define HANDLE_CASE(tid,type) \
874 bt = new (type)(cvar->getNewName(),cvar->getFullPath()); \
885 HANDLE_CASE(H5FSTRING, Str);
886 HANDLE_CASE(H5VSTRING, Str);
889 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
895 const vector<HDF5CF::Dimension *>& dims = cvar->
getDimensions();
896 vector <HDF5CF::Dimension*>:: const_iterator it_d;
897 vector <size_t> dimsizes;
898 dimsizes.resize(cvar->
getRank());
899 for(
int i = 0; i <cvar->
getRank();i++)
900 dimsizes[i] = (dims[i])->getSize();
904 throw InternalErr(__FILE__,__LINE__,
"the coordinate variable cannot be a scalar");
913 bool is_latlon = cvar->isLatLon();
923 cvar->getTotalElems(),
933 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5CFArray. ");
936 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
937 if (
""==(*it_d)->getNewName())
938 ar->append_dim((*it_d)->getSize());
940 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
968 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissLLArray. ");
972 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
973 if (
""==(*it_d)->getNewName())
974 ar->append_dim((*it_d)->getSize());
976 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
985 case CV_NONLATLON_MISS:
990 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
1005 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
1009 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1010 if (
""==(*it_d)->getNewName())
1011 ar->append_dim((*it_d)->getSize());
1013 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1026 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
1041 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
1045 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1046 if (
""==(*it_d)->getNewName())
1047 ar->append_dim((*it_d)->getSize());
1049 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1063 throw InternalErr(__FILE__, __LINE__,
"The rank of special coordinate variable must be 1");
1076 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1077 if (
""==(*it_d)->getNewName())
1078 ar->append_dim((*it_d)->getSize());
1080 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1092 throw InternalErr(__FILE__,__LINE__,
"Coordinate variable type is not supported.");
1098void gen_dap_onegmspvar_dds(DDS &dds,
const HDF5CF::GMSPVar* spvar,
const hid_t fileid,
const string & filename) {
1100 BESDEBUG(
"h5",
"Coming to gen_dap_onegmspvar_dds() "<<endl);
1101 BaseType *bt = NULL;
1104#define HANDLE_CASE(tid,type) \
1106 bt = new (type)(spvar->getNewName(),spvar->getFullPath()); \
1117 HANDLE_CASE(H5FSTRING, Str);
1118 HANDLE_CASE(H5VSTRING, Str);
1120 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
1126 const vector<HDF5CF::Dimension *>& dims = spvar->
getDimensions();
1127 vector <HDF5CF::Dimension*>:: const_iterator it_d;
1130 throw InternalErr(__FILE__,__LINE__,
"Currently don't support scalar special variables. ");
1141 spvar->getOriginalType(),
1142 spvar->getStartBit(),
1149 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
1153 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1154 if (
""==(*it_d)->getNewName())
1155 ar->append_dim((*it_d)->getSize());
1157 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1171void update_GPM_special_attrs(DAS& das,
const HDF5CF::Var *var,
bool is_cvar) {
1173 BESDEBUG(
"h5",
"Coming to update_GPM_special_attrs() "<<endl);
1174 if(H5FLOAT64 == var->
getType() ||
1175 H5FLOAT32 == var->
getType() ||
1179 AttrTable *at = das.get_table(var->
getNewName());
1181 at = das.add_table(var->
getNewName(),
new AttrTable);
1182 bool has_fillvalue =
false;
1183 AttrTable::Attr_iter it = at->attr_begin();
1184 while (it!=at->attr_end() &&
false==has_fillvalue) {
1185 if (at->get_name(it) ==
"_FillValue")
1187 has_fillvalue =
true;
1188 string fillvalue =
"";
1189 if(H5FLOAT32 == var->
getType()) {
1190 const string cor_fill_value =
"-9999.9";
1191 fillvalue = (*at->get_attr_vector(it)->begin());
1192 if((fillvalue.find(cor_fill_value) == 0) && (fillvalue!= cor_fill_value)) {
1193 at->del_attr(
"_FillValue");
1194 at->append_attr(
"_FillValue",
"Float32",cor_fill_value);
1197 else if(H5FLOAT64 == var->
getType()) {
1198 const string cor_fill_value =
"-9999.9";
1199 const string exist_fill_value_substr =
"-9999.8999";
1200 fillvalue = (*at->get_attr_vector(it)->begin());
1201 if((fillvalue.find(exist_fill_value_substr) == 0) && (fillvalue!= cor_fill_value)) {
1202 at->del_attr(
"_FillValue");
1203 at->append_attr(
"_FillValue",
"Float64",cor_fill_value);
1212 if(
false == is_cvar ) {
1215 if (has_fillvalue !=
true ) {
1217 if(H5FLOAT32 == var->
getType())
1218 at->append_attr(
"_FillValue",
"Float32",
"-9999.9");
1219 else if(H5FLOAT64 == var->
getType())
1220 at->append_attr(
"_FillValue",
"Float64",
"-9999.9");
1221 else if (H5INT16 == var->
getType())
1222 at->append_attr(
"_FillValue",
"Int16",
"-9999");
1223 else if (H5CHAR == var->
getType())
1224 at->append_attr(
"_FillValue",
"Int16",
"-99");
1231void gen_dap_onegmcvar_dmr(D4Group*d4_root,
const GMCVar* cvar,
const hid_t fileid,
const string &filename) {
1233 BESDEBUG(
"h5",
"Coming to gen_dap_onegmcvar_dds() "<<endl);
1235 BaseType *bt = NULL;
1238#define HANDLE_CASE(tid,type) \
1240 bt = new (type)(cvar->getNewName(),cvar->getFullPath()); \
1253 HANDLE_CASE(H5FSTRING, Str);
1254 HANDLE_CASE(H5VSTRING, Str);
1257 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
1263 const vector<HDF5CF::Dimension *>& dims = cvar->
getDimensions();
1264 vector <HDF5CF::Dimension*>:: const_iterator it_d;
1265 vector <size_t> dimsizes;
1266 dimsizes.resize(cvar->
getRank());
1268 for(
int i = 0; i <cvar->
getRank();i++)
1269 dimsizes[i] = (dims[i])->getSize();
1272 throw InternalErr(__FILE__,__LINE__,
"the coordinate variable cannot be a scalar");
1281 bool is_latlon = cvar->isLatLon();
1285 bool is_dap4 =
true;
1293 cvar->getTotalElems(),
1303 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5CFArray. ");
1306 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1307 if (
""==(*it_d)->getNewName())
1308 ar->append_dim((*it_d)->getSize());
1310 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1313 ar->set_is_dap4(
true);
1314 BaseType* d4_var=ar->h5cfdims_transform_to_dap4(d4_root);
1315 map_cfh5_var_attrs_to_dap4(cvar,d4_var);
1316 d4_root->add_var_nocopy(d4_var);
1341 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissLLArray. ");
1344 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1345 if (
""==(*it_d)->getNewName())
1346 ar->append_dim((*it_d)->getSize());
1348 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1351 ar->set_is_dap4(
true);
1352 BaseType* d4_var=ar->h5cfdims_transform_to_dap4(d4_root);
1353 map_cfh5_var_attrs_to_dap4(cvar,d4_var);
1354 d4_root->add_var_nocopy(d4_var);
1360 case CV_NONLATLON_MISS:
1365 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
1380 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
1384 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1385 if (
""==(*it_d)->getNewName())
1386 ar->append_dim((*it_d)->getSize());
1388 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1390 ar->set_is_dap4(
true);
1391 BaseType* d4_var=ar->h5cfdims_transform_to_dap4(d4_root);
1392 map_cfh5_var_attrs_to_dap4(cvar,d4_var);
1393 d4_root->add_var_nocopy(d4_var);
1404 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
1419 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
1423 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1424 if (
""==(*it_d)->getNewName())
1425 ar->append_dim((*it_d)->getSize());
1427 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1429 ar->set_is_dap4(
true);
1430 BaseType* d4_var=ar->h5cfdims_transform_to_dap4(d4_root);
1431 map_cfh5_var_attrs_to_dap4(cvar,d4_var);
1432 d4_root->add_var_nocopy(d4_var);
1444 throw InternalErr(__FILE__, __LINE__,
"The rank of special coordinate variable must be 1");
1457 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1458 if (
""==(*it_d)->getNewName())
1459 ar->append_dim((*it_d)->getSize());
1461 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1464 ar->set_is_dap4(
true);
1465 BaseType* d4_var=ar->h5cfdims_transform_to_dap4(d4_root);
1466 map_cfh5_var_attrs_to_dap4(cvar,d4_var);
1467 d4_root->add_var_nocopy(d4_var);
1476 throw InternalErr(__FILE__,__LINE__,
"Coordinate variable type is not supported.");
1483void gen_dap_onegmspvar_dmr(D4Group*d4_root,
const GMSPVar*spvar,
const hid_t fileid,
const string &filename) {
1485 BESDEBUG(
"h5",
"Coming to gen_dap_onegmspvar_dmr() "<<endl);
1486 BaseType *bt = NULL;
1494#define HANDLE_CASE(tid,type) \
1496 bt = new (type)(spvar->getNewName(),spvar->getFullPath()); \
1507 HANDLE_CASE(H5FSTRING, Str);
1508 HANDLE_CASE(H5VSTRING, Str);
1510 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
1516 const vector<HDF5CF::Dimension *>& dims = spvar->
getDimensions();
1517 vector <HDF5CF::Dimension*>:: const_iterator it_d;
1520 throw InternalErr(__FILE__,__LINE__,
"Currently don't support scalar special variables. ");
1531 spvar->getOriginalType(),
1532 spvar->getStartBit(),
1539 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
1543 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
1544 if (
""==(*it_d)->getNewName())
1545 ar->append_dim((*it_d)->getSize());
1547 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
1550 ar->set_is_dap4(
true);
1551 BaseType* d4_var=ar->h5cfdims_transform_to_dap4(d4_root);
1552 map_cfh5_var_attrs_to_dap4(spvar,d4_var);
1553 d4_root->add_var_nocopy(d4_var);
This class includes the methods to read data array into DAP buffer from an HDF5 dataset for the CF op...
This class provides a way to map HDF5 byte to DAP byte for the CF option.
This class provides a way to map HDF5 float to DAP float for the CF option.
This class provides a way to map HDF5 64-bit floating-point(double) to DAP 64-bit floating-point for ...
This class provides a way to map HDF5 int16 to DAP int16 for the CF option.
This class provides a way to map HDF5 32-bit integer to DAP Int32 for the CF option.
This class provides a way to map HDF5 64-bit integer to DAP4 Int64 for the CF option.
This class provides a way to map HDF5 int8 to DAP int16 for the CF option.
This class provides a way to map HDF5 Str to DAP Str for the CF option.
This class provides a way to map HDF5 unsigned 16-bit integer to DAP uint16 for the CF option.
This class provides a way to map HDF5 unsigned 32-bit integer to DAP uint32 for the CF option.
This class provides a way to map HDF5 64-bit unsigned integer to DAP4 UInt64 for the CF option.
This class includes the methods to read data array into DAP buffer from an HDF5 dataset for the CF op...
This class specifies the retrieval of the missing lat/lon values for general HDF5 products.
This class specifies the retrieval of the values of non-lat/lon coordinate variables for general HDF5...
This class specifies the retrieval of the missing lat/lon values for general HDF5 products.
This class specifies the retrieval of data values for special HDF5 products Currently this only appli...
include the entry functions to execute the handlers
CVType getCVType() const
Get the coordinate variable type of this variable.
bool HaveUnlimitedDim() const
Has unlimited dimensions.
virtual void Retrieve_H5_Var_Attr_Values(Var *var)
Retrieve attribute values for a variable.
hid_t getFileID() const
Obtain the HDF5 file ID.
const std::vector< Attribute * > & getAttributes() const
Public interface to obtain information of all attributes under the root group.
const std::vector< Group * > & getGroups() const
Public interface to obtain all the group info.
const std::string & getPath() const
Obtain the path of the file.
const std::vector< Var * > & getVars() const
Public interface to obtain information of all variables.
This class is a derived class of CVar. It represents a coordinate variable for general HDF5 files.
H5GCFProduct getPtType() const
Get the data type of this variable.
This class is a derived class of File. It includes methods applied to general HDF5 files only.
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.
virtual bool Get_IgnoredInfo_Flag()
Obtain ignored info. flag.
virtual void Handle_Unsupported_Dspace(bool)
Handle unsupported HDF5 dataspaces for general HDF5 products.
virtual void Handle_Unsupported_Others(bool)
Handle other unmapped objects/attributes for general HDF5 products.
void Remove_Unneeded_Objects()
Remove unneeded objects.
virtual const std::string & Get_Ignored_Msg()
Get the message that contains the ignored obj. info.
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)
int getRank() const
Get the dimension rank of this variable.
const std::string & getFullPath() const
Get the full path of this variable.
H5DataType getType() const
Get the data type of this variable(Not HDF5 datatype id)
const std::vector< Dimension * > & getDimensions() const
Get the list of the dimensions.
int getCompRatio() const
Get the compression ratio of this dataset.
const std::string & getNewName() const
Get the new name of this variable.
Helper functions for generating DAS attributes and a function to check BES Key.
Map and generate DDS and DAS for the CF option for generic HDF5 products.