Commit ea545fba authored by Uwe Schulzweida's avatar Uwe Schulzweida

Renamed timrms to timrmsd.

parent cc5b137e
Pipeline #5055 passed with stages
in 16 minutes and 28 seconds
...@@ -131,39 +131,35 @@ covariance(size_t gridsize, double missval1, double missval2, size_t *nofvals, d ...@@ -131,39 +131,35 @@ covariance(size_t gridsize, double missval1, double missval2, size_t *nofvals, d
// rms in time // rms in time
static void static void
rms_init(size_t gridsize, const double *array1, const double *array2, double missval1, double missval2, size_t *nofvals, rmsd_init(size_t gridsize, const double *x, const double *y, double xmissval, double ymissval, size_t *nofvals,
double *work0) double *rmsd)
{ {
for (size_t i = 0; i < gridsize; ++i) for (size_t i = 0; i < gridsize; ++i)
{ {
if ((!DBL_IS_EQUAL(array1[i], missval1)) && (!DBL_IS_EQUAL(array2[i], missval2))) if ((!DBL_IS_EQUAL(x[i], xmissval)) && (!DBL_IS_EQUAL(y[i], ymissval)))
{ {
work0[i] += (array2[i] - array1[i]) * (array2[i] - array1[i]); rmsd[i] += ((x[i] - y[i]) * (x[i] - y[i]));
nofvals[i]++; nofvals[i]++;
} }
} }
} }
static size_t static size_t
rms(size_t gridsize, double missval, size_t *nofvals, double *work0) rmsd_compute(size_t gridsize, double missval, size_t *nofvals, double *rmsd)
{ {
size_t nmiss = 0; size_t nmiss = 0;
for (size_t i = 0; i < gridsize; ++i) for (size_t i = 0; i < gridsize; ++i)
{ {
double rms; if (nofvals[i] > 0)
const auto nvals = nofvals[i];
if (nvals > 0)
{ {
rms = std::sqrt(work0[i]); rmsd[i] = std::sqrt(rmsd[i] / (double)nofvals[i]);
} }
else else
{ {
nmiss++; nmiss++;
rms = missval; rmsd[i] = missval;
} }
work0[i] = rms;
} }
return nmiss; return nmiss;
...@@ -182,13 +178,13 @@ Timstat2(void *process) ...@@ -182,13 +178,13 @@ Timstat2(void *process)
// clang-format off // clang-format off
cdoOperatorAdd("timcor", func_cor, 5, nullptr); cdoOperatorAdd("timcor", func_cor, 5, nullptr);
cdoOperatorAdd("timcovar", func_covar, 3, nullptr); cdoOperatorAdd("timcovar", func_covar, 3, nullptr);
cdoOperatorAdd("timrms", func_rms, 1, nullptr); cdoOperatorAdd("timrmsd", func_rmsd, 1, nullptr);
// clang-format on // clang-format on
const auto operatorID = cdoOperatorID(); const auto operatorID = cdoOperatorID();
const auto operfunc = cdoOperatorF1(operatorID); const auto operfunc = cdoOperatorF1(operatorID);
const auto nwork = cdoOperatorF2(operatorID); const auto nwork = cdoOperatorF2(operatorID);
const auto timeIsConst = (operfunc == func_rms); const auto timeIsConst = (operfunc == func_rmsd);
operatorCheckArgc(0); operatorCheckArgc(0);
...@@ -284,9 +280,9 @@ Timstat2(void *process) ...@@ -284,9 +280,9 @@ Timstat2(void *process)
covariance_init(gridsize, array1.data(), array2.data(), missval1, missval2, rnofvals.data(), covariance_init(gridsize, array1.data(), array2.data(), missval1, missval2, rnofvals.data(),
rwork[0].data(), rwork[1].data(), rwork[2].data()); rwork[0].data(), rwork[1].data(), rwork[2].data());
} }
else if (operfunc == func_rms) else if (operfunc == func_rmsd)
{ {
rms_init(gridsize, array1.data(), array2.data(), missval1, missval2, rnofvals.data(), rwork[0].data()); rmsd_init(gridsize, array1.data(), array2.data(), missval1, missval2, rnofvals.data(), rwork[0].data());
} }
} }
...@@ -320,9 +316,9 @@ Timstat2(void *process) ...@@ -320,9 +316,9 @@ Timstat2(void *process)
nmiss = covariance(gridsize, missval1, missval2, rnofvals.data(), rwork[0].data(), nmiss = covariance(gridsize, missval1, missval2, rnofvals.data(), rwork[0].data(),
rwork[1].data(), rwork[2].data()); rwork[1].data(), rwork[2].data());
} }
else if (operfunc == func_rms) else if (operfunc == func_rmsd)
{ {
nmiss = rms(gridsize, missval1, rnofvals.data(), rwork[0].data()); nmiss = rmsd_compute(gridsize, missval1, rnofvals.data(), rwork[0].data());
} }
cdoDefRecord(streamID3, varID, levelID); cdoDefRecord(streamID3, varID, levelID);
......
...@@ -1599,7 +1599,7 @@ void init_modules() ...@@ -1599,7 +1599,7 @@ void init_modules()
{"Hourstat" ,module_Hourstat }, {"Hourstat" ,module_Hourstat },
{"Timcor" ,module_Timcor }, {"Timcor" ,module_Timcor },
{"Timcorvar" ,module_Timcorvar }, {"Timcorvar" ,module_Timcorvar },
{"Timrms" ,module_Timrms }, {"Timrmsd" ,module_Timrmsd },
{"Timstat3" ,module_Timstat3 }, {"Timstat3" ,module_Timstat3 },
{"Tinfo" ,module_Tinfo }, {"Tinfo" ,module_Tinfo },
{"Tocomplex" ,module_Tocomplex }, {"Tocomplex" ,module_Tocomplex },
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#define func_minidx 34 #define func_minidx 34
#define func_maxidx 35 #define func_maxidx 35
#define func_rms 36 #define func_rmsd 36
#define func_add 41 #define func_add 41
#define func_sub 42 #define func_sub 42
......
...@@ -541,7 +541,7 @@ void *Timstat(void *argument); ...@@ -541,7 +541,7 @@ void *Timstat(void *argument);
void *Timstat2(void *argument); void *Timstat2(void *argument);
#define TimcorOperators {"timcor"} #define TimcorOperators {"timcor"}
#define TimcovarOperators {"timcovar"} #define TimcovarOperators {"timcovar"}
#define TimrmsOperators {"timrms"} #define TimrmsdOperators {"timrmsd"}
void *Timstat3(void *argument); void *Timstat3(void *argument);
#define Timstat3Operators {"meandiff2test", "varquot2test"} #define Timstat3Operators {"meandiff2test", "varquot2test"}
......
...@@ -207,7 +207,7 @@ static const module_t module_Daystat = {Timstat , DaystatHelp ...@@ -207,7 +207,7 @@ static const module_t module_Daystat = {Timstat , DaystatHelp
static const module_t module_Hourstat = {Timstat , HourstatHelp , HourstatOperators , EXPOSED , CDI_BOTH , 1 , 1 , NoRestriction }; static const module_t module_Hourstat = {Timstat , HourstatHelp , HourstatOperators , EXPOSED , CDI_BOTH , 1 , 1 , NoRestriction };
static const module_t module_Timcor = {Timstat2 , TimcorHelp , TimcorOperators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction }; static const module_t module_Timcor = {Timstat2 , TimcorHelp , TimcorOperators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction };
static const module_t module_Timcorvar = {Timstat2 , TimcovarHelp , TimcovarOperators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction }; static const module_t module_Timcorvar = {Timstat2 , TimcovarHelp , TimcovarOperators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction };
static const module_t module_Timrms = {Timstat2 , {} , TimrmsOperators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction }; static const module_t module_Timrmsd = {Timstat2 , {} , TimrmsdOperators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction };
static const module_t module_Timstat3 = {Timstat3 , {} , Timstat3Operators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction }; static const module_t module_Timstat3 = {Timstat3 , {} , Timstat3Operators , EXPOSED , CDI_REAL , 2 , 1 , NoRestriction };
static const module_t module_Tinfo = {Tinfo , {} , TinfoOperators , EXPOSED , CDI_BOTH , 1 , 0 , NoRestriction }; static const module_t module_Tinfo = {Tinfo , {} , TinfoOperators , EXPOSED , CDI_BOTH , 1 , 0 , NoRestriction };
static const module_t module_Tocomplex = {Tocomplex , {} , TocomplexOperators , EXPOSED , CDI_REAL , 1 , 1 , NoRestriction }; static const module_t module_Tocomplex = {Tocomplex , {} , TocomplexOperators , EXPOSED , CDI_REAL , 1 , 1 , NoRestriction };
......
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