Commit 6421dc45 authored by Fabian Wachsmann's avatar Fabian Wachsmann
Browse files

Added etccdi operators with specific output frequency

parent ee6a6b9c
......@@ -290,9 +290,11 @@ static void addWithFrequency(std::vector<std::string> &params, const char *opera
cdoOperatorAdd(operatorName, 0, 8, nullptr);
else if ( kv->values[0].compare("year") == 0 )
cdoOperatorAdd(operatorName, 0, 10, nullptr);
else
cdoAbort("Frequency '%s' unknown.", kv->values[0]);
}
else
cdoOperatorAdd(operatorName, 0, 31, nullptr);
cdoOperatorAdd(operatorName, 0, 31, nullptr);
}
void *EcaCfd(void *process)
......@@ -408,11 +410,22 @@ void *EcaCwdi(void *process)
ECA_REQUEST_2 request;
cdoInitialize(process);
cdoOperatorAdd("eca_cwdi", 0, 31, nullptr);
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
if ( operatorArgc() > 1 ) argT = parameter2double(cdoOperatorArgv(1));
if ( operatorArgc() > 2 )
{
auto params = cdoGetOperArgv();
params = std::vector<std::string>(params.begin() + 2, params.end());
addWithFrequency(params, "eca_cwdi");
argT = parameter2double(cdoOperatorArgv(1));
argN = parameter2int(cdoOperatorArgv(0));
}
else
{
if ( operatorArgc() > 1 ) argT = parameter2double(cdoOperatorArgv(1));
else if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
cdoOperatorAdd("eca_cwdi", 0, 31, nullptr);
}
longname = (char*) Malloc(strlen(CWDI_LONGNAME) + 80);
sprintf(longname, CWDI_LONGNAME, argN, argT);
......@@ -449,9 +462,20 @@ void *EcaCwfi(void *process)
ECA_REQUEST_2 request;
cdoInitialize(process);
cdoOperatorAdd("eca_cwfi", 0, 31, nullptr);
cdoOperatorAdd("etccdi_csdi", 0, 10, nullptr);
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
if ( operatorArgc() > 1 )
{
auto params = cdoGetOperArgv();
params = std::vector<std::string>(params.begin() + 1, params.end());
addWithFrequency(params, "eca_cwfi");
argN = parameter2int(cdoOperatorArgv(0));
}
else
{
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
cdoOperatorAdd("eca_cwfi", 0, 31, nullptr);
}
char *longname = (char*) Malloc(strlen(CWFI_LONGNAME) + 40);
sprintf(longname, CWFI_LONGNAME, argN);
......@@ -509,6 +533,7 @@ void *EcaFd(void *process)
cdoInitialize(process);
cdoOperatorAdd("etccdi_fd", 0, 10, nullptr);
if ( operatorArgc() > 0 )
{
auto params = cdoGetOperArgv();
......@@ -633,10 +658,21 @@ void *EcaHwdi(void *process)
ECA_REQUEST_2 request;
cdoInitialize(process);
cdoOperatorAdd("eca_hwdi", 0, 31, nullptr);
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
if ( operatorArgc() > 1 ) argT = parameter2double(cdoOperatorArgv(1));
if ( operatorArgc() > 2 )
{
auto params = cdoGetOperArgv();
params = std::vector<std::string>(params.begin() + 2, params.end());
addWithFrequency(params, "eca_hwdi");
argN = parameter2int(cdoOperatorArgv(0));
argT = parameter2double(cdoOperatorArgv(1));
}
else
{
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
if ( operatorArgc() > 1 ) argT = parameter2double(cdoOperatorArgv(1));
cdoOperatorAdd("eca_hwdi", 0, 31, nullptr);
}
char *longname = (char*) Malloc(strlen(HWDI_LONGNAME) + 80);
sprintf(longname, HWDI_LONGNAME, argN, argT);
......@@ -674,9 +710,20 @@ void *EcaHwfi(void *process)
ECA_REQUEST_2 request;
cdoInitialize(process);
cdoOperatorAdd("eca_hwfi", 0, 31, nullptr);
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
cdoOperatorAdd("etccdi_wsdi", 0, 10, nullptr);
if ( operatorArgc() > 1 )
{
auto params = cdoGetOperArgv();
params = std::vector<std::string>(params.begin() + 1, params.end());
addWithFrequency(params, "eca_hwfi");
argN = parameter2int(cdoOperatorArgv(0));
}
else
{
if ( operatorArgc() > 0 ) argN = parameter2int(cdoOperatorArgv(0));
cdoOperatorAdd("eca_hwfi", 0, 31, nullptr);
}
char *longname = (char*) Malloc(strlen(HWFI_LONGNAME) + 40);
sprintf(longname, HWFI_LONGNAME, argN);
......@@ -712,6 +759,7 @@ void *EcaId(void *process)
ECA_REQUEST_1 request;
cdoInitialize(process);
cdoOperatorAdd("etccdi_id", 0, 10, nullptr);
if ( operatorArgc() > 0 )
{
auto params = cdoGetOperArgv();
......@@ -746,6 +794,7 @@ void *EcaSu(void *process)
ECA_REQUEST_1 request;
cdoInitialize(process);
cdoOperatorAdd("etccdi_csdi", 0, 10, nullptr);
if ( operatorArgc() > 0 ) argT = parameter2double(cdoOperatorArgv(0));
if ( operatorArgc() > 1 )
......@@ -890,6 +939,7 @@ void *EcaTr(void *process)
char tr_longname[1024];
cdoInitialize(process);
cdoOperatorAdd("etccdi_tr", 0, 10, nullptr);
if ( operatorArgc() > 0 ) argT = parameter2double(cdoOperatorArgv(0));
if ( operatorArgc() > 1 )
......@@ -999,6 +1049,7 @@ void *EcaCdd(void *process)
char cdd_name2[1024];
cdoInitialize(process);
cdoOperatorAdd("etccdi_cdd", 0, 10, nullptr);
if ( operatorArgc() > 3 ) cdoAbort("Too many arguments!");
else if ( operatorArgc() > 2 )
......@@ -1056,6 +1107,7 @@ void *EcaCwd(void *process)
char cwd_name2[1024];
cdoInitialize(process);
cdoOperatorAdd("etccdi_cwd", 0, 10, nullptr);
if ( operatorArgc() > 3 ) cdoAbort("Too many arguments!");
else if ( operatorArgc() > 2 )
......@@ -1116,26 +1168,34 @@ void *EcaPd(void *process)
{
auto params = cdoGetOperArgv();
KVList kvlist;
if (kvlist.parseArguments(operatorArgc(), params) != 0) cdoAbort("Argument parse error!");
auto kv = kvlist.search("freq");
if (kv && kv->nvalues > 0 )
{
if ( kv->values[0].compare("month") == 0 )
datelenOp = 8;
else if ( kv->values[0].compare("year") == 0 )
datelenOp = 10;
if ( strstr(cdoOperatorArgv(0).c_str(), "=") || operatorArgc() > 1 )
{
if ( operatorArgc() > 1 )
params = std::vector<std::string>(params.begin() + 1, params.end());
if (kvlist.parseArguments(1, params) != 0) cdoAbort("Argument parse error!");
auto kv = kvlist.search("freq");
if (kv && kv->nvalues > 0 )
{
if ( kv->values[0].compare("month") == 0 )
datelenOp = 8;
else if ( kv->values[0].compare("year") == 0 )
datelenOp = 10;
}
}
}
// clang-format off
const auto ECA_PD = cdoOperatorAdd("eca_pd", 0, datelenOp, nullptr);
const auto ETCCDI_PD = cdoOperatorAdd("etccdi_r1mm", 0, 10, nullptr);
const auto ECA_R10MM = cdoOperatorAdd("eca_r10mm", 0, datelenOp, nullptr);
const auto ETCCDI_R10MM = cdoOperatorAdd("etccdi_r10mm", 0, 10, nullptr);
const auto ECA_R20MM = cdoOperatorAdd("eca_r20mm", 0, datelenOp, nullptr);
const auto ETCCDI_R20MM = cdoOperatorAdd("etccdi_r20mm", 0, 10, nullptr);
// clang-format on
const auto operatorID = cdoOperatorID();
if (operatorID == ECA_PD)
if (operatorID == ECA_PD || operatorID == ETCCDI_PD)
{
operatorInputArg("daily precipitation amount threshold in [mm]");
......@@ -1151,7 +1211,7 @@ void *EcaPd(void *process)
request.var1.longname = lnamebuffer;
request.var1.units = PD_UNITS;
}
else if (operatorID == ECA_R10MM)
else if (operatorID == ECA_R10MM || operatorID == ETCCDI_R10MM )
{
threshold = 10;
......@@ -1159,7 +1219,7 @@ void *EcaPd(void *process)
request.var1.longname = R10MM_LONGNAME;
request.var1.units = R10MM_UNITS;
}
else if (operatorID == ECA_R20MM)
else if (operatorID == ECA_R20MM || operatorID == ETCCDI_R20MM)
{
threshold = 20;
......@@ -1444,6 +1504,8 @@ EcaRx1day(void *process)
ECA_REQUEST_1 request;
cdoInitialize(process);
cdoOperatorAdd("etccdi_rx1day", 0, 10, nullptr);
cdoOperatorAdd("etccdi_rx1daymon", 0, 8, nullptr);
if (operatorArgc() > 0)
{
auto params = cdoGetOperArgv();
......@@ -1477,6 +1539,8 @@ EcaRx5day(void *process)
ECA_REQUEST_1 request;
cdoInitialize(process);
cdoOperatorAdd("etccdi_rx5day", 0, 10, nullptr);
cdoOperatorAdd("etccdi_rx5daymon", 0, 8, nullptr);
if (operatorArgc() > 0)
{
argX = parameter2double(cdoOperatorArgv(0));
......@@ -1528,7 +1592,9 @@ EcaSdii(void *process)
double threshold = 1;
cdoInitialize(process);
cdoOperatorAdd("etccdi_sdii", 0, 31, nullptr);
cdoOperatorAdd("eca_sdii", 0, 10, nullptr);
if (operatorArgc() > 2) cdoAbort("Too many arguments!");
else if ( operatorArgc() > 1 )
{
......
......@@ -654,25 +654,25 @@ void *EcaCsu(void *argument);
void *EcaCwdi(void *argument);
#define EcaCwdiOperators {"eca_cwdi"}
void *EcaCwfi(void *argument);
#define EcaCwfiOperators {"eca_cwfi"}
#define EcaCwfiOperators {"eca_cwfi", "etccdi_csdi"}
void *EcaEtr(void *argument);
#define EcaEtrOperators {"eca_etr"}
void *EcaFd(void *argument);
#define EcaFdOperators {"eca_fd"}
#define EcaFdOperators {"eca_fd", "etccdi_fd"}
void *EcaGsl(void *argument);
#define EcaGslOperators {"eca_gsl"}
#define EcaGslOperators {"eca_gsl", "etccdi_gsl"}
void *EcaHd(void *argument);
#define EcaHdOperators {"eca_hd"}
#define EcaHdOperators {"eca_hd", "etccdi_hd"}
void *EcaHwdi(void *argument);
#define EcaHwdiOperators {"eca_hwdi"}
void *EcaHwfi(void *argument);
#define EcaHwfiOperators {"eca_hwfi"}
#define EcaHwfiOperators {"eca_hwfi", "etccdi_wsdi"}
void *EcaId(void *argument);
#define EcaIdOperators {"eca_id"}
#define EcaIdOperators {"eca_id", "etccdi_id"}
void *EcaSu(void *argument);
#define EcaSuOperators {"eca_su"}
#define EcaSuOperators {"eca_su", "etccdi_du"}
void *EcaTr(void *argument);
#define EcaTrOperators {"eca_tr"}
#define EcaTrOperators {"eca_tr", "etccdi_tr"}
void *EcaTg10p(void *argument);
#define EcaTg10pOperators {"eca_tg10p"}
void *EcaTg90p(void *argument);
......@@ -686,13 +686,13 @@ void *EcaTx10p(void *argument);
void *EcaTx90p(void *argument);
#define EcaTx90pOperators {"eca_tx90p"}
void *EcaCdd(void *argument);
#define EcaCddOperators {"eca_cdd"}
#define EcaCddOperators {"eca_cdd", "etccdi_cdd"}
void *EcaCwd(void *argument);
#define EcaCwdOperators {"eca_cwd"}
#define EcaCwdOperators {"eca_cwd", "etccdi_cwd"}
void *EcaRr1(void *argument);
#define EcaRr1Operators {"eca_rr1"}
void *EcaPd(void *argument);
#define EcaPdOperators {"eca_pd", "eca_r10mm", "eca_r20mm"}
#define EcaPdOperators {"eca_pd", "eca_r10mm", "eca_r20mm", "etccdi_r1mm", "etccdi_r10mm", "etccdi_r20mm"}
void *EcaR75p(void *argument);
#define EcaR75pOperators {"eca_r75p"}
void *EcaR75ptot(void *argument);
......@@ -710,11 +710,11 @@ void *EcaR99p(void *argument);
void *EcaR99ptot(void *argument);
#define EcaR99ptotOperators {"eca_r99ptot"}
void *EcaRx1day(void *argument);
#define EcaRx1dayOperators {"eca_rx1day"}
#define EcaRx1dayOperators {"eca_rx1day", "etccdi_rx1day", "etccdi_rx1daymon"}
void *EcaRx5day(void *argument);
#define EcaRx5dayOperators {"eca_rx5day"}
#define EcaRx5dayOperators {"eca_rx5day", "etccdi_rx5day", "etccdi_rx5daymon"}
void *EcaSdii(void *argument);
#define EcaSdiiOperators {"eca_sdii"}
#define EcaSdiiOperators {"eca_sdii", "etccdi_sdii"}
void *EcaEtccdi(void *argument);
#define EcaEtccdiOperators {"etccdi_tx90p","etccdi_tx10p","etccdi_tn90p","etccdi_tn10p","etccdi_r95p","etccdi_r99p","etccdi"}
......
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