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

Removed weights from class Field.

parent ebd0e54c
......@@ -125,7 +125,7 @@ cdoReadTimestep(void *rarg)
else
cdoReadRecord(streamID, input_vars[varID][levelID].vec.data(), &nmiss);
input_vars[varID][levelID].nmiss2 = nmiss;
input_vars[varID][levelID].nmiss = nmiss;
}
// timer_stop(timer_read);
......
......@@ -28,36 +28,18 @@ vfldrange(const Field &field)
return field.nmiss ? arrayRangeMV(field.gridsize, field.vec.data(), field.missval) : arrayRange(field.gridsize, field.vec.data());
}
double
fldmin(const Field &field)
{
return field.nmiss ? arrayMinMV(field.gridsize, field.ptr, field.missval) : arrayMin(field.gridsize, field.ptr);
}
double
vfldmin(const Field &field)
{
return field.nmiss ? arrayMinMV(field.gridsize, field.vec.data(), field.missval) : arrayMin(field.gridsize, field.vec.data());
}
double
fldmax(const Field &field)
{
return field.nmiss ? arrayMaxMV(field.gridsize, field.ptr, field.missval) : arrayMax(field.gridsize, field.ptr);
}
double
vfldmax(const Field &field)
{
return field.nmiss ? arrayMaxMV(field.gridsize, field.vec.data(), field.missval) : arrayMax(field.gridsize, field.vec.data());
}
double
fldsum(const Field &field)
{
return field.nmiss ? arraySumMV(field.gridsize, field.ptr, field.missval) : arraySum(field.gridsize, field.ptr);
}
double
vfldsum(const Field &field)
{
......@@ -70,13 +52,6 @@ vfldmean(const Field &field)
return field.nmiss ? arrayMeanMV(field.gridsize, field.vec.data(), field.missval) : arrayMean(field.gridsize, field.vec.data());
}
double
fldmeanw(const Field &field)
{
return field.nmiss ? arrayWeightedMeanMV(field.gridsize, field.ptr, field.weight, field.missval)
: arrayWeightedMean(field.gridsize, field.ptr, field.weight, field.missval);
}
double
vfldmeanw(const Field &field)
{
......@@ -90,13 +65,6 @@ vfldavg(const Field &field)
return field.nmiss ? arrayMeanMV(field.gridsize, field.vec.data(), field.missval) : arrayMean(field.gridsize, field.vec.data());
}
double
fldavgw(const Field &field)
{
return field.nmiss ? arrayWeightedAvgMV(field.gridsize, field.ptr, field.weight, field.missval)
: arrayWeightedMean(field.gridsize, field.ptr, field.weight, field.missval);
}
double
vfldavgw(const Field &field)
{
......@@ -361,22 +329,6 @@ prevarsumw(const double *restrict array, const double *restrict w, size_t len, s
rsumwq = xsumwq;
}
double
fldvarw(const Field &field)
{
const size_t nmiss = field.nmiss > 0;
const size_t len = field.gridsize;
const double missval = field.missval;
double rsum, rsumw, rsumq, rsumwq;
prevarsumw(field.ptr, field.weight, len, nmiss, missval, rsum, rsumw, rsumq, rsumwq);
double rvar = IS_NOT_EQUAL(rsumw, 0) ? (rsumq * rsumw - rsum * rsum) / (rsumw * rsumw) : missval;
if (rvar < 0 && rvar > -1.e-5) rvar = 0;
return rvar;
}
double
vfldvarw(const Field &field)
{
......@@ -393,22 +345,6 @@ vfldvarw(const Field &field)
return rvar;
}
double
fldvar1w(const Field &field)
{
const size_t nmiss = field.nmiss > 0;
const size_t len = field.gridsize;
const double missval = field.missval;
double rsum, rsumw, rsumq, rsumwq;
prevarsumw(field.ptr, field.weight, len, nmiss, missval, rsum, rsumw, rsumq, rsumwq);
double rvar = (rsumw * rsumw > rsumwq) ? (rsumq * rsumw - rsum * rsum) / (rsumw * rsumw - rsumwq) : missval;
if (rvar < 0 && rvar > -1.e-5) rvar = 0;
return rvar;
}
double
vfldvar1w(const Field &field)
{
......@@ -442,12 +378,6 @@ varToStd(double rvar, double missval)
return rstd;
}
double
fldstd(const Field &field)
{
return varToStd(fldvar(field), field.missval);
}
double
vfldstd(const Field &field)
{
......@@ -466,24 +396,12 @@ vfldstd1(const Field &field)
return varToStd(vfldvar1(field), field.missval);
}
double
fldstdw(const Field &field)
{
return varToStd(fldvarw(field), field.missval);
}
double
vfldstdw(const Field &field)
{
return varToStd(vfldvarw(field), field.missval);
}
double
fldstd1w(const Field &field)
{
return varToStd(fldvar1w(field), field.missval);
}
double
vfldstd1w(const Field &field)
{
......
......@@ -42,16 +42,14 @@ class Field
size_t gridsize;
size_t nsamp;
size_t nmiss;
size_t nmiss2;
double missval;
double *weight;
double *ptr;
std::vector<double> vec;
std::vector<float> vecf;
std::vector<double> weightv;
Field() : fpeRaised(0), nwpv(-1), memtype(-1), grid(-1), gridsize(0), nsamp(0),
nmiss(0), nmiss2(), missval(0), weight(0), ptr(nullptr)
nmiss(0), missval(0), ptr(nullptr)
{
size = 0;
}
......@@ -105,20 +103,6 @@ void fieldsFromVlist(int vlistID, FieldVector2D &field2D, int ptype);
void fieldsFromVlist(int vlistID, FieldVector2D &field2D, int ptype, double fillValue);
// field.cc
double fldmin(const Field &field);
double fldmax(const Field &field);
double fldsum(const Field &field);
double fldmeanw(const Field &field);
double fldavgw(const Field &field);
double fldstd(const Field &field);
double fldstd1(const Field &field);
double fldvar(const Field &field);
double fldvar1(const Field &field);
double fldstdw(const Field &field);
double fldstd1w(const Field &field);
double fldvarw(const Field &field);
double fldvar1w(const Field &field);
double vfldfun(const Field &field, int function);
double vfldmin(const Field &field);
double vfldmax(const Field &field);
......
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