Commit 84894527 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added operator splitparam - Split parameter identifiers

parent b8f08444
......@@ -3,6 +3,10 @@
* using CDI library version 1.5.0
* Version 1.5.0 released
2011-03-12 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Added operator splitparam - Split parameter identifiers
2011-03-11 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Added operator selparam - Select parameters by identifier
......@@ -10,7 +14,7 @@
* sinfo: changed output of table and code number to parameter identifier
* info: changed output of code number to parameter identifier
* diff: changed output of code number to parameter identifier
2011-03-09 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* setgrid: added parameter: dereference
......
......@@ -10,6 +10,7 @@ Version 1.5.0 (?? March 2011):
New operators:
* selparam: Select parameters by identifier
* delparam: Delete parameters by identifier
* splitparam: Split parameter identifiers
Changed operators:
* expr: added functions abs(), int(), nint(), sqr()
* sinfo: changed output of table and code number to parameter identifier
......
......@@ -44,6 +44,7 @@ Operator catalog:
Merge merge Merge datasets with different fields
Merge mergetime Merge datasets sorted by date and time
Split splitcode Split code numbers
Split splitparam Split parammeter identifiers
Split splitname Split variable names
Split splitlevel Split levels
Split splitgrid Split grids
......
......@@ -53,8 +53,9 @@ delname -delname \
delparam -delparam \
detrend -detrend \
diff -diff \
diffc -diffc \
diffn -diffn \
diffp -diffp \
diffv -diffv \
div -div \
divc -divc \
divdpm -divdpm \
......@@ -188,8 +189,9 @@ import_binary -import_binary \
import_cmsaf -import_cmsaf \
import_grads -import_grads \
info -info \
infoc -infoc \
infon -infon \
infop -infop \
infov -infov \
input -input \
inputext -inputext \
inputsrv -inputsrv \
......@@ -386,8 +388,9 @@ showtimestamp -showtimestamp \
showyear -showyear \
sin -sin \
sinfo -sinfo \
sinfoc -sinfoc \
sinfon -sinfon \
sinfop -sinfop \
sinfov -sinfov \
smooth9 -smooth9 \
sp2gp -sp2gp \
sp2gpl -sp2gpl \
......@@ -400,6 +403,7 @@ splithour -splithour \
splitlevel -splitlevel \
splitmon -splitmon \
splitname -splitname \
splitparam -splitparam \
splitrec -splitrec \
splitseas -splitseas \
splitsel -splitsel \
......
......@@ -53,8 +53,9 @@ delname \
delparam \
detrend \
diff \
diffc \
diffn \
diffp \
diffv \
div \
divc \
divdpm \
......@@ -188,8 +189,9 @@ import_binary \
import_cmsaf \
import_grads \
info \
infoc \
infon \
infop \
infov \
input \
inputext \
inputsrv \
......@@ -386,8 +388,9 @@ showtimestamp \
showyear \
sin \
sinfo \
sinfoc \
sinfon \
sinfop \
sinfov \
smooth9 \
sp2gp \
sp2gpl \
......@@ -400,6 +403,7 @@ splithour \
splitlevel \
splitmon \
splitname \
splitparam \
splitrec \
splitseas \
splitsel \
......
......@@ -53,8 +53,9 @@ delname -delname \
delparam -delparam \
detrend -detrend \
diff -diff \
diffc -diffc \
diffn -diffn \
diffp -diffp \
diffv -diffv \
div -div \
divc -divc \
divdpm -divdpm \
......@@ -188,8 +189,9 @@ import_binary -import_binary \
import_cmsaf -import_cmsaf \
import_grads -import_grads \
info -info \
infoc -infoc \
infon -infon \
infop -infop \
infov -infov \
input -input \
inputext -inputext \
inputsrv -inputsrv \
......@@ -386,8 +388,9 @@ showtimestamp -showtimestamp \
showyear -showyear \
sin -sin \
sinfo -sinfo \
sinfoc -sinfoc \
sinfon -sinfon \
sinfop -sinfop \
sinfov -sinfov \
smooth9 -smooth9 \
sp2gp -sp2gp \
sp2gpl -sp2gpl \
......@@ -400,6 +403,7 @@ splithour -splithour \
splitlevel -splitlevel \
splitmon -splitmon \
splitname -splitname \
splitparam -splitparam \
splitrec -splitrec \
splitseas -splitseas \
splitsel -splitsel \
......
......@@ -5,7 +5,7 @@
@Section = File operations
@Class = File operation
@Arguments = ifile obase
@Operators = splitcode splitname splitlevel splitgrid splitzaxis splittabnum
@Operators = splitcode splitparam splitname splitlevel splitgrid splitzaxis splittabnum
@BeginDescription
This module splits @file{ifile} into pieces. The output files will be named @file{<obase><xxx><suffix>}
......@@ -25,6 +25,16 @@ Splits a dataset into pieces, one for each different code number.
@EndOperator
@BeginOperator_splitparam
@Title = Split parammeter identifiers
@BeginDescription
Splits a dataset into pieces, one for each different parammeter identifier.
@file{xxx} will be a string with the parammeter identifier.
@EndDescription
@EndOperator
@BeginOperator_splitname
@Title = Split variable names
......
......@@ -19,7 +19,8 @@
This module contains the following operators:
Split splitcode Split codes
Split splitname Split variables
Split splitparam Split parameters
Split splitname Split variables
Split splitlevel Split levels
Split splitgrid Split grids
Split splitzaxis Split zaxis
......@@ -35,12 +36,12 @@
void *Split(void *argument)
{
int SPLITCODE, SPLITNAME, SPLITLEVEL, SPLITGRID, SPLITZAXIS, SPLITTABNUM;
int SPLITCODE, SPLITPARAM, SPLITNAME, SPLITLEVEL, SPLITGRID, SPLITZAXIS, SPLITTABNUM;
int operatorID;
int nchars;
int streamID1;
int varID;
int code, tabnum;
int code, tabnum, param;
int nrecs, nvars, nzaxis, nlevs;
int tsID, recID, levelID, zaxisID, levID;
int varID2, levelID2;
......@@ -61,6 +62,7 @@ void *Split(void *argument)
cdoInitialize(argument);
SPLITCODE = cdoOperatorAdd("splitcode", 0, 0, NULL);
SPLITPARAM = cdoOperatorAdd("splitparam", 0, 0, NULL);
SPLITNAME = cdoOperatorAdd("splitname", 0, 0, NULL);
SPLITLEVEL = cdoOperatorAdd("splitlevel", 0, 0, NULL);
SPLITGRID = cdoOperatorAdd("splitgrid", 0, 0, NULL);
......@@ -153,6 +155,63 @@ void *Split(void *argument)
}
if ( codes ) free(codes);
}
else if ( operatorID == SPLITPARAM )
{
char paramstr[32];
int *params = NULL;
nsplit = 0;
for ( varID = 0; varID < nvars; varID++ )
{
param = vlistInqVarParam(vlistID1, varID);
for ( index = 0; index < varID; index++ )
if ( param == vlistInqVarParam(vlistID1, index) ) break;
if ( index == varID )
{
itmp[nsplit] = param;
nsplit++;
}
}
params = (int *) malloc(nsplit*sizeof(int));
vlistIDs = (int *) malloc(nsplit*sizeof(int));
streamIDs = (int *) malloc(nsplit*sizeof(int));
memcpy(params, itmp, nsplit*sizeof(int));
for ( index = 0; index < nsplit; index++ )
{
vlistClearFlag(vlistID1);
for ( varID = 0; varID < nvars; varID++ )
{
param = vlistInqVarParam(vlistID1, varID);
zaxisID = vlistInqVarZaxis(vlistID1, varID);
nlevs = zaxisInqSize(zaxisID);
if ( params[index] == param )
{
for ( levID = 0; levID < nlevs; levID++ )
{
vlistDefIndex(vlistID1, varID, levID, index);
vlistDefFlag(vlistID1, varID, levID, TRUE);
}
}
}
vlistID2 = vlistCreate();
vlistCopyFlag(vlistID2, vlistID1);
vlistIDs[index] = vlistID2;
cdiParamToString(params[index], paramstr, sizeof(paramstr));
filename[nchars] = '\0';
strcat(filename, paramstr);
if ( filesuffix[0] )
strcat(filename, filesuffix);
streamIDs[index] = streamOpenWrite(filename, cdoFiletype());
streamDefVlist(streamIDs[index], vlistIDs[index]);
}
if ( params ) free(params);
}
else if ( operatorID == SPLITTABNUM )
{
int *tabnums = NULL;
......@@ -407,7 +466,6 @@ void *Split(void *argument)
/*
printf("%d %d %d %d %d %d\n", index, vlistID2, varID, levelID, varID2, levelID2);
*/
streamDefRecord(streamIDs[index], varID2, levelID2);
if ( lcopy )
{
......
......@@ -377,7 +377,7 @@ void *Wct(void *argument);
#define SpecinfoOperators {"specinfo"}
#define SpectralOperators {"gp2sp", "gp2spl", "sp2gp", "sp2gpl", "sp2sp", "spcut"}
#define SpectrumOperators {"spectrum"}
#define SplitOperators {"splitcode", "splitname", "splitlevel", "splitgrid", "splitzaxis", "splittabnum"}
#define SplitOperators {"splitcode", "splitparam", "splitname", "splitlevel", "splitgrid", "splitzaxis", "splittabnum"}
#define SplitrecOperators {"splitrec"}
#define SplitselOperators {"splitsel"}
#define SplittimeOperators {"splithour", "splitday", "splitmon", "splitseas"}
......
......@@ -245,8 +245,8 @@ static char *MergeHelp[] = {
static char *SplitHelp[] = {
"NAME",
" splitcode, splitname, splitlevel, splitgrid, splitzaxis, splittabnum - ",
" Split a dataset",
" splitcode, splitparam, splitname, splitlevel, splitgrid, splitzaxis, ",
" splittabnum - Split a dataset",
"",
"SYNOPSIS",
" <operator> ifile obase",
......@@ -260,6 +260,9 @@ static char *SplitHelp[] = {
" splitcode Split code numbers",
" Splits a dataset into pieces, one for each different code number.",
" xxx will have three digits with the code number.",
" splitparam Split parammeter identifiers",
" Splits a dataset into pieces, one for each different parammeter identifier.",
" xxx will be a string with the parammeter identifier.",
" splitname Split variable names",
" Splits a dataset into pieces, one for each variable name.",
" xxx will be a string with the variable name.",
......@@ -358,8 +361,8 @@ static char *SelvarHelp[] = {
" delparam,params ifile ofile",
" selcode,codes ifile ofile",
" delcode,codes ifile ofile",
" selname,varnames ifile ofile",
" delname,varnames ifile ofile",
" selname,names ifile ofile",
" delname,names ifile ofile",
" selstdname,stdnames ifile ofile",
" sellevel,levels ifile ofile",
" sellevidx,levidx ifile ofile",
......@@ -376,7 +379,7 @@ static char *SelvarHelp[] = {
" selparam Select parameters by identifier",
" Selects all fields with parameter identifiers in a user given list.",
" delparam Delete parameters by identifier",
" Deletes all fields with parameter ideniifiers in a user given list.",
" Deletes all fields with parameter identifiers in a user given list.",
" selcode Select parameters by code number",
" Selects all fields with code numbers in a user given list.",
" delcode Delete parameters by code number",
......@@ -403,7 +406,7 @@ static char *SelvarHelp[] = {
"PARAMETER",
" params INTEGER Comma separated list of parameter identifiers",
" codes INTEGER Comma separated list of code numbers",
" varnames STRING Comma separated list of variable names",
" names STRING Comma separated list of variable names",
" stdnames STRING Comma separated list of standard names",
" levels FLOAT Comma separated list of levels",
" levidx INTEGER Comma separated list of index of levels",
......
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