Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

FilterNETCDF.h

Go to the documentation of this file.
00001 //LabPlot : FilterNETCDF.h
00002 
00003 #ifndef FILTERNETCDF_H
00004 #define FILTERNETCDF_H
00005 
00006 #include <qstring.h>
00007 #include <qstringlist.h>
00008 
00009 #ifdef HAVE_NETCDF
00010 #include <netcdf.h>
00011 
00012 struct ncdim {                  // dimension
00013     char name[NC_MAX_NAME];
00014     size_t size;
00015 };
00016 
00017 struct ncvar {                          // variable
00018     char name[NC_MAX_NAME];
00019     nc_type type;
00020     int ndims;
00021     int dims[MAX_VAR_DIMS];
00022     int natts;
00023     bool has_fillval;
00024     double fillval;
00025 };
00026 
00027 struct ncatt {                          // attribute
00028     int var;
00029     char name[NC_MAX_NAME];
00030     nc_type type;
00031     size_t len;
00032     char *string;                               // for text attributes (type = NC_CHAR)
00033     double *vals;                       // for numeric attributes of all types
00034 };
00035 #endif
00036 
00037 class FilterNETCDF
00038 {
00039 public:
00040         FilterNETCDF(QString filename=0);
00041         bool fileOK() { return fileok; }
00042 #ifdef HAVE_NETCDF
00043         QString version() { return QString(nc_inq_libvers());}
00044         int NDims() { return ndims; }
00045         int NVars() { return nvars; }
00046         int NAtts() { return natts; }
00047         int DimId() { return xdimid; }
00048         QString Dim(int dimid);                         // get dimension dimid
00049         QString Var(int varid);                                 // get variable varid description
00050         QString VarName(int varid);                     // get variable varid name
00051         QString Att(int aid) { return pr_att(ncid, NC_GLOBAL, "", aid); } // get attribute aid
00052         int VarLen(QString var);                                // get length of variable var
00053         QStringList DataString(int varid);              // get variable data as string
00054         double Data(QString var,const size_t index);            // get data for variable var at index
00055 protected:
00056         QString typeName(nc_type type);
00057         QString pr_att_string(size_t len,const char *string);
00058         QString pr_att_vals(nc_type type,size_t len,const double *vals);
00059         QString pr_att(int ncid,int varid,const char *varname, int ia);
00060 #endif
00061 private:
00062         bool fileok;                                            // is a netcdf file and readable
00063         QString filename;                                       // file
00064 #ifdef HAVE_NETCDF
00065         int ncid, ndims, nvars, natts, xdimid;  // netcdf id / number of dimensions / vars / attributes / dim id
00066         ncdim dims[NC_MAX_DIMS];                        // nc dimensions
00067 #endif
00068 };
00069 
00070 #endif //FILTERNETCDF_H

Generated on Sat Oct 13 21:55:01 2007 for LabPlot by  doxygen 1.4.4