Commit a830aec2 authored by Ralf Mueller's avatar Ralf Mueller
Browse files

Added new operators for computation of consecutive timesteps: consecsum + consects

refs #14
parent 0d59edfe
......@@ -38,7 +38,8 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/cdo.spec.in \
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
config/config.guess config/config.sub config/depcomp \
config/install-sh config/missing config/mkinstalldirs
config/install-sh config/ltmain.sh config/missing \
config/mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_c_package.m4 \
$(top_srcdir)/m4/acx_lang_check_include.m4 \
......
......@@ -4,14 +4,14 @@
Name: cdo
#BuildRequires:
Version: 1.4.1
Version: 1.4.5.1
Release: 1
Summary: Climate Data Operators
License: GNU GENERAL PUBLIC LICENSE Version 2, June 1991
Group: Productivity/Graphics/Visualization/Other
Requires: netcdf
Autoreqprov: on
URL: http://www.mpimet.mpg.de/fileadmin/software/cdo/
URL: http://code.zmaw.de/projects/cdo
Source0: cdo-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
......@@ -27,7 +27,7 @@ Authors:
Uwe Schulzweida, Uwe.Schulzweida@zmaw.de, is the main author.
Luis Kornblueh, Luis.Kornblueh@zmaw.de
Ralf Quast, Ralf.Quast@brockmann-consult.de
Send questions, comments and bug reports to Uwe.Schulzweida@zmaw.de
Send questions, comments and bug reports to <http://code.zmaw.de/projects/cdo>
%prep
......
......@@ -38,37 +38,38 @@ Arith Arithmetic
Monarith Arithmetic
Ymonarith Arithmetic
Arithdays Arithmetic
Consecstat Statistical values
Daypctl Statistical values
Daystat Statistical values
Ensstat Statistical values
Fldstat Statistical values
Zonstat Statistical values
Merstat Statistical values
Gridboxstat Statistical values
Vertstat Statistical values
Timselstat Statistical values
Timselpctl Statistical values
Runstat Statistical values
Runpctl Statistical values
Timstat Statistical values
Timpctl Statistical values
Hourstat Statistical values
Hourpctl Statistical values
Daystat Statistical values
Daypctl Statistical values
Monstat Statistical values
Hourstat Statistical values
Merstat Statistical values
Monpctl Statistical values
Yearstat Statistical values
Yearpctl Statistical values
Seasstat Statistical values
Monstat Statistical values
Runpctl Statistical values
Runstat Statistical values
Seaspctl Statistical values
Yhourstat Statistical values
Ydaystat Statistical values
Seasstat Statistical values
Timpctl Statistical values
Timselpctl Statistical values
Timselstat Statistical values
Timstat Statistical values
Vertstat Statistical values
Ydaypctl Statistical values
Ymonstat Statistical values
Ydaystat Statistical values
Ydrunpctl Statistical values
Ydrunstat Statistical values
Yearpctl Statistical values
Yearstat Statistical values
Yhourstat Statistical values
Ymonpctl Statistical values
Yseasstat Statistical values
Ymonstat Statistical values
Yseaspctl Statistical values
Ydrunstat Statistical values
Ydrunpctl Statistical values
Yseasstat Statistical values
Zonstat Statistical values
Fldcor Correlation
Timcor Correlation
Regres Regression
......
......@@ -19,6 +19,7 @@ cdo_SOURCES = Arith.c \
Cond2.c \
Condc.c \
Complextorect.c \
Consecstat.c \
Copy.c \
Deltime.c \
Detrend.c \
......
......@@ -69,15 +69,15 @@ am_cdo_OBJECTS = Arith.$(OBJEXT) Arithc.$(OBJEXT) Arithdays.$(OBJEXT) \
Arithlat.$(OBJEXT) Cat.$(OBJEXT) CDItest.$(OBJEXT) \
Change.$(OBJEXT) Change_e5slm.$(OBJEXT) Cloudlayer.$(OBJEXT) \
Comp.$(OBJEXT) Compc.$(OBJEXT) Cond.$(OBJEXT) Cond2.$(OBJEXT) \
Condc.$(OBJEXT) Complextorect.$(OBJEXT) Copy.$(OBJEXT) \
Deltime.$(OBJEXT) Detrend.$(OBJEXT) Diff.$(OBJEXT) \
Echam5ini.$(OBJEXT) Enlarge.$(OBJEXT) Enlargegrid.$(OBJEXT) \
Ensstat.$(OBJEXT) Eofcoeff.$(OBJEXT) Exprf.$(OBJEXT) \
Filedes.$(OBJEXT) Fillmiss.$(OBJEXT) Filter.$(OBJEXT) \
Fldrms.$(OBJEXT) Fldstat.$(OBJEXT) Fldstat2.$(OBJEXT) \
Fourier.$(OBJEXT) Gengrid.$(OBJEXT) Gradsdes.$(OBJEXT) \
Gridboxstat.$(OBJEXT) Gridcell.$(OBJEXT) Harmonic.$(OBJEXT) \
Histogram.$(OBJEXT) Importamsr.$(OBJEXT) \
Condc.$(OBJEXT) Complextorect.$(OBJEXT) Consecstat.$(OBJEXT) \
Copy.$(OBJEXT) Deltime.$(OBJEXT) Detrend.$(OBJEXT) \
Diff.$(OBJEXT) Echam5ini.$(OBJEXT) Enlarge.$(OBJEXT) \
Enlargegrid.$(OBJEXT) Ensstat.$(OBJEXT) Eofcoeff.$(OBJEXT) \
Exprf.$(OBJEXT) Filedes.$(OBJEXT) Fillmiss.$(OBJEXT) \
Filter.$(OBJEXT) Fldrms.$(OBJEXT) Fldstat.$(OBJEXT) \
Fldstat2.$(OBJEXT) Fourier.$(OBJEXT) Gengrid.$(OBJEXT) \
Gradsdes.$(OBJEXT) Gridboxstat.$(OBJEXT) Gridcell.$(OBJEXT) \
Harmonic.$(OBJEXT) Histogram.$(OBJEXT) Importamsr.$(OBJEXT) \
Importbinary.$(OBJEXT) Importcmsaf.$(OBJEXT) \
Importobs.$(OBJEXT) Info.$(OBJEXT) Input.$(OBJEXT) \
Intgrid.$(OBJEXT) Intgridtraj.$(OBJEXT) Intlevel.$(OBJEXT) \
......@@ -294,6 +294,7 @@ cdo_SOURCES = Arith.c \
Cond2.c \
Condc.c \
Complextorect.c \
Consecstat.c \
Copy.c \
Deltime.c \
Detrend.c \
......@@ -657,6 +658,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cond.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cond2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Condc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Consecstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Copy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Deltime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Detrend.Po@am__quote@
......
......@@ -127,6 +127,7 @@ void farfun(field_t *field1, field_t field2, int function);
void faradd(field_t *field1, field_t field2);
void farsum(field_t *field1, field_t field2);
void farsumq(field_t *field1, field_t field2);
void farsumtr(field_t *field1, field_t field2, double refval);
void farsub(field_t *field1, field_t field2);
void farmul(field_t *field1, field_t field2);
void fardiv(field_t *field1, field_t field2);
......
......@@ -119,6 +119,61 @@ void farsum(field_t *field1, field_t field2)
}
/*
* Compute the occurrence of values in field, if they do not equal refval.
* This can be used to compute the lengths of multiple periods in a timeseries.
* Missing field values are handled like refval, i.e. they stop a running
* period. If there is missing data in the occurence field, missing fields
* values do not change anything (they do not start a non-period by setting
* occurrence to zero).
*/
void farsumtr(field_t *occur, field_t field, double refval)
{
static char func[] = "farsumtr";
long i, len;
double omissval = occur->missval;
double *oarray = occur->ptr;
double fmissval = field.missval;
double *farray = field.ptr;
len = gridInqSize(occur->grid);
if ( len != gridInqSize(field.grid) )
cdoAbort("Fields have different gridsize (%s)", func);
if ( occur->nmiss > 0 || field.nmiss > 0 )
{
#if defined (_OPENMP)
#pragma omp parallel for default(shared) schedule(static)
#endif
for ( i = 0; i < len; i++ )
if ( !DBL_IS_EQUAL(farray[i], fmissval) )
{
if ( !DBL_IS_EQUAL(oarray[i], omissval) )
oarray[i] = (DBL_IS_EQUAL(farray[i], refval)) ? 0.0 : oarray[i] + 1.0;
else
oarray[i] = (DBL_IS_EQUAL(farray[i], refval)) ? 0.0 : 1.0;
}
else
{
if ( !DBL_IS_EQUAL(oarray[i], omissval) )
oarray[i] = 0.0;
}
occur->nmiss = 0;
for ( i = 0; i < len; i++ )
if ( DBL_IS_EQUAL(oarray[i], omissval) ) occur->nmiss++;
}
else
{
#if defined (_OPENMP)
#pragma omp parallel for default(shared)
#endif
for ( i = 0; i < len; i++ )
oarray[i] = (DBL_IS_EQUAL(farray[i], refval)) ? 0.0 : oarray[i] + 1.0;
}
}
void farsumq(field_t *field1, field_t field2)
{
static char func[] = "farsumq";
......
......@@ -53,6 +53,7 @@ void *Cond(void *argument);
void *Cond2(void *argument);
void *Condc(void *argument);
void *Complextorect(void *argument);
void *Consecstat(void *argument);
void *Copy(void *argument);
void *Deltime(void *argument);
void *Detrend(void *argument);
......@@ -250,6 +251,7 @@ void *Wct(void *argument);
#define Cond2Operators {"ifthenelse"}
#define CondcOperators {"ifthenc", "ifnotthenc"}
#define ComplextorectOperators {"complextorect"}
#define ConsecstatOperators {"consects", "consecsum"}
#define CopyOperators {"copy", "selall"}
#define DeltimeOperators {"delday", "del29feb"}
#define DetrendOperators {"detrend"}
......@@ -483,6 +485,7 @@ static modules_t Modules[] =
{ Cond2, Cond2Help, Cond2Operators, CDI_REAL, 3, 1 },
{ Condc, CondcHelp, CondcOperators, CDI_REAL, 1, 1 },
{ Complextorect, NULL, ComplextorectOperators, CDI_COMP, 1, 2 },
{ Consecstat, ConsecstatHelp, ConsecstatOperators, CDI_REAL, 1, 1 },
{ Copy, CopyHelp, CopyOperators, CDI_REAL, -1, 1 },
{ Deltime, NULL, DeltimeOperators, CDI_REAL, 1, 1 },
{ Detrend, DetrendHelp, DetrendOperators, CDI_REAL, 1, 1 },
......
This diff is collapsed.
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