Commit 810745ec authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added operator vertrange.

parent 07f30efa
......@@ -5,6 +5,7 @@
2017-06-02 Uwe Schulzweida
* New operator vertrange: Vertical range (vertmax-vertmin)
* New operator merrange: Meridional range (mermax-mermin)
* New operator gridboxrange: Gridbox range (gribboxmax-gridboxmin)
......
......@@ -301,6 +301,7 @@ Operator catalog:
Gridboxstat gridboxvar1 Gridbox variance (n-1)
Vertstat vertmin Vertical minimum
Vertstat vertmax Vertical maximum
Vertstat vertrange Vertical range
Vertstat vertsum Vertical sum
Vertstat vertmean Vertical mean
Vertstat vertavg Vertical average
......
......@@ -5,11 +5,11 @@
@Section = Statistical values
@Class = Statistic
@Arguments = infile outfile
@Operators = vertmin vertmax vertsum vertmean vertavg vertstd vertstd1 vertvar vertvar1
@Operators = vertmin vertmax vertrange vertsum vertmean vertavg vertstd vertstd1 vertvar vertvar1
@BeginDescription
This module computes statistical values over all levels of the input variables.
According to chosen operator the vertical minimum, maximum, sum, average, variance
According to chosen operator the vertical minimum, maximum, range, sum, average, variance
or standard deviation is written to @file{outfile}.
@EndDescription
@EndModule
......@@ -33,6 +33,15 @@ For every gridpoint the maximum over all levels is computed.
@EndOperator
@BeginOperator_vertrange
@Title = Vertical range
@BeginDescription
For every gridpoint the range over all levels is computed.
@EndDescription
@EndOperator
@BeginOperator_vertsum
@Title = Vertical sum
......
......@@ -18,6 +18,7 @@
/*
This module contains the following operators:
Vertstat vertrange Vertical range
Vertstat vertmin Vertical minimum
Vertstat vertmax Vertical maximum
Vertstat vertsum Vertical sum
......@@ -169,6 +170,7 @@ void *Vertstat(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("vertrange", func_range, 0, NULL);
cdoOperatorAdd("vertmin", func_min, 0, NULL);
cdoOperatorAdd("vertmax", func_max, 0, NULL);
cdoOperatorAdd("vertsum", func_sum, 0, NULL);
......@@ -184,6 +186,7 @@ void *Vertstat(void *argument)
int operfunc = cdoOperatorF1(operatorID);
bool needWeights = cdoOperatorF2(operatorID);
bool lrange = operfunc == func_range;
bool lmean = operfunc == func_mean || operfunc == func_avg;
bool lstd = operfunc == func_std || operfunc == func_std1;
bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
......@@ -259,7 +262,7 @@ void *Vertstat(void *argument)
field_type *vars1 = (field_type*) Malloc(nvars*sizeof(field_type));
field_type *samp1 = (field_type*) Malloc(nvars*sizeof(field_type));
field_type *vars2 = NULL;
if ( lvarstd )
if ( lvarstd || lrange )
vars2 = (field_type*) Malloc(nvars*sizeof(field_type));
for ( varID = 0; varID < nvars; varID++ )
......@@ -281,7 +284,7 @@ void *Vertstat(void *argument)
samp1[varID].nmiss = 0;
samp1[varID].missval = missval;
samp1[varID].ptr = NULL;
if ( lvarstd )
if ( lvarstd || lrange )
{
field_init(&vars2[varID]);
vars2[varID].grid = gridID;
......@@ -302,6 +305,7 @@ void *Vertstat(void *argument)
streamInqRecord(streamID1, &varID, &levelID);
vars1[varID].nsamp++;
if ( lrange ) vars2[varID].nsamp++;
gridsize = gridInqSize(vars1[varID].grid);
zaxisID = vars1[varID].zaxis;
nlev = zaxisInqSize(zaxisID);
......@@ -333,6 +337,12 @@ void *Vertstat(void *argument)
{
streamReadRecord(streamID1, vars1[varID].ptr, &nmiss);
vars1[varID].nmiss = (size_t)nmiss;
if ( lrange )
{
vars2[varID].nmiss = (size_t)nmiss;
for ( int i = 0; i < gridsize; i++ )
vars2[varID].ptr[i] = vars1[varID].ptr[i];
}
if ( operatorID == VERTINT && IS_NOT_EQUAL(layer_thickness, 1.0) ) farcmul(&vars1[varID], layer_thickness);
if ( lmean && IS_NOT_EQUAL(layer_weight, 1.0) ) farcmul(&vars1[varID], layer_weight);
......@@ -399,6 +409,11 @@ void *Vertstat(void *argument)
farsum(&vars1[varID], field);
}
}
else if ( lrange )
{
farmin(&vars2[varID], field);
farmax(&vars1[varID], field);
}
else
{
farfun(&vars1[varID], field, operfunc);
......@@ -434,6 +449,10 @@ void *Vertstat(void *argument)
farvar(&vars1[varID], vars2[varID], samp1[varID], divisor);
}
}
else if ( lrange )
{
farsub(&vars1[varID], vars2[varID]);
}
streamDefRecord(streamID2, varID, 0);
streamWriteRecord(streamID2, vars1[varID].ptr, (int)vars1[varID].nmiss);
......
......@@ -488,7 +488,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define VarrmsOperators {"varrms"}
#define VertintmlOperators {"ml2pl", "ml2hl", "ml2plx", "ml2hlx", "ml2pl_lp", "ml2hl_lp", "ml2plx_lp", "ml2hlx_lp"}
#define VertintapOperators {"ap2pl", "ap2plx", "ap2pl_lp", "ap2plx_lp", "ap2hl", "ap2hlx"}
#define VertstatOperators {"vertmin", "vertmax", "vertsum", "vertint", "vertmean", "vertavg", "vertstd", "vertstd1", "vertvar", "vertvar1"}
#define VertstatOperators {"vertrange", "vertmin", "vertmax", "vertsum", "vertint", "vertmean", "vertavg", "vertstd", "vertstd1", "vertvar", "vertvar1"}
#define VertcumOperators {"vertcum", "vertcumhl"}
#define VertwindOperators {"vertwind"}
#define VerifygridOperators {"verifygrid"}
......
......@@ -2170,15 +2170,15 @@ std::vector<std::string> GridboxstatHelp = {
std::vector<std::string> VertstatHelp = {
"NAME",
" vertmin, vertmax, vertsum, vertmean, vertavg, vertstd, vertstd1, vertvar, ",
" vertvar1 - Vertical statistical values",
" vertmin, vertmax, vertrange, vertsum, vertmean, vertavg, vertstd, vertstd1, ",
" vertvar, vertvar1 - Vertical statistical values",
"",
"SYNOPSIS",
" <operator> infile outfile",
"",
"DESCRIPTION",
" This module computes statistical values over all levels of the input variables.",
" According to chosen operator the vertical minimum, maximum, sum, average, variance",
" According to chosen operator the vertical minimum, maximum, range, sum, average, variance",
" or standard deviation is written to outfile.",
"",
"OPERATORS",
......@@ -2186,6 +2186,8 @@ std::vector<std::string> VertstatHelp = {
" For every gridpoint the minimum over all levels is computed.",
" vertmax Vertical maximum",
" For every gridpoint the maximum over all levels is computed.",
" vertrange Vertical range",
" For every gridpoint the range over all levels is computed.",
" vertsum Vertical sum",
" For every gridpoint the sum over all levels is computed.",
" vertmean Vertical mean",
......
#! @BASH@
echo 1..10 # Number of tests to be executed.
echo 1..11 # 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=vert
STATS="min max sum avg mean std std1 var var1 int"
STATS="min max range sum avg mean std std1 var var1 int"
#
IFILE=$DATAPATH/pl_data.grb
#
......
......@@ -16,7 +16,7 @@ TIMSTAT_REF = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_re
YEARSTAT_REF = yearmin_ref yearmax_ref yearsum_ref yearavg_ref yearmean_ref yearstd_ref yearstd1_ref yearvar_ref yearvar1_ref yearrange_ref
MONSTAT_REF = monmin_ref monmax_ref monsum_ref monavg_ref monmean_ref monstd_ref monstd1_ref monvar_ref monvar1_ref monrange_ref
DAYSTAT_REF = daymin_ref daymax_ref daysum_ref dayavg_ref daymean_ref daystd_ref daystd1_ref dayvar_ref dayvar1_ref dayrange_ref
VERTSTAT_REF = vertmin_ref vertmax_ref vertsum_ref vertavg_ref vertmean_ref vertstd_ref vertstd1_ref vertvar_ref vertvar1_ref vertint_ref
VERTSTAT_REF = vertmin_ref vertmax_ref vertsum_ref vertavg_ref vertmean_ref vertstd_ref vertstd1_ref vertvar_ref vertvar1_ref vertint_ref vertrange_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 merrange_ref
......
......@@ -306,7 +306,7 @@ TIMSTAT_REF = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_ref
YEARSTAT_REF = yearmin_ref yearmax_ref yearsum_ref yearavg_ref yearmean_ref yearstd_ref yearstd1_ref yearvar_ref yearvar1_ref yearrange_ref
MONSTAT_REF = monmin_ref monmax_ref monsum_ref monavg_ref monmean_ref monstd_ref monstd1_ref monvar_ref monvar1_ref monrange_ref
DAYSTAT_REF = daymin_ref daymax_ref daysum_ref dayavg_ref daymean_ref daystd_ref daystd1_ref dayvar_ref dayvar1_ref dayrange_ref
VERTSTAT_REF = vertmin_ref vertmax_ref vertsum_ref vertavg_ref vertmean_ref vertstd_ref vertstd1_ref vertvar_ref vertvar1_ref vertint_ref
VERTSTAT_REF = vertmin_ref vertmax_ref vertsum_ref vertavg_ref vertmean_ref vertstd_ref vertstd1_ref vertvar_ref vertvar1_ref vertint_ref vertrange_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 merrange_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