OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDFEOS2.h
Go to the documentation of this file.
1 // This file is part of the hdf4 data handler for the OPeNDAP data server.
3 //
4 // Author: Kent Yang,Choonghwan Lee <myang6@hdfgroup.org>
5 // Copyright (c) 2010-2012 The HDF Group
7 
8 //#include "InternalErr.h"
9 #ifdef USE_HDFEOS2_LIB
10 
11 #ifndef _HDFEOS2_H
12 #define _HDFEOS2_H
13 #ifdef _WIN32
14 #ifdef _DEBUG
15 #define _CRTDBG_MAP_ALLOC
16 #include <stdlib.h>
17 #include <crtdbg.h>
18 #endif
19 #endif
20 
21 
22 #include <iostream>
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <set>
27 #include "mfhdf.h"
28 #include "hdf.h"
29 #include "HdfEosDef.h"
30 
31 
32 // Add MISR SOM projection header
33 #include "misrproj.h"
34 
35 #include "HDFEOS2EnumType.h"
36 
37 #ifdef _WIN32
38 #ifdef _MSC_VER
39 #pragma warning(disable:4290)
40 #endif
41 #endif
42 
63 namespace HDFEOS2
64 {
67  class Exception:public std::exception
68  {
69  public:
71  Exception (const std::string & msg)
72  : message (msg), isHDFEOS2 (true)
73  {
74  }
75 
77  virtual ~ Exception () throw ()
78  {
79  }
80 
82  virtual const char *what () const throw ()
83  {
84  return this->message.c_str ();
85  }
86 
89  virtual bool getFileType ()
90  {
91  return this->isHDFEOS2;
92  }
93 
95  virtual void setFileType (bool isHDFEOS2)
96  {
97  this->isHDFEOS2 = isHDFEOS2;
98  }
99 
101  virtual void setException (std::string message)
102  {
103  this->message = message;
104  }
105 
106  protected:
107  std::string message;
108  bool isHDFEOS2;
109  };
110 
119  template < typename T > class LightVector {
120  public:
121  LightVector ()
122  : data (0), length (0), capacity (0) {
123  }
124 
125  LightVector (const LightVector < T > &that)
126  {
127  this->data = new T[that.length];
128  for (unsigned int i = 0; i < that.length; ++i)
129  this->data[i] = that[i];
130  this->length = that.length;
131  this->capacity = that.length;
132  }
133 
134  ~LightVector () {
135  if (this->data)
136  delete[]data;
137  }
138 
139  void push_back (const T & d)
140  {
141  this->reserve (this->length + 1);
142  this->data[this->length] = d;
143  ++this->length;
144  }
145 
146  void reserve (unsigned int len)
147  {
148  if (this->capacity >= len)
149  return;
150 
151  this->capacity = len;
152  T *old = this->data;
153 
154  this->data = new T[len];
155  if (old) {
156  for (unsigned int i = 0; i < this->length; ++i)
157  this->data[i] = old[i];
158  delete[]old;
159  }
160  }
161 
162  void resize (unsigned int len)
163  {
165  if (this->length == len)
166  return;
167  else if (this->length < len) {
168  if (this->capacity < len) {
169  this->capacity = len;
170  T *old = this->data;
171 
172  this->data = new T[len];
173  if (old) {
174  for (unsigned int i = 0; i < this->length; ++i)
175  this->data[i] = old[i];
176  delete[]old;
177  }
178  }
179  }
180  else {
181  this->capacity = len;
182  T *old = this->data;
183 
184  this->data = new T[len];
185  for (unsigned int i = 0; i < len; ++i)
186  this->data[i] = old[i];
187  if (old)
188  delete[]old;
189  }
190  this->length = len;
191  }
192 
193  unsigned int size () const
194  {
195  return this->length;
196  }
197 
198  T & operator[] (unsigned int i)
199  {
200  return this->data[i];
201  }
202  const T & operator[] (unsigned int i) const
203  {
204  return this->data[i];
205  }
206 
207  LightVector < T > &operator= (const LightVector < T > &that)
208  {
209  if (this != &that) {
210  this->data = new T[that.length];
211  for (unsigned int i = 0; i < that.length; ++i)
212  this->data[i] = that[i];
213  this->length = that.length;
214  this->capacity = that.length;
215  }
216  return *this;
217  }
218 
219  private:
220  T * data;
221  unsigned int length;
222  unsigned int capacity;
223  };
224 
225  class SwathDimensionAdjustment;
226 
230  class Dimension
231  {
232  public:
233  const std::string & getName () const
234  {
235  return this->name;
236  }
237  int32 getSize () const
238  {
239  return this->dimsize;
240  }
241 
242  protected:
243  Dimension (const std::string & name, int32 dimsize)
244  : name (name), dimsize (dimsize)
245  {
246  }
247 
248  protected:
249  std::string name;
250  int32 dimsize;
251 
252  friend class File;
253  friend class Dataset;
254  friend class SwathDimensionAdjustment;
255  };
256 
259  class Field
260  {
261  public:
262  Field ()
263  :fieldtype (0), condenseddim (false), iscoard (false), ydimmajor (true), speciallon (false), specialformat (0), haveaddedfv (false), addedfv (-9999.0), dmap (false)/*, field_cache(0)*/
264 
265  {
266  }
267  virtual ~ Field ();
268 
269  public:
270 
272  const std::string & getName () const
273  {
274  return this->name;
275  }
276 
278  const std::string & getNewName () const
279  {
280  return this->newname;
281  }
282 
284  int32 getRank () const
285  {
286  return this->rank;
287  }
288 
290  int32 getType () const
291  {
292  return this->type;
293  }
294 
296  const std::vector < Dimension * >&getCorrectedDimensions () const
297  {
298  return this->correcteddims;
299  }
300 
302  std::vector < Dimension * >*getCorrectedDimensionsPtr ()
303  {
304  return &(this->correcteddims);
305  }
306 
308  void setCorrectedDimensions (std::vector < Dimension * >dims)
309  {
310  correcteddims = dims;
311  }
312 
314  const std::string getCoordinate () const
315  {
316  return this->coordinates;
317  }
318 
320  void setCoordinates (std::string coor)
321  {
322  coordinates = coor;
323  }
324 
326  const std::string getUnits () const
327  {
328  return this->units;
329  }
330 
332  void setUnits (std::string uni)
333  {
334  units = uni;
335  }
336 
338  const float getAddedFillValue () const
339  {
340  return this->addedfv;
341  }
342 
343  // Add the "_FillValue" attribute
344  // This is for supporting the old versions of HDF-EOS2 data(AIRS) because
345  // some data products have fillvalue(-9999.0) but don't specify the fillvalue.
346  // We add the fillvalue to ensure the netCDF client can successfully display the data.
347  // KY 2013-06-30
348  void addFillValue (float fv)
349  {
350  addedfv = fv;
351  }
352 
354  const bool haveAddedFillValue () const
355  {
356  return this->haveaddedfv;
357  }
358 
360  void setAddedFillValue (bool havefv)
361  {
362  haveaddedfv = havefv;
363  }
364 
365 
366  // Obtain fieldtype values
367  // For fieldtype values:
368  // 0 is general fields
369  // 1 is latitude.
370  // 2 is longtitude.
371  // 3 is defined level.
372  // 4 is an inserted natural number.
373  // 5 is time.
374 
375  const int getFieldType () const
376  {
377  return this->fieldtype;
378  }
379 
381  const std::vector < Dimension * >&getDimensions () const
382  {
383  return this->dims;
384  }
385 
387  const std::vector < char >&getFillValue () const
388  {
389  return this->filler;
390  }
391 
393  const bool getYDimMajor () const
394  {
395  return this->ydimmajor;
396  }
397 
399  const bool getSpecialLon () const
400  {
401  return this->speciallon;
402  }
403 
405  const int getSpecialLLFormat () const
406  {
407  return this->specialformat;
408  }
409 
411  const bool getCondensedDim () const
412  {
413  return this->condenseddim;
414  }
415 
417  const bool UseDimMap () const
418  {
419  return this->dmap;
420  }
421 
422 //No need to check field_cache in the DDS level.
423 //May remove the debugging info. totally in the next release.
424 //KY 2014-10-23
425 #if 0
426  // 2 exactly cached
428  // 1 maybe cached, need to check the
429  // file size when accessing the data
430  const short UseFieldCache () const
431  {
432  return this->field_cache;
433  }
434 #endif
435  protected:
436 
437  // field name
438  std::string name;
439 
440  // field dimension rank
441  int32 rank;
442 
443  // field datatype
444  int32 type;
445 
446  // field dimensions with original dimension names
447  std::vector < Dimension * >dims;
448 
449  // field dimensions with the corrected(CF) dimension names
450  std::vector < Dimension * >correcteddims;
451 
452  // This is for reading the fillvalue.
453  // HDF-EOS2 provides a special routine to read fillvalue.
454  // Up to HDF-EOS2 version 2.18, this is the only field attribute
455  // that HDF-EOS2 APIs provide. KY 2013-07-01
456 
457  std::vector < char >filler;
458 
459  // Coordinate attributes that includes coordinate variable list.
460  std::string coordinates;
461 
462  // newname is to record CF Grid/Swath name + "_"+ CF field name(special characters replaced by underscores).
463  std::string newname;
464 
465 
466  // This flag will specify the fieldtype.
467  // 0 means this field is general field.
468  // 1 means this field is lat.
469  // 2 means this field is lon.
470  // 3 means this field is other dimension variable.
471  // 4 means this field is added other dimension variable with nature number.
472  // 5 means time, but currently the units is not correct.
473  int fieldtype;
474 
475  // Latitude and longitude retrieved by HDF-EOS2 are always
476  // 2-D arrays(XDim * YDim). However, for some projections
477  // (geographic etc.), latiude and longitude can be condensed to
478  // 1-D arrays. The handler will track such projections and condense
479  // the latitude and longitude to 1-D arrays. This can reduce
480  // the disk storage and can greatly improve the performance for
481  // the visualization tool to access the latitude and longitde.
482  // condenseddim is the flag internally used by the handler to track this.
483  bool condenseddim;
484 
485  // This flag is to mark if the data should follow COARDS.
486  bool iscoard;
487 
488  // This flag is to check if the field is YDim major(temp(YDim,XDim). This
489  // flag is necessary when calling GDij2ll to retrieve latitude and longitude.
490  bool ydimmajor;
491 
492  // SOme special longitude is from 0 to 360.We need to check this case with this flag.
493  bool speciallon;
494 
495  // This flag specifies the special latitude/longitude coordinate format
496  // The latiude and longitude should represent as DDDMMMSSS format
497  // However, we found some files simply represent lat/lon as -180.0000000 or -90.000000.
498  // Some other files use default. So we this flag to record this and correctly retrieve
499  // the latitude and longitude values in the DAP output.
500  // 0 means normal
501  // 1 means the coordinate is -180 to 180
502  // 2 means the coordinate is default(0)
503  int specialformat;
504 
505  // CF units attribute(mostly to add latitude and longitude CF units).
506  std::string units;
507 
508  // Some data products have fillvalue(-9999.0) but don't specify the fillvalue.
509  // We add the fillvalue to ensure the netCDF client can successfully display the data.
510  // haveaddedfv and addedfv are to check if having added fillvalues.
511  bool haveaddedfv;
512  float addedfv;
513 
514  // Check if this swath uses the dimension map.
515  bool dmap;
516 
517  // Flag to indicate the field cache. Now this only applies to some HDF-EOS2 grid lat/lon fields.
518  //short field_cache;
519 
522  // This may not necessary. Check in the next release. KY 2012-09-20
523  // bool need_adjustment;
524 
525  friend class Dataset;
526  friend class SwathDimensionAdjustment;
527  friend class GridDataset;
528  friend class SwathDataset;
529  friend class File;
530  };
531 
532 #if 0
533  // For future improvement of the modulization
534  class GeoField:public Field
535  {
536 
537  protected:
538  bool condenseddim;
539  bool ydimmajor;
540  bool speciallon;
541 
542  };
543 #endif
544 
546  class Attribute
547  {
548  public:
549 
551  const std::string & getName () const
552  {
553  return this->name;
554  }
555 
557  const std::string & getNewName () const
558  {
559  return this->newname;
560  }
561 
563  int32 getType () const
564  {
565  return this->type;
566  }
567 
569  int32 getCount () const
570  {
571  return this->count;
572  }
573 
575  const std::vector < char >&getValue () const
576  {
577  return this->value;
578  }
579 
580  protected:
581 
583  std::string name;
584 
586  std::string newname;
587 
589  int32 type;
590 
592  int32 count;
593 
595  std::vector < char >value;
596 
597  friend class Dataset;
598  };
599 
603  class Dataset
604  {
605  public:
607  const std::string & getName () const
608  {
609  return this->name;
610  }
612  const std::vector < Dimension * >&getDimensions () const
613  {
614  return this->dims;
615  }
617  const std::vector < Field * >&getDataFields () const
618  {
619  return this->datafields;
620  }
621 
623  const std::vector < Attribute * >&getAttributes () const
624  {
625  return this->attrs;
626  }
627 
629  const SOType getScaleType () const
630  {
631  return this->scaletype;
632  }
633 
634 
635  protected:
636  Dataset (const std::string & n)
637  : datasetid (-1), addfvalueattr(false),name (n),scaletype(DEFAULT_CF_EQU)
638  {
639  }
640 
641  virtual ~ Dataset ();
642 
645  void ReadDimensions (int32 (*entries) (int32, int32, int32 *),
646  int32 (*inq) (int32, char *, int32 *),
647  std::vector < Dimension * >&dims) throw (Exception);
648 
652  void ReadFields (int32 (*entries) (int32, int32, int32 *),
653  int32 (*inq) (int32, char *, int32 *, int32 *),
654  intn (*fldinfo) (int32, char *, int32 *, int32 *,
655  int32 *, char *),
656  intn (*readfld) (int32, char *, int32 *, int32 *,
657  int32 *, VOIDP),
658  intn (*getfill) (int32, char *, VOIDP),
659  bool geofield, std::vector < Field * >&fields)
660  throw (Exception);
661 
664  void ReadAttributes (int32 (*inq) (int32, char *, int32 *),
665  intn (*attrinfo) (int32, char *, int32 *, int32 *),
666  intn (*readattr) (int32, char *, VOIDP),
667  std::vector < Attribute * >&attrs)
668  throw (Exception);
669 
676  void SetScaleType(const std::string EOS2ObjName) throw(Exception);
677 
678  protected:
680  int32 datasetid;
681 
685  bool addfvalueattr;
686 
688  std::string name;
689 
691  std::vector < Dimension * >dims;
692 
694  std::vector < Field * >datafields;
695 
697  std::vector < Attribute * >attrs;
698 
701  std::map < std::string, std::string > dimcvarlist;
702 
704  std::map < std::string, std::string > ncvarnamelist;
705 
707  std::map < std::string, std::string > ndimnamelist;
708 
709  // Some MODIS files don't use the CF linear equation y = scale * x + offset,
710  // The scaletype distinguishs products following different scale and offset rules.
711  // Note the assumption here: we assume that all fields will
712  // use one scale and offset function in a file. If
713  // multiple scale and offset equations are used in one file, our
714  // function will fail. So far only one scale and offset equation is
715  // applied for NASA HDF-EOS2 files we observed. KY 2012-6-13
716  // Since I found one MODIS product(MOD09GA) uses different scale offset
717  // equations for different grids. I had to move the scaletype to the
718  // group level. Hopefully this is the final fix. Truly hope that
719  // this will not happen at the field level since it will be too messy to
720  // check. KY 2012-11-21
721  SOType scaletype;
722 
723  friend class File;
724  };
725 
728  class GridDataset:public Dataset
729  {
730  public:
731  class Info
732  {
733  public:
734 
736  int32 getX ()const
737  {
738  return this->xdim;
739  }
740 
742  int32 getY () const
743  {
744  return this->ydim;
745  }
746 
752  const float64 *getUpLeft () const
753  {
754  return this->upleft;
755  }
756 
762  const float64 *getLowRight () const
763  {
764  return this->lowright;
765  }
766 
767  protected:
768  int32 xdim;
769  int32 ydim;
770  float64 upleft[2];
771  float64 lowright[2];
772 
773  friend class GridDataset;
774  };
775 
776  class Projection
777  {
778  public:
781 
784  int32 getCode () const
785  {
786  return this->code;
787  }
788 
790  int32 getZone () const
791  {
792  return this->zone;
793  }
794 
796  int32 getSphere () const
797  {
798  return this->sphere;
799  }
800 
802  const float64 *getParam () const
803  {
804  return this->param;
805  }
806 
808  int32 getPix () const
809  {
810  return this->pix;
811  }
812 
814  int32 getOrigin () const
815  {
816  return this->origin;
817  }
818 
819  protected:
820  int32 code;
821  int32 zone;
822  int32 sphere;
823  float64 param[16];
824  int32 pix;
825  int32 origin;
826 
827  friend class GridDataset;
828  };
829 
832  class Calculated
833  {
834  public:
835 
838  bool isYDimMajor () throw (Exception);
842 
843  protected:
844 
845  Calculated (const GridDataset * grid)
846  : grid (grid), ydimmajor (false)
847  {
848  }
849 
850  Calculated & operator= (const Calculated & victim)
851  {
852  if (this != &victim) {
853  this->grid = victim.grid;
854  this->ydimmajor = victim.ydimmajor;
855  }
856  return *this;
857  }
858 
861  void DetectMajorDimension () throw (Exception);
862 
864  int DetectFieldMajorDimension () throw (Exception);
865 
866 
867  protected:
868  const GridDataset *grid;
869  bool ydimmajor;
870 
871  friend class GridDataset;
872  friend class File;
873  };
874 
875  public:
877  static GridDataset *Read (int32 fd, const std::string & gridname) throw (Exception);
878 
879  virtual ~ GridDataset ();
880 
882  const Info & getInfo () const
883  {
884  return this->info;
885  }
886 
888  const Projection & getProjection () const
889  {
890  return this->proj;
891  }
892 
894  Calculated & getCalculated () const;
895 
897  void setDimxName (std::string dxname)
898  {
899  dimxname = dxname;
900  }
902  void setDimyName (std::string dyname)
903  {
904  dimyname = dyname;
905  }
906 
908  const bool getLatLonFlag () const
909  {
910  return this->ownllflag;
911  }
912 
913  private:
914  GridDataset (const std::string & name)
915  : Dataset (name), calculated (0), ownllflag (false), iscoard (false)
916  {
917  }
918 
919  protected:
920 
922  Info info;
923 
925  Projection proj;
926 
929  mutable Calculated calculated;
930 
932  bool ownllflag;
933 
935  bool iscoard;
936 
938  Field *latfield;
939  Field *lonfield;
940 
942  std::string dimxname;
943  std::string dimyname;
944 
945  friend class File;
946 
947  };
948 
949  class File;
950 
954 
955  class SwathDataset:public Dataset
956  {
957 
958  public:
973 
974  class DimensionMap
975  {
976  public:
977  const std::string & getGeoDimension () const
978  {
979  return this->geodim;
980  }
981  const std::string & getDataDimension () const
982  {
983  return this->datadim;
984  }
985  int32 getOffset () const
986  {
987  return this->offset;
988  }
989  int32 getIncrement () const
990  {
991  return this->increment;
992  }
993 
994  protected:
995  DimensionMap (const std::string & geodim, const std::string & datadim, int32 offset, int32 increment)
996  : geodim (geodim), datadim (datadim), offset (offset), increment (increment)
997  {
998  }
999 
1000  protected:
1001 
1002  std::string geodim;
1003  std::string datadim;
1004  int32 offset;
1005  int32 increment;
1006 
1007  friend class SwathDataset;
1008  friend class SwathDimensionAdjustment;
1009  friend class File;
1010  };
1011 
1015  class IndexMap
1016  {
1017  public:
1018  const std::string & getGeoDimension () const
1019  {
1020  return this->geo;
1021  }
1022  const std::string & getDataDimension () const
1023  {
1024  return this->data;
1025  }
1026  const LightVector < int32 > &getIndices () const
1027  {
1028  return this->indices;
1029  }
1030 
1031  protected:
1032  std::string geo;
1033  std::string data;
1034  LightVector < int32 > indices;
1035 
1036  friend class SwathDataset;
1037  };
1038 
1039  public:
1041  static SwathDataset *Read (int32 fd, const std::string & swathname) throw (Exception);
1042 
1043  virtual ~ SwathDataset ();
1044 
1046  const std::vector < DimensionMap * >&getDimensionMaps () const
1047  {
1048  return this->dimmaps;
1049  }
1050  const std::vector < IndexMap * >&getIndexMaps () const
1051  {
1052  return this->indexmaps;
1053  }
1054 
1056  const std::vector < Field * >&getGeoFields () const
1057  {
1058  return this->geofields;
1059  }
1060 
1061 
1063  void set_num_map (int this_num_map)
1064  {
1065  num_map = this_num_map;
1066  }
1067  int get_num_map () const
1068  {
1069  return num_map;
1070  };
1071 
1072  private:
1073  SwathDataset (const std::string & name)
1074  : Dataset (name) {
1075  }
1076 
1077 
1080  int ReadDimensionMaps (std::vector < DimensionMap * >&dimmaps) throw (Exception);
1081 
1083  void ReadIndexMaps (std::vector < IndexMap * >&indexmaps) throw (Exception);
1084 
1085  protected:
1086 
1088  std::vector < DimensionMap * >dimmaps;
1089 
1091  std::vector < IndexMap * >indexmaps;
1092 
1094  std::set < std::string > nonmisscvdimlist;
1095 
1097  std::vector < Field * >geofields;
1098 
1101  int num_map;
1102 
1103  friend class File;
1104  };
1105 
1109  class PointDataset:public Dataset
1110  {
1111  public:
1112  static PointDataset *Read (int32 fd, const std::string & pointname) throw (Exception);
1113  virtual ~ PointDataset ();
1114 
1115  private:
1116  PointDataset (const std::string & name)
1117  : Dataset (name)
1118  {
1119  }
1120  };
1121 
1122 
1125  class File
1126  {
1127  public:
1128 
1130  static File *Read (const char *path,int32 gridfd,int32 swathfd) throw (Exception);
1131 
1132 
1136  void Prepare(const char *path) throw(Exception);
1137 
1139  bool check_special_1d_grid() throw(Exception);
1140 
1141 
1144  bool getOneLatLon ()
1145  {
1146  return this->onelatlon;
1147  }
1148 
1150  ~File ();
1151 
1152  const std::string & getPath () const
1153  {
1154  return this->path;
1155  }
1156 
1157  const std::vector < GridDataset * >&getGrids () const
1158  {
1159  return this->grids;
1160  }
1161 
1162  const std::vector < SwathDataset * >&getSwaths () const
1163  {
1164  return this->swaths;
1165  }
1166 
1167  const std::vector < PointDataset * >&getPoints () const
1168  {
1169  return this->points;
1170  }
1171 
1172  const std::string get_first_grid_name() const
1173  { return this->grids[0]->getName();}
1181 
1182 
1183  protected:
1184  File (const char *path)
1185  : path (path), onelatlon (false), iscoard (false), gridfd (-1), swathfd (-1)
1186  {
1187  }
1188 
1189  protected:
1190 
1192  std::string path;
1193 
1195  std::vector < GridDataset * >grids;
1196 
1198  std::vector < SwathDataset * >swaths;
1199 
1201  std::vector < PointDataset * >points;
1202 
1203  // This is for the case that only one lat/lon
1204  // set is provided for multiple grid cases.
1205  // The current case is that the user provides
1206  // the latitude and longitude under a special grid.
1207  // By default, the grid name is "location". This will
1208  // cover the AIRS grid case.
1209  bool onelatlon;
1210 
1212  bool iscoard;
1213 
1214  /*
1215  A grid's X-dimension can have different names: XDim, LatDim, etc.
1216  * Y-dimension also has YDim, LonDim, etc.
1217  * This function returns the name of X-dimension which is used in
1218  * the given file.
1219  * For better performance, we check the first grid or swath only.
1220  */
1221  std::string get_geodim_x_name ();
1222  std::string get_geodim_y_name ();
1223 
1224  // Internal function used by
1225  // get_geodim_x_name and get_geodim_y_name functions.
1226  // This function is not intended to be used outside the
1227  // get_geodim_x_name and get_geodim_y_name functions.
1228  void _find_geodim_names ();
1229 
1230  std::string _geodim_x_name;
1231  std::string _geodim_y_name;
1232  static const char *_geodim_x_names[];
1233  static const char *_geodim_y_names[];
1234 
1244  std::string get_latfield_name ();
1245  std::string get_lonfield_name ();
1246 
1247  // Internal function used by
1248  // get_latfield_name and get_lonfield_name functions.
1249  // This function is not intended to be used outside
1250  // the get_latfield_name and get_lonfield_name functions.
1251  void _find_latlonfield_names ();
1252 
1253  std::string _latfield_name;
1254  std::string _lonfield_name;
1255  static const char *_latfield_names[];
1256  static const char *_lonfield_names[];
1257 
1263  std::string get_geogrid_name ();
1264 
1265  // Internal function used by
1266  // the get_geogrid_name function.
1267  // This function is not intended to be used outside the get_geogrid_name function.
1268  void _find_geogrid_name ();
1269 
1270  std::string _geogrid_name;
1271  static const char *_geogrid_names[];
1272 
1273 
1274  // All the following functions are called by the Prepare() function.
1275 
1276  // Check if we have the dedicated lat/lon grid.
1277  void check_onelatlon_grids();
1278 
1279  // For one grid, need to handle the third-dimension(both existing and missing) coordinate variables
1280  void handle_one_grid_zdim(GridDataset*);
1281 
1282  // For one grid, need to handle lat/lon(both existing lat/lon and calculated lat/lon from EOS2 APIs)
1283  void handle_one_grid_latlon(GridDataset*) throw(Exception);
1284 
1285  // For the case of which all grids have one dedicated lat/lon grid,
1286  // this function shows how to handle lat/lon fields.
1287  void handle_onelatlon_grids() throw (Exception);
1288 
1289  // Handle the dimension name to coordinate variable map for grid.
1290  void handle_grid_dim_cvar_maps() throw(Exception);
1291 
1292  // Follow COARDS for grids.
1293  void handle_grid_coards() throw(Exception);
1294 
1295  // Create the corrected dimension vector for each field when COARDS is not followed.
1296  void update_grid_field_corrected_dims() throw(Exception);
1297 
1298  // Handle CF attributes for grids.
1299  // The CF attributes include "coordinates", "units" for coordinate variables and "_FillValue".
1300  void handle_grid_cf_attrs() throw(Exception);
1301 
1302  // Special handling SOM(Space Oblique Mercator) projection files
1303  void handle_grid_SOM_projection() throw(Exception);
1304 
1305  // Obtain the number of dimension maps in this file. The input parameter is the number of swath.
1306  int obtain_dimmap_num(int numswath) throw(Exception);
1307 
1308  // Create the dimension name to coordinate variable name map for lat/lon.
1309  // The input parameter is the number of dimension maps in this file.
1310  void create_swath_latlon_dim_cvar_map(int numdm) throw(Exception);
1311 
1312  // Create the dimension name to coordinate variable name map for non lat/lon coordinate variables.
1313  void create_swath_nonll_dim_cvar_map() throw(Exception);
1314 
1315  // Handle swath dimension name to coordinate variable name maps.
1316  // The input parameter is the number of dimension maps in this file.
1317  void handle_swath_dim_cvar_maps(int numdm) throw(Exception);
1318 
1319  // Handle CF attributes for swaths.
1320  // The CF attributes include "coordinates", "units" for coordinate variables and "_FillValue".
1321  void handle_swath_cf_attrs() throw(Exception);
1322 
1323  private:
1324 
1325  // HDF-EOS2 Grid File ID. Notice this ID is not an individual grid ID but the grid file ID returned by
1326  // calling the HDF-EOS2 API GDopen.
1327  int32 gridfd;
1328 
1329  // HDF-EOS2 Swath File ID. Notice this ID is not an individual swath ID but the swath file ID returned by
1330  // calling the HDF-EOS2 API SWopen.
1331  int32 swathfd;
1332 
1345 
1347  };
1348 
1349 
1350  struct Utility
1351  {
1352 
1354  static bool ReadNamelist (const char *path,
1355  int32 (*inq) (char *, char *, int32 *),
1356  std::vector < std::string > &names);
1357 
1358 
1359  };
1360 
1361 }
1362 #endif
1363 
1364 #endif
SOType
void getGrids(BaseType *bt, vector< Grid * > *grids)
Recursively traverses the BaseType bt (if its a constructor type) and collects pointers to all of the...
Definition: grid_utils.cc:54
STL namespace.