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

Field: added member function numMissUpdate().

parent aa5d8a2a
......@@ -302,10 +302,12 @@ Adisit(void *process)
for (levelID = 0; levelID < nlevel; ++levelID)
{
cdoDefRecord(streamID2, tisID2, levelID);
cdoWriteRecord(streamID2, tis[levelID].vec.data(), tis[levelID].numMiss());
tis[levelID].numMissUpdate();
cdoWriteRecord(streamID2, tis[levelID].vec.data(), tis[levelID].nmiss);
cdoDefRecord(streamID2, saoID2, levelID);
cdoWriteRecord(streamID2, sao[levelID].vec.data(), sao[levelID].numMiss());
sao[levelID].numMissUpdate();
cdoWriteRecord(streamID2, sao[levelID].vec.data(), sao[levelID].nmiss);
}
tsID++;
......
......@@ -1126,12 +1126,12 @@ eca4(const ECA_REQUEST_4 *request)
}
}
// update nmiss for saving data in GRIB
vfldunm(startCount[levelID]);
vfldunm(endCount[levelID]);
vfldunm(startDateWithHist[1][levelID]);
vfldunm(startDateWithHist[0][levelID]);
vfldunm(endDateWithHist[1][levelID]);
vfldunm(endDateWithHist[0][levelID]);
startCount[levelID].numMissUpdate();
endCount[levelID].numMissUpdate();
startDateWithHist[1][levelID].numMissUpdate();
startDateWithHist[0][levelID].numMissUpdate();
endDateWithHist[1][levelID].numMissUpdate();
endDateWithHist[0][levelID].numMissUpdate();
}
ovdate = ivdate;
......
......@@ -18,6 +18,7 @@
#ifndef FIELD_H
#define FIELD_H
#include <cstdio>
#include <vector>
#include "compare.h"
#include "array.h"
......@@ -55,12 +56,14 @@ class Field
{
size = _size;
vec.resize(size);
if (!gridsize) gridsize = size;
}
void resize(size_t _size, double _value)
{
size = _size;
vec.resize(size, _value);
if (!gridsize) gridsize = size;
}
bool empty()
......@@ -68,22 +71,30 @@ class Field
return size == 0;
}
size_t numMiss()
void check_gridsize()
{
if (gridsize == 0) fprintf(stderr, "Internal problem, gridsize of field not set!");
if (gridsize > size) fprintf(stderr, "Internal problem, gridsize of field is greater than allocated size of field!");
}
void numMissUpdate()
{
check_gridsize();
size_t nummiss = 0;
if (DBL_IS_NAN(missval))
{
for (size_t i = 0; i < size; ++i)
for (size_t i = 0; i < gridsize; ++i)
if (DBL_IS_EQUAL(vec[i], missval)) nummiss++;
}
else
{
for (size_t i = 0; i < size; ++i)
for (size_t i = 0; i < gridsize; ++i)
if (IS_EQUAL(vec[i], missval)) nummiss++;
}
return nummiss;
nmiss = nummiss;
}
private:
......
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