48#include "HDFSPEnumType.h"
50#define MAX_FULL_PATH_LEN 1024
54#define _HDF_CHK_TBL_CLASS "_HDF_CHK_TBL_"
55#define CERE_META_NAME "CERES_metadata"
56#define CERE_META_FIELD_NAME "LOCALGRANULEID"
57#define SENSOR_NAME "Sensor Name"
58#define PRO_NAME "Product Name"
59#define CER_AVG_NAME "CER_AVG"
60#define CER_ES4_NAME "CER_ES4"
61#define CER_CDAY_NAME "CER_ISCCP-D2like-Day"
62#define CER_CGEO_NAME "CER_ISCCP-D2like-GEO"
63#define CER_SRB_NAME "CER_SRBAVG3"
64#define CER_SYN_NAME "CER_SYN"
65#define CER_ZAVG_NAME "CER_ZAVG"
104 ~ Exception () throw () override = default;
107 const
char *
what () const throw ()
override
109 return this->message.c_str ();
115 this->message = exception_message;
140 return this->dimsize;
147 return this->dimtype;
151 Dimension (
const std::string & dim_name, int32 hdf4_dimsize, int32 hdf4_dimtype)
152 : name (dim_name), dimsize (hdf4_dimsize), dimtype (hdf4_dimtype)
168 friend class SDField;
185 return this->newname;
221 std::vector < char >value;
266 std::vector < Attribute * >attrs;
346 return this->correcteddims;
352 return &(this->correcteddims);
358 correcteddims = cor_dims;
364 return this->coordinates;
380 void setUnits (
const std::string &uni)
386 int getFieldType ()
const
388 return this->fieldtype;
392 int32 getFieldRef ()
const
394 return this->fieldref;
406 return this->dims_info;
413 return is_noscale_dim;
425 return special_product_fullpath;
430 std::vector < Dimension * >dims;
435 std::vector < Dimension * >correcteddims;
438 std::vector<AttrContainer *>dims_info;
440 std::string coordinates;
463 std::string special_product_fullpath;
470 bool condenseddim =
false;
475 bool is_noscale_dim =
false;
478 bool is_dim_scale =
false;
482 std::string rootfieldname;
534 std::vector < char >value;
554 const std::string & getPath ()
const
563 return this->sdfields;
581 SD (int32 sdfileid, int32 hfileid)
582 : sdfd (sdfileid), fileid (hfileid)
589 std::vector < SDField * >sdfields;
592 std::vector < Attribute * >attrs;
595 std::list <int32> sds_ref_list;
598 std::map < int32, int >refindexlist;
602 std::map < std::string, int32 > n1dimnamelist;
605 std::map < std::string, std::string > n2dimnamelist;
608 std::set < std::string > fulldimnamelist;
613 std::set < std::string > nonmisscvdimnamelist;
616 std::map < std::string, std::string > dimcvarlist;
645 return this->newname;
657 return this->vdfields;
671 return TreatAsAttrFlag;
681 VDATA (int32 vdata_myid, int32 obj_ref)
682 :vdref(obj_ref),vdata_id (vdata_myid) {
685 VDATA (int32 obj_ref)
697 std::vector < VDField * >vdfields;
700 std::vector < Attribute * >attrs;
706 bool TreatAsAttrFlag =
true;
735 bool Check_update_special(
const std::string &gridname)
throw(
Exception);
750 return this->OTHERHDF_Has_Dim_NoScale_Field;
777 return this->vg_attrs;
783 explicit File (
const char *hdf4file_path)
784 : path (hdf4file_path)
797 std::vector < VDATA * >vds;
800 std::vector<AttrContainer *>vg_attrs;
817 void handle_sds_names(
bool & COARDFLAG , std::
string & lldimname1, std::
string &lldimname2) throw(Exception);
820 void handle_sds_coords(
bool & COARDFLAG, std::
string &lldimname1,std::
string &lldimname2) throw(Exception);
843 bool Obtain_TRMM_V7_latlon_name(const SDField* sdfield, const
int latsize, const
int lonsize, std::
string& latname, std::
string& lonname) throw(Exception);
892 void ReadVgattrs(int32 vgroup_id, const
char *fullpath) throw(Exception);
898 void obtain_path (int32 file_id, int32 sd_id,
char *full_path, int32 pobj_ref) throw (Exception);
901 void obtain_vdata_path(int32 file_id,
char *full_path, int32 pobj_ref) throw (Exception);
913 std::vector < VDATA * >vds;
916 std::vector<AttrContainer *>vg_attrs;
926 SPType sptype = OTHERHDF;
929 bool OTHERHDF_Has_Dim_NoScale_Field = false;
933 bool EOS2Swathflag = false;
const std::vector< Attribute * > & getAttributes() const
const std::string & getName() const
Get the name of this attribute container.
Representing one attribute in grid or swath.
const std::string & getName() const
Get the attribute name.
int32 getType() const
Get the attribute datatype.
const std::vector< char > & getValue() const
Get the attribute value.
const std::string & getNewName() const
Get the CF attribute name(special characters are replaced by underscores)
int32 getCount() const
Get the number of elements of this attribute.
const std::string & getName() const
Get dimension name.
int32 getSize() const
Get dimension size.
const char * what() const override
Return exception message.
Exception(const std::string &msg)
Constructor.
virtual void setException(const std::string &exception_message)
Set exception message.
const std::vector< Attribute * > & getAttributes() const
Get the attributes of this field.
int32 rank
The rank of this field.
std::vector< Attribute * > attrs
The attributes of this field.
std::string newname
The CF full path(special characters replaced by underscores) of this field.
int32 type
The datatype of this field.
int32 getType() const
Get the data type of this field.
const std::string & getNewName() const
Get the CF name(special characters replaced by underscores) of this field.
std::string name
The original name of this field.
int32 getRank() const
Get the dimension rank of this field.
const std::string & getName() const
Get the name of this field.
static File * Read(const char *path, int32 sdid, int32 fileid)
Retrieve SDS and Vdata information from the HDF4 file.
void handle_sds_final_dim_names()
Create the final CF-compliant dimension name list for each field.
void PrepareTRMML3M_V7()
Special method to prepare TRMM multiple grid Level 3 geolocation fields(latitude,longitude,...
void handle_sds_coords(bool &COARDFLAG, std::string &lldimname1, std::string &lldimname2)
Create "coordinates", "units" CF attributes.
void handle_vdata()
Handle Vdata.
const std::vector< VDATA * > & getVDATAs() const
Public interface to Obtain Vdata.
const std::vector< AttrContainer * > & getVgattrs() const
Get attributes for all vgroups.
void handle_sds_missing_fields()
Add the missing coordinate variables based on the corrected dimension name list.
void PrepareTRMML3S_V7()
Special method to prepare TRMM single grid Level 3 geolocation fields(latitude,longitude,...
bool Has_Dim_NoScale_Field() const
This file has a field that is a SDS dimension but no dimension scale.
void CheckSDType()
This method will check if the HDF4 file is one of TRMM or OBPG products we supported.
SD * getSD() const
Public interface to Obtain SD.
void ReadVgattrs(int32 vgroup_id, const char *fullpath)
Obtain vgroup attributes.
void PrepareTRMML2_V7()
Latitude and longitude are stored in different fields. Need to separate.
void Obtain_TRMML3S_V7_latlon_size(int &latsize, int &lonsize)
void Obtain_TRMML3S_V7_latlon_size(int &latsize, int&lonsize) throw(Exception);
void PrepareTRMML3C_V6()
Special method to prepare TRMM Level 3 CSH latitude,longitude and Height information.
static File * Read_Hybrid(const char *path, int32 sdid, int32 fileid)
void handle_sds_fakedim_names()
void PrepareOBPGL3()
Special method to prepare OBPG Level 3 latitude and longitude information. The latitude and longitude...
void ReadHybridNonLoneVdatas(File *)
void obtain_vdata_path(int32 file_id, char *full_path, int32 pobj_ref)
The internal function used to obtain the path for hybrid non-lone vdata.
void handle_sds_names(bool &COARDFLAG, std::string &lldimname1, std::string &lldimname2)
Create the final CF-compliant field name list.
SPType getSPType() const
Obtain special HDF4 product type.
void PrepareOTHERHDF()
We still provide a hook for other HDF data product although no CF compliant is followed.
void ReadLoneVdatas(File *)
Handle non-attribute lone vdatas.
void PrepareTRMML3A_V6()
Special method to prepare TRMM Level 3A46 latitude and longitude information.
void PrepareTRMML3B_V6()
Special method to prepare TRMM Level 3B latitude and longitude information.
void InsertOrigFieldPath_ReadVgVdata()
The full path of SDS and Vdata will be obtained.
void PrepareOBPGL2()
Special method to prepare OBPG Level 2 latitude and longitude information. The latitude and longitude...
void create_sds_dim_name_list()
Create the new dimension name set and the dimension name to size map.
void obtain_path(int32 file_id, int32 sd_id, char *full_path, int32 pobj_ref)
The internal function used by InsertOrigFieldPath_ReadVgVdata.
void PrepareCERZAVG()
Special method to prepare CERES Zonal Average latitude and longitude information.
void PrepareTRMML2_V6()
Latitude and longitude are stored in one array(geolocation). Need to separate.
const std::string & getPath() const
Obtain the path of the file.
One instance of this class represents one SDS object.
void setCorrectedDimensions(const std::vector< Dimension * > &cor_dims)
Set the list of the corrected dimensions.
const std::vector< Dimension * > & getCorrectedDimensions() const
Get the list of the corrected dimensions.
std::string getSpecFullPath() const
This function returns the full path of some special products that have a very long path.
bool IsDimScale() const
Is this field a dimension scale field?
std::vector< Dimension * > * getCorrectedDimensionsPtr()
Get the list of the corrected dimension ptrs.
const std::vector< AttrContainer * > & getDimInfo() const
Get the list of OHTERHDF dimension attribute container information.
const std::vector< Dimension * > & getDimensions() const
Get the list of dimensions.
std::string getCoordinate() const
Get the "coordinates" attribute.
std::string getUnits() const
Get the "units" attribute.
bool IsDimNoScale() const
Is this field a dimension without dimension scale(or empty[no data]dimension variable)
void setCoordinates(const std::string &coor)
Set the coordinate attribute.
This class retrieves all SDS objects and SD file attributes.
const std::vector< Attribute * > & getAttributes() const
Public interface to obtain the SD(file) attributes.
static SD * Read_Hybrid(int32 sdfileid, int32 hfileid)
Read the information of all hybrid SDS objects from the HDF4 file.
const std::vector< SDField * > & getFields() const
Redundant member function.
static SD * Read(int32 sdfileid, int32 hfileid)
Read the information of all SDS objects from the HDF4 file.
void obtain_noneos2_sds_path(int32, char *, int32)
Obtain SDS path, this is like a clone of obtain_path in File class, except the Vdata and some minor p...
This class retrieves all information of one Vdata.
bool getTreatAsAttrFlag() const
int32 getObjRef() const
Obtain Vdata reference number, this is necessary for retrieving Vdata information from HDF4.
const std::vector< VDField * > & getFields() const
Obtain Vdata fields.
const std::string & getNewName() const
Obtain new names(with the path and special characters and name clashing handlings)
void ReadAttributes(int32 vdata_id)
Retrieve all attributes of this Vdata.
const std::string & getName() const
Obtain the original vdata name.
static VDATA * Read(int32 vdata_id, int32 obj_ref)
Retrieve all information of this Vdata.
const std::vector< Attribute * > & getAttributes() const
Obtain Vdata attributes.
One instance of this class represents one Vdata field.
void ReadAttributes(int32 vdata_id, int32 fieldindex)
Read vdata field attributes.
int32 getNumRec() const
Get the number of record.
const std::vector< char > & getValue() const
Get the vdata field values.
int32 getFieldOrder() const
Get the order of this field.
int32 getFieldsize() const
Get the field size.