Commit dd4ec788 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

histcount: doesn't recognize missing values (bug fix)

parent 6bc97dd1
......@@ -5,6 +5,7 @@
2014-11-11 Uwe Schulzweida
* histcount: doesn't recognize missing values (bug fix)
* filesdes: doesn't work for GRIB2 files [Bug #5307]
2014-10-31 Uwe Schulzweida
......
CDO NEWS
--------
Version 1.7.0 (19 February 2015):
Fixed bugs:
* histcount: doesn't recognize missing values
* filesdes: doesn't work for GRIB2 files [Bug #5307]
Version 1.6.5 (23 October 2014):
New operators:
......
......@@ -4,7 +4,7 @@
Name: cdo
#BuildRequires:
Version: 1.6.5
Version: 1.7.0
Release: 1
Summary: Climate Data Operators
License: GNU GENERAL PUBLIC LICENSE Version 2, June 1991
......
......@@ -15,7 +15,7 @@ start with "\&parameter" and to end with "/".
The following parameter table entries are supported:
@BeginTable
@bold{Entry} & @bold{Type} & @bold{Description}
@bold{Entry} & @bold{Type} & @bold{Description}
name & WORD & Name of the variable
out_name & WORD & New name of the variable
param & WORD & Parameter identifier (GRIB1: code[.tabnum]; GRIB2: num[.cat[.dis]])
......
......@@ -58,6 +58,8 @@ void *Histogram(void *argument)
HISTMEAN = cdoOperatorAdd("histmean", 0, 0, NULL);
HISTFREQ = cdoOperatorAdd("histfreq", 0, 0, NULL);
UNUSED(HISTSUM);
operatorID = cdoOperatorID();
operatorInputArg("bins");
......@@ -147,16 +149,16 @@ void *Histogram(void *argument)
{
if ( !DBL_IS_EQUAL(array[i], missval) )
{
*(vartcount[varID]+i) += 1;
vartcount[varID][i] += 1;
index = 0;
while( index < nbins )
{
offset = gridsize*index;
if ( !DBL_IS_EQUAL(*(vardata[varID]+offset+i), missval) &&
if ( !DBL_IS_EQUAL(vardata[varID][offset+i], missval) &&
array[i] >= fltarr[index] && array[i] < fltarr[index+1] )
{
*(vardata[varID]+offset+i) += array[i];
*(varcount[varID]+offset+i) += 1;
vardata[varID][offset+i] += array[i];
varcount[varID][offset+i] += 1;
break;
}
index++;
......@@ -177,36 +179,39 @@ void *Histogram(void *argument)
{
missval = vlistInqVarMissval(vlistID2, varID);
gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
nmiss = 0;
/* fix mising values */
for ( index = 0; index < nbins; index++ )
{
streamDefRecord(streamID2, varID, index);
offset = gridsize*index;
nmiss = 0;
offset = gridsize*index;
for ( i = 0; i < gridsize; i++ )
{
if ( *(vartcount[varID]+i) > 0 )
if ( vartcount[varID][i] > 0 )
{
if ( operatorID == HISTMEAN || operatorID == HISTFREQ )
{
if ( *(varcount[varID]+offset+i) > 0 )
if ( varcount[varID][offset+i] > 0 )
{
if ( operatorID == HISTMEAN )
*(vardata[varID]+offset+i) /= *(varcount[varID]+offset+i);
vardata[varID][offset+i] /= varcount[varID][offset+i];
else
*(vardata[varID]+offset+i) = *(varcount[varID]+offset+i) / *(vartcount[varID]+i);
vardata[varID][offset+i] = varcount[varID][offset+i] / vartcount[varID][i];
}
}
}
else
{
nmiss++;
*(vardata[varID]+offset+i) = missval;
varcount[varID][offset+i] = missval;
vardata[varID][offset+i] = missval;
}
}
streamDefRecord(streamID2, varID, index);
if ( operatorID == HISTCOUNT )
streamWriteRecord(streamID2, varcount[varID]+offset, nmiss);
else
......
......@@ -805,7 +805,7 @@ static char *SetpartabHelp[] = {
" ",
" The following parameter table entries are supported:",
" ",
" Entry & Type & Description ",
" Entry & Type & Description ",
" name & WORD & Name of the variable",
" out_name & WORD & New name of the variable",
" param & WORD & Parameter identifier (GRIB1: code[.tabnum]; GRIB2: num[.cat[.dis]])",
......
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