Commit 1aa49bc1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added option --reduce_dim to reduce dimension (Timstat, Fldstat)

parent 39087bc0
......@@ -7,6 +7,7 @@
2015-04-21 Uwe Schulzweida
* New operator: genlevelbounds - Generate level bounds
* Added option --reduce_dim to reduce dimension (Timstat, Fldstat)
2015-04-17 Uwe Schulzweida
......
......@@ -6,6 +6,7 @@ Version 1.6.9 (26 September 2015):
New features:
* select: added parameter date, startdate, enddate
* expr: added support for operator ?:,&&,||
* option --reduce_dim: reduce dimension (Timstat, Fldstat)
New operators:
* after: ECHAM standard post processor
* aexpr: Evaluate expressions and append results
......
......@@ -93,10 +93,8 @@ void *Fldstat(void *argument)
int index;
int recID, nrecs;
int varID, levelID;
int lim;
int needWeights = FALSE;
int nmiss;
double slon, slat;
double sglval;
field_t field;
int pn = 0;
......@@ -156,13 +154,22 @@ void *Fldstat(void *argument)
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
slon = 0;
slat = 0;
gridID2 = gridCreate(GRID_LONLAT, 1);
gridDefXsize(gridID2, 1);
gridDefYsize(gridID2, 1);
gridDefXvals(gridID2, &slon);
gridDefYvals(gridID2, &slat);
if ( CDO_Reduce_Dim )
{
gridID2 = gridCreate(GRID_GENERIC, 1);
gridDefXsize(gridID2, 0);
gridDefYsize(gridID2, 0);
}
else
{
double slon = 0;
double slat = 0;
gridID2 = gridCreate(GRID_LONLAT, 1);
gridDefXsize(gridID2, 1);
gridDefYsize(gridID2, 1);
gridDefXvals(gridID2, &slon);
gridDefYvals(gridID2, &slat);
}
int ngrids = vlistNgrids(vlistID1);
......@@ -175,7 +182,7 @@ void *Fldstat(void *argument)
field_init(&field);
lim = vlistGridsizeMax(vlistID1);
int lim = vlistGridsizeMax(vlistID1);
field.ptr = (double*) malloc(lim*sizeof(double));
field.weight = NULL;
if ( needWeights )
......
......@@ -75,7 +75,6 @@
void *Timstat(void *argument)
{
int timestat_date = TIMESTAT_MEAN;
int cmplen;
int gridsize;
int vdate = 0, vtime = 0;
int vdate0 = 0, vtime0 = 0;
......@@ -95,15 +94,15 @@ void *Timstat(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("timmin", func_min, 31, NULL);
cdoOperatorAdd("timmax", func_max, 31, NULL);
cdoOperatorAdd("timsum", func_sum, 31, NULL);
cdoOperatorAdd("timmean", func_mean, 31, NULL);
cdoOperatorAdd("timavg", func_avg, 31, NULL);
cdoOperatorAdd("timvar", func_var, 31, NULL);
cdoOperatorAdd("timvar1", func_var1, 31, NULL);
cdoOperatorAdd("timstd", func_std, 31, NULL);
cdoOperatorAdd("timstd1", func_std1, 31, NULL);
cdoOperatorAdd("timmin", func_min, DATE_LEN, NULL);
cdoOperatorAdd("timmax", func_max, DATE_LEN, NULL);
cdoOperatorAdd("timsum", func_sum, DATE_LEN, NULL);
cdoOperatorAdd("timmean", func_mean, DATE_LEN, NULL);
cdoOperatorAdd("timavg", func_avg, DATE_LEN, NULL);
cdoOperatorAdd("timvar", func_var, DATE_LEN, NULL);
cdoOperatorAdd("timvar1", func_var1, DATE_LEN, NULL);
cdoOperatorAdd("timstd", func_std, DATE_LEN, NULL);
cdoOperatorAdd("timstd1", func_std1, DATE_LEN, NULL);
cdoOperatorAdd("yearmin", func_min, 10, NULL);
cdoOperatorAdd("yearmax", func_max, 10, NULL);
cdoOperatorAdd("yearsum", func_sum, 10, NULL);
......@@ -142,7 +141,8 @@ void *Timstat(void *argument)
cdoOperatorAdd("hourstd1", func_std1, 4, NULL);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
int operfunc = cdoOperatorF1(operatorID);
int comparelen = cdoOperatorF2(operatorID);
int lmean = operfunc == func_mean || operfunc == func_avg;
int lstd = operfunc == func_std || operfunc == func_std1;
......@@ -165,27 +165,31 @@ void *Timstat(void *argument)
cdoAbort("Too many arguments!");
}
cmplen = DATE_LEN - cdoOperatorF2(operatorID);
int cmplen = DATE_LEN - comparelen;
int streamID1 = streamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
if ( cdoOperatorF2(operatorID) == 31 ) vlistDefNtsteps(vlistID2, 1);
if ( cmplen == 0 ) vlistDefNtsteps(vlistID2, 1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
if ( taxisInqType(taxisID2) == TAXIS_FORECAST ) taxisDefType(taxisID2, TAXIS_RELATIVE);
vlistDefTaxis(vlistID2, taxisID2);
int nvars = vlistNvars(vlistID1);
int nrecords = vlistNrecs(vlistID1);
if ( cmplen == 0 && CDO_Reduce_Dim )
for ( varID = 0; varID < nvars; ++varID )
vlistDefVarTsteptype(vlistID2, varID, TSTEP_CONSTANT);
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
int nvars = vlistNvars(vlistID1);
int nrecords = vlistNrecs(vlistID1);
if ( cdoDiag )
{
char filename[8192];
......
......@@ -1005,6 +1005,7 @@ int parse_options_long(int argc, char *argv[])
{ "hdr_pad", required_argument, &lnetcdf_hdr_pad, 1 },
{ "use_fftw", required_argument, &luse_fftw, 1 },
{ "remap_genweights", required_argument, &lremap_genweights, 1 },
{ "reduce_dim", no_argument, &CDO_Reduce_Dim, 1 },
{ "no_warnings", no_argument, &_Verbose, 0 },
{ "format", required_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
......@@ -1358,6 +1359,7 @@ int main(int argc, char *argv[])
memExitOnError();
_Verbose = 1;
CDO_Reduce_Dim = 0;
/* mallopt(M_MMAP_MAX, 0); */
......
......@@ -83,6 +83,7 @@ int CDO_Color = FALSE;
int CDO_Use_FFTW = TRUE;
int cdoDiag = FALSE;
int CDO_Reduce_Dim = FALSE;
int CDO_Append_History = TRUE;
int CDO_Reset_History = FALSE;
......
......@@ -36,21 +36,19 @@
#define UNCHANGED_RECORD (processSelf() == 0 && cdoStreamName(0)->argv[0][0] != '-' && cdoRegulargrid == FALSE && cdoDefaultFileType == -1 && cdoDefaultDataType == -1 && cdoDefaultByteorder == -1 )
/* refactor: moved here from *.c files */
extern char *Progname; // refactor: process.c defined in cdo.c
extern char *cdoGridSearchDir; // refactor: gridreference.c defined in cd.c
extern int CDO_Append_History; // refactor: history.c defined in cdo.c
extern int CDO_Reset_History; // refactor: history.c defined in cdo.c
extern char *Progname;
extern char *cdoGridSearchDir;
extern int CDO_Reduce_Dim;
extern int CDO_Append_History;
extern int CDO_Reset_History;
extern int timer_read, timer_write; // refactor: both pstream.c and CDIread.c CDIwrite.c defined in cdo.c
/* refactor: moved from cdo.c */
extern int CDO_optind;
extern char *CDO_optarg;
extern int CDO_opterr;
extern int remap_genweights;
/* refactor: moved from cdo.h */
extern char *cdoExpName; // refactor: added keyword extern
extern char *cdoExpName;
extern int ompNumThreads;
extern int stdin_is_tty;
......@@ -61,8 +59,8 @@ extern int cdoDefaultFileType;
extern int cdoDefaultDataType;
extern int cdoDefaultByteorder;
extern int cdoDefaultTableID;
extern int cdoDefaultInstID; // refactor: moved here from institution.c
extern int cdoDefaultTimeType; // refactor: moved here from pstream.c
extern int cdoDefaultInstID;
extern int cdoDefaultTimeType;
extern int cdoLogOff;
extern int cdoLockIO;
......
Supports Markdown
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