Esempio n. 1
0
/* -------------------------------------------------------------------- */
void DiffPreFilter(DATASET_INFO *set, float out[])
{
  size_t i;

  for (i = set->nPoints-1; i > 0; --i)
    if (isMissingValue(out[i], set->missingValue) || isMissingValue(out[i-1], set->missingValue))
      out[i] = set->missingValue;
    else
      out[i] = out[i] - out[i-1];

  out[0] = 0.0;

}	/* END DIFFPREFILTER */
Esempio n. 2
0
void Utils::replaceMissingWithMAX_VALUE(double_array &array_Renamed) {

    for (int i = 0; i < array_Renamed.size(); i++) {
        if (isMissingValue(array_Renamed[i])) {
            array_Renamed[i] = std::numeric_limits<double>::max();
        }
    }
}
Esempio n. 3
0
/* -------------------------------------------------------------------- */
void DetrendMean(DATASET_INFO *set, float out[])
{
  size_t	i;
  float		datum;

  for (i = 0; i < set->nPoints; ++i)
    {
    datum = out[i];

    if (isMissingValue(datum, set->missingValue))
      out[i] = out[i-1];
    else
      out[i] = datum - set->stats.mean;
    }

}	/* END DETRENDMEAN */
Esempio n. 4
0
/* -------------------------------------------------------------------- */
void DetrendLinear(DATASET_INFO *set, float out[])
{
  size_t i;
  float datum, *out1;

  out1 = new float[set->nPoints];

  LinearLeastSquare(set, out, out1);

  for (i = 0; i < set->nPoints; ++i)
    {
    datum = out[i];

    if (isMissingValue(datum, set->missingValue))
      out[i] = out[i-1];
    else
      out[i] = datum - out1[i];
    }

  delete [] out1;

}	/* END DETRENDLINEAR */
Esempio n. 5
0
template<> QString valueToString<QTime>(QTime value) {
    return isMissingValue(value) ? QString("NA") :value.toString("0:0:0");
}
Esempio n. 6
0
template<> QString valueToString<QDate>(QDate value) {
    return isMissingValue(value) ? QString("NA") :value.toString("d/M/yyyy");
}
Esempio n. 7
0
template<> QString valueToString<char>(char value) {
    return isMissingValue(value) ? QString("NA") :QString(value);
}
Esempio n. 8
0
/* -------------------------------------------------------------------- */
void ComputeStats(DATASET_INFO *set)
{
  size_t i, missCnt, len = 0;
  double y, sum, sigma;
 
  /* Read in variables units from file.
   */
  buffer[0] = '\0';

  if (set->varInfo->inVarID != COMPUTED)
    {
    nc_inq_attlen(dataFile[set->fileIndex].ncid, set->varInfo->inVarID,
						"units", (size_t *)&len);
    nc_get_att_text(dataFile[set->fileIndex].ncid, set->varInfo->inVarID,
						"units", buffer);
    buffer[len] = '\0';
    while (isspace(buffer[--len]) || buffer[len] == 0) // Strip trailing spaces.
      buffer[len] = '\0';

    if (strcmp(buffer, "C") == 0 ||
        strcmp(buffer, "deg_C") == 0)
      {
      buffer[0] = 0xb0;
      buffer[1] = 'C';
      buffer[2] = '\0';
      }
    }
  else
    strcpy(buffer, "Unknown");

  set->stats.units = buffer;

  missCnt = 0;
  sum = sigma = 0.0;
 
  set->stats.min = FLT_MAX;
  set->stats.max = -FLT_MAX;
 
  for (i = 0; i < set->nPoints; ++i)
    {
    if (isMissingValue((y = set->data[i]), set->missingValue) ||
        y < set->stats.outlierMin || y > set->stats.outlierMax)
      {
      ++missCnt;
      continue;
      }
 
    set->stats.min = std::min(set->stats.min, y);
    set->stats.max = std::max(set->stats.max, y);

    sum += y;
    }
 
  if (set->nPoints == missCnt)
    {
    set->stats.mean = 0.0;
    set->stats.min = 0.0;
    set->stats.max = 0.0;
    }
  else
    {
    set->stats.nPoints = set->nPoints - missCnt;
    set->stats.mean = sum / set->stats.nPoints;
    }

  for (i = 0; i < set->nPoints; ++i)
    if (!isMissingValue((y = set->data[i]), set->missingValue) ||
        y < set->stats.outlierMin || y > set->stats.outlierMax)
      sigma += pow(y - set->stats.mean, 2.0);
 
  set->stats.variance = sigma / (set->stats.nPoints - 1);
  set->stats.sigma = (float)sqrt(sigma / (set->stats.nPoints - 1));

}   /* END COMPUTESTATS */