1 /* 2 This file is part of CDO. CDO is a collection of Operators to manipulate and analyse Climate model Data. 3 4 Copyright (C) 2006 Brockmann Consult 5 6 Author: Ralf Quast 7 8 */ 9 #ifndef ECA_H_ 10 #define ECA_H_ 11 12 #include "field.h" 13 14 enum ECA_EPILOG 15 { 16 ECA_NONE, 17 MEAN, 18 PERCENT_OF_TIME, 19 PERCENT_OF_TOTAL_AMOUNT 20 }; 21 22 using ECA_FUNC_1 = void (*)(Field &, double); 23 using ECA_FUNC_2 = void (*)(Field &, const Field &); 24 using ECA_FUNC_3 = void (*)(Field &, const Field &, double); 25 26 /** 27 * Structure describing a processing request of the form 28 * 29 * o = F3(F2(a * F1(i) + b)) 30 * 31 * where i and o denote the input and output fields, and 32 * F1, F2 and F3 are field operators. 33 * 34 * The structure contains the following elements: 35 * 36 * name the name of the output variable 37 * longname the longname of the output variable 38 * units the units of the output variable 39 * f1 the 1st field operator 40 * f1arg the argument of the 1st field operator 41 * f2 the 2nd field operator 42 * f3 the 3rd field operator 43 * mulc the multiplier a 44 * addc the addend b 45 * epilog the final operation carried out after processing 46 */ 47 struct ECA_MAJOR_REQUEST_ELEMENT_1 48 { 49 const char *name = nullptr; 50 const char *longname = nullptr; 51 const char *units = nullptr; 52 int refdate; 53 ECA_FUNC_1 f1 = nullptr; 54 double f1arg = 1.0; 55 ECA_FUNC_2 f2 = nullptr; 56 ECA_FUNC_2 f3 = nullptr; 57 double mulc = 0.0; 58 double addc = 0.0; 59 ECA_EPILOG epilog = ECA_NONE; 60 }; 61 62 /** 63 * Structure describing a processing request of the form 64 * 65 * o = H3(H2(H1(i))) 66 * 67 * where i and o denote the input and output fields, and 68 * H1, H2 and H3 are field operators. 69 * 70 * The structure contains the following elements: 71 * 72 * name the name of the output variable 73 * longname the longname of the output variable 74 * h1 the 1st field operator 75 * h1arg the argument of the 1st field operator 76 * h2 the 2nd field operator 77 * h3 the 3rd field operator 78 */ 79 struct ECA_MINOR_REQUEST_ELEMENT_1 80 { 81 const char *name = nullptr; 82 const char *longname = nullptr; 83 const char *units = nullptr; 84 ECA_FUNC_1 h1 = nullptr; 85 double h1arg; 86 ECA_FUNC_2 h2 = nullptr; 87 ECA_FUNC_2 h3 = nullptr; 88 }; 89 90 struct ECA_REQUEST_1 91 { 92 ECA_MAJOR_REQUEST_ELEMENT_1 var1; 93 ECA_MINOR_REQUEST_ELEMENT_1 var2; 94 }; 95 96 /** 97 * Structure describing a processing request of the form 98 * 99 * o = F5(F4(F3(F1(i1), F2(i2)))) 100 * 101 * where i1, i2 and o denote the input and output fields, 102 * and F1, F2, F3, F4 and F3 are field operators. 103 * 104 * The structure contains the following elements: 105 * 106 * name the name of the output variable 107 * longname the longname of the output variable 108 * units the units of the output variable 109 * f1 the 1st field operator 110 * f1arg the argument of the 1st field operator 111 * f2 the 2nd field operator 112 * f2arg the argument of the 2nd field operator 113 * f3 the 3rd field operator 114 * f4 the 4th field operator 115 * f5 the 5th field operator 116 * f5arg the argument of the 5th field operator 117 * epilog the final operation carried out after processing 118 */ 119 struct ECA_MAJOR_REQUEST_ELEMENT_2 120 { 121 const char *name = nullptr; 122 const char *longname = nullptr; 123 const char *units = nullptr; 124 int refdate; 125 ECA_FUNC_1 f1 = nullptr; 126 double f1arg; 127 ECA_FUNC_1 f2 = nullptr; 128 double f2arg; 129 ECA_FUNC_2 f3 = nullptr; 130 ECA_FUNC_2 f4 = nullptr; 131 ECA_FUNC_3 f5 = nullptr; 132 double f5arg; 133 ECA_EPILOG epilog = ECA_NONE; 134 }; 135 136 /** 137 * Structure describing a processing request of the form 138 * 139 * o = H2(H1(i)) 140 * 141 * where i and o denote the input and output fields, and 142 * H1, and H2 are field operators. 143 * 144 * The structure contains the following elements: 145 * 146 * name the name of the output variable 147 * longname the longname of the output variable 148 * units the units of the output variable 149 * h1 the 1st field operator 150 * h1arg the argument of the 1st field operator 151 * h2 the 2nd field operator 152 */ 153 struct ECA_MINOR_REQUEST_ELEMENT_2 154 { 155 const char *name = nullptr; 156 const char *longname = nullptr; 157 const char *units = nullptr; 158 ECA_FUNC_1 h1 = nullptr; 159 double h1arg; 160 ECA_FUNC_2 h2 = nullptr; 161 }; 162 163 struct ECA_REQUEST_2 164 { 165 ECA_MAJOR_REQUEST_ELEMENT_2 var1; 166 ECA_MINOR_REQUEST_ELEMENT_2 var2; 167 }; 168 169 /** 170 * Structure describing a processing request of the form 171 * 172 * o = F3(F1(i1), F2(i2)) 173 * 174 * where i1, i2 and o denote the input and output fields, 175 * and F1, F2 and F3 are field operators. 176 * 177 * The structure contains the following elements: 178 * 179 * name the name of the output variable 180 * longname the longname of the output variable 181 * units the units of the output variable 182 * f1 the 1st field operator 183 * f2 the 2nd field operator 184 * f3 the 3rd field operator 185 */ 186 struct ECA_REQUEST_3 187 { 188 const char *name = nullptr; 189 const char *longname = nullptr; 190 const char *units = nullptr; 191 int refdate; 192 ECA_FUNC_2 f1 = nullptr; 193 ECA_FUNC_2 f2 = nullptr; 194 ECA_FUNC_2 f3 = nullptr; 195 }; 196 197 /** 198 * Structure describing a GSL-like processing request. The structure 199 * contains the following elements: 200 * 201 * name the name of the 1st output variable 202 * longname the longname of the 1st output variable 203 * units the units of the 1st output variable 204 * name2 the name of the 2nd output variable 205 * longname2 the longname of the 2nd output variable 206 * units2 the units of the 2nd output variable 207 * name3 the name of the 3rd output variable 208 * longname3 the longname of the 3rd output variable 209 * units3 the units of the 3rd output variable 210 * s1 the 1st field selector 211 * s1arg argument of the 1st field selector 212 * s2 the 2nd field selector 213 * s2arg argument of the 2nd field selector 214 * consecutiveDays the number od concecutive days 215 */ 216 struct ECA_REQUEST_4 217 { 218 const char *name = nullptr; 219 const char *longname = nullptr; 220 const char *units = nullptr; 221 const char *name2 = nullptr; 222 const char *longname2 = nullptr; 223 const char *units2 = nullptr; 224 ECA_FUNC_1 s1 = nullptr; 225 double s1arg; 226 ECA_FUNC_1 s2 = nullptr; 227 double s2arg; 228 ECA_FUNC_1 s3 = nullptr; 229 double s3arg; 230 int consecutiveDays; 231 }; 232 233 /** 234 * Structure describing an ETCCDI index processing request. The structure 235 * contains the following elements: 236 * 237 * name the name of the output variable 238 * longname the longname of the output variable 239 * units the units of the output variable 240 * pn the percentile for the threshold 241 * ndates the window size 242 * startboot the begin year of the bootstrapping interval 243 * endboot the end year of the bootstrapping interval 244 * func2 either FieldFunc_Sum or func_average 245 */ 246 247 struct ETCCDI_REQUEST 248 { 249 const char *name = nullptr; 250 const char *longname = nullptr; 251 const char *units = nullptr; 252 int pn; 253 int ndates; 254 int startboot; 255 int endboot; 256 int func2; 257 }; 258 259 /** 260 * Function processing a request of type 1. 261 * 262 * @param request the processing request 263 */ 264 void eca1(const ECA_REQUEST_1 &request); 265 266 /** 267 * Function processing a request of type 2. 268 * 269 * @param request the processing request 270 */ 271 void eca2(const ECA_REQUEST_2 &request); 272 273 /** 274 * Function processing a request of type 3. 275 * 276 * @param request the processing request 277 */ 278 void eca3(const ECA_REQUEST_3 &request); 279 280 /** 281 * Function processing a request of type 4. 282 * 283 * @param request the processing request 284 */ 285 void eca4(const ECA_REQUEST_4 &request); 286 287 /** 288 * Function processing a etccdi request. 289 * 290 * @param request the processing request 291 */ 292 293 void etccdi_op(ETCCDI_REQUEST &request); 294 295 #endif /* ECA_H_ */ 296