OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDF5CF.h
Go to the documentation of this file.
1 // This file is part of the hdf5_handler implementing for the CF-compliant
2 // Copyright (c) 2011-2013 The HDF Group, Inc. and OPeNDAP, Inc.
3 //
4 // This is free software; you can redistribute it and/or modify it under the
5 // terms of the GNU Lesser General Public License as published by the Free
6 // Software Foundation; either version 2.1 of the License, or (at your
7 // option) any later version.
8 //
9 // This software is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 // License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 //
18 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
19 // You can contact The HDF Group, Inc. at 1800 South Oak Street,
20 // Suite 203, Champaign, IL 61820
21 
37 
38 #ifndef _HDF5CF_H
39 #define _HDF5CF_H
40 
41 #include<sstream>
42 #include <iostream>
43 #include <vector>
44 #include <map>
45 #include <set>
46 #include <list>
47 #include "HDF5CFUtil.h"
48 #include "h5cfdaputil.h"
49 #include "HDF5GCFProduct.h"
50 #include "HE5Parser.h"
51 
52 
57 static string FILE_ATTR_TABLE_NAME ="HDF5_GLOBAL";
58 
59 
60 namespace HDF5CF
61 {
62  class File;
63  class GMFile;
64  class EOS5File;
65 
66  class Exception:public exception
67  {
68  public:
70  Exception (const string & msg)
71  : message (msg)
72  {
73  }
74 
75  virtual ~ Exception () throw ()
76  {
77  }
78 
79  virtual const char *what () const throw ()
80  {
81  return this->message.c_str ();
82  }
83 
84 
85  virtual void setException (string message)
86  {
87  this->message = message;
88  }
89 
90 
91  protected:
92  std::string message;
93  };
94  template < typename T, typename U, typename V, typename W, typename X > static void
95  _throw5 (const char *fname, int line, int numarg,
96  const T & a1, const U & a2, const V & a3, const W & a4, const X & a5)
97  {
98  ostringstream ss;
99  ss << fname << ":" << line << ":";
100  for (int i = 0; i < numarg; ++i) {
101  ss << " ";
102  switch (i) {
103  case 0:
104  ss << a1;
105  break;
106  case 1:
107  ss << a2;
108  break;
109  case 2:
110  ss << a3;
111  break;
112  case 3:
113  ss << a4;
114  break;
115  case 4:
116  ss << a5;
117  break;
118  }
119  }
120  throw Exception (ss.str ());
121  }
122 
124 // number of arguments.
126 #define throw1(a1) _throw5(__FILE__, __LINE__, 1, a1, 0, 0, 0, 0)
127 #define throw2(a1, a2) _throw5(__FILE__, __LINE__, 2, a1, a2, 0, 0, 0)
128 #define throw3(a1, a2, a3) _throw5(__FILE__, __LINE__, 3, a1, a2, a3, 0, 0)
129 #define throw4(a1, a2, a3, a4) _throw5(__FILE__, __LINE__, 4, a1, a2, a3, a4, 0)
130 #define throw5(a1, a2, a3, a4, a5) _throw5(__FILE__, __LINE__, 5, a1, a2, a3, a4, a5)
131 
132  struct delete_elem
133  {
134  template < typename T > void operator () (T * ptr)
135  {
136  delete ptr;
137  }
138  };
139 
140 
142  // It holds only the size of that dimension.
143  // Note: currently the unlimited dimension(maxdims) case
144  // doesn't need to be considered.
145  class Dimension
146  {
147  public:
148  hsize_t getSize () const
149  {
150  return this->size;
151  }
152  const string & getName () const
153  {
154  return this->name;
155  }
156  const string & getNewName () const
157  {
158  return this->newname;
159  }
160 
161 
162  protected:
163  Dimension (hsize_t dimsize)
164  : size (dimsize),name(""),newname("")
165  {
166  }
167 
168  protected:
169  hsize_t size;
170  string name;
171  string newname;
172 
173  friend class EOS5File;
174  friend class GMFile;
175  friend class File;
176  friend class Var;
177  friend class CVar;
178  friend class GMCVar;
179  friend class EOS5CVar;
180  friend class GMSPVar;
181  };
182 
184  class Attribute
185  {
186 
187  public:
189  {
190  }
191  ~Attribute ();
192 
193  public:
194  const string & getName () const
195  {
196  return this->name;
197  }
198 
199  const string & getNewName () const
200  {
201  return this->newname;
202  }
203 
205  {
206  return this->dtype;
207  }
208 
209  hsize_t getCount () const
210  {
211  return this->count;
212  }
213 
214  size_t getBufSize() const
215  {
216  return (this->value).size();
217  }
218 
219  const std::vector < char >&getValue () const
220  {
221  return this->value;
222  }
223 
224  const std::vector < size_t >&getStrSize () const
225  {
226  return this->strsize;
227  }
228 
229 
230  protected:
231  string name;
232  string newname;
234  hsize_t count;
235  vector <size_t>strsize;
236  size_t fstrsize;
237  vector < char >value;
238 
239  friend class File;
240  friend class GMFile;
241  friend class EOS5File;
242  friend class Var;
243  friend class CVar;
244  friend class GMCVar;
245  friend class GMSPVar;
246  friend class EOS5CVar;
247  };
248 
249 
251  class Var
252  {
253  public:
254  Var ():
255  dtype (H5UNSUPTYPE),
256  rank (-1),
257  unsupported_attr_dtype(false),
258  unsupported_dspace(false),
259  dimnameflag(false)
260  {
261  }
262  ~Var ();
263 
264  public:
265 
267  const string & getName () const
268  {
269  return this->name;
270  }
271 
273  const string & getNewName () const
274  {
275  return this->newname;
276  }
277 
279  const string & getFullPath () const
280  {
281  return this->fullpath;
282  }
283 
285  int getRank () const
286  {
287  return this->rank;
288  }
289 
292  {
293  return this->dtype;
294  }
295 
296  const vector < Attribute * >&getAttributes () const
297  {
298  return this->attrs;
299  }
300 
302  const vector < Dimension * >&getDimensions () const
303  {
304  return this->dims;
305  }
306 
307 
308  protected:
309 
310  std::string newname;
311  std::string name;
312  std::string fullpath;
314  int rank;
318 
319  vector < Attribute * >attrs;
320  vector < Dimension *>dims;
321 
322  friend class CVar;
323  friend class GMCVar;
324  friend class GMSPVar;
325  friend class EOS5CVar;
326  friend class File;
327  friend class GMFile;
328  friend class EOS5File;
329  };
330 
332  class CVar:public Var {
333  public:
334  CVar() {}
335  ~CVar() { }
337  CVType getCVType () const
338  {
339  return this->cvartype;
340  }
341 
342  private:
343  // Each coordinate variable has and only has one dimension
344  // This assumption is based on the exact match between
345  // variables and dimensions
346  string cfdimname;
347  CVType cvartype;
348 
349  friend class File;
350  friend class GMFile;
351  friend class EOS5File;
352  };
353 
355  class GMSPVar:public Var {
356  public:
358  sdbit(-1),
359  numofdbits(-1)
360  {
361  }
362  GMSPVar(Var *var);
363  ~GMSPVar() {}
365  return this->otype;
366  }
367 
368  int getStartBit() const {
369  return this->sdbit;
370  }
371 
372  int getBitNum() const {
373  return this->numofdbits;
374  }
375 
376  private:
377  H5DataType otype;
378  int sdbit;
379  int numofdbits;
380 
381  friend class File;
382  friend class GMFile;
383  };
384 
386  class GMCVar:public CVar {
387  public:
388  GMCVar():product_type(General_Product) {}
389  GMCVar(Var*var);
390  ~GMCVar() {}
391 
394  {
395  return this->product_type;
396  }
397 
398  private:
399  H5GCFProduct product_type;
400  friend class GMFile;
401  };
402 
404  class EOS5CVar: public CVar {
405  public:
406  EOS5CVar():is_2dlatlon(false) {}
407  EOS5CVar(Var *);
408 
410 
412  return this->eos_type;
413  }
414  float getPointLower() const{
415  return this->point_lower;
416  }
417  float getPointUpper() const{
418  return this->point_upper;
419  }
420 
421  float getPointLeft() const{
422  return this->point_left;
423  }
424  float getPointRight() const{
425  return this->point_right;
426  }
427 
429  return this->eos5_pixelreg;
430  }
432  return this->eos5_origin;
433  }
434 
436  return this->eos5_projcode;
437  }
438 
439  int getXDimSize() const {
440  return this->xdimsize;
441  }
442 
443  int getYDimSize() const {
444  return this->ydimsize;
445  }
446 
447  private:
448  EOS5Type eos_type;
449  bool is_2dlatlon;
450  float point_lower;
451  float point_upper;
452  float point_left;
453  float point_right;
454  int xdimsize;
455  int ydimsize;
456  EOS5GridPRType eos5_pixelreg;
457  EOS5GridOriginType eos5_origin;
458  EOS5GridPCType eos5_projcode;
459  friend class EOS5File;
460  };
461 
462 
464  class Group
465  {
466  public:
468  {
469  }
470  ~Group ();
471 
472  public:
473 
475  const string & getPath () const
476  {
477  return this->path;
478  }
479 
481  const string & getNewName () const
482  {
483  return this->newname;
484  }
485 
486  const vector < Attribute * >&getAttributes () const
487  {
488  return this->attrs;
489  }
490 
491  protected:
492 
493  string newname;
494  string path;
495 
496  vector < Attribute * >attrs;
498 
499  friend class File;
500  friend class GMFile;
501  friend class EOS5File;
502  };
503 
504 
506  class File
507  {
508  public:
509 
517  virtual void Retrieve_H5_Info (const char *path,
518  hid_t file_id, bool include_attr) throw (Exception);
519 
521  virtual void Retrieve_H5_Supported_Attr_Values() throw (Exception);
522 
524  virtual void Handle_Unsupported_Dtype(bool) throw(Exception);
525 
527  virtual void Handle_Unsupported_Dspace() throw(Exception);
528 
530  virtual void Flatten_Obj_Name(bool) throw(Exception);
531 
533  virtual void Add_Supplement_Attrs(bool) throw(Exception);
534 
536  virtual void Handle_Coor_Attr() = 0;
537 
539  virtual void Handle_CVar() = 0;
540 
542  virtual void Handle_SpVar() = 0;
543 
545  virtual void Handle_SpVar_Attr() = 0;
546 
547 
549  virtual void Adjust_Obj_Name() = 0;
550 
552  virtual void Adjust_Dim_Name() = 0;
553 
556  virtual void Handle_DimNameClashing() = 0;
557 
559  const hid_t getFileID () const
560  {
561  return this->fileid;
562  }
563 
564 
566  const string & getPath () const
567  {
568  return this->path;
569  }
570 
572  const vector < Var * >&getVars () const
573  {
574  return this->vars;
575  }
576 
578  const vector < Attribute * >&getAttributes () const
579  {
580  return this->root_attrs;
581  }
582 
584  const vector < Group * >&getGroups () const
585  {
586  return this->groups;
587  }
588 
589  virtual ~File ();
590 
591  protected:
592 
593  void Retrieve_H5_Obj(hid_t grp_id,const char*gname, bool include_attr) throw(Exception);
594  void Retrieve_H5_Attr_Info(Attribute *,hid_t obj_id,const int j, bool& unsup_attr_dtype) throw(Exception);
595  void Retrieve_H5_Attr_Value( Attribute *attr, string) throw (Exception);
596 
597  void Retrieve_H5_VarType(Var*,hid_t dset_id, const string& varname, bool &unsup_var_dtype) throw(Exception);
598  void Retrieve_H5_VarDim(Var*,hid_t dset_id,const string &varname, bool & unsup_var_dspace) throw(Exception);
599 
600  void Handle_GeneralObj_NameClashing(bool,set<string> &objnameset) throw(Exception);
601  void Handle_Var_NameClashing(set<string> &objnameset) throw(Exception);
602  void Handle_RootGroup_NameClashing(set<string> &objnameset) throw(Exception);
603  void Handle_Obj_AttrNameClashing() throw(Exception);
604  template <typename T> void Handle_General_NameClashing(set <string>&objnameset, vector<T*>& objvec) throw(Exception);
605 
606  void Add_One_FakeDim_Name(Dimension *dim) throw(Exception);
607  void Adjust_Duplicate_FakeDim_Name(Dimension * dim)throw(Exception);
608  void Insert_One_NameSizeMap_Element(string name,hsize_t size) throw(Exception);
609  void Insert_One_NameSizeMap_Element2(map<string,hsize_t> &,string name,hsize_t size) throw(Exception);
610 
611  virtual string get_CF_string(string);
612  virtual void Replace_Var_Info(Var* src, Var *target);
613  virtual void Replace_Var_Attrs(Var *src, Var*target);
614 
615  void Add_Str_Attr(Attribute* attr,const string &attrname, const string& strvalue) throw(Exception);
616  void Add_One_Float_Attr(Attribute* attr,const string &attrname, float float_value) throw(Exception);
617  void Change_Attr_One_Str_to_Others(Attribute *attr, Var *var) throw(Exception);
618 
619 
620  protected:
621  File (const char *path, hid_t file_id)
622  : path (string(path)),
623  fileid (file_id),
624  rootid(-1),
625  unsupported_var_dtype(false),
626  unsupported_attr_dtype(false),
627  unsupported_var_dspace(false),
628  addeddimindex(0)
629  {
630  }
631 
632  protected:
633 
634  string path;
635  hid_t fileid;
636  hid_t rootid;
637 
639  vector < Var * >vars;
640 
642  vector < Attribute * >root_attrs;
643 
645  vector < Group* >groups;
646 
649 
651 
652  set<string> dimnamelist;
653  map<string,hsize_t> dimname_to_dimsize;
654 
656  map<hsize_t,string> dimsize_to_fakedimname;
658 
659  };
660 
662  class GMFile:public File {
663  public:
664  GMFile(const char*path, hid_t file_id, H5GCFProduct product,GMPattern gproduct_pattern);
665  virtual ~GMFile();
666  public:
668  return product_type;
669  }
670 
671  const vector<GMCVar *>&getCVars() const {
672  return this->cvars;
673  }
674 
675  const vector<GMSPVar *>&getSPVars() const {
676  return this->spvars;
677  }
678 
680  void Retrieve_H5_Info(const char *path,
681  hid_t file_id, bool include_attr) throw (Exception);
682 
685 
687  void Adjust_H5_Attr_Value(Attribute *attr) throw (Exception);
688 
690  void Handle_Unsupported_Dtype(bool) throw(Exception);
691 
693  void Handle_Unsupported_Dspace() throw(Exception);
694 
696  void Add_Dim_Name()throw(Exception);
697 
699  void Handle_CVar() throw(Exception);
700 
702  void Handle_SpVar()throw(Exception);
703 
705  void Handle_SpVar_Attr()throw(Exception);
706 
707 
709  void Adjust_Obj_Name() throw(Exception);
710 
712  void Flatten_Obj_Name(bool include_attr) throw(Exception);
713 
715  void Handle_Obj_NameClashing(bool) throw(Exception);
716 
717 
719  void Adjust_Dim_Name() throw(Exception);
720 
721  void Handle_DimNameClashing() throw(Exception);
722 
724  void Add_Supplement_Attrs(bool) throw(Exception);
725 
727  void Handle_Coor_Attr();
728 
729  protected:
730  void Add_Dim_Name_GPM() throw(Exception);
731  void Add_Dim_Name_Mea_SeaWiFS() throw(Exception);
734 
735  void Add_Dim_Name_Mea_Ozonel3z() throw(Exception);
736  bool check_cv(string & varname) throw(Exception);
737 
738 
739  void Add_Dim_Name_Aqu_L3()throw(Exception);
740  void Add_Dim_Name_OBPG_L3()throw(Exception);
741  void Add_Dim_Name_SMAP()throw(Exception);
742  void Add_Dim_Name_ACOS_L2S()throw(Exception);
743 
744  void Add_Dim_Name_General_Product()throw(Exception);
745  void Check_General_Product_Pattern() throw(Exception);
746  void Add_Dim_Name_Dimscale_General_Product() throw(Exception);
747  void Handle_UseDimscale_Var_Dim_Names_General_Product(Var*) throw(Exception);
748  void Add_UseDimscale_Var_Dim_Names_General_Product(Var*,Attribute*) throw(Exception);
749 
750  void Handle_CVar_GPM_L1() throw(Exception);
751  void Handle_CVar_GPM_L3() throw(Exception);
752  void Handle_CVar_Mea_SeaWiFS() throw(Exception);
753  void Handle_CVar_Aqu_L3() throw(Exception);
754  void Handle_CVar_OBPG_L3() throw(Exception);
755  void Handle_CVar_SMAP() throw(Exception);
756  void Handle_CVar_Mea_Ozone() throw(Exception);
757  void Handle_SpVar_ACOS() throw(Exception);
758  void Handle_CVar_Dimscale_General_Product() throw(Exception);
759 
760  void Adjust_Mea_Ozone_Obj_Name() throw(Exception);
761  void Adjust_GPM_L3_Obj_Name() throw(Exception);
762 
763  void Handle_GMCVar_NameClashing(set<string> &) throw(Exception);
764  void Handle_GMCVar_AttrNameClashing() throw(Exception);
765  void Handle_GMSPVar_NameClashing(set<string> &) throw(Exception);
766  void Handle_GMSPVar_AttrNameClashing() throw(Exception);
767  template <typename T> void GMHandle_General_NameClashing(set <string>&objnameset, vector<T*>& objvec) throw(Exception);
768 
769  string get_CF_string(string s);
770 
771  void Handle_GPM_l1_Coor_Attr() throw(Exception);
772  void Add_GPM_Attrs() throw(Exception);
773  void Add_Aqu_Attrs() throw(Exception);
774  void Add_SeaWiFS_Attrs() throw(Exception);
775  void Create_Missing_CV(GMCVar*,const string &) throw(Exception);
776  bool Is_netCDF_Dimension(Var *var) throw(Exception);
777 
778  private:
779  H5GCFProduct product_type;
780  GMPattern gproduct_pattern;
781  vector <GMCVar *>cvars;
782  vector <GMSPVar *>spvars;
783  bool iscoard;
784 
785  };
786 
788  class EOS5CFGrid {
789  public:
791  addeddimindex(0),
792  has_nolatlon(true),
793  has_1dlatlon(false),
794  has_2dlatlon(false),
795  has_g2dlatlon(false)
796  {};
798  protected:
799  void Update_Dimnamelist();
800  private:
801  float point_lower;
802  float point_upper;
803  float point_left;
804  float point_right;
805  EOS5GridPRType eos5_pixelreg;
806  EOS5GridOriginType eos5_origin;
807  EOS5GridPCType eos5_projcode;
808 
809  vector <string> dimnames;
810  set <string> vardimnames;
811  map <string,hsize_t>dimnames_to_dimsizes;
812  map <hsize_t,string>dimsizes_to_dimnames;
813  int addeddimindex;
814 
815 
816  map <string,string> dnames_to_1dvnames;
817  string name;
818  int xdimsize;
819  int ydimsize;
820  bool has_nodimnames_vars;
821  bool has_nolatlon;
822  bool has_1dlatlon;
823  bool has_2dlatlon;
824  bool has_g2dlatlon;
825 
826  friend class EOS5File;
827  };
828 
830  class EOS5CFSwath {
831  public:
833  addeddimindex(0),
834  has_nolatlon(true),
835  has_1dlatlon(false),
836  has_2dlatlon(false),
837  has_g2dlatlon(false)
838  {};
840 
841  private:
842 
843  vector <string> dimnames;
844  set <string> vardimnames;
845  map <string,hsize_t>dimnames_to_dimsizes;
846  map <hsize_t,string>dimsizes_to_dimnames;
847  int addeddimindex;
848 
849  map <string,string> dnames_to_geo1dvnames;
850  string name;
851  bool has_nolatlon;
852  bool has_1dlatlon;
853  bool has_2dlatlon;
854  bool has_g2dlatlon;
855 
856  friend class EOS5File;
857  };
858 
860  class EOS5CFZa {
861  public:
863  ~EOS5CFZa() {};
864  private:
865 
866  vector <string> dimnames;
867  set <string> vardimnames;
868  map <string,hsize_t>dimnames_to_dimsizes;
869  map <hsize_t,string>dimsizes_to_dimnames;
870  int addeddimindex;
871 
872  map <string,string> dnames_to_1dvnames;
873  string name;
874 
875  friend class EOS5File;
876  };
877 
878 
880  class EOS5File:public File {
881  public:
882  EOS5File(const char*path, hid_t file_id):
883  File(path,file_id),
884  iscoard(false),
885  grids_multi_latloncvs(false),
886  isaura(false),
887  orig_num_grids(0)
888  { };
889  virtual ~EOS5File();
890  public:
891 
893  const vector<EOS5CVar *>&getCVars() const{
894  return this->cvars;
895  }
896 
898  void Retrieve_H5_Info(const char *path,
899  hid_t file_id, bool include_attr) throw (Exception);
900 
903 
905  void Handle_Unsupported_Dtype(bool) throw(Exception);
906 
908  void Handle_Unsupported_Dspace() throw(Exception);
909 
911  void Adjust_EOS5Dim_Info(HE5Parser*strmeta_info) throw(Exception);
912 
914  void Add_EOS5File_Info(HE5Parser*, bool) throw(Exception);
915 
917  void Adjust_Var_NewName_After_Parsing() throw(Exception);
918 
920  void Adjust_Obj_Name() throw(Exception);
921 
923  void Add_Dim_Name( HE5Parser *)throw(Exception);
924 
926  void Check_Aura_Product_Status() throw(Exception);
927 
929  void Handle_CVar() throw(Exception);
930 
932  void Handle_SpVar()throw(Exception) ;
933 
935  void Handle_SpVar_Attr()throw(Exception) ;
936 
937 
939  void Adjust_Var_Dim_NewName_Before_Flattening() throw(Exception);
940 
942  void Flatten_Obj_Name(bool include_attr) throw(Exception);
943 
945  void Set_COARDS_Status() throw(Exception);
946 
948  void Adjust_Attr_Info() throw(Exception);
949 
950 // void Adjust_Special_EOS5CVar_Name() throw(Exception);
951 
953  void Handle_Obj_NameClashing(bool) throw(Exception);
954 
956  void Add_Supplement_Attrs(bool) throw(Exception);
957 
959  void Handle_Coor_Attr();
960 
962  void Adjust_Dim_Name() throw(Exception);
963 
964  void Handle_DimNameClashing() throw(Exception);
965 
966  protected:
967  void Adjust_H5_Attr_Value(Attribute *attr) throw (Exception);
968 
969  void Adjust_EOS5Dim_List(vector<HE5Dim>&) throw(Exception);
970  void Condense_EOS5Dim_List(vector<HE5Dim>&) throw(Exception);
971  void Remove_NegativeSizeDims(vector<HE5Dim>&) throw(Exception);
972  void Adjust_EOS5VarDim_Info(vector<HE5Dim>&, vector<HE5Dim>&,const string &, EOS5Type) throw(Exception);
973 
974  void EOS5Handle_nonlatlon_dimcvars(vector<HE5Var> & eos5varlist,EOS5Type,string groupname, map<string,string>& dnamesgeo1dvnames) throw(Exception);
975  template <class T> void EOS5SwathGrid_Set_LatLon_Flags(T* eos5gridswath, vector<HE5Var>& eos5varlist) throw(Exception);
976 
977  void Obtain_Var_NewName(Var*) throw(Exception);
978  EOS5Type Get_Var_EOS5_Type(Var*) throw(Exception);
979 
980  bool Obtain_Var_Dims(Var*,HE5Parser*) throw(Exception);
981  template <class T> bool Set_Var_Dims(T*, Var*,vector<HE5Var>&, const string&, int,EOS5Type) throw(Exception);
982  template<class T> void Create_Unique_DimName(T*,set<string>&, Dimension *,int , EOS5Type ) throw(Exception);
983 
984  template <class T> bool Check_All_DimNames(T*,string &, hsize_t);
985  string Obtain_Var_EOS5Type_GroupName(Var*,EOS5Type ) throw(Exception);
986  int Check_EOS5Swath_FieldType(Var*) throw(Exception);
987  void Get_Unique_Name(set<string>&, string& ) throw(Exception);
988 
989  template<class T> string Create_Unique_FakeDimName(T*, EOS5Type) throw(Exception);
990  template<class T> void Set_NonParse_Var_Dims(T*, Var*, map<hsize_t,string>& ,int,EOS5Type )throw(Exception);
991 
992  void Handle_Grid_CVar(bool) throw(Exception);
993  void Handle_Augmented_Grid_CVar() throw(Exception);
994  template <class T> void Handle_Single_Augment_CVar(T*,EOS5Type) throw(Exception);
995 
996  void Handle_Multi_Nonaugment_Grid_CVar() throw(Exception);
997  void Handle_Single_Nonaugment_Grid_CVar(EOS5CFGrid*) throw(Exception);
998  bool Handle_Single_Nonaugment_Grid_CVar_OwnLatLon(EOS5CFGrid *, set<string>& ) throw(Exception);
999  bool Handle_Single_Nonaugment_Grid_CVar_EOS5LatLon(EOS5CFGrid *, set<string>& ) throw(Exception);
1000  void Handle_NonLatLon_Grid_CVar(EOS5CFGrid *, set<string>& ) throw(Exception);
1001  void Remove_MultiDim_LatLon_EOS5CFGrid() throw(Exception);
1002  void Adjust_EOS5GridDimNames(EOS5CFGrid *) throw(Exception);
1003 
1004  void Handle_Swath_CVar(bool) throw(Exception);
1005  void Handle_Single_1DLatLon_Swath_CVar(EOS5CFSwath *cfswath, bool is_augmented) throw(Exception);
1006  void Handle_Single_2DLatLon_Swath_CVar(EOS5CFSwath *cfswath, bool is_augmented) throw(Exception);
1007  void Handle_NonLatLon_Swath_CVar(EOS5CFSwath *cfswath, set<string>& tempvardimnamelist) throw(Exception);
1008  void Handle_Special_NonLatLon_Swath_CVar(EOS5CFSwath *cfswath, set<string>&tempvardimnamelist) throw(Exception);
1009 
1010  void Handle_Za_CVar(bool) throw(Exception);
1011 
1012  bool Check_Augmentation_Status() throw(Exception);
1013  bool Check_Augmented_Var_Attrs(Var *var) throw(Exception);
1014  template<class T> bool Check_Augmented_Var_Candidate(T* , Var*, EOS5Type ) throw(Exception);
1015 
1016  template <class T>void Adjust_Per_Var_Dim_NewName_Before_Flattening(T*,bool,int,int,int) throw(Exception);
1017  void Adjust_SharedLatLon_Grid_Var_Dim_Name() throw(Exception);
1018 
1019  void Adjust_Attr_Name() throw(Exception);
1020  void Adjust_Attr_Value() throw(Exception);
1021  void Handle_EOS5CVar_Unit_Attr()throw(Exception);
1022  void Handle_EOS5CVar_Special_Attr() throw(Exception);
1023 
1024  string get_CF_string(string s);
1025  void Replace_Var_Info(EOS5CVar *src, EOS5CVar *target);
1026  void Replace_Var_Attrs(EOS5CVar *src, EOS5CVar *target);
1027  void Handle_EOS5CVar_NameClashing(set<string> &) throw(Exception);
1028  void Handle_EOS5CVar_AttrNameClashing() throw(Exception);
1029  template <typename T> void EOS5Handle_General_NameClashing(set <string>&objnameset, vector<T*>& objvec) throw(Exception);
1030  void Adjust_CF_attr() throw(Exception);
1031  template <typename T> void Create_Missing_CV(T*, EOS5CVar*,const string &, EOS5Type, int) throw(Exception);
1032  void Create_Added_Var_NewName_FullPath(EOS5Type, const string& , const string& , string &, string &) throw(Exception);
1033 
1034 
1035  private:
1036  vector <EOS5CVar *>cvars;
1037  vector <EOS5CFGrid *>eos5cfgrids;
1038  vector <EOS5CFSwath *>eos5cfswaths;
1039  vector <EOS5CFZa *>eos5cfzas;
1040  map <string,string>eos5_to_cf_attr_map;
1041  bool iscoard;
1042  EOS5AuraName aura_name;
1043  bool grids_multi_latloncvs;
1044  bool isaura;
1045  int orig_num_grids;
1046  multimap<string,string>dimname_to_dupdimnamelist;
1047  };
1048 }
1049 #endif
Definition: HDF5CF.h:54
std::string message
Definition: HDF5CF.h:92
void Adjust_H5_Attr_Value(Attribute *attr)
Adjust attribute values for general HDF5 products.
Definition: HDF5GMCF.cc:178
Definition: HDF5CF.h:60
void Flatten_Obj_Name(bool include_attr)
Flatten the object name for general NASA HDF5 products.
Definition: HDF5GMCF.cc:1860
hsize_t getSize() const
Definition: HDF5CF.h:148
void Retrieve_H5_Attr_Value(Attribute *attr, string)
Definition: HDF5CF.cc:614
void Handle_GMSPVar_AttrNameClashing()
Definition: HDF5GMCF.cc:1953
vector< Dimension * > dims
Definition: HDF5CF.h:320
std::string newname
Definition: HDF5CF.h:310
void Handle_SpVar()
Handle special variables for general NASA HDF5 products.
Definition: HDF5GMCF.cc:1697
void Create_Missing_CV(GMCVar *, const string &)
Definition: HDF5GMCF.cc:2889
EOS5Type
Definition: HDF5CF.h:54
const string & getFullPath() const
Get the full path of this variable.
Definition: HDF5CF.h:279
size_t fstrsize
Definition: HDF5CF.h:236
const vector< GMCVar * > & getCVars() const
Definition: HDF5CF.h:671
This class represents one HDF5 dataset(CF variable)
Definition: HDF5CF.h:251
Definition: HE5Dim.h:8
void Handle_Coor_Attr()
Handle "coordinates" attributes for general HDF5 products.
Definition: HDF5GMCF.cc:2618
hsize_t size
Definition: HDF5CF.h:169
string path
Definition: HDF5CF.h:494
void Handle_CVar()
Handle coordinate variables for general NASA HDF5 products.
Definition: HDF5GMCF.cc:1197
Definition: HDF5CF.h:54
int getRank() const
Get the dimension rank of this variable.
Definition: HDF5CF.h:285
void Adjust_GPM_L3_Obj_Name()
Definition: HDF5GMCF.cc:1799
void Add_GPM_Attrs()
Definition: HDF5GMCF.cc:2189
const string & getName() const
Get the original name of this variable.
Definition: HDF5CF.h:267
void operator()(T *ptr)
Definition: HDF5CF.h:134
void Handle_DimNameClashing()
Handle dimension name clashing. Since COARDS requires the change of cv names, So we need to handle di...
Definition: HDF5GMCF.cc:2011
void Handle_GPM_l1_Coor_Attr()
Definition: HDF5GMCF.cc:2706
virtual void Replace_Var_Info(Var *src, Var *target)
Definition: HDF5CF.cc:1365
void Add_Dim_Name()
Add dimension name.
Definition: HDF5GMCF.cc:278
Definition: HDF5CF.h:56
const string & getName() const
Definition: HDF5CF.h:194
int getBitNum() const
Definition: HDF5CF.h:372
void Handle_GeneralObj_NameClashing(bool, set< string > &objnameset)
Definition: HDF5CF.cc:1016
std::string name
Definition: HDF5CF.h:311
void Add_Dim_Name_Dimscale_General_Product()
Definition: HDF5GMCF.cc:981
void Add_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(Var *, Attribute *)
Definition: HDF5GMCF.cc:426
virtual void Handle_DimNameClashing()=0
Handle dimension name clashing. Since COARDS requires the change of cv names, So we need to handle di...
hid_t fileid
Definition: HDF5CF.h:635
bool check_cv(string &varname)
Definition: HDF5GMCF.cc:692
virtual void Retrieve_H5_Info(const char *path, hid_t file_id, bool include_attr)
Retrieve DDS information from the HDF5 file. The reason to separate reading DDS from DAS is: DAP need...
Definition: HDF5CF.cc:83
void Handle_RootGroup_NameClashing(set< string > &objnameset)
Definition: HDF5CF.cc:911
void Handle_CVar_Dimscale_General_Product()
Definition: HDF5GMCF.cc:1570
const string & getNewName() const
Definition: HDF5CF.h:199
const string & getPath() const
Get the original path of this group.
Definition: HDF5CF.h:475
vector< size_t > strsize
Definition: HDF5CF.h:235
vector< char > value
Definition: HDF5CF.h:237
void Handle_Obj_NameClashing(bool)
Handle object name clashing for general NASA HDF5 products.
Definition: HDF5GMCF.cc:1914
GMPattern
Definition: HDF5CF.h:55
void GMHandle_General_NameClashing(set< string > &objnameset, vector< T * > &objvec)
Definition: HDF5GMCF.cc:1966
This class is a derived class of Var. It represents a special general HDF5 product(currently ACOS) ...
Definition: HDF5CF.h:355
void Add_Dim_Name_ACOS_L2S()
Definition: HDF5GMCF.cc:898
void Handle_CVar_Aqu_L3()
Definition: HDF5GMCF.cc:1497
This class simulates an HDF-EOS5 Swath.
Definition: HDF5CF.h:830
void Add_One_FakeDim_Name(Dimension *dim)
Definition: HDF5CF.cc:1077
This class is a derived class of CVar. It represents a coordinate variable for general HDF5 files...
Definition: HDF5CF.h:386
EOS5Type getEos5Type() const
Definition: HDF5CF.h:411
virtual void Adjust_Obj_Name()=0
Adjust object names based on different products.
Definition: HDF5CF.h:54
virtual void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes.
Definition: HDF5CF.cc:776
const std::vector< char > & getValue() const
Definition: HDF5CF.h:219
const vector< Attribute * > & getAttributes() const
Public interface to obtain information of all attributes under the root group.
Definition: HDF5CF.h:578
set< string > dimnamelist
Definition: HDF5CF.h:652
const vector< Attribute * > & getAttributes() const
Definition: HDF5CF.h:296
virtual void Adjust_Dim_Name()=0
Adjust dimension names based on different products.
void Handle_SpVar_Attr()
Handle special variable attributes for general NASA HDF5 products.
Definition: HDF5GMCF.cc:2936
void Retrieve_H5_VarType(Var *, hid_t dset_id, const string &varname, bool &unsup_var_dtype)
Definition: HDF5CF.cc:334
map< hsize_t, string > dimsize_to_fakedimname
Handle added dimension names.
Definition: HDF5CF.h:656
int rank
Definition: HDF5CF.h:314
const std::vector< size_t > & getStrSize() const
Definition: HDF5CF.h:224
string newname
Definition: HDF5CF.h:232
string newname
Definition: HDF5CF.h:493
Definition: HDF5CF.h:56
This file includes functions to identify different NASA HDF5 products. Current supported products inc...
virtual ~GMFile()
Definition: HDF5GMCF.cc:111
void Add_Dim_Name_GPM()
Definition: HDF5GMCF.cc:714
void Add_Dim_Name_Mea_SeaWiFS()
Definition: HDF5GMCF.cc:328
virtual void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes.
Definition: HDF5CF.cc:588
H5DataType
Definition: HDF5CFUtil.h:54
void Handle_CVar_OBPG_L3()
Definition: HDF5GMCF.cc:1621
const string & getNewName() const
Get the new name of this group(flattened,name clashed checked)
Definition: HDF5CF.h:481
virtual void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name.
Definition: HDF5CF.cc:1322
bool unsupported_dspace
Definition: HDF5CF.h:316
This class retrieves all information from an HDF5 file.
Definition: HDF5CF.h:506
vector< Var * > vars
Var vectors.
Definition: HDF5CF.h:639
virtual string get_CF_string(string)
Definition: HDF5CF.cc:1026
H5DataType getOriginalType() const
Definition: HDF5CF.h:364
void Add_Str_Attr(Attribute *attr, const string &attrname, const string &strvalue)
Definition: HDF5CF.cc:1163
virtual void setException(string message)
Definition: HDF5CF.h:85
EOS5AuraName
Definition: HDF5CF.h:56
int addeddimindex
Definition: HDF5CF.h:657
bool unsupported_attr_dtype
Definition: HDF5CF.h:497
void Adjust_Duplicate_FakeDim_Name(Dimension *dim)
Definition: HDF5CF.cc:1130
const string & getNewName() const
Definition: HDF5CF.h:156
This class is a derived class of CVar. It represents a coordinate variable for HDF-EOS5 files...
Definition: HDF5CF.h:404
int getStartBit() const
Definition: HDF5CF.h:368
H5GCFProduct
float getPointRight() const
Definition: HDF5CF.h:424
virtual void Handle_Unsupported_Dspace()
Handle unsupported HDF5 dataspaces for datasets.
Definition: HDF5CF.cc:850
void Add_Aqu_Attrs()
Definition: HDF5GMCF.cc:2488
H5DataType getType() const
Get the data type of this variable(Not HDF5 datatype id)
Definition: HDF5CF.h:291
This class is a derived class of File. It includes methods applied to general HDF5 files only...
Definition: HDF5CF.h:662
EOS5GridOriginType getOrigin() const
Definition: HDF5CF.h:431
const vector< GMSPVar * > & getSPVars() const
Definition: HDF5CF.h:675
EOS5GridPCType getProjCode() const
Definition: HDF5CF.h:435
void Adjust_Mea_Ozone_Obj_Name()
Definition: HDF5GMCF.cc:1825
void Handle_CVar_GPM_L3()
Definition: HDF5GMCF.cc:1313
void Handle_CVar_GPM_L1()
Definition: HDF5GMCF.cc:1227
const vector< Attribute * > & getAttributes() const
Definition: HDF5CF.h:486
void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes for general HDF5 products.
Definition: HDF5GMCF.cc:152
const string & getName() const
Definition: HDF5CF.h:152
void Add_SeaWiFS_Attrs()
Definition: HDF5GMCF.cc:2580
int getYDimSize() const
Definition: HDF5CF.h:443
void Adjust_Dim_Name()
Adjust dimension name for general NASA HDF5 products.
Definition: HDF5GMCF.cc:2078
void Change_Attr_One_Str_to_Others(Attribute *attr, Var *var)
Definition: HDF5CF.cc:1187
void Add_Dim_Name_Aqu_L3()
Definition: HDF5GMCF.cc:805
void Retrieve_H5_Attr_Info(Attribute *, hid_t obj_id, const int j, bool &unsup_attr_dtype)
Definition: HDF5CF.cc:461
EOS5GridPRType
This file defines a few enum types used by HDF-EOS5 products.
Definition: HE5GridPara.h:3
H5DataType dtype
Definition: HDF5CF.h:233
Definition: HDF5CF.h:56
Exception(const string &msg)
Constructor.
Definition: HDF5CF.h:70
float getPointLeft() const
Definition: HDF5CF.h:421
void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes for general HDF5 products.
Definition: HDF5GMCF.cc:194
CVType getCVType() const
Get the coordinate variable type of this variable.
Definition: HDF5CF.h:337
hsize_t count
Definition: HDF5CF.h:234
H5DataType dtype
Definition: HDF5CF.h:313
const hid_t getFileID() const
Obtain the HDF5 file ID.
Definition: HDF5CF.h:559
H5GCFProduct getPtType() const
Get the data type of this variable.
Definition: HDF5CF.h:393
const string & getNewName() const
Get the new name of this variable.
Definition: HDF5CF.h:273
void Handle_Obj_AttrNameClashing()
Definition: HDF5CF.cc:939
Dimension(hsize_t dimsize)
Definition: HDF5CF.h:163
const string & getPath() const
Obtain the path of the file.
Definition: HDF5CF.h:566
virtual void Handle_Coor_Attr()=0
Handle "coordinates" attributes.
virtual ~File()
Definition: HDF5CF.cc:47
void Handle_UseDimscale_Var_Dim_Names_Mea_SeaWiFS_Ozone(Var *)
Definition: HDF5GMCF.cc:351
GMFile(const char *path, hid_t file_id, H5GCFProduct product, GMPattern gproduct_pattern)
Definition: HDF5GMCF.cc:105
bool unsupported_var_dtype
Definition: HDF5CF.h:647
This class is a derived class of File. It includes methods applied to HDF-EOS5 files only...
Definition: HDF5CF.h:880
virtual void Handle_SpVar()=0
Handle special variables.
void Add_Dim_Name_Mea_Ozonel3z()
Definition: HDF5GMCF.cc:553
const vector< Dimension * > & getDimensions() const
Get the list of the dimensions.
Definition: HDF5CF.h:302
map< string, hsize_t > dimname_to_dimsize
Definition: HDF5CF.h:653
const vector< EOS5CVar * > & getCVars() const
Obtain coordinate variables for HDF-EOS5 products.
Definition: HDF5CF.h:893
EOS5GridPRType getPixelReg() const
Definition: HDF5CF.h:428
virtual void Replace_Var_Attrs(Var *src, Var *target)
Definition: HDF5CF.cc:1424
void Retrieve_H5_VarDim(Var *, hid_t dset_id, const string &varname, bool &unsup_var_dspace)
Definition: HDF5CF.cc:367
vector< Attribute * > attrs
Definition: HDF5CF.h:319
H5DataType getType() const
Definition: HDF5CF.h:204
This class simulates an HDF-EOS5 Zonal average object.
Definition: HDF5CF.h:860
A class for parsing NASA HDF-EOS5 StructMetadata.
This class represents one attribute.
Definition: HDF5CF.h:184
int getXDimSize() const
Definition: HDF5CF.h:439
void Handle_Unsupported_Dspace()
Handle unsupported HDF5 dataspaces for general HDF5 products.
Definition: HDF5GMCF.cc:246
Helper functions for generating DAS attributes and a function to check BES Key.
void Insert_One_NameSizeMap_Element2(map< string, hsize_t > &, string name, hsize_t size)
Definition: HDF5CF.cc:1054
CVType
Definition: HDF5CF.h:53
bool dimnameflag
Definition: HDF5CF.h:317
string newname
Definition: HDF5CF.h:171
EOS5GridOriginType
Definition: HE5GridPara.h:8
string path
Definition: HDF5CF.h:634
void Handle_CVar_SMAP()
Definition: HDF5GMCF.cc:1426
bool Is_netCDF_Dimension(Var *var)
Definition: HDF5GMCF.cc:2908
virtual ~Exception()
Definition: HDF5CF.h:75
void Check_General_Product_Pattern()
Definition: HDF5GMCF.cc:925
virtual void Handle_SpVar_Attr()=0
Handle special variable attributes.
This class simulates an HDF-EOS5 Grid. Currently only geographic projection is supported.
Definition: HDF5CF.h:788
This file includes several helper functions for translating HDF5 to CF-compliant. ...
void Add_One_Float_Attr(Attribute *attr, const string &attrname, float float_value)
Definition: HDF5CF.cc:1177
void Retrieve_H5_Obj(hid_t grp_id, const char *gname, bool include_attr)
Definition: HDF5CF.cc:131
void Handle_CVar_Mea_Ozone()
Definition: HDF5GMCF.cc:1527
const vector< Var * > & getVars() const
Public interface to obtain information of all variables.
Definition: HDF5CF.h:572
bool unsupported_attr_dtype
Definition: HDF5CF.h:648
void Handle_SpVar_ACOS()
Definition: HDF5GMCF.cc:1738
virtual const char * what() const
Definition: HDF5CF.h:79
void Handle_GMCVar_NameClashing(set< string > &)
Definition: HDF5GMCF.cc:1932
std::string fullpath
Definition: HDF5CF.h:312
void Handle_GMSPVar_NameClashing(set< string > &)
Definition: HDF5GMCF.cc:1937
const vector< Group * > & getGroups() const
Public interface to obtain all the group info.
Definition: HDF5CF.h:584
void Handle_UseDimscale_Var_Dim_Names_General_Product(Var *)
Definition: HDF5GMCF.cc:1003
virtual void Handle_CVar()=0
Handle coordinate variables.
bool unsupported_attr_dtype
Definition: HDF5CF.h:315
Definition: HDF5CF.h:56
float getPointLower() const
Definition: HDF5CF.h:414
void Adjust_Obj_Name()
Adjust object names based on different general NASA HDF5 products.
Definition: HDF5GMCF.cc:1777
This class repersents one dimension of an HDF5 dataset(variable).
Definition: HDF5CF.h:145
void Handle_CVar_Mea_SeaWiFS()
Definition: HDF5GMCF.cc:1368
This class is a derived class of Var. It represents a coordinate variable.
Definition: HDF5CF.h:332
void Add_Dim_Name_General_Product()
Definition: HDF5GMCF.cc:914
void Handle_Var_NameClashing(set< string > &objnameset)
Definition: HDF5CF.cc:906
void Insert_One_NameSizeMap_Element(string name, hsize_t size)
Definition: HDF5CF.cc:1044
void Handle_GMCVar_AttrNameClashing()
Definition: HDF5GMCF.cc:1943
bool unsupported_var_dspace
Definition: HDF5CF.h:650
string get_CF_string(string s)
Definition: HDF5GMCF.cc:128
hid_t rootid
Definition: HDF5CF.h:636
H5GCFProduct getProductType() const
Definition: HDF5CF.h:667
void Add_UseDimscale_Var_Dim_Names_General_Product(Var *, Attribute *)
Definition: HDF5GMCF.cc:1069
virtual void Flatten_Obj_Name(bool)
Flatten the object name.
Definition: HDF5CF.cc:866
void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name for general NASA HDF5 products...
Definition: HDF5GMCF.cc:2132
This class represents an HDF5 group. The group will be flattened according to the CF conventions...
Definition: HDF5CF.h:464
size_t getBufSize() const
Definition: HDF5CF.h:214
hsize_t getCount() const
Definition: HDF5CF.h:209
vector< Attribute * > attrs
Definition: HDF5CF.h:496
vector< Group * > groups
Non-root group vectors.
Definition: HDF5CF.h:645
EOS5File(const char *path, hid_t file_id)
Definition: HDF5CF.h:882
Definition: HE5Var.h:9
void Handle_General_NameClashing(set< string > &objnameset, vector< T * > &objvec)
Definition: HDF5CF.cc:971
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...
Definition: HDF5GMCF.cc:138
float getPointUpper() const
Definition: HDF5CF.h:417
vector< Attribute * > root_attrs
Root attribute vectors.
Definition: HDF5CF.h:642
void Add_Dim_Name_OBPG_L3()
Definition: HDF5GMCF.cc:323
void Add_Dim_Name_SMAP()
Definition: HDF5GMCF.cc:831
EOS5GridPCType
Definition: HE5GridPara.h:13