1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <string>
#include <vector>
#include <map>
// the following include is only needed for buggy versions of SWIG
// (2.0.7 and earlier) with newer STL which no longer include cstddef
#include <cstddef>
#include "cdi.h"
class CdiGrid
{
public:
CdiGrid();
CdiGrid(int gridid);
~CdiGrid();
int gridID;
int type, size, xsize, ysize, prec, ncorner;
bool hasXValues, hasYValues, hasBounds;
std::vector<double> xvalues, yvalues, xbounds, ybounds;
// [xy]stdname cannot be set arbitrarily
std::string xname, xlongname, xstdname, xunits;
std::string yname, ylongname, ystdname, yunits;
std::string name;
void getValues();
void getBounds();
void getValuesAsPointer(double *xvals, double *yvals);
void getBoundsAsPointer(double *xbnds, double *ybnds);
void getFloatVals(float *xvals, float *yvals);
void getFloatBounds(float *xbnds, float *ybnds);
private:
void determineGrid(int gridID);
};
class CdiTaxis
{
public:
CdiTaxis();
CdiTaxis(int vlistID);
~CdiTaxis();
int taxisID;
int ntsteps, unit;
int rdate, rtime, vdate, vtime;
int type, calendar, hasBounds;
char name[CDI_MAX_NAME];
const char *unitname;
};
class CdiZaxis
{
public:
CdiZaxis();
CdiZaxis(int zaxisid);
~CdiZaxis();
int zaxisID;
int type, ltype, size, prec;
double *plevels, *plbounds, *pubounds, *pweights;
std::vector<double> levels, lbounds, ubounds, weights;
std::string name, longname, units;
};
class CdiVariable
{
public:
CdiVariable();
CdiVariable(int streamid, int vlistid, int varid);
~CdiVariable();
int varID, zaxisID, gridID, taxisID, timeID, vlistID;
int size, code, datatype;
int streamID;
std::string name, longname, units, stdname;
double missval;
std::vector<double> values;
std::vector<std::vector<double>> valuesWithLevel;
CdiGrid grid;
CdiZaxis zaxis;
CdiTaxis taxis;
void sinfo();
void getValues();
void getValuesWithLevel(int tsID = 0);
std::vector<float> getFValues();
std::vector<std::vector<float>> getFValuesWithLevel(int tsID = 0);
double *getValuesAsPointer();
double **getValuesWithLevelAsPointer(int tsID = 0);
};
class Cdi
{
public:
Cdi(const char *path);
~Cdi();
int streamID;
int vlistID, nvars, nzaxes, ngrids, ntaxes, taxisID;
std::vector<std::string> varnames;
std::vector<int> codes;
std::vector<CdiVariable> variables;
std::map<std::string, CdiVariable> var;
std::map<int, CdiVariable> varByCode;
std::map<int, CdiTaxis> taxes;
std::map<int, CdiZaxis> zaxes;
std::map<int, CdiGrid> grids;
void griddes();
private:
void getTaxes();
void getZaxes();
void getGrids();
void getVars();
};
|