Commit 3f74e335 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added support for netcdf attribute valid_min/valid_max

parent 8fe9ec4a
2011-11-01 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added support for netcdf attribute valid_min/valid_max [request: Etienne Tourigny]
2011-10-27 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* cdilib.c::defineAttributes: bug fix atttxt [report: Florian Prill]
......
......@@ -3525,7 +3525,7 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
if ( xtype == NC_BYTE )
{
for ( i = 0; i < gridsize; i++ )
if ( data[i] < 0 ) data[i] += 255;
if ( data[i] < 0 ) data[i] += 256;
}
}
......@@ -3538,7 +3538,10 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
// printf("readvarslice: validrange %d %g %g\n", lvalidrange, validrange[0], validrange[1]);
if ( lvalidrange )
for ( i = 0; i < gridsize; i++ )
if ( data[i] < validrange[0] || data[i] > validrange[1] ) data[i] = missval;
{
if ( IS_NOT_EQUAL(validrange[0], VALIDMISS) && data[i] < validrange[0] ) data[i] = missval;
if ( IS_NOT_EQUAL(validrange[1], VALIDMISS) && data[i] > validrange[1] ) data[i] = missval;
}
// printf("XXX %31.0f %31.0f %31.0f %31.0f\n", missval, (float)data[0]);
for ( i = 0; i < gridsize; i++ )
......@@ -4048,6 +4051,8 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
ncvars[ncvarid].deflate = 0;
ncvars[ncvarid].lunsigned = 0;
ncvars[ncvarid].lvalidrange = 0;
ncvars[ncvarid].validrange[0] = VALIDMISS;
ncvars[ncvarid].validrange[1] = VALIDMISS;
}
}
......@@ -4674,7 +4679,6 @@ void scanVarAttributes(int fileID, int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
/* cdfSetVar(ncvars, ncvarid, TRUE); */
}
}
/*
else if ( strcmp(attname, "valid_min") == 0 && attlen == 1 )
{
cdfGetAttDouble(fileID, ncvarid, attname, 1, &(ncvars[ncvarid].validrange)[0]);
......@@ -4685,7 +4689,6 @@ void scanVarAttributes(int fileID, int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
cdfGetAttDouble(fileID, ncvarid, attname, 1, &(ncvars[ncvarid].validrange)[1]);
ncvars[ncvarid].lvalidrange = TRUE;
}
*/
else if ( strcmp(attname, "_Unsigned") == 0 && atttype == NC_CHAR )
{
cdfGetAttText(fileID, ncvarid, attname, attstringlen-1, attstring);
......
......@@ -7,6 +7,7 @@
# include "cdi_limits.h"
#endif
#define VALIDMISS 1.e+303
/*
* CDI attribute
......
......@@ -17,36 +17,38 @@ void vlistvarInitEntry(int vlistID, int varID)
vlistptr = vlist_to_pointer(vlistID);
vlistptr->vars[varID].fvarID = varID;
vlistptr->vars[varID].mvarID = varID;
vlistptr->vars[varID].flag = 0;
vlistptr->vars[varID].param = 0;
vlistptr->vars[varID].timeID = CDI_UNDEFID;
vlistptr->vars[varID].datatype = CDI_UNDEFID;
vlistptr->vars[varID].tsteptype = TSTEP_INSTANT;
vlistptr->vars[varID].timave = 0;
vlistptr->vars[varID].timaccu = 0;
vlistptr->vars[varID].xyz = 0;
vlistptr->vars[varID].gridID = CDI_UNDEFID;
vlistptr->vars[varID].zaxisID = CDI_UNDEFID;
vlistptr->vars[varID].instID = CDI_UNDEFID;
vlistptr->vars[varID].modelID = CDI_UNDEFID;
vlistptr->vars[varID].tableID = CDI_UNDEFID;
vlistptr->vars[varID].missvalused = FALSE;
vlistptr->vars[varID].missval = cdiDefaultMissval;
vlistptr->vars[varID].addoffset = 0.0;
vlistptr->vars[varID].scalefactor = 1.0;
vlistptr->vars[varID].name = NULL;
vlistptr->vars[varID].longname = NULL;
vlistptr->vars[varID].stdname = NULL;
vlistptr->vars[varID].units = NULL;
vlistptr->vars[varID].nlevs = 0;
vlistptr->vars[varID].levinfo = NULL;
vlistptr->vars[varID].comptype = COMPRESS_NONE;
vlistptr->vars[varID].complevel = 1;
vlistptr->vars[varID].atts.nalloc = MAX_ATTRIBUTES;
vlistptr->vars[varID].atts.nelems = 0;
vlistptr->vars[varID].lvalidrange = 0;
vlistptr->vars[varID].fvarID = varID;
vlistptr->vars[varID].mvarID = varID;
vlistptr->vars[varID].flag = 0;
vlistptr->vars[varID].param = 0;
vlistptr->vars[varID].timeID = CDI_UNDEFID;
vlistptr->vars[varID].datatype = CDI_UNDEFID;
vlistptr->vars[varID].tsteptype = TSTEP_INSTANT;
vlistptr->vars[varID].timave = 0;
vlistptr->vars[varID].timaccu = 0;
vlistptr->vars[varID].xyz = 0;
vlistptr->vars[varID].gridID = CDI_UNDEFID;
vlistptr->vars[varID].zaxisID = CDI_UNDEFID;
vlistptr->vars[varID].instID = CDI_UNDEFID;
vlistptr->vars[varID].modelID = CDI_UNDEFID;
vlistptr->vars[varID].tableID = CDI_UNDEFID;
vlistptr->vars[varID].missvalused = FALSE;
vlistptr->vars[varID].missval = cdiDefaultMissval;
vlistptr->vars[varID].addoffset = 0.0;
vlistptr->vars[varID].scalefactor = 1.0;
vlistptr->vars[varID].name = NULL;
vlistptr->vars[varID].longname = NULL;
vlistptr->vars[varID].stdname = NULL;
vlistptr->vars[varID].units = NULL;
vlistptr->vars[varID].nlevs = 0;
vlistptr->vars[varID].levinfo = NULL;
vlistptr->vars[varID].comptype = COMPRESS_NONE;
vlistptr->vars[varID].complevel = 1;
vlistptr->vars[varID].atts.nalloc = MAX_ATTRIBUTES;
vlistptr->vars[varID].atts.nelems = 0;
vlistptr->vars[varID].lvalidrange = 0;
vlistptr->vars[varID].validrange[0] = VALIDMISS;
vlistptr->vars[varID].validrange[1] = VALIDMISS;
}
static
......
Markdown is supported
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