Commit 03d3a76d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

replaced farcmul(array, 1./nsets) by farcdiv(array, (double)nsets) to get...

replaced farcmul(array, 1./nsets) by farcdiv(array, (double)nsets) to get exactly the same result with and without missvals
parent 3620773c
......@@ -3,6 +3,10 @@
* using CDI library version 1.7.0
* Version 1.7.0 released
2015-08-08 Uwe Schulzweida
* replaced farcmul(array, 1./nsets) by farcdiv(array, (double)nsets) to get exactly the same result with and without missvals
2015-08-05 Uwe Schulzweida
* ap2pl: changed to generalized height
......
......@@ -208,7 +208,7 @@ void *Runstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( runstat_nomiss )
farcmul(&vars1[0][varID][levelID], 1.0/ndates);
farcdiv(&vars1[0][varID][levelID], (double)ndates);
else
fardiv(&vars1[0][varID][levelID], samp1[0][varID][levelID]);
}
......
......@@ -235,7 +235,7 @@ void *Seasstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/nsets);
farcdiv(&vars1[varID][levelID], (double)nsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
......
......@@ -228,7 +228,7 @@ void *Timselstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/nsets);
farcdiv(&vars1[varID][levelID], (double)nsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
......
......@@ -340,10 +340,13 @@ void *Timstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/nsets);
farcdiv(&vars1[varID][levelID], (double)nsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
{
// farround(&samp1[varID][levelID]); not necessary
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
}
}
else if ( lvarstd )
for ( varID = 0; varID < nvars; varID++ )
......
......@@ -417,7 +417,7 @@ void *Vertstat(void *argument)
if ( lmean )
{
if ( samp1[varID].ptr == NULL )
farcmul(&vars1[varID], 1.0/vars1[varID].nsamp);
farcdiv(&vars1[varID], (double)vars1[varID].nsamp);
else
fardiv(&vars1[varID], samp1[varID]);
}
......
......@@ -240,7 +240,7 @@ void *Ydaystat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[dayoy][varID][levelID].ptr == NULL )
farcmul(&vars1[dayoy][varID][levelID], 1.0/nsets[dayoy]);
farcdiv(&vars1[dayoy][varID][levelID], (double)nsets[dayoy]);
else
fardiv(&vars1[dayoy][varID][levelID], samp1[dayoy][varID][levelID]);
}
......
......@@ -445,7 +445,7 @@ void ydstatFinalize(YDAY_STATS *stats, int operfunc)
if ( vlistInqVarTsteptype(stats->vlist, varID) == TSTEP_CONSTANT ) continue;
nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
for ( levelID = 0; levelID < nlevels; levelID++ )
farcmul(&stats->vars1[dayoy][varID][levelID], 1.0 / stats->nsets[dayoy]);
farcdiv(&stats->vars1[dayoy][varID][levelID], (double) stats->nsets[dayoy]);
}
break;
......
......@@ -195,7 +195,7 @@ void *Yearmonstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/dsets);
farcdiv(&vars1[varID][levelID], dsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
......
......@@ -250,7 +250,7 @@ void *Yhourstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[houroy][varID][levelID].ptr == NULL )
farcmul(&vars1[houroy][varID][levelID], 1.0/nsets[houroy]);
farcdiv(&vars1[houroy][varID][levelID], (double)nsets[houroy]);
else
fardiv(&vars1[houroy][varID][levelID], samp1[houroy][varID][levelID]);
}
......
......@@ -274,7 +274,7 @@ void *Ymonstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[month][varID][levelID].ptr == NULL )
farcmul(&vars1[month][varID][levelID], 1.0/nsets[month]);
farcdiv(&vars1[month][varID][levelID], (double)nsets[month]);
else
fardiv(&vars1[month][varID][levelID], samp1[month][varID][levelID]);
}
......
......@@ -236,7 +236,7 @@ void *Yseasstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[seas][varID][levelID].ptr == NULL )
farcmul(&vars1[seas][varID][levelID], 1.0/nsets[seas]);
farcdiv(&vars1[seas][varID][levelID], (double)nsets[seas]);
else
fardiv(&vars1[seas][varID][levelID], samp1[seas][varID][levelID]);
}
......
......@@ -138,6 +138,7 @@ void farcsub(field_t *field, const double rconst);
void farmod(field_t *field, const double divisor);
void farinv(field_t *field);
void farround(field_t *field);
/* field2.c */
......
......@@ -137,6 +137,24 @@ void farinv(field_t *field)
}
void farround(field_t *field)
{
int grid = field->grid;
double missval1 = field->missval;
double missval2 = field->missval;
double *array = field->ptr;
int len = gridInqSize(grid);
for ( int i = 0; i < len; i++ )
array[i] = round(array[i]);
field->nmiss = 0;
for ( int i = 0; i < len; i++ )
if ( DBL_IS_EQUAL(array[i], missval1) ) field->nmiss++;
}
void farmod(field_t *field, double divisor)
{
int i, len;
......
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