33 #include <sys/types.h>
41 #include <InternalErr.h>
64 BESDEBUG(
"h5",
"Coming to GM products DDS mapping function map_gmh5_cfdds "<<endl);
65 string check_objnameclashing_key =
"H5.EnableCheckNameClashing";
66 bool is_check_nameclashing =
false;
76 f =
new GMFile(filename.c_str(),file_id,product_type,gproduct_pattern);
79 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate memory for GMFile ");
82 bool include_attr =
false;
114 true == is_check_nameclashing)
120 true == is_check_nameclashing)
126 throw InternalErr(e.
what());
146 BESDEBUG(
"h5",
"Coming to GM products DAS mapping function map_gmh5_cfdas "<<endl);
147 string check_objnameclashing_key =
"H5.EnableCheckNameClashing";
148 bool is_check_nameclashing =
false;
153 string add_path_attrs_key =
"H5.EnableAddPathAttrs";
154 bool is_add_path_attrs =
false;
165 f =
new GMFile(filename.c_str(),file_id,product_type,gproduct_pattern);
168 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate memory for GMFile ");
171 bool include_attr =
true;
193 true == is_check_nameclashing)
202 throw InternalErr(e.
what());
222 BESDEBUG(
"h5",
"Coming to GM DDS generation function gen_gmh5_cfdds "<<endl);
224 const vector<HDF5CF::Var *>& vars = f->
getVars();
225 const vector<HDF5CF::GMCVar *>& cvars = f->
getCVars();
226 const vector<HDF5CF::GMSPVar *>& spvars = f->
getSPVars();
227 const string filename = f->
getPath();
232 vector<HDF5CF::Var *>::const_iterator it_v;
233 vector<HDF5CF::GMCVar *>::const_iterator it_cv;
234 vector<HDF5CF::GMSPVar *>::const_iterator it_spv;
236 for (it_v = vars.begin(); it_v !=vars.end();++it_v) {
240 for (it_cv = cvars.begin(); it_cv !=cvars.end();++it_cv) {
245 for (it_spv = spvars.begin(); it_spv !=spvars.end();it_spv++) {
254 BESDEBUG(
"h5",
"Coming to GM DAS generation function gen_gmh5_cfdas "<<endl);
257 const vector<HDF5CF::Var *>& vars = f->
getVars();
258 const vector<HDF5CF::GMCVar *>& cvars = f->
getCVars();
259 const vector<HDF5CF::GMSPVar *>& spvars = f->
getSPVars();
260 const vector<HDF5CF::Group *>& grps = f->
getGroups();
261 const vector<HDF5CF::Attribute *>& root_attrs = f->
getAttributes();
264 vector<HDF5CF::Var *>::const_iterator it_v;
265 vector<HDF5CF::GMCVar *>::const_iterator it_cv;
266 vector<HDF5CF::GMSPVar *>::const_iterator it_spv;
267 vector<HDF5CF::Group *>::const_iterator it_g;
268 vector<HDF5CF::Attribute *>::const_iterator it_ra;
273 if (
false == root_attrs.empty()) {
275 AttrTable *at = das.get_table(FILE_ATTR_TABLE_NAME);
277 at = das.add_table(FILE_ATTR_TABLE_NAME,
new AttrTable);
279 for (it_ra = root_attrs.begin(); it_ra != root_attrs.end(); ++it_ra) {
284 if (
false == grps.empty()) {
285 for (it_g = grps.begin();
286 it_g != grps.end(); ++it_g) {
287 AttrTable *at = das.get_table((*it_g)->getNewName());
289 at = das.add_table((*it_g)->getNewName(),
new AttrTable);
291 for (it_ra = (*it_g)->getAttributes().begin();
292 it_ra != (*it_g)->getAttributes().end(); ++it_ra) {
298 for (it_v = vars.begin();
299 it_v != vars.end(); ++it_v) {
300 if (
false == ((*it_v)->getAttributes().empty())) {
302 AttrTable *at = das.get_table((*it_v)->getNewName());
304 at = das.add_table((*it_v)->getNewName(),
new AttrTable);
306 for (it_ra = (*it_v)->getAttributes().begin();
307 it_ra != (*it_v)->getAttributes().end(); ++it_ra)
318 for (it_cv = cvars.begin();
319 it_cv != cvars.end(); ++it_cv) {
320 if (
false == ((*it_cv)->getAttributes().empty())) {
322 AttrTable *at = das.get_table((*it_cv)->getNewName());
324 at = das.add_table((*it_cv)->getNewName(),
new AttrTable);
326 for (it_ra = (*it_cv)->getAttributes().begin();
327 it_ra != (*it_cv)->getAttributes().end(); ++it_ra){
333 for (it_spv = spvars.begin();
334 it_spv != spvars.end(); ++it_spv) {
335 if (
false == ((*it_spv)->getAttributes().empty())) {
337 AttrTable *at = das.get_table((*it_spv)->getNewName());
339 at = das.add_table((*it_spv)->getNewName(),
new AttrTable);
342 for (it_ra = (*it_spv)->getAttributes().begin();
343 it_ra != (*it_spv)->getAttributes().end(); ++it_ra)
357 #define HANDLE_CASE(tid,type) \
359 bt = new (type)(cvar->getNewName(),cvar->getFullPath()); \
374 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
380 const vector<HDF5CF::Dimension *>& dims = cvar->
getDimensions();
381 vector <HDF5CF::Dimension*>:: const_iterator it_d;
401 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5CFArray. ");
404 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
405 if (
""==(*it_d)->getNewName())
406 ar->append_dim((*it_d)->getSize());
408 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
436 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissLLArray. ");
440 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
441 if (
""==(*it_d)->getNewName())
442 ar->append_dim((*it_d)->getSize());
444 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
458 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
473 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
477 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
478 if (
""==(*it_d)->getNewName())
479 ar->append_dim((*it_d)->getSize());
481 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
494 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
508 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
512 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
513 if (
""==(*it_d)->getNewName())
514 ar->append_dim((*it_d)->getSize());
516 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
530 throw InternalErr(__FILE__, __LINE__,
"The rank of special coordinate variable must be 1");
543 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
544 if (
""==(*it_d)->getNewName())
545 ar->append_dim((*it_d)->getSize());
547 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
558 throw InternalErr(__FILE__,__LINE__,
"Coordinate variable type is not supported.");
568 #define HANDLE_CASE(tid,type) \
570 bt = new (type)(spvar->getNewName(),spvar->getFullPath()); \
584 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
590 const vector<HDF5CF::Dimension *>& dims = spvar->
getDimensions();
591 vector <HDF5CF::Dimension*>:: const_iterator it_d;
610 throw InternalErr(__FILE__,__LINE__,
"Unable to allocate HDF5GMCFMissNonLLCVArray. ");
614 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
615 if (
""==(*it_d)->getNewName())
616 ar->append_dim((*it_d)->getSize());
618 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
639 AttrTable *at = das.get_table(var->
getNewName());
641 at = das.add_table(var->
getNewName(),
new AttrTable);
642 bool has_fillvalue =
false;
643 AttrTable::Attr_iter it = at->attr_begin();
644 while (it!=at->attr_end() &&
false==has_fillvalue) {
645 if (at->get_name(it) ==
"_FillValue")
647 has_fillvalue =
true;
648 string fillvalue =
"";
650 const string cor_fill_value =
"-9999.9";
651 fillvalue = (*at->get_attr_vector(it)->begin());
652 if((fillvalue.find(cor_fill_value) == 0) && (fillvalue!= cor_fill_value)) {
653 at->del_attr(
"_FillValue");
654 at->append_attr(
"_FillValue",
"Float32",cor_fill_value);
658 const string cor_fill_value =
"-9999.9";
659 const string exist_fill_value_substr =
"-9999.8999";
660 fillvalue = (*at->get_attr_vector(it)->begin());
661 if((fillvalue.find(exist_fill_value_substr) == 0) && (fillvalue!= cor_fill_value)) {
662 at->del_attr(
"_FillValue");
663 at->append_attr(
"_FillValue",
"Float64",cor_fill_value);
672 if (has_fillvalue !=
true ) {
675 at->append_attr(
"_FillValue",
"Float32",
"-9999.9");
677 at->append_attr(
"_FillValue",
"Float64",
"-9999.9");
679 at->append_attr(
"_FillValue",
"Int16",
"-9999");
681 at->append_attr(
"_FillValue",
"Int16",
"-99");
This class provides a way to map HDF5 Str to DAP Str for the CF option.
void Flatten_Obj_Name(bool include_attr)
Flatten the object name for general NASA HDF5 products.
This class specifies the retrieval of the missing lat/lon values for general HDF5 products...
void Handle_SpVar()
Handle special variables for general NASA HDF5 products.
const string & getFullPath() const
Get the full path of this variable.
const vector< GMCVar * > & getCVars() const
This class represents one HDF5 dataset(CF variable)
void Handle_Coor_Attr()
Handle "coordinates" attributes for general HDF5 products.
void Handle_CVar()
Handle coordinate variables for general NASA HDF5 products.
int getRank() const
Get the dimension rank of this variable.
void Handle_DimNameClashing()
Handle dimension name clashing. Since COARDS requires the change of cv names, So we need to handle di...
void map_gmh5_cfdds(DDS &dds, hid_t file_id, const string &filename)
void Add_Dim_Name()
Add dimension name.
This class provides a way to map HDF5 unsigned 16-bit integer to DAP uint16 for the CF option...
void gen_dap_onegmcvar_dds(DDS &dds, const HDF5CF::GMCVar *cvar, const hid_t file_id, const string &filename)
void Handle_Obj_NameClashing(bool)
Handle object name clashing for general NASA HDF5 products.
This class provides a way to map HDF5 float to DAP float for the CF option.
This class is a derived class of Var. It represents a special general HDF5 product(currently ACOS) ...
void gen_dap_onegmspvar_dds(DDS &dds, const HDF5CF::GMSPVar *spvar, const hid_t fileid, const string &filename)
This class is a derived class of CVar. It represents a coordinate variable for general HDF5 files...
static bool check_beskeys(const string key)
const vector< Attribute * > & getAttributes() const
Public interface to obtain information of all attributes under the root group.
This class specifies the retrieval of the missing lat/lon values for general HDF5 products...
This class provides a way to map HDF5 int16 to DAP int16 for the CF option.
void gen_dap_oneobj_das(AttrTable *at, const HDF5CF::Attribute *attr, const HDF5CF::Var *var)
void update_GPM_special_attrs(DAS &das, const HDF5CF::Var *var)
Map and generate DDS and DAS for the CF option for generic HDF5 products.
This class provides a way to map HDF5 64-bit floating-point(double) to DAP 64-bit floating-point for ...
H5DataType getOriginalType() const
H5DataType getType() const
Get the data type of this variable(Not HDF5 datatype id)
This class is a derived class of File. It includes methods applied to general HDF5 files only...
const vector< GMSPVar * > & getSPVars() const
void map_gmh5_cfdas(DAS &das, hid_t file_id, const string &filename)
void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes for general HDF5 products.
void Adjust_Dim_Name()
Adjust dimension name for general NASA HDF5 products.
This class specifies the retrieval of data values for special HDF5 products Currently this only appli...
void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes for general HDF5 products.
CVType getCVType() const
Get the coordinate variable type of this variable.
const hid_t getFileID() const
Obtain the HDF5 file ID.
H5GCFProduct getPtType() const
Get the data type of this variable.
const string & getNewName() const
Get the new name of this variable.
#define HANDLE_CASE(tid, type)
const string & getPath() const
Obtain the path of the file.
This class provides a way to map HDF5 32-bit integer to DAP Int32 for the CF option.
This class includes the methods to read data array into DAP buffer from an HDF5 dataset for the CF op...
const vector< Dimension * > & getDimensions() const
Get the list of the dimensions.
void Handle_Unsupported_Dspace()
Handle unsupported HDF5 dataspaces for general HDF5 products.
Helper functions for generating DAS attributes and a function to check BES Key.
This class provides a way to map HDF5 unsigned 32-bit integer to DAP uint32 for the CF option...
void gen_gmh5_cfdas(DAS &das, HDF5CF::GMFile *f)
const vector< Var * > & getVars() const
Public interface to obtain information of all variables.
virtual const char * what() const
const vector< Group * > & getGroups() const
Public interface to obtain all the group info.
void Adjust_Obj_Name()
Adjust object names based on different general NASA HDF5 products.
This class specifies the retrieval of the values of non-lat/lon coordinate variables for general HDF5...
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
void gen_dap_onevar_dds(DDS &dds, const HDF5CF::Var *var, const hid_t file_id, const string &filename)
This class provides a way to map HDF5 byte to DAP byte for the CF option.
void gen_gmh5_cfdds(DDS &dds, HDF5CF::GMFile *f)
This class includes the methods to read data array into DAP buffer from an HDF5 dataset for the CF op...
H5GCFProduct check_product(hid_t file_id)
H5GCFProduct getProductType() const
void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name for general NASA HDF5 products...
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...