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;
234 class AttrContainer {
237 AttrContainer() =
default;
260 std::vector < Attribute * >attrs;
330 class SDField:
public Field
333 SDField () =
default;
334 ~SDField ()
override;
340 return this->correcteddims;
346 return &(this->correcteddims);
352 correcteddims = cor_dims;
358 return this->coordinates;
374 void setUnits (
const std::string &uni)
380 int getFieldType ()
const
382 return this->fieldtype;
386 int32 getFieldRef ()
const
388 return this->fieldref;
400 return this->dims_info;
407 return is_noscale_dim;
419 return special_product_fullpath;
424 std::vector < Dimension * >dims;
429 std::vector < Dimension * >correcteddims;
432 std::vector<AttrContainer *>dims_info;
434 std::string coordinates;
457 std::string special_product_fullpath;
465 bool is_noscale_dim =
false;
468 bool is_dim_scale =
false;
472 std::string rootfieldname;
479 class VDField:
public Field
482 VDField () =
default;
483 ~VDField ()
override =
default;
524 std::vector < char >value;
536 static SD *
Read (int32 sdfileid, int32 hfileid) ;
539 static SD *
Read_Hybrid (int32 sdfileid, int32 hfileid) ;
545 return this->sdfields;
565 std::vector < SDField * >sdfields;
568 std::vector < Attribute * >attrs;
571 std::list <int32> sds_ref_list;
574 std::map < int32, int >refindexlist;
578 std::map < std::string, int32 > n1dimnamelist;
581 std::map < std::string, std::string > n2dimnamelist;
584 std::set < std::string > fulldimnamelist;
589 std::set < std::string > nonmisscvdimnamelist;
592 std::map < std::string, std::string > dimcvarlist;
605 static VDATA *
Read (int32 vdata_id, int32 obj_ref) ;
613 return this->newname;
625 return this->vdfields;
639 return TreatAsAttrFlag;
648 VDATA (int32 obj_ref)
660 std::vector < VDField * >vdfields;
663 std::vector < Attribute * >attrs;
669 bool TreatAsAttrFlag =
true;
681 static File *
Read (
const char *path, int32 sdid,int32 fileid);
685 static File *
Read_Hybrid (
const char *path, int32 sdid,
693 bool Check_update_special(
const std::string &gridname)
const;
695 void Handle_AIRS_L23();
708 return this->OTHERHDF_Has_Dim_NoScale_Field;
735 return this->vg_attrs;
741 explicit File (
const char *hdf4file_path)
742 : path (hdf4file_path)
761 void handle_sds_names(
bool & COARDFLAG , std::string & lldimname1, std::string &lldimname2);
764 void handle_sds_coords(
bool COARDFLAG,
const std::string &lldimname1,
const std::string &lldimname2);
787 bool Obtain_TRMM_V7_latlon_name(
const SDField* sdfield,
const int latsize,
const int lonsize, std::string& latname, std::string& lonname);
836 void ReadVgattrs(int32 vgroup_id,
const char *fullpath);
842 void obtain_path (int32 file_id, int32 sd_id,
char *full_path, int32 pobj_ref) ;
857 std::vector < VDATA * >vds;
860 std::vector<AttrContainer *>vg_attrs;
870 SPType sptype = OTHERHDF;
873 bool OTHERHDF_Has_Dim_NoScale_Field =
false;
877 bool EOS2Swathflag =
false;
const std::vector< Attribute * > & getAttributes() const
No need to have the newname since we will make the name follow CF conventions.
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,...
const std::vector< VDATA * > & getVDATAs() const
Public interface to Obtain Vdata.
const std::vector< AttrContainer * > & getVgattrs() const
Get attributes for all vgroups.
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 ReadHybridNonLoneVdatas(const File *)
void handle_vdata() const
Handle Vdata.
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 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 handle_sds_missing_fields() const
Add the missing coordinate variables based on the corrected dimension name list.
void ReadLoneVdatas(File *) const
Handle non-attribute lone vdatas.
void PrepareOTHERHDF()
We still provide a hook for other HDF data product although no CF compliant is followed.
void handle_sds_coords(bool COARDFLAG, const std::string &lldimname1, const std::string &lldimname2)
Create "coordinates", "units" CF attributes.
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.
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
Public interface to obtain information of all SDS vectors(objects).
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.