Commit a91815e7 authored by Ralf Mueller's avatar Ralf Mueller
Browse files

Enhance CdiGrid attributes

parent 09e69dd2
......@@ -9,6 +9,7 @@ int main() {
Cdi info("./testdata/mulval.nc");
std::cout << "#===============================" << std::endl;
for (int i = 0; i < info.nvars; i++)
std::cout << info.codes[i] << ' ';
std::cout << std::endl;
......@@ -30,11 +31,15 @@ int main() {
std::cout << "Gridname:%s" << std::endl;
std::cout << var.grid.name << std::endl;
std::cout << "GridBounds: NumberOfCorners = " << var.grid.ncorner << std::endl;
// std::cout << "xbounds " << var.grid.xbounds[0] << ' ' << var.grid.xbounds[1000] << ' ';
// std::cout << "ybounds " << var.grid.ybounds[0] << ' ' << var.grid.ybounds[1000] << std::endl;
// var.grid.readFloatBounds();
// std::cout << "xboundsF " << var.grid.xboundsF[0] << ' ' << var.grid.xboundsF[1000] << ' ';
// std::cout << "yboundsF " << var.grid.yboundsF[0] << ' ' << var.grid.yboundsF[1000] << std::endl;
std::cout << "xvals " << var.grid.xvals[0] << std::endl;
std::cout << "yvals " << var.grid.yvals[0] << std::endl;
std::cout << "xvalues " << var.grid.xvalues[0] << std::endl;
/* std::cout << "yvalues " << var.grid.yvalues.back() << std::endl;
*/
/* var.grid.readFloatBounds();
* std::cout << "xboundsF " << var.grid.xboundsF[0] << ' ' << var.grid.xboundsF[1000] << ' ';
* std::cout << "yboundsF " << var.grid.yboundsF[0] << ' ' << var.grid.yboundsF[1000] << std::endl;
*/
std::cout << "#===============================" << std::endl;
printf("Stream:%d\n" , var.streamID);
printf("Taxis (unit):%d\n" , var.taxis.unit);
......
......@@ -112,6 +112,6 @@ help:
#
AM_CPPFLAGS = -I$(top_srcdir)/src
#
all-local: $(BINDINGS)
#all-local: $(BINDINGS)
#
CLEANFILES = `ls *~`
......@@ -276,6 +276,8 @@ CdiInfo_LDFLAGS = @NETCDF_LDFLAGS@ @HDF5_LDFLAGS@ @SZLIB_LDFLAGS@ @ZLIB_LDFLAGS@
#
AM_CPPFLAGS = -I$(top_srcdir)/src
#
#all-local: $(BINDINGS)
#
CLEANFILES = `ls *~`
all: all-am
......@@ -498,7 +500,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) all-local
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
......@@ -602,20 +604,20 @@ uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am all-local check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool \
clean-noinstLTLIBRARIES clean-noinstPROGRAMS ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-binPROGRAMS install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-binPROGRAMS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic clean-libtool clean-noinstLTLIBRARIES \
clean-noinstPROGRAMS ctags distclean distclean-compile \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-binPROGRAMS
# Ruby ====================================================
@WITH_RUBY_TRUE@rubyLibMakefile:
......@@ -682,8 +684,6 @@ help:
@echo " <lang>LibTest - run function library test (./<lang>/testLib.rb). Accepts input file argument."
@echo " <lang>ObjInstall - install shared libraries and optional language files for <lang>"
@echo " <lang>LibInstall - see <lang>ObjInstall"
#
all-local: $(BINDINGS)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
......
......@@ -22,14 +22,23 @@ CdiGrid::CdiGrid(int gridid) {
gridID = gridid;
type = gridInqType(gridID);
strcpy(_name,gridNamePtr(type));
size = gridInqSize(gridID);
xsize = gridInqXsize(gridID);
ysize = gridInqXsize(gridID);
xvals = (double *) malloc(xsize*sizeof(double));
yvals = (double *) malloc(ysize*sizeof(double));
prec = gridInqPrec(gridID);
gridInqXvals(gridID , xvals);
gridInqYvals(gridID , yvals);
gridInqXvals(gridID, xvals);
gridInqYvals(gridID, yvals);
xvalues.resize(xsize);
yvalues.resize(ysize);
std::copy(xvals, xvals + xsize, xvalues.begin());
std::copy(yvals, yvals + ysize, yvalues.begin());
std::cout << xvalues.back() << std::endl;
std::cout << yvalues.back() << std::endl;
gridInqXname(gridID , _xname);
gridInqXlongname(gridID, _xlongname);
gridInqXstdname(gridID , _xstdname);
......@@ -52,10 +61,14 @@ CdiGrid::CdiGrid(int gridid) {
{
ncorner = ( gridInqType(gridID) == GRID_CELL ) ? gridInqNvertex(gridID) : 4;
ncorner *= size;
xbounds = (double *) malloc((ncorner*size)*sizeof(double));
ybounds = (double *) malloc((ncorner*size)*sizeof(double));
gridInqYbounds(gridID, xbounds);
gridInqXbounds(gridID, ybounds);
xbnds = (double *) malloc((ncorner*size)*sizeof(double));
ybnds = (double *) malloc((ncorner*size)*sizeof(double));
gridInqYbounds(gridID, xbnds);
gridInqXbounds(gridID, ybnds);
xbounds.resize(ncorner*size);
ybounds.resize(ncorner*size);
std::copy(xbnds, xbnds + ncorner*size, xbounds.begin());
std::copy(ybnds, ybnds + ncorner*size, ybounds.begin());
}
else
ncorner = 0;
......@@ -67,10 +80,10 @@ CdiGrid::readFloatBounds()
{
if (hasBounds)
{
xboundsF = (float *) malloc(ncorner*size*sizeof(float));
yboundsF = (float *) malloc(ncorner*size*sizeof(float));
xboundsF = (float *) xbounds;
yboundsF = (float *) ybounds;
xbndsF = (float *) malloc(ncorner*size*sizeof(float));
ybndsF = (float *) malloc(ncorner*size*sizeof(float));
xbndsF = (float *) xbnds;
ybndsF = (float *) ybnds;
}
else
std::cout << "No bounds available." << std::endl;
......@@ -113,27 +126,31 @@ CdiTaxis::~CdiTaxis() { if (taxisID >= 0) taxisID = -1; }
*/
CdiZaxis::CdiZaxis() { zaxisID = -1; }
CdiZaxis::CdiZaxis(int zaxisid) {
char _name[CHARSIZE], _longname[CHARSIZE], _units[CHARSIZE];
char name[CHARSIZE], longname[CHARSIZE], units[CHARSIZE];
zaxisID = zaxisid;
size = zaxisInqSize(zaxisID);
prec = zaxisInqPrec(zaxisID);
type = zaxisInqType(zaxisID);
ltype = zaxisInqLtype(zaxisID);
levels = (double *) malloc(size*sizeof(double));
lbounds = (double *) malloc(size*sizeof(double));
ubounds = (double *) malloc(size*sizeof(double));
weights = (double *) malloc(size*sizeof(double));
zaxisInqLevels(zaxisID , levels);
zaxisInqLbounds(zaxisID , lbounds);
zaxisInqUbounds(zaxisID , ubounds);
zaxisInqWeights(zaxisID , weights);
zaxisInqName(zaxisid , _name);
zaxisInqLongname(zaxisid, _longname);
zaxisInqUnits(zaxisid , _units);
name = _name;
longname = _longname;
units = _units;
plevels = (double *) malloc(size*sizeof(double));
plbounds = (double *) malloc(size*sizeof(double));
pubounds = (double *) malloc(size*sizeof(double));
pweights = (double *) malloc(size*sizeof(double));
zaxisInqLevels(zaxisID ,plevels);
zaxisInqLbounds(zaxisID ,plbounds);
zaxisInqUbounds(zaxisID ,pubounds);
zaxisInqWeights(zaxisID ,pweights);
levels.resize(size); lbounds.resize(size); ubounds.resize(size); weights.resize(size);
std::copy(plevels,plevels+size,levels.begin());
std::copy(plbounds,plbounds+size,lbounds.begin());
std::copy(pubounds,pubounds+size,ubounds.begin());
std::copy(pweights,pweights+size,weights.begin());
zaxisInqName(zaxisid ,name);
zaxisInqLongname(zaxisid,longname);
zaxisInqUnits(zaxisid ,units);
}
CdiZaxis::~CdiZaxis() { if (zaxisID >= 0) zaxisID = -1; }
/* } */
......
......@@ -13,10 +13,9 @@ class CdiGrid {
int gridID;
int type, size, xsize, ysize, prec, ncorner;
bool hasBounds;
double *xvals , *yvals;
float *xvalsF , *yvalsF;
double *xbounds , *ybounds;
float *xboundsF, *yboundsF;
double *xvals , *yvals , *xbnds , *ybnds;
float *xvalsF, *yvalsF, *xbndsF, *ybndsF;
std::vector<double> xvalues, yvalues, xbounds, ybounds;
std::string xname, xlongname, xstdname, xunits;
std::string yname, ylongname, ystdname, yunits;
......@@ -50,7 +49,8 @@ class CdiZaxis {
int zaxisID;
int type, ltype, size, prec;
double *levels, *lbounds, *ubounds, *weights;
double *plevels, *plbounds, *pubounds, *pweights;
vector<double> levels, lbounds, ubounds, weights;
std::string name, longname, units;
};
......
......@@ -571,18 +571,30 @@ class CdiGrid(_object):
__swig_setmethods__["yvalsF"] = _CdiObj.CdiGrid_yvalsF_set
__swig_getmethods__["yvalsF"] = _CdiObj.CdiGrid_yvalsF_get
if _newclass:yvalsF = _swig_property(_CdiObj.CdiGrid_yvalsF_get, _CdiObj.CdiGrid_yvalsF_set)
__swig_setmethods__["xbnds"] = _CdiObj.CdiGrid_xbnds_set
__swig_getmethods__["xbnds"] = _CdiObj.CdiGrid_xbnds_get
if _newclass:xbnds = _swig_property(_CdiObj.CdiGrid_xbnds_get, _CdiObj.CdiGrid_xbnds_set)
__swig_setmethods__["ybnds"] = _CdiObj.CdiGrid_ybnds_set
__swig_getmethods__["ybnds"] = _CdiObj.CdiGrid_ybnds_get
if _newclass:ybnds = _swig_property(_CdiObj.CdiGrid_ybnds_get, _CdiObj.CdiGrid_ybnds_set)
__swig_setmethods__["xbndsF"] = _CdiObj.CdiGrid_xbndsF_set
__swig_getmethods__["xbndsF"] = _CdiObj.CdiGrid_xbndsF_get
if _newclass:xbndsF = _swig_property(_CdiObj.CdiGrid_xbndsF_get, _CdiObj.CdiGrid_xbndsF_set)
__swig_setmethods__["ybndsF"] = _CdiObj.CdiGrid_ybndsF_set
__swig_getmethods__["ybndsF"] = _CdiObj.CdiGrid_ybndsF_get
if _newclass:ybndsF = _swig_property(_CdiObj.CdiGrid_ybndsF_get, _CdiObj.CdiGrid_ybndsF_set)
__swig_setmethods__["xvalues"] = _CdiObj.CdiGrid_xvalues_set
__swig_getmethods__["xvalues"] = _CdiObj.CdiGrid_xvalues_get
if _newclass:xvalues = _swig_property(_CdiObj.CdiGrid_xvalues_get, _CdiObj.CdiGrid_xvalues_set)
__swig_setmethods__["yvalues"] = _CdiObj.CdiGrid_yvalues_set
__swig_getmethods__["yvalues"] = _CdiObj.CdiGrid_yvalues_get
if _newclass:yvalues = _swig_property(_CdiObj.CdiGrid_yvalues_get, _CdiObj.CdiGrid_yvalues_set)
__swig_setmethods__["xbounds"] = _CdiObj.CdiGrid_xbounds_set
__swig_getmethods__["xbounds"] = _CdiObj.CdiGrid_xbounds_get
if _newclass:xbounds = _swig_property(_CdiObj.CdiGrid_xbounds_get, _CdiObj.CdiGrid_xbounds_set)
__swig_setmethods__["ybounds"] = _CdiObj.CdiGrid_ybounds_set
__swig_getmethods__["ybounds"] = _CdiObj.CdiGrid_ybounds_get
if _newclass:ybounds = _swig_property(_CdiObj.CdiGrid_ybounds_get, _CdiObj.CdiGrid_ybounds_set)
__swig_setmethods__["xboundsF"] = _CdiObj.CdiGrid_xboundsF_set
__swig_getmethods__["xboundsF"] = _CdiObj.CdiGrid_xboundsF_get
if _newclass:xboundsF = _swig_property(_CdiObj.CdiGrid_xboundsF_get, _CdiObj.CdiGrid_xboundsF_set)
__swig_setmethods__["yboundsF"] = _CdiObj.CdiGrid_yboundsF_set
__swig_getmethods__["yboundsF"] = _CdiObj.CdiGrid_yboundsF_get
if _newclass:yboundsF = _swig_property(_CdiObj.CdiGrid_yboundsF_get, _CdiObj.CdiGrid_yboundsF_set)
__swig_setmethods__["xname"] = _CdiObj.CdiGrid_xname_set
__swig_getmethods__["xname"] = _CdiObj.CdiGrid_xname_get
if _newclass:xname = _swig_property(_CdiObj.CdiGrid_xname_get, _CdiObj.CdiGrid_xname_set)
......@@ -693,6 +705,18 @@ class CdiZaxis(_object):
__swig_setmethods__["prec"] = _CdiObj.CdiZaxis_prec_set
__swig_getmethods__["prec"] = _CdiObj.CdiZaxis_prec_get
if _newclass:prec = _swig_property(_CdiObj.CdiZaxis_prec_get, _CdiObj.CdiZaxis_prec_set)
__swig_setmethods__["plevels"] = _CdiObj.CdiZaxis_plevels_set
__swig_getmethods__["plevels"] = _CdiObj.CdiZaxis_plevels_get
if _newclass:plevels = _swig_property(_CdiObj.CdiZaxis_plevels_get, _CdiObj.CdiZaxis_plevels_set)
__swig_setmethods__["plbounds"] = _CdiObj.CdiZaxis_plbounds_set
__swig_getmethods__["plbounds"] = _CdiObj.CdiZaxis_plbounds_get
if _newclass:plbounds = _swig_property(_CdiObj.CdiZaxis_plbounds_get, _CdiObj.CdiZaxis_plbounds_set)
__swig_setmethods__["pubounds"] = _CdiObj.CdiZaxis_pubounds_set
__swig_getmethods__["pubounds"] = _CdiObj.CdiZaxis_pubounds_get
if _newclass:pubounds = _swig_property(_CdiObj.CdiZaxis_pubounds_get, _CdiObj.CdiZaxis_pubounds_set)
__swig_setmethods__["pweights"] = _CdiObj.CdiZaxis_pweights_set
__swig_getmethods__["pweights"] = _CdiObj.CdiZaxis_pweights_get
if _newclass:pweights = _swig_property(_CdiObj.CdiZaxis_pweights_get, _CdiObj.CdiZaxis_pweights_set)
__swig_setmethods__["levels"] = _CdiObj.CdiZaxis_levels_set
__swig_getmethods__["levels"] = _CdiObj.CdiZaxis_levels_get
if _newclass:levels = _swig_property(_CdiObj.CdiZaxis_levels_get, _CdiObj.CdiZaxis_levels_set)
......
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment