Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
fb9b620f
Commit
fb9b620f
authored
Jun 17, 2010
by
Uwe Schulzweida
Browse files
Added operator setvals
parent
e774385a
Changes
12
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
fb9b620f
...
...
@@ -151,6 +151,7 @@ doc/tex/mod/Remap -text
doc/tex/mod/Remapeta -text
doc/tex/mod/Remapgrid -text
doc/tex/mod/Replace -text
doc/tex/mod/Replacevalues -text
doc/tex/mod/Rotuv -text
doc/tex/mod/Runpctl -text
doc/tex/mod/Runstat -text
...
...
@@ -165,7 +166,6 @@ doc/tex/mod/Setgatt -text
doc/tex/mod/Setgrid -text
doc/tex/mod/Sethalo -text
doc/tex/mod/Setmiss -text
doc/tex/mod/Setrange -text
doc/tex/mod/Settime -text
doc/tex/mod/Setzaxis -text
doc/tex/mod/Showinfo -text
...
...
ChangeLog
View file @
fb9b620f
2010-06-17 Etienne Tourigny <tourigny@sca.uqam.ca>
* Added operator setvals - Set list of old values to new values
2010-05-18 Cedrick Ansorge <Cedrick.Ansorge.zmaw.de>
* Added operator eof - Calculate EOFs in spatial or time space
...
...
OPERATORS
View file @
fb9b620f
...
...
@@ -419,8 +419,9 @@ Operator catalog:
Gradsdes gradsdes1 GrADS data descriptor file (version 1 GRIB map)
Gradsdes gradsdes2 GrADS data descriptor file (version 2 GRIB map)
Smooth9 smooth9 9 point smoothing
Setrange setrtoc Set range to constant
Setrange setrtoc2 Set range to constant others to constant2
Replacevalues setvals Set list of old values to new values
Replacevalues setrtoc Set range to constant
Replacevalues setrtoc2 Set range to constant others to constant2
Timsort timsort Sort over the time
Vargen const Create a constant field
Vargen random Create a field with random numbers
...
...
config/default
View file @
fb9b620f
...
...
@@ -89,13 +89,13 @@ case "${HOSTNAME}" in
${
CONFPATH
}
configure
--prefix
=
$HOME
/local
--exec_prefix
=
$HOME
/local/etch-ia32
\
--with-jasper
=
/sw/etch-ia32/jasper-1.900.1
\
--with-grib_api
=
/scratch/local2/m214003/local
\
--with-netcdf
=
/sw/etch-ia32/netcdf-4.
1
.1
-gcc
\
--with-netcdf
=
/sw/etch-ia32/netcdf-4.
0
.1
\
--with-hdf5
=
/sw/etch-ia32/hdf5-1.8.4-threadsafe
\
--with-zlib
=
/sw/etch-ia32/zlib-1.2.3
\
--with-szlib
=
$HOME
/local/etch-ia32
\
--with-proj
=
/sw/etch-ia32/proj-4.6.0
\
LIBS
=
"-ljpeg"
\
CC
=
gcc
CFLAGS
=
"-g -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2
-static
"
CC
=
gcc
CFLAGS
=
"-g -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2"
else
${
CONFPATH
}
configure
--prefix
=
$HOME
/local
--exec_prefix
=
$HOME
/local/etch-ia32
\
--program-suffix
=
_
${
SGE_SUFFIX
}
\
...
...
doc/cdo_refcard.pdf
View file @
fb9b620f
No preview for this file type
doc/tex/Modules
View file @
fb9b620f
...
...
@@ -96,7 +96,7 @@ Output Import/Export
Gridcell Miscellaneous
Gradsdes Miscellaneous
Smooth9 Miscellaneous
Setrange
Miscellaneous
Replacevalues
Miscellaneous
Timsort Miscellaneous
Vargen Miscellaneous
Rotuv Miscellaneous
...
...
doc/tex/mod/
Setrange
→
doc/tex/mod/
Replacevalues
View file @
fb9b620f
@BeginModule
@Name =
Setrange
@Title =
Set range to constant
@Name =
Replacevalues
@Title =
Replace variable values
@Section = Miscellaneous
@Arguments = ifile ofile
@Operators = setrtoc setrtoc2
@Operators =
setvals
setrtoc setrtoc2
@BeginDescription
This module sets part of a field to a constant value or missing values.
Which part of the field is set depends on the chosen operator.
This module replaces old variable values with new values, depending on the operator.
@EndDescription
@EndModule
@BeginOperator_setvals
@Title = Set list of old values to new values
@Parameter = oldval newval [...]
@BeginDescription
Supply a list of n pairs of old and new values.
@EndDescription
@EndOperator
@BeginOperator_setrtoc
@Title = Set range to constant
@Parameter = rmin rmax c
...
...
@@ -58,14 +67,16 @@ o(t,x) = \left\{
@EndOperator
@BeginParameter rmax
@BeginParameter
@Item = oldval,newval,...
FLOAT Pairs of old and new values
@Item = rmin
FLOAT Lower bound
FLOAT
Lower bound
@Item = rmax
FLOAT Upper bound
FLOAT
Upper bound
@Item = c
FLOAT New value - inside range
FLOAT
New value - inside range
@Item = c2
FLOAT New value - outside range
FLOAT
New value - outside range
@EndParameter
src/Makefile.am
View file @
fb9b620f
...
...
@@ -80,6 +80,7 @@ cdo_SOURCES = Arith.c \
Remap.c
\
Remapeta.c
\
Replace.c
\
Replacevalues.c
\
Rotuv.c
\
Runpctl.c
\
Runstat.c
\
...
...
@@ -98,7 +99,6 @@ cdo_SOURCES = Arith.c \
Setgrid.c
\
Sethalo.c
\
Setmiss.c
\
Setrange.c
\
Setrcaname.c
\
Settime.c
\
Setzaxis.c
\
...
...
src/Makefile.in
View file @
fb9b620f
...
...
@@ -90,13 +90,13 @@ am_cdo_OBJECTS = Arith.$(OBJEXT) Arithc.$(OBJEXT) Arithdays.$(OBJEXT) \
Mrotuvb.
$(OBJEXT)
Ninfo.
$(OBJEXT)
Nmltest.
$(OBJEXT)
\
Output.
$(OBJEXT)
Outputgmt.
$(OBJEXT)
Pinfo.
$(OBJEXT)
\
Pressure.
$(OBJEXT)
Regres.
$(OBJEXT)
Remap.
$(OBJEXT)
\
Remapeta.
$(OBJEXT)
Replace.
$(OBJEXT)
R
otuv
.
$(OBJEXT)
\
Runpctl.
$(OBJEXT)
Runstat.
$(OBJEXT)
Seascount.
$(OBJEXT)
\
Seaspctl.
$(OBJEXT)
Seasstat.
$(OBJEXT)
Selbox.
$(OBJEXT)
\
Sel
ect
.
$(OBJEXT)
Sel
var
.
$(OBJEXT)
Sel
operato
r.
$(OBJEXT)
\
Sel
rec
.
$(OBJEXT)
Sel
time
.
$(OBJEXT)
Se
t
.
$(OBJEXT)
\
Setbox.
$(OBJEXT)
Setgatt.
$(OBJEXT)
Setgrid.
$(OBJEXT)
\
Sethalo.
$(OBJEXT)
Setmiss.
$(OBJEXT)
Setrange.
$(OBJEXT)
\
Remapeta.
$(OBJEXT)
Replace.
$(OBJEXT)
R
eplacevalues
.
$(OBJEXT)
\
Rotuv.
$(OBJEXT)
Runpctl.
$(OBJEXT)
Runstat.
$(OBJEXT)
\
Seascount.
$(OBJEXT)
Seaspctl.
$(OBJEXT)
Seasstat.
$(OBJEXT)
\
Sel
box
.
$(OBJEXT)
Sel
ect
.
$(OBJEXT)
Sel
va
r.
$(OBJEXT)
\
Sel
operator
.
$(OBJEXT)
Sel
rec
.
$(OBJEXT)
Se
ltime
.
$(OBJEXT)
\
Set.
$(OBJEXT)
Setbox.
$(OBJEXT)
Setgatt.
$(OBJEXT)
\
Setgrid.
$(OBJEXT)
Sethalo.
$(OBJEXT)
Setmiss.
$(OBJEXT)
\
Setrcaname.
$(OBJEXT)
Settime.
$(OBJEXT)
Setzaxis.
$(OBJEXT)
\
Showinfo.
$(OBJEXT)
Sinfo.
$(OBJEXT)
Smooth9.
$(OBJEXT)
\
Sort.
$(OBJEXT)
Sorttimestamp.
$(OBJEXT)
Specinfo.
$(OBJEXT)
\
...
...
@@ -356,6 +356,7 @@ cdo_SOURCES = Arith.c \
Remap.c
\
Remapeta.c
\
Replace.c
\
Replacevalues.c
\
Rotuv.c
\
Runpctl.c
\
Runstat.c
\
...
...
@@ -374,7 +375,6 @@ cdo_SOURCES = Arith.c \
Setgrid.c
\
Sethalo.c
\
Setmiss.c
\
Setrange.c
\
Setrcaname.c
\
Settime.c
\
Setzaxis.c
\
...
...
@@ -725,6 +725,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Remap.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Remapeta.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Replace.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Replacevalues.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Rotuv.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Runpctl.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Runstat.Po@am__quote@
...
...
@@ -743,7 +744,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Setgrid.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Sethalo.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Setmiss.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Setrange.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Setrcaname.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Settime.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/Setzaxis.Po@am__quote@
...
...
src/Replacevalues.c
View file @
fb9b620f
...
...
@@ -18,6 +18,7 @@
/*
This module contains the following operators:
Setvals setvals Set list of old values to new values
Setrtoc setrtoc Set range to new value
Setrtoc2 setrtoc2 Set range to new value others to value2
*/
...
...
@@ -33,7 +34,7 @@
#include
"cdo.h"
#include
"cdo_int.h"
#include
"pstream.h"
#include
"list.h"
double
arg2val
(
char
*
arg
)
{
...
...
@@ -42,10 +43,10 @@ double arg2val(char *arg)
else
return
atof
(
arg
);
}
void
*
Setrange
(
void
*
argument
)
void
*
Replacevalues
(
void
*
argument
)
{
static
char
func
[]
=
"
Setrange
"
;
int
SETRTOC
,
SETRTOC2
;
static
char
func
[]
=
"
Replacevalues
"
;
int
SETVALS
,
SETRTOC
,
SETRTOC2
;
int
operatorID
;
int
streamID1
,
streamID2
;
int
gridsize
;
...
...
@@ -54,7 +55,10 @@ void *Setrange(void *argument)
int
varID
,
levelID
;
int
vlistID1
,
vlistID2
;
int
nmiss
;
int
i
;
int
nvals
;
LIST
*
flist
=
listNew
(
FLT_LIST
);
double
*
fltarr
=
NULL
;
int
i
,
j
;
double
missval
;
double
rmin
=
0
,
rmax
=
0
;
double
*
array
;
...
...
@@ -63,6 +67,7 @@ void *Setrange(void *argument)
cdoInitialize
(
argument
);
SETVALS
=
cdoOperatorAdd
(
"setvals"
,
0
,
0
,
"I1,O1,...,In,On"
);
SETRTOC
=
cdoOperatorAdd
(
"setrtoc"
,
0
,
0
,
"range (min, max), value"
);
SETRTOC2
=
cdoOperatorAdd
(
"setrtoc2"
,
0
,
0
,
"range (min, max), value1, value2"
);
...
...
@@ -70,7 +75,15 @@ void *Setrange(void *argument)
operatorInputArg
(
cdoOperatorEnter
(
operatorID
));
if
(
operatorID
==
SETRTOC
)
if
(
operatorID
==
SETVALS
)
{
nvals
=
args2fltlist
(
operatorArgc
(),
operatorArgv
(),
flist
);
if
(
nvals
<
2
)
cdoAbort
(
"Too few arguments!"
);
if
(
nvals
%
2
!=
0
)
cdoAbort
(
"Need pairs of arguments!"
);
fltarr
=
(
double
*
)
listArrayPtr
(
flist
);
nvals
=
nvals
/
2
;
}
else
if
(
operatorID
==
SETRTOC
)
{
operatorCheckArgc
(
3
);
rmin
=
arg2val
(
operatorArgv
()[
0
]);
...
...
@@ -120,7 +133,25 @@ void *Setrange(void *argument)
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistID1
,
varID
));
missval
=
vlistInqVarMissval
(
vlistID1
,
varID
);
if
(
operatorID
==
SETRTOC
)
if
(
operatorID
==
SETVALS
)
{
for
(
i
=
0
;
i
<
gridsize
;
i
++
)
if
(
!
DBL_IS_EQUAL
(
array
[
i
],
missval
)
)
{
/* printf("\nelem %d val %f ",i,array[i]); */
for
(
j
=
0
;
j
<
nvals
;
j
++
)
{
if
(
DBL_IS_EQUAL
(
array
[
i
],
fltarr
[
j
*
2
]
)
)
{
array
[
i
]
=
fltarr
[
j
*
2
+
1
];
/* printf("j=%d %f %f ",j,fltarr[j*2],fltarr[j*2+1]); */
break
;
}
}
}
}
else
if
(
operatorID
==
SETRTOC
)
{
for
(
i
=
0
;
i
<
gridsize
;
i
++
)
if
(
!
DBL_IS_EQUAL
(
array
[
i
],
missval
)
)
...
...
@@ -158,6 +189,8 @@ void *Setrange(void *argument)
if
(
array
)
free
(
array
);
listDelete
(
flist
);
cdoFinish
();
return
(
0
);
...
...
src/modules.c
View file @
fb9b620f
...
...
@@ -114,6 +114,7 @@ void *Regres(void *argument);
void
*
Remap
(
void
*
argument
);
void
*
Remapeta
(
void
*
argument
);
void
*
Replace
(
void
*
argument
);
void
*
Replacevalues
(
void
*
argument
);
void
*
Rotuv
(
void
*
argument
);
void
*
Runpctl
(
void
*
argument
);
void
*
Runstat
(
void
*
argument
);
...
...
@@ -132,7 +133,6 @@ void *Setgatt(void *argument);
void
*
Setgrid
(
void
*
argument
);
void
*
Sethalo
(
void
*
argument
);
void
*
Setmiss
(
void
*
argument
);
void
*
Setrange
(
void
*
argument
);
void
*
Setrcaname
(
void
*
argument
);
void
*
Settime
(
void
*
argument
);
void
*
Setzaxis
(
void
*
argument
);
...
...
@@ -324,6 +324,7 @@ void *Wct(void *argument);
#define GenweightsOperators {"gencon", "genbil", "genbic", "gendis", "gennn", "genlaf", "gencon2"}
#define RemapetaOperators {"remapeta", "remapeta_s", "remapeta_z"}
#define ReplaceOperators {"replace"}
#define ReplacevaluesOperators {"setvals", "setrtoc", "setrtoc2"}
#define RotuvOperators {"rotuvb"}
#define RunpctlOperators {"runpctl"}
#define RunstatOperators {"runmin", "runmax", "runsum", "runmean", "runavg", "runvar", "runstd"}
...
...
@@ -344,7 +345,6 @@ void *Wct(void *argument);
#define SetgridOperators {"setgrid", "setgridtype", "setgridarea"}
#define SethaloOperators {"sethalo", "tpnhalo"}
#define SetmissOperators {"setmissval", "setctomiss", "setmisstoc", "setrtomiss", "setvrange"}
#define SetrangeOperators {"setrtoc", "setrtoc2"}
#define SetrcanameOperators {"setrcaname"}
#define SettimeOperators {"setyear", "setmon", "setday", "setdate", "settime", "settunits", \
"settaxis", "setreftime", "setcalendar", "shifttime"}
...
...
@@ -551,6 +551,7 @@ static modules_t Modules[] =
{
Remap
,
GenweightsHelp
,
GenweightsOperators
,
CDI_REAL
,
1
,
1
},
{
Remapeta
,
RemapetaHelp
,
RemapetaOperators
,
CDI_REAL
,
1
,
1
},
{
Replace
,
ReplaceHelp
,
ReplaceOperators
,
CDI_REAL
,
2
,
1
},
{
Replacevalues
,
ReplacevaluesHelp
,
ReplacevaluesOperators
,
CDI_REAL
,
1
,
1
},
{
Rotuv
,
RotuvHelp
,
RotuvOperators
,
CDI_REAL
,
1
,
1
},
{
Runpctl
,
RunpctlHelp
,
RunpctlOperators
,
CDI_REAL
,
1
,
1
},
{
Runstat
,
RunstatHelp
,
RunstatOperators
,
CDI_REAL
,
1
,
1
},
...
...
@@ -568,7 +569,6 @@ static modules_t Modules[] =
{
Setgatt
,
SetgattHelp
,
SetgattOperators
,
CDI_REAL
,
1
,
1
},
{
Setgrid
,
SetgridHelp
,
SetgridOperators
,
CDI_REAL
,
1
,
1
},
{
Sethalo
,
SethaloHelp
,
SethaloOperators
,
CDI_REAL
,
1
,
1
},
{
Setrange
,
SetrangeHelp
,
SetrangeOperators
,
CDI_REAL
,
1
,
1
},
{
Setrcaname
,
NULL
,
SetrcanameOperators
,
CDI_REAL
,
1
,
1
},
{
Setmiss
,
SetmissHelp
,
SetmissOperators
,
CDI_REAL
,
1
,
1
},
{
Settime
,
SettimeHelp
,
SettimeOperators
,
CDI_REAL
,
1
,
1
},
...
...
src/operator_help.h
View file @
fb9b620f
...
...
@@ -3304,19 +3304,21 @@ static char *Smooth9Help[] = {
NULL
};
static
char
*
Setrange
Help
[]
=
{
static
char
*
Replacevalues
Help
[]
=
{
"NAME"
,
" setrtoc, setrtoc2 -
Set range to constant
"
,
"
setvals,
setrtoc, setrtoc2 -
Replace variable values
"
,
""
,
"SYNOPSIS"
,
" setvals,oldval,newval[,...] ifile ofile"
,
" setrtoc,rmin,rmax,c ifile ofile"
,
" setrtoc2,rmin,rmax,c,c2 ifile ofile"
,
""
,
"DESCRIPTION"
,
" This module sets part of a field to a constant value or missing values. "
,
" Which part of the field is set depends on the chosen operator."
,
" This module replaces old variable values with new values, depending on the operator."
,
""
,
"OPERATORS"
,
" setvals Set list of old values to new values"
,
" Supply a list of n pairs of old and new values."
,
" setrtoc Set range to constant"
,
" / c if i(t,x) GE rmin AND i(t,x) LE rmax"
,
" o(t,x) = "
,
...
...
@@ -3327,10 +3329,11 @@ static char *SetrangeHelp[] = {
"
\\
c2 if i(t,x) LT rmin AND i(t,x) GT rmax"
,
""
,
"PARAMETER"
,
" rmin FLOAT Lower bound"
,
" rmax FLOAT Upper bound"
,
" c FLOAT New value - inside range"
,
" c2 FLOAT New value - outside range"
,
" oldval,newval,... FLOAT Pairs of old and new values"
,
" rmin FLOAT Lower bound"
,
" rmax FLOAT Upper bound"
,
" c FLOAT New value - inside range"
,
" c2 FLOAT New value - outside range"
,
NULL
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment