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
d97308a3
Commit
d97308a3
authored
Sep 16, 2016
by
Uwe Schulzweida
Browse files
Added module Shiftxy.
parent
62bf3b12
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Makefile.am
View file @
d97308a3
...
...
@@ -298,6 +298,7 @@ cdo_SOURCES += Adisit.c \
Setrcaname.c
\
Settime.c
\
Setzaxis.c
\
Shiftxy.c
\
Showinfo.c
\
Sinfo.c
\
Smooth.c
\
...
...
src/Makefile.in
View file @
d97308a3
...
...
@@ -216,8 +216,8 @@ am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Adisit.$(OBJEXT) \
cdo-Sethalo.$(OBJEXT) cdo-Setmiss.$(OBJEXT) \
cdo-Setpartab.$(OBJEXT) cdo-Setrcaname.$(OBJEXT) \
cdo-Settime.$(OBJEXT) cdo-Setzaxis.$(OBJEXT) \
cdo-Sh
owinfo
.
$(OBJEXT)
cdo-Sinfo.
$(OBJEXT)
\
cdo-Smooth.
$(OBJEXT)
cdo-Sort.
$(OBJEXT)
\
cdo-Sh
iftxy
.$(OBJEXT) cdo-S
how
info.$(OBJEXT) \
cdo-Sinfo.$(OBJEXT)
cdo-Smooth.$(OBJEXT) cdo-Sort.$(OBJEXT) \
cdo-Sorttimestamp.$(OBJEXT) cdo-Specinfo.$(OBJEXT) \
cdo-Spectral.$(OBJEXT) cdo-Spectrum.$(OBJEXT) \
cdo-Split.$(OBJEXT) cdo-Splitrec.$(OBJEXT) \
...
...
@@ -567,23 +567,23 @@ cdo_SOURCES = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
Seascount.c Seaspctl.c Seasstat.c Selbox.c Selindex.c Select.c \
Seloperator.c Selrec.c Seltime.c Selvar.c Set.c Setbox.c \
Setgatt.c Setgrid.c Sethalo.c Setmiss.c Setpartab.c \
Setrcaname.c Settime.c Setzaxis.c Showinfo.c Sinfo.c
Smooth.c
\
Sort.c Sorttimestamp.c Specinfo.c Spectral.c
Spectrum.c
\
Split.c Splitrec.c Splitsel.c Splittime.c
Splityear.c
\
Subtrend.c Tee.c Templates.c Test.c Tests.c
Timcount.c
\
Timpctl.c Timselpctl.c Timselstat.c Timsort.c
Timstat.c
\
Timstat2.c Timstat3.c Tinfo.c Tocomplex.c
Transpose.c Trend.c
\
Trms.c Tstepcount.c Vargen.c Varrms.c
Vertintml.c Vertintap.c
\
Vert
stat
.c Vert
cum
.c Vert
wind
.c Ver
ifygrid.c Wct.c W
ind.c
\
Writegrid.c Writerandom.c XTimstat.c
YAR.c Yearmonstat.c
\
Ydayarith.c Ydaypctl.c Ydaystat.c
Ydrunpctl.c Ydrunstat.c
\
Yhourarith.c Yhourstat.c Ymonarith.c
Ymonpctl.c Ymonstat.c
\
Yseaspctl.c Yseasstat.c Zonstat.c cdo.h
nearpt3c.h Magplot.c
\
Magvector.c Maggraph.c template_parser.h
template_parser.c
\
results_
template_parser.
h
results_template_parser.
c
\
magic
s_template_parser.
h
magics_template_parser.
c
\
StringUtilities.h StringUtilities.c
CdoMagicsMapper.h
\
CdoMagicsMapper.c
Setrcaname.c Settime.c Setzaxis.c
Shiftxy.c
Showinfo.c Sinfo.c \
Smooth.c
Sort.c Sorttimestamp.c Specinfo.c Spectral.c \
Spectrum.c
Split.c Splitrec.c Splitsel.c Splittime.c \
Splityear.c
Subtrend.c Tee.c Templates.c Test.c Tests.c \
Timcount.c
Timpctl.c Timselpctl.c Timselstat.c Timsort.c \
Timstat.c
Timstat2.c Timstat3.c Tinfo.c Tocomplex.c \
Transpose.c Trend.c
Trms.c Tstepcount.c Vargen.c Varrms.c \
Vert
intml
.c Vert
intap
.c Vert
stat
.c Ver
tcum.c Vertw
ind.c \
Verifygrid.c Wct.c Wind.c
Writegrid.c Writerandom.c XTimstat.c \
YAR.c Yearmonstat.c
Ydayarith.c Ydaypctl.c Ydaystat.c \
Ydrunpctl.c Ydrunstat.c
Yhourarith.c Yhourstat.c Ymonarith.c \
Ymonpctl.c Ymonstat.c
Yseaspctl.c Yseasstat.c Zonstat.c cdo.h \
nearpt3c.h Magplot.c
Magvector.c Maggraph.c template_parser.h \
template_parser.
c
results_template_parser.
h
\
result
s_template_parser.
c
magics_template_parser.
h
\
magics_template_parser.c
StringUtilities.h StringUtilities.c \
CdoMagicsMapper.h
CdoMagicsMapper.c
#endif
cdo_CPPFLAGS = -I$(top_srcdir)/libcdi/src
cdo_LDADD = libcdo.la $(top_builddir)/libcdi/src/libcdi.la
...
...
@@ -906,6 +906,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Setrcaname.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Settime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Setzaxis.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Shiftxy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Showinfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Sinfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Smooth.Po@am__quote@
...
...
@@ -3513,6 +3514,20 @@ cdo-Setzaxis.obj: Setzaxis.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Setzaxis.obj `if test -f 'Setzaxis.c'; then $(CYGPATH_W) 'Setzaxis.c'; else $(CYGPATH_W) '$(srcdir)/Setzaxis.c'; fi`
cdo-Shiftxy.o: Shiftxy.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Shiftxy.o -MD -MP -MF $(DEPDIR)/cdo-Shiftxy.Tpo -c -o cdo-Shiftxy.o `test -f 'Shiftxy.c' || echo '$(srcdir)/'`Shiftxy.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Shiftxy.Tpo $(DEPDIR)/cdo-Shiftxy.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='Shiftxy.c' object='cdo-Shiftxy.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Shiftxy.o `test -f 'Shiftxy.c' || echo '$(srcdir)/'`Shiftxy.c
cdo-Shiftxy.obj: Shiftxy.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Shiftxy.obj -MD -MP -MF $(DEPDIR)/cdo-Shiftxy.Tpo -c -o cdo-Shiftxy.obj `if test -f 'Shiftxy.c'; then $(CYGPATH_W) 'Shiftxy.c'; else $(CYGPATH_W) '$(srcdir)/Shiftxy.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Shiftxy.Tpo $(DEPDIR)/cdo-Shiftxy.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='Shiftxy.c' object='cdo-Shiftxy.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Shiftxy.obj `if test -f 'Shiftxy.c'; then $(CYGPATH_W) 'Shiftxy.c'; else $(CYGPATH_W) '$(srcdir)/Shiftxy.c'; fi`
cdo-Showinfo.o: Showinfo.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Showinfo.o -MD -MP -MF $(DEPDIR)/cdo-Showinfo.Tpo -c -o cdo-Showinfo.o `test -f 'Showinfo.c' || echo '$(srcdir)/'`Showinfo.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Showinfo.Tpo $(DEPDIR)/cdo-Showinfo.Po
...
...
src/Mrotuv.c
View file @
d97308a3
...
...
@@ -146,7 +146,6 @@ void p_to_uv_grid(int nlon, int nlat, double *grid1x, double *grid1y,
{
int
i
,
j
,
jp1
,
ip1
;
/* interpolate scalar to u points */
for
(
j
=
0
;
j
<
nlat
;
j
++
)
for
(
i
=
0
;
i
<
nlon
;
i
++
)
...
...
src/Shiftxy.c
0 → 100644
View file @
d97308a3
/*
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2016 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
/*
This module contains the following operators:
Selbox sellonlatbox Select lon/lat box
Selbox selindexbox Select index box
*/
#include
<cdi.h>
#include
"cdo.h"
#include
"cdo_int.h"
#include
"grid.h"
#include
"pstream.h"
static
void
shiftx
(
bool
lcyclic
,
int
nshift
,
int
gridID
,
double
*
array1
,
double
*
array2
,
double
missval
)
{
int
nx
=
gridInqXsize
(
gridID
);
int
ny
=
gridInqYsize
(
gridID
);
for
(
int
i
=
0
;
i
<
nx
;
i
++
)
{
bool
is_cyclic
=
false
;
int
ins
=
i
+
nshift
%
nx
;
while
(
ins
>=
nx
)
{
ins
-=
nx
;
is_cyclic
=
true
;
}
while
(
ins
<
0
)
{
ins
+=
nx
;
is_cyclic
=
true
;
}
if
(
!
lcyclic
&&
is_cyclic
)
{
for
(
int
j
=
0
;
j
<
ny
;
j
++
)
array2
[
IX2D
(
j
,
ins
,
nx
)]
=
missval
;
}
else
{
for
(
int
j
=
0
;
j
<
ny
;
j
++
)
array2
[
IX2D
(
j
,
ins
,
nx
)]
=
array1
[
IX2D
(
j
,
i
,
nx
)];
}
}
}
static
void
shifty
(
bool
lcyclic
,
int
nshift
,
int
gridID
,
double
*
array1
,
double
*
array2
,
double
missval
)
{
int
nx
=
gridInqXsize
(
gridID
);
int
ny
=
gridInqYsize
(
gridID
);
for
(
int
j
=
0
;
j
<
ny
;
j
++
)
{
bool
is_cyclic
=
false
;
int
jns
=
j
+
nshift
%
ny
;
while
(
jns
>=
ny
)
{
jns
-=
ny
;
is_cyclic
=
true
;
}
while
(
jns
<
0
)
{
jns
+=
ny
;
is_cyclic
=
true
;
}
if
(
!
lcyclic
&&
is_cyclic
)
{
for
(
int
i
=
0
;
i
<
nx
;
i
++
)
array2
[
IX2D
(
jns
,
i
,
nx
)]
=
missval
;
}
else
{
for
(
int
i
=
0
;
i
<
nx
;
i
++
)
array2
[
IX2D
(
jns
,
i
,
nx
)]
=
array1
[
IX2D
(
j
,
i
,
nx
)];
}
}
}
void
*
Shiftxy
(
void
*
argument
)
{
int
nrecs
;
int
varID
,
levelID
;
int
nmiss
;
cdoInitialize
(
argument
);
int
SHIFTX
=
cdoOperatorAdd
(
"shiftx"
,
0
,
0
,
NULL
);
int
SHIFTY
=
cdoOperatorAdd
(
"shifty"
,
0
,
0
,
NULL
);
int
operatorID
=
cdoOperatorID
();
int
nshift
=
1
;
if
(
operatorArgc
()
>
0
)
{
operatorCheckArgc
(
1
);
nshift
=
parameter2int
(
operatorArgv
()[
0
]);
}
int
streamID1
=
streamOpenRead
(
cdoStreamName
(
0
));
int
vlistID1
=
streamInqVlist
(
streamID1
);
int
vlistID2
=
vlistDuplicate
(
vlistID1
);
int
taxisID1
=
vlistInqTaxis
(
vlistID1
);
int
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
int
nvars
=
vlistNvars
(
vlistID1
);
bool
*
vars
=
(
bool
*
)
Malloc
(
nvars
*
sizeof
(
bool
));
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
vars
[
varID
]
=
false
;
int
ngrids
=
vlistNgrids
(
vlistID1
);
for
(
int
index
=
0
;
index
<
ngrids
;
index
++
)
{
int
gridID1
=
vlistGrid
(
vlistID1
,
index
);
int
gridtype
=
gridInqType
(
gridID1
);
if
(
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_CURVILINEAR
||
(
gridtype
==
GRID_PROJECTION
&&
gridInqProjType
(
gridID1
)
==
CDI_PROJ_RLL
)
||
(
gridtype
==
GRID_GENERIC
&&
gridInqXsize
(
gridID1
)
>
0
&&
gridInqYsize
(
gridID1
)
>
0
)
)
{
if
(
operatorID
==
SHIFTX
)
{
}
/*
vlistChangeGridIndex(vlistID2, index, gridID2);
*/
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
if
(
gridID1
==
vlistInqVarGrid
(
vlistID1
,
varID
)
)
vars
[
varID
]
=
true
;
}
else
if
(
gridtype
==
GRID_GENERIC
&&
gridInqXsize
(
gridID1
)
<=
1
&&
gridInqYsize
(
gridID1
)
<=
1
)
{
}
else
{
cdoPrint
(
"Unsupported grid type: %s"
,
gridNamePtr
(
gridtype
));
if
(
gridtype
==
GRID_GAUSSIAN_REDUCED
)
cdoPrint
(
"Use option -R to convert Gaussian reduced grid to a regular grid!"
);
cdoAbort
(
"Unsupported grid type!"
);
}
}
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
if
(
vars
[
varID
]
)
break
;
if
(
varID
>=
nvars
)
cdoWarning
(
"No variables selected!"
);
int
streamID2
=
streamOpenWrite
(
cdoStreamName
(
1
),
cdoFiletype
());
streamDefVlist
(
streamID2
,
vlistID2
);
int
gridsize
=
vlistGridsizeMax
(
vlistID1
);
double
*
array1
=
(
double
*
)
Malloc
(
gridsize
*
sizeof
(
double
));
double
*
array2
=
(
double
*
)
Malloc
(
gridsize
*
sizeof
(
double
));
int
tsID
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
))
)
{
taxisCopyTimestep
(
taxisID2
,
taxisID1
);
streamDefTimestep
(
streamID2
,
tsID
);
for
(
int
recID
=
0
;
recID
<
nrecs
;
recID
++
)
{
streamInqRecord
(
streamID1
,
&
varID
,
&
levelID
);
streamReadRecord
(
streamID1
,
array1
,
&
nmiss
);
streamDefRecord
(
streamID2
,
varID
,
levelID
);
if
(
vars
[
varID
]
)
{
int
gridID1
=
vlistInqVarGrid
(
vlistID1
,
varID
);
int
gridsize
=
gridInqSize
(
gridID1
);
double
missval
=
vlistInqVarMissval
(
vlistID2
,
varID
);
if
(
operatorID
==
SHIFTX
)
shiftx
(
false
,
nshift
,
gridID1
,
array1
,
array2
,
missval
);
else
if
(
operatorID
==
SHIFTY
)
shifty
(
false
,
nshift
,
gridID1
,
array1
,
array2
,
missval
);
nmiss
=
0
;
for
(
int
i
=
0
;
i
<
gridsize
;
i
++
)
if
(
DBL_IS_EQUAL
(
array2
[
i
],
missval
)
)
nmiss
++
;
streamWriteRecord
(
streamID2
,
array2
,
nmiss
);
}
else
{
streamWriteRecord
(
streamID2
,
array1
,
nmiss
);
}
}
tsID
++
;
}
streamClose
(
streamID2
);
streamClose
(
streamID1
);
vlistDestroy
(
vlistID2
);
if
(
vars
)
Free
(
vars
);
if
(
array2
)
Free
(
array2
);
if
(
array1
)
Free
(
array1
);
cdoFinish
();
return
0
;
}
src/modules.c
View file @
d97308a3
...
...
@@ -163,6 +163,7 @@ void *Setpartab(void *argument);
void
*
Setrcaname
(
void
*
argument
);
void
*
Settime
(
void
*
argument
);
void
*
Setzaxis
(
void
*
argument
);
void
*
Shiftxy
(
void
*
argument
);
void
*
Showinfo
(
void
*
argument
);
void
*
Sinfo
(
void
*
argument
);
void
*
Smooth
(
void
*
argument
);
...
...
@@ -421,6 +422,7 @@ void *Maggraph(void *argument);
#define SettimeOperators {"setyear", "setmon", "setday", "setdate", "settime", "settunits", \
"settaxis", "settbounds", "setreftime", "setcalendar", "shifttime"}
#define SetzaxisOperators {"setzaxis", "genlevelbounds"}
#define ShiftxyOperators {"shiftx", "shifty"}
#define ShowinfoOperators {"showyear", "showmon", "showdate", "showtime", "showtimestamp", "showcode", "showunit", \
"showparam", "showname", "showstdname", "showlevel", "showltype", "showformat"}
#define SinfoOperators {"sinfo", "sinfop", "sinfon", "sinfoc", "seinfo", "seinfop", "seinfon", "seinfoc"}
...
...
@@ -700,6 +702,7 @@ static modules_t Modules[] =
{
Setrcaname
,
NULL
,
SetrcanameOperators
,
1
,
CDI_REAL
,
1
,
1
},
{
Settime
,
SettimeHelp
,
SettimeOperators
,
1
,
CDI_BOTH
,
1
,
1
},
{
Setzaxis
,
SetzaxisHelp
,
SetzaxisOperators
,
1
,
CDI_BOTH
,
1
,
1
},
{
Shiftxy
,
NULL
,
ShiftxyOperators
,
1
,
CDI_REAL
,
1
,
1
},
{
Showinfo
,
ShowinfoHelp
,
ShowinfoOperators
,
1
,
CDI_BOTH
,
1
,
0
},
{
Sinfo
,
SinfoHelp
,
SinfoOperators
,
1
,
CDI_BOTH
,
-
1
,
0
},
{
Smooth
,
SmoothHelp
,
SmoothOperators
,
1
,
CDI_REAL
,
1
,
1
},
...
...
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