Commit 07f30efa authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added operator merrange.

parent dab1d74b
......@@ -5,7 +5,8 @@
2017-06-02 Uwe Schulzweida
* New operator gridboxrange: gridbox range (gribboxmax-gridboxmin)
* New operator merrange: Meridional range (mermax-mermin)
* New operator gridboxrange: Gridbox range (gribboxmax-gridboxmin)
2017-06-01 Uwe Schulzweida
......
......@@ -280,6 +280,7 @@ Operator catalog:
Zonstat zonpctl Zonal percentiles
Merstat mermin Meridional minimum
Merstat mermax Meridional maximum
Merstat merrange Meridional range
Merstat mersum Meridional sum
Merstat mermean Meridional mean
Merstat meravg Meridional average
......
......@@ -9,7 +9,7 @@
@BeginDescription
This module computes statistical values over surrounding grid boxes.
According to the chosen operator the minimum, maximum, sum, average,
According to the chosen operator the minimum, maximum, range, sum, average,
variance, or standard deviation of the neighboring grid boxes is written to @file{outfile}.
All gridbox operators only works on quadrilateral curvilinear grids.
@EndDescription
......
......@@ -5,11 +5,11 @@
@Section = Statistical values
@Class = Statistic
@Arguments = infile outfile
@Operators = mermin mermax mersum mermean meravg merstd merstd1 mervar mervar1 merpctl
@Operators = mermin mermax merrange mersum mermean meravg merstd merstd1 mervar mervar1 merpctl
@BeginDescription
This module computes meridional statistical values of the input fields.
According to the chosen operator the meridional minimum, maximum, sum, average,
According to the chosen operator the meridional minimum, maximum, range, sum, average,
variance, standard deviation or a certain percentile is written to @file{outfile}.
This operator requires all variables on the same regular lon/lat grid.
@EndDescription
......@@ -34,6 +34,15 @@ For every longitude the maximum over all latitudes is computed.
@EndOperator
@BeginOperator_merrange
@Title = Meridional range
@BeginDescription
For every longitude the range over all latitudes is computed.
@EndDescription
@EndOperator
@BeginOperator_mersum
@Title = Meridional sum
......
......@@ -18,6 +18,7 @@
/*
This module contains the following operators:
Merstat merrange Meridional range
Merstat mermin Meridional minimum
Merstat mermax Meridional maximum
Merstat mersum Meridional sum
......@@ -50,16 +51,17 @@ void *Merstat(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("mermin", func_min, 0, NULL);
cdoOperatorAdd("mermax", func_max, 0, NULL);
cdoOperatorAdd("mersum", func_sum, 0, NULL);
cdoOperatorAdd("mermean", func_meanw, 1, NULL);
cdoOperatorAdd("meravg", func_avgw, 1, NULL);
cdoOperatorAdd("mervar", func_varw, 1, NULL);
cdoOperatorAdd("mervar1", func_var1w, 1, NULL);
cdoOperatorAdd("merstd", func_stdw, 1, NULL);
cdoOperatorAdd("merstd1", func_std1w, 1, NULL);
cdoOperatorAdd("merpctl", func_pctl, 0, NULL);
cdoOperatorAdd("merrange", func_range, 0, NULL);
cdoOperatorAdd("mermin", func_min, 0, NULL);
cdoOperatorAdd("mermax", func_max, 0, NULL);
cdoOperatorAdd("mersum", func_sum, 0, NULL);
cdoOperatorAdd("mermean", func_meanw, 1, NULL);
cdoOperatorAdd("meravg", func_avgw, 1, NULL);
cdoOperatorAdd("mervar", func_varw, 1, NULL);
cdoOperatorAdd("mervar1", func_var1w, 1, NULL);
cdoOperatorAdd("merstd", func_stdw, 1, NULL);
cdoOperatorAdd("merstd1", func_std1w, 1, NULL);
cdoOperatorAdd("merpctl", func_pctl, 0, NULL);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
......
......@@ -153,6 +153,7 @@ void zonpctl(field_type field1, field_type *field2, const int k);
void merfun(field_type field1, field_type *field2, const int function);
void mermin(field_type field1, field_type *field2);
void mermax(field_type field1, field_type *field2);
void merrange(field_type field1, field_type *field2);
void mersum(field_type field1, field_type *field2);
void meravgw(field_type field1, field_type *field2);
void mermeanw(field_type field1, field_type *field2);
......
......@@ -27,6 +27,7 @@ void merfun(field_type field1, field_type *field2, int function)
{
case func_min: mermin(field1, field2); break;
case func_max: mermax(field1, field2); break;
case func_range: merrange(field1, field2); break;
case func_sum: mersum(field1, field2); break;
case func_meanw: mermeanw(field1, field2); break;
case func_avgw: meravgw(field1, field2); break;
......@@ -123,6 +124,64 @@ void mermax(field_type field1, field_type *field2)
}
void merrange(field_type field1, field_type *field2)
{
long i, j, nx, ny;
int rnmiss = 0;
int grid = field1.grid;
int nmiss = field1.nmiss;
double missval = field1.missval;
double *array = field1.ptr;
double rmin = 0;
double rmax = 0;
double rrange = 0;
nx = gridInqXsize(grid);
ny = gridInqYsize(grid);
for ( i = 0; i < nx; i++ )
{
if ( nmiss > 0 )
{
rmin = DBL_MAX;
rmax = -DBL_MAX;
for ( j = 0; j < ny; j++ )
if ( !DBL_IS_EQUAL(array[j*nx+i], missval) )
{
if ( array[j*nx+i] < rmin ) rmin = array[j*nx+i];
else if ( array[j*nx+i] > rmax ) rmax = array[j*nx+i];
}
if ( IS_EQUAL(rmin, DBL_MAX) || IS_EQUAL(rmax, -DBL_MAX) )
{
rnmiss++;
rrange = missval;
}
else
{
rrange = rmax - rmin;
}
}
else
{
rmin = DBL_MAX;
rmax = DBL_MIN;
for ( j = 0; j < ny; j++ )
{
if ( array[j*nx+i] < rmin ) rmin = array[j*nx+i];
else if ( array[j*nx+i] > rmax ) rmax = array[j*nx+i];
}
rrange = rmax - rmin;
}
field2->ptr[i] = rrange;
}
field2->nmiss = rnmiss;
}
void mersum(field_type field1, field_type *field2)
{
long i, j, nx, ny;
......
......@@ -370,7 +370,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define MergeOperators {"merge"}
#define MergegridOperators {"mergegrid"}
#define MergetimeOperators {"mergetime"}
#define MerstatOperators {"mermin", "mermax", "mersum", "mermean", "meravg", "merstd", "merstd1", "mervar", "mervar1", "merpctl"}
#define MerstatOperators {"merrange", "mermin", "mermax", "mersum", "mermean", "meravg", "merstd", "merstd1", "mervar", "mervar1", "merpctl"}
#define MonarithOperators {"monadd", "monsub", "monmul", "mondiv"}
#define MrotuvOperators {"mrotuv"}
#define MrotuvbOperators {"mrotuvb"}
......
......@@ -2085,8 +2085,8 @@ std::vector<std::string> ZonstatHelp = {
std::vector<std::string> MerstatHelp = {
"NAME",
" mermin, mermax, mersum, mermean, meravg, merstd, merstd1, mervar, mervar1, ",
" merpctl - Meridional statistical values",
" mermin, mermax, merrange, mersum, mermean, meravg, merstd, merstd1, mervar, ",
" mervar1, merpctl - Meridional statistical values",
"",
"SYNOPSIS",
" <operator> infile outfile",
......@@ -2094,31 +2094,33 @@ std::vector<std::string> MerstatHelp = {
"",
"DESCRIPTION",
" This module computes meridional statistical values of the input fields.",
" According to the chosen operator the meridional minimum, maximum, sum, average,",
" According to the chosen operator the meridional minimum, maximum, range, sum, average,",
" variance, standard deviation or a certain percentile is written to outfile.",
" This operator requires all variables on the same regular lon/lat grid.",
"",
"OPERATORS",
" mermin Meridional minimum",
" For every longitude the minimum over all latitudes is computed.",
" mermax Meridional maximum",
" For every longitude the maximum over all latitudes is computed.",
" mersum Meridional sum",
" For every longitude the sum over all latitudes is computed.",
" mermean Meridional mean",
" For every longitude the area weighted mean over all latitudes is computed.",
" meravg Meridional average",
" For every longitude the area weighted average over all latitudes is computed.",
" merstd Meridional standard deviation",
" For every longitude the standard deviation over all latitudes is computed. Normalize by n.",
" merstd1 Meridional standard deviation (n-1)",
" For every longitude the standard deviation over all latitudes is computed. Normalize by (n-1).",
" mervar Meridional variance",
" For every longitude the variance over all latitudes is computed. Normalize by n.",
" mervar1 Meridional variance (n-1)",
" For every longitude the variance over all latitudes is computed. Normalize by (n-1).",
" merpctl Meridional percentiles",
" For every longitude the pth percentile over all latitudes is computed.",
" mermin Meridional minimum",
" For every longitude the minimum over all latitudes is computed.",
" mermax Meridional maximum",
" For every longitude the maximum over all latitudes is computed.",
" merrange Meridional range",
" For every longitude the range over all latitudes is computed.",
" mersum Meridional sum",
" For every longitude the sum over all latitudes is computed.",
" mermean Meridional mean",
" For every longitude the area weighted mean over all latitudes is computed.",
" meravg Meridional average",
" For every longitude the area weighted average over all latitudes is computed.",
" merstd Meridional standard deviation",
" For every longitude the standard deviation over all latitudes is computed. Normalize by n.",
" merstd1 Meridional standard deviation (n-1)",
" For every longitude the standard deviation over all latitudes is computed. Normalize by (n-1).",
" mervar Meridional variance",
" For every longitude the variance over all latitudes is computed. Normalize by n.",
" mervar1 Meridional variance (n-1)",
" For every longitude the variance over all latitudes is computed. Normalize by (n-1).",
" merpctl Meridional percentiles",
" For every longitude the pth percentile over all latitudes is computed.",
"",
"PARAMETER",
" p FLOAT Percentile number in {0, ..., 100}",
......@@ -2135,7 +2137,7 @@ std::vector<std::string> GridboxstatHelp = {
"",
"DESCRIPTION",
" This module computes statistical values over surrounding grid boxes.",
" According to the chosen operator the minimum, maximum, sum, average, ",
" According to the chosen operator the minimum, maximum, range, sum, average, ",
" variance, or standard deviation of the neighboring grid boxes is written to outfile.",
" All gridbox operators only works on quadrilateral curvilinear grids.",
"",
......
#! @BASH@
echo 1..9 # Number of tests to be executed.
echo 1..10 # Number of tests to be executed.
#
test -n "$CDO" || CDO=cdo
test -n "$DATAPATH" || DATAPATH=./data
......@@ -9,7 +9,7 @@ CDOERR=cerr$$
FORMAT="-f srv -b 32"
#
TYPE=mer
STATS="min max sum avg mean std std1 var var1"
STATS="min max range sum avg mean std std1 var var1"
#
IFILE=$DATAPATH/t21_geosp_tsurf.grb
#
......
......@@ -19,7 +19,7 @@ DAYSTAT_REF = daymin_ref daymax_ref daysum_ref dayavg_ref daymean_ref daystd_re
VERTSTAT_REF = vertmin_ref vertmax_ref vertsum_ref vertavg_ref vertmean_ref vertstd_ref vertstd1_ref vertvar_ref vertvar1_ref vertint_ref
FLDSTAT_REF = fldmin_ref fldmax_ref fldsum_ref fldavg_ref fldmean_ref fldstd_ref fldstd1_ref fldvar_ref fldvar1_ref fldrange_ref
FLDPSTAT_REF = fldpctl1_ref fldpctl20_ref fldpctl25_ref fldpctl33_ref fldpctl50_ref fldpctl66_ref fldpctl75_ref fldpctl80_ref fldpctl99_ref fldpctl100_ref
MERSTAT_REF = mermin_ref mermax_ref mersum_ref meravg_ref mermean_ref merstd_ref merstd1_ref mervar_ref mervar1_ref
MERSTAT_REF = mermin_ref mermax_ref mersum_ref meravg_ref mermean_ref merstd_ref merstd1_ref mervar_ref mervar1_ref merrange_ref
ZONSTAT_REF = zonmin_ref zonmax_ref zonsum_ref zonavg_ref zonmean_ref zonstd_ref zonstd1_ref zonvar_ref zonvar1_ref zonrange_ref
ENSPSTAT_REF = enspctl1_ref enspctl20_ref enspctl25_ref enspctl33_ref enspctl50_ref enspctl66_ref enspctl75_ref enspctl80_ref enspctl99_ref enspctl100_ref
SPECTRAL_REF = sp2gp_ref sp2gpl_ref gp2sp_ref gp2spl_ref
......
......@@ -309,7 +309,7 @@ DAYSTAT_REF = daymin_ref daymax_ref daysum_ref dayavg_ref daymean_ref daystd_ref
VERTSTAT_REF = vertmin_ref vertmax_ref vertsum_ref vertavg_ref vertmean_ref vertstd_ref vertstd1_ref vertvar_ref vertvar1_ref vertint_ref
FLDSTAT_REF = fldmin_ref fldmax_ref fldsum_ref fldavg_ref fldmean_ref fldstd_ref fldstd1_ref fldvar_ref fldvar1_ref fldrange_ref
FLDPSTAT_REF = fldpctl1_ref fldpctl20_ref fldpctl25_ref fldpctl33_ref fldpctl50_ref fldpctl66_ref fldpctl75_ref fldpctl80_ref fldpctl99_ref fldpctl100_ref
MERSTAT_REF = mermin_ref mermax_ref mersum_ref meravg_ref mermean_ref merstd_ref merstd1_ref mervar_ref mervar1_ref
MERSTAT_REF = mermin_ref mermax_ref mersum_ref meravg_ref mermean_ref merstd_ref merstd1_ref mervar_ref mervar1_ref merrange_ref
ZONSTAT_REF = zonmin_ref zonmax_ref zonsum_ref zonavg_ref zonmean_ref zonstd_ref zonstd1_ref zonvar_ref zonvar1_ref zonrange_ref
ENSPSTAT_REF = enspctl1_ref enspctl20_ref enspctl25_ref enspctl33_ref enspctl50_ref enspctl66_ref enspctl75_ref enspctl80_ref enspctl99_ref enspctl100_ref
SPECTRAL_REF = sp2gp_ref sp2gpl_ref gp2sp_ref gp2spl_ref
......
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