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

Added operator vertrange.

parent 07f30efa
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
2017-06-02 Uwe Schulzweida 2017-06-02 Uwe Schulzweida
* New operator vertrange: Vertical range (vertmax-vertmin)
* New operator merrange: Meridional range (mermax-mermin) * New operator merrange: Meridional range (mermax-mermin)
* New operator gridboxrange: Gridbox range (gribboxmax-gridboxmin) * New operator gridboxrange: Gridbox range (gribboxmax-gridboxmin)
......
...@@ -301,6 +301,7 @@ Operator catalog: ...@@ -301,6 +301,7 @@ Operator catalog:
Gridboxstat gridboxvar1 Gridbox variance (n-1) Gridboxstat gridboxvar1 Gridbox variance (n-1)
Vertstat vertmin Vertical minimum Vertstat vertmin Vertical minimum
Vertstat vertmax Vertical maximum Vertstat vertmax Vertical maximum
Vertstat vertrange Vertical range
Vertstat vertsum Vertical sum Vertstat vertsum Vertical sum
Vertstat vertmean Vertical mean Vertstat vertmean Vertical mean
Vertstat vertavg Vertical average Vertstat vertavg Vertical average
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
@Section = Statistical values @Section = Statistical values
@Class = Statistic @Class = Statistic
@Arguments = infile outfile @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 @BeginDescription
This module computes statistical values over all levels of the input variables. 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}. or standard deviation is written to @file{outfile}.
@EndDescription @EndDescription
@EndModule @EndModule
...@@ -33,6 +33,15 @@ For every gridpoint the maximum over all levels is computed. ...@@ -33,6 +33,15 @@ For every gridpoint the maximum over all levels is computed.
@EndOperator @EndOperator
@BeginOperator_vertrange
@Title = Vertical range
@BeginDescription
For every gridpoint the range over all levels is computed.
@EndDescription
@EndOperator
@BeginOperator_vertsum @BeginOperator_vertsum
@Title = Vertical sum @Title = Vertical sum
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
/* /*
This module contains the following operators: This module contains the following operators:
Vertstat vertrange Vertical range
Vertstat vertmin Vertical minimum Vertstat vertmin Vertical minimum
Vertstat vertmax Vertical maximum Vertstat vertmax Vertical maximum
Vertstat vertsum Vertical sum Vertstat vertsum Vertical sum
...@@ -169,25 +170,27 @@ void *Vertstat(void *argument) ...@@ -169,25 +170,27 @@ void *Vertstat(void *argument)
cdoInitialize(argument); cdoInitialize(argument);
cdoOperatorAdd("vertmin", func_min, 0, NULL); cdoOperatorAdd("vertrange", func_range, 0, NULL);
cdoOperatorAdd("vertmax", func_max, 0, NULL); cdoOperatorAdd("vertmin", func_min, 0, NULL);
cdoOperatorAdd("vertsum", func_sum, 0, NULL); cdoOperatorAdd("vertmax", func_max, 0, NULL);
int VERTINT = cdoOperatorAdd("vertint", func_sum, 1, NULL); cdoOperatorAdd("vertsum", func_sum, 0, NULL);
cdoOperatorAdd("vertmean", func_mean, 1, NULL); int VERTINT = cdoOperatorAdd("vertint", func_sum, 1, NULL);
cdoOperatorAdd("vertavg", func_avg, 1, NULL); cdoOperatorAdd("vertmean", func_mean, 1, NULL);
cdoOperatorAdd("vertvar", func_var, 1, NULL); cdoOperatorAdd("vertavg", func_avg, 1, NULL);
cdoOperatorAdd("vertvar1", func_var1, 1, NULL); cdoOperatorAdd("vertvar", func_var, 1, NULL);
cdoOperatorAdd("vertstd", func_std, 1, NULL); cdoOperatorAdd("vertvar1", func_var1, 1, NULL);
cdoOperatorAdd("vertstd1", func_std1, 1, NULL); cdoOperatorAdd("vertstd", func_std, 1, NULL);
cdoOperatorAdd("vertstd1", func_std1, 1, NULL);
int operatorID = cdoOperatorID(); int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID); int operfunc = cdoOperatorF1(operatorID);
bool needWeights = cdoOperatorF2(operatorID); bool needWeights = cdoOperatorF2(operatorID);
bool lrange = operfunc == func_range;
bool lmean = operfunc == func_mean || operfunc == func_avg; bool lmean = operfunc == func_mean || operfunc == func_avg;
bool lstd = operfunc == func_std || operfunc == func_std1; bool lstd = operfunc == func_std || operfunc == func_std1;
bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1; bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
int divisor = operfunc == func_std1 || operfunc == func_var1; int divisor = operfunc == func_std1 || operfunc == func_var1;
//int applyWeights = lmean; //int applyWeights = lmean;
...@@ -259,7 +262,7 @@ void *Vertstat(void *argument) ...@@ -259,7 +262,7 @@ void *Vertstat(void *argument)
field_type *vars1 = (field_type*) Malloc(nvars*sizeof(field_type)); field_type *vars1 = (field_type*) Malloc(nvars*sizeof(field_type));
field_type *samp1 = (field_type*) Malloc(nvars*sizeof(field_type)); field_type *samp1 = (field_type*) Malloc(nvars*sizeof(field_type));
field_type *vars2 = NULL; field_type *vars2 = NULL;
if ( lvarstd ) if ( lvarstd || lrange )
vars2 = (field_type*) Malloc(nvars*sizeof(field_type)); vars2 = (field_type*) Malloc(nvars*sizeof(field_type));
for ( varID = 0; varID < nvars; varID++ ) for ( varID = 0; varID < nvars; varID++ )
...@@ -281,7 +284,7 @@ void *Vertstat(void *argument) ...@@ -281,7 +284,7 @@ void *Vertstat(void *argument)
samp1[varID].nmiss = 0; samp1[varID].nmiss = 0;
samp1[varID].missval = missval; samp1[varID].missval = missval;
samp1[varID].ptr = NULL; samp1[varID].ptr = NULL;
if ( lvarstd ) if ( lvarstd || lrange )
{ {
field_init(&vars2[varID]); field_init(&vars2[varID]);
vars2[varID].grid = gridID; vars2[varID].grid = gridID;
...@@ -302,6 +305,7 @@ void *Vertstat(void *argument) ...@@ -302,6 +305,7 @@ void *Vertstat(void *argument)
streamInqRecord(streamID1, &varID, &levelID); streamInqRecord(streamID1, &varID, &levelID);
vars1[varID].nsamp++; vars1[varID].nsamp++;
if ( lrange ) vars2[varID].nsamp++;
gridsize = gridInqSize(vars1[varID].grid); gridsize = gridInqSize(vars1[varID].grid);
zaxisID = vars1[varID].zaxis; zaxisID = vars1[varID].zaxis;
nlev = zaxisInqSize(zaxisID); nlev = zaxisInqSize(zaxisID);
...@@ -333,6 +337,12 @@ void *Vertstat(void *argument) ...@@ -333,6 +337,12 @@ void *Vertstat(void *argument)
{ {
streamReadRecord(streamID1, vars1[varID].ptr, &nmiss); streamReadRecord(streamID1, vars1[varID].ptr, &nmiss);
vars1[varID].nmiss = (size_t)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 ( 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); if ( lmean && IS_NOT_EQUAL(layer_weight, 1.0) ) farcmul(&vars1[varID], layer_weight);
...@@ -399,6 +409,11 @@ void *Vertstat(void *argument) ...@@ -399,6 +409,11 @@ void *Vertstat(void *argument)
farsum(&vars1[varID], field); farsum(&vars1[varID], field);
} }
} }
else if ( lrange )
{
farmin(&vars2[varID], field);
farmax(&vars1[varID], field);
}
else else
{ {
farfun(&vars1[varID], field, operfunc); farfun(&vars1[varID], field, operfunc);
...@@ -434,6 +449,10 @@ void *Vertstat(void *argument) ...@@ -434,6 +449,10 @@ void *Vertstat(void *argument)
farvar(&vars1[varID], vars2[varID], samp1[varID], divisor); farvar(&vars1[varID], vars2[varID], samp1[varID], divisor);
} }
} }
else if ( lrange )
{
farsub(&vars1[varID], vars2[varID]);
}
streamDefRecord(streamID2, varID, 0); streamDefRecord(streamID2, varID, 0);
streamWriteRecord(streamID2, vars1[varID].ptr, (int)vars1[varID].nmiss); streamWriteRecord(streamID2, vars1[varID].ptr, (int)vars1[varID].nmiss);
......
...@@ -488,7 +488,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid" ...@@ -488,7 +488,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define VarrmsOperators {"varrms"} #define VarrmsOperators {"varrms"}
#define VertintmlOperators {"ml2pl", "ml2hl", "ml2plx", "ml2hlx", "ml2pl_lp", "ml2hl_lp", "ml2plx_lp", "ml2hlx_lp"} #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 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 VertcumOperators {"vertcum", "vertcumhl"}
#define VertwindOperators {"vertwind"} #define VertwindOperators {"vertwind"}
#define VerifygridOperators {"verifygrid"} #define VerifygridOperators {"verifygrid"}
......
...@@ -2170,36 +2170,38 @@ std::vector<std::string> GridboxstatHelp = { ...@@ -2170,36 +2170,38 @@ std::vector<std::string> GridboxstatHelp = {
std::vector<std::string> VertstatHelp = { std::vector<std::string> VertstatHelp = {
"NAME", "NAME",
" vertmin, vertmax, vertsum, vertmean, vertavg, vertstd, vertstd1, vertvar, ", " vertmin, vertmax, vertrange, vertsum, vertmean, vertavg, vertstd, vertstd1, ",
" vertvar1 - Vertical statistical values", " vertvar, vertvar1 - Vertical statistical values",
"", "",
"SYNOPSIS", "SYNOPSIS",
" <operator> infile outfile", " <operator> infile outfile",
"", "",
"DESCRIPTION", "DESCRIPTION",
" This module computes statistical values over all levels of the input variables.", " 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.", " or standard deviation is written to outfile.",
"", "",
"OPERATORS", "OPERATORS",
" vertmin Vertical minimum", " vertmin Vertical minimum",
" For every gridpoint the minimum over all levels is computed.", " For every gridpoint the minimum over all levels is computed.",
" vertmax Vertical maximum", " vertmax Vertical maximum",
" For every gridpoint the maximum over all levels is computed.", " For every gridpoint the maximum over all levels is computed.",
" vertsum Vertical sum", " vertrange Vertical range",
" For every gridpoint the sum over all levels is computed.", " For every gridpoint the range over all levels is computed.",
" vertmean Vertical mean", " vertsum Vertical sum",
" For every gridpoint the layer weighted mean over all levels is computed.", " For every gridpoint the sum over all levels is computed.",
" vertavg Vertical average", " vertmean Vertical mean",
" For every gridpoint the layer weighted average over all levels is computed.", " For every gridpoint the layer weighted mean over all levels is computed.",
" vertstd Vertical standard deviation", " vertavg Vertical average",
" For every gridpoint the standard deviation over all levels is computed. Normalize by n.", " For every gridpoint the layer weighted average over all levels is computed.",
" vertstd1 Vertical standard deviation (n-1)", " vertstd Vertical standard deviation",
" For every gridpoint the standard deviation over all levels is computed. Normalize by (n-1).", " For every gridpoint the standard deviation over all levels is computed. Normalize by n.",
" vertvar Vertical variance", " vertstd1 Vertical standard deviation (n-1)",
" For every gridpoint the variance over all levels is computed. Normalize by n.", " For every gridpoint the standard deviation over all levels is computed. Normalize by (n-1).",
" vertvar1 Vertical variance (n-1)", " vertvar Vertical variance",
" For every gridpoint the variance over all levels is computed. Normalize by (n-1).", " For every gridpoint the variance over all levels is computed. Normalize by n.",
" vertvar1 Vertical variance (n-1)",
" For every gridpoint the variance over all levels is computed. Normalize by (n-1).",
}; };
std::vector<std::string> TimselstatHelp = { std::vector<std::string> TimselstatHelp = {
......
#! @BASH@ #! @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 "$CDO" || CDO=cdo
test -n "$DATAPATH" || DATAPATH=./data test -n "$DATAPATH" || DATAPATH=./data
...@@ -9,7 +9,7 @@ CDOERR=cerr$$ ...@@ -9,7 +9,7 @@ CDOERR=cerr$$
FORMAT="-f srv -b 32" FORMAT="-f srv -b 32"
# #
TYPE=vert 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 IFILE=$DATAPATH/pl_data.grb
# #
......
...@@ -16,7 +16,7 @@ TIMSTAT_REF = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_re ...@@ -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 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 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 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 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 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 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 ...@@ -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 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 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 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 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 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 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