Main Page | Namespace List | Class Hierarchy | Class List | 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 #include <netcdf.h>
00010 
00011 struct ncdim {                  // dimension
00012     char name[NC_MAX_NAME];
00013     size_t size;
00014 };
00015 
00016 struct ncvar {                          // variable
00017     char name[NC_MAX_NAME];
00018     nc_type type;
00019     int ndims;
00020     int dims[MAX_VAR_DIMS];
00021     int natts;
00022     bool has_fillval;
00023     double fillval;
00024 };
00025 
00026 struct ncatt {                          // attribute
00027     int var;
00028     char name[NC_MAX_NAME];
00029     nc_type type;
00030     size_t len;
00031     char *string;                               // for text attributes (type = NC_CHAR)
00032     double *vals;                       // for numeric attributes of all types
00033 };
00034 
00035 class FilterNETCDF
00036 {
00037 public:
00038         FilterNETCDF(QString filename=0);
00039         bool fileOK() { return fileok; }
00040         QString version() { return QString(nc_inq_libvers());}
00041         int getNDims() { return ndims; }
00042         int getNVars() { return nvars; }
00043         int getNAtts() { return natts; }
00044         int getDimId() { return xdimid; }
00045         QString getDim(int dimid);                              // get dimension dimid
00046         QString getVar(int varid);                                      // get variable varid
00047         QString getAtt(int aid) { return pr_att(ncid, NC_GLOBAL, "", aid); } // get attribute aid
00048         int getVarLen(QString var);                             // get length of variable var
00049         QStringList getDataString(int varid);           // get variable data as string
00050         double getData(QString var,const size_t index);         // get data for variable var at index
00051 protected:
00052         QString typeName(nc_type type);
00053         QString pr_att_string(size_t len,const char *string);
00054         QString pr_att_vals(nc_type type,size_t len,const double *vals);
00055         QString pr_att(int ncid,int varid,const char *varname, int ia);
00056 private:
00057         QString filename;                                       // file
00058         bool fileok;                                            // is a netcdf file and readable
00059         int ncid, ndims, nvars, natts, xdimid;  // netcdf id / number of dimensions / vars / attributes / dim id
00060         ncdim dims[NC_MAX_DIMS];                        // nc dimensions
00061 };
00062 
00063 #endif //FILTERNETCDF_H

Generated on Sun Aug 29 14:56:04 2004 for LabPlot by doxygen 1.3.6