Changeset 6f951ca in flex_extract.git for source/python/classes
- Timestamp:
- Jan 15, 2019, 1:05:10 AM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- d4696e0
- Parents:
- 2625ca8
- Location:
- source/python/classes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/classes/ControlFile.py
rf2616a3 r6f951ca 21 21 # 22 22 # @License: 23 # (C) Copyright 2015-2018. 23 # (C) Copyright 2014-2019. 24 # Anne Philipp, Leopold Haimberger 24 25 # 25 # This software is licensed under the terms of the Apache Licence Version 2.0 26 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 26 # This work is licensed under the Creative Commons Attribution 4.0 27 # International License. To view a copy of this license, visit 28 # http://creativecommons.org/licenses/by/4.0/ or send a letter to 29 # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 27 30 # 28 # @Class Description: 29 # The CONTROL file is the steering part of the FLEXPART extraction 30 # software. All necessary parameters needed to retrieve the data fields 31 # from the MARS archive for driving FLEXPART are set in a CONTROL file. 32 # Some specific parameters like the start and end dates can be overwritten 33 # by the command line parameters, but in generel all parameters needed 34 # for a complete set of fields for FLEXPART can be set in the CONTROL file. 35 # 36 # @Class Content: 37 # - __init__ 38 # - __read_controlfile__ 39 # - __str__ 40 # - assign_args_to_control 41 # - assign_envs_to_control 42 # - check_conditions 43 # - check_install_conditions 44 # - to_list 45 # 46 # @Class Attributes: 47 # 48 # 31 # @Class Methods: 32 # __init__ 33 # _read_controlfile 34 # __str__ 35 # assign_args_to_control 36 # assign_envs_to_control 37 # check_conditions 38 # check_install_conditions 39 # to_list 49 40 #******************************************************************************* 50 41 … … 76 67 ''' 77 68 Contains the information which are stored in the CONTROL files. 69 70 The CONTROL file is the steering part of the FLEXPART extraction 71 software. All necessary parameters needed to retrieve the data fields 72 from the MARS archive for driving FLEXPART are set in a CONTROL file. 73 Some specific parameters like the start and end dates can be overwritten 74 by the command line parameters, but in generel all parameters needed 75 for a complete set of fields for FLEXPART can be set in the CONTROL file. 76 77 Attributes 78 ---------- 79 controlfile : str 80 The name of the control file to be processed. Default value is the 81 filename passed to the init function when initialised. 82 83 start_date : str 84 The first day of the retrieval period. Default value is None. 85 86 end_date :str 87 The last day of the retrieval period. Default value is None. 88 89 date_chunk : int 90 Length of period for a single mars retrieval. Default value is 3. 91 92 dtime :str 93 The time step in hours. Default value is None. 94 95 basetime : str 96 The time for a half day retrieval. The 12 hours upfront are to be 97 retrieved. Default value is None. 98 99 maxstep : int 100 The maximum forecast step for non flux data. Default value is None. 101 102 type : list of str 103 List of field type per retrieving hour. Default value is None. 104 105 time : list of str 106 List of retrieving times in hours. Default valuer is None. 107 108 step : list of str or str 109 List of forecast time steps in hours for non flux data. 110 Default value is None. 111 112 acctype : str 113 The field type for the accumulated forecast fields. 114 Default value is None. 115 116 acctime : str 117 The starting time of the accumulated forecasts. Default value is None. 118 119 accmaxstep : int 120 The maximum forecast step for the accumulated forecast fields 121 (flux data). Default value is None. 122 123 marsclass : str 124 Characterisation of dataset. Default value is None. 125 126 dataset : str 127 For public datasets there is the specific naming and parameter 128 dataset which has to be used to characterize the type of 129 data. Default value is None. 130 131 stream : str 132 Identifies the forecasting system used to generate the data. 133 Default value is None. 134 135 number : str 136 Selects the member in ensemble forecast run. Default value is 'OFF'. 137 138 expver : str 139 The version number of the dataset. Default value is '1'. 140 141 gaussian : str 142 This parameter is deprecated and should no longer be used. 143 Specifies the desired type of Gaussian grid for the output. 144 Default value is an empty string ''. 145 146 grid : str 147 Specifies the output grid which can be either a Gaussian grid 148 or a Latitude/Longitude grid. Default value is None. 149 150 area : str 151 Specifies the desired sub-area of data to be extracted. 152 Default value is None. 153 154 left : str 155 The western most longitude of the area to be extracted. 156 Default value is None. 157 158 lower : str 159 The southern most latitude of the area to be extracted. 160 Default value is None. 161 162 upper : str 163 The northern most latitued of the area to be extracted. 164 Default value is None. 165 166 right : str 167 The eastern most longitude of the area to be extracted. 168 Default value is None. 169 170 level : str 171 Specifies the maximum level. Default value is None. 172 173 levelist : str 174 Specifies the required level list. Default value is None. 175 176 resol : str 177 Specifies the desired triangular truncation of retrieved data, 178 before carrying out any other selected post-processing. 179 Default value is None. 180 181 gauss : int 182 Switch to select gaussian fields (1) or regular lat/lon (0). 183 Default value is 0. 184 185 accuracy : int 186 Specifies the number of bits per value to be used in the 187 generated GRIB coded fields. Default value is 24. 188 189 omega : int 190 Switch to select omega retrieval (1) or not (0). Default value is 0. 191 192 omegadiff : int 193 Switch to decide to calculate Omega and Dps/Dt from continuity 194 equation for diagnostic purposes (1) or not (0). Default value is 0. 195 196 eta : int 197 Switch to select direct retrieval of etadot from MARS (1) or 198 wether it has to be calculated (0). Then Default value is 0. 199 200 etadiff : int 201 Switch to select calculation of etadot and Dps/Dt from continuity 202 equation for diagnostic purposes (1) or not (0). Default value is 0. 203 204 etapar : int 205 GRIB parameter Id for etadot fields. Default value is 77. 206 207 dpdeta : int 208 Switch to select multiplication of etadot with dpdeta. 209 Default value is 1. 210 211 smooth : int 212 Spectral truncation of ETADOT after calculation on Gaussian grid. 213 Default value is 0. 214 215 format : str 216 The format of the GRIB data. Default value is 'GRIB1'. 217 218 addpar : str 219 List of additional surface level ECMWF parameter to be retrieved. 220 Default value is None. 221 222 prefix : str 223 Prefix string for the final FLEXPART/FLEXTRA ready input files. 224 Default value is 'EN'. 225 226 cwc : int 227 Switch to select wether the sum of cloud liquid water content and 228 cloud ice water content should be retrieved. Default value is 0. 229 230 wrf : int 231 Switch to select further parameters for retrievment to support 232 WRF simulations. Default value is 0. 233 234 ecfsdir : str 235 Path to the ECMWF storage 'ectmp:/${USER}/econdemand/' 236 237 mailfail : list of str 238 Email list for sending error log files from ECMWF servers. 239 The email addresses should be seperated by a comma. 240 Default value is ['${USER}']. 241 242 mailops : list of str 243 Email list for sending operational log files from ECMWF servers. 244 The email addresses should be seperated by a comma. 245 Default value is ['${USER}']. 246 247 grib2flexpart : int 0 248 Switch to select generation of preprocessed FLEXPART files ".fp". 249 If it is selected, the program grib2flexpart will try 250 to convert the flex_extract output files into ".fp" format. 251 252 ecstorage : int 253 Switch to select storage of FLEXPART ready output files 254 in the ECFS file system. Default value is 0. 255 256 ectrans : int 257 Switch to select the transfer of FLEXPART ready output files 258 to the gateway server. Default value is 0. 259 260 inputdir : str 261 Path to the temporary directory for the retrieval grib files and 262 other processing files. Default value is _config.PATH_INPUT_DIR. 263 264 outputdir : str 265 Path to the final directory where the final FLEXPART ready input 266 files are stored. Default value is None. 267 268 flexextractdir : str 269 Path to the flex_extract root directory. Default value is 270 _config.PATH_FLEXEXTRACT_DIR. 271 272 exedir : str 273 Path to the FORTRAN executable file. Default value is 274 _config.PATH_FORTRAN_SRC. 275 276 flexpartdir : str 277 Path to a FLEXPART root directory. Default value is None. 278 279 makefile : str 280 Name of the makefile to be used for the Fortran program. 281 Default value is 'Makefile.gfortran'. 282 283 destination : str 284 The remote destination which is used to transfer files 285 from ECMWF server to local gateway server. Default value is None. 286 287 gateway : str 288 The gateway server the user is using. Default value is None. 289 290 ecuid : str 291 The user id on ECMWF server. Default value is None. 292 293 ecgid : str 294 The group id on ECMWF server. Default value is None. 295 296 install_target : str 297 Defines the location where the installation is to be done. 298 Default value is None. 299 300 debug : int 301 Switch to keep temporary files at the end of postprocessing (1) or 302 to delete all temporary files except the final output files (0). 303 Default value is 0. 304 305 request : int 306 Switch to select between just retrieving the data (0), writing the mars 307 parameter values to a csv file (1) or doing both (2). 308 Default value is 0. 309 310 public : int 311 Switch to select kind of ECMWF Web Api access and the 312 possible data sets. Public data sets (1) and Memberstate data sets (0). 313 Default value is 0. 314 315 ecapi : boolean 316 Tells wether the ECMWF Web APi was able to load or not. 317 Default value is None. 318 319 purefc : int 320 Switch to decide wether the job is a pure forecast retrieval or 321 coupled with analysis data. Default value is 0. 322 323 rrint: int 324 Switch to select between old precipitation disaggregation method (0) 325 or the new IA3 disaggegration method (1). Default value is 0. 326 327 logicals : list of str 328 List of the names of logical switches which controls the flow 329 of the program. Default list is ['gauss', 'omega', 'omegadiff', 'eta', 330 'etadiff', 'dpdeta', 'cwc', 'wrf', 'grib2flexpart', 'ecstorage', 331 'ectrans', 'debug', 'request', 'public', 'purefc', 'rrint'] 78 332 ''' 79 333 … … 85 339 Parameters 86 340 ---------- 87 filename : :obj:`string`341 filename : str 88 342 Name of CONTROL file. 89 343 … … 98 352 self.end_date = None 99 353 self.date_chunk = 3 354 self.job_chunk = None 100 355 self.dtime = None 101 356 self.basetime = None … … 273 528 Parameters 274 529 ---------- 275 args : :obj:`Namespace`530 args : Namespace 276 531 Contains the commandline arguments from script/program call. 277 532 … … 298 553 Parameters 299 554 ---------- 300 envs : :obj:`dictionary` of :obj:`strings`555 envs : dict of str 301 556 Contains the ECMWF environment parameternames "ECUID", "ECGID", 302 557 "DESTINATION" and "GATEWAY" with its corresponding values. … … 320 575 Parameters 321 576 ---------- 322 queue : :obj:`string`577 queue : str 323 578 Name of the queue if submitted to the ECMWF servers. 324 579 Used to check if ecuid, ecgid, gateway and destination … … 397 652 Return 398 653 ------ 399 l : :obj:`list`654 l : list of * 400 655 A sorted list of the all ControlFile class attributes with 401 656 their values except the attributes "_expanded", "exedir", -
source/python/classes/EcFlexpart.py
rbf48c8a r6f951ca 41 41 # 42 42 # @License: 43 # (C) Copyright 2014-2018. 43 # (C) Copyright 2014-2019. 44 # Anne Philipp, Leopold Haimberger 44 45 # 45 # This software is licensed under the terms of the Apache Licence Version 2.0 46 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 47 # 48 # @Class Description: 49 # FLEXPART needs grib files in a specifc format. All necessary data fields 50 # for one time step are stored in a single file. The class represents an 51 # instance with all the parameter and settings necessary for retrieving 52 # MARS data and modifing them so they are fitting FLEXPART need. The class 53 # is able to disaggregate the fluxes and convert grid types to the one needed 54 # by FLEXPART, therefore using the FORTRAN program. 55 # 56 # @Class Content: 57 # - __init__ 58 # - write_namelist 59 # - retrieve 60 # - process_output 61 # - create 62 # - deacc_fluxes 63 # 64 # @Class Attributes: 65 # 66 # TODO 67 # 46 # This work is licensed under the Creative Commons Attribution 4.0 47 # International License. To view a copy of this license, visit 48 # http://creativecommons.org/licenses/by/4.0/ or send a letter to 49 # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 68 50 #******************************************************************************* 69 51 #pylint: disable=unsupported-assignment-operation … … 102 84 class EcFlexpart(object): 103 85 ''' 104 Class to retrieve FLEXPART specific ECMWF data. 86 Class to represent FLEXPART specific ECMWF data. 87 88 FLEXPART needs grib files in a specifc format. All necessary data fields 89 for one time step are stored in a single file. The class represents an 90 instance with all the parameter and settings necessary for retrieving 91 MARS data and modifing them so they are fitting FLEXPART needs. The class 92 is able to disaggregate the fluxes and convert grid types to the one needed 93 by FLEXPART, therefore using the FORTRAN program. 94 95 Attributes 96 ---------- 97 mreq_count : int 98 Counter for the number of generated mars requests. 99 100 inputdir : str 101 Path to the directory where the retrieved data is stored. 102 103 dataset : str 104 For public datasets there is the specific naming and parameter 105 dataset which has to be used to characterize the type of 106 data. 107 108 basetime : str 109 The time for a half day retrieval. The 12 hours upfront are to be 110 retrieved. 111 112 dtime : str 113 Time step in hours. 114 115 acctype : str 116 The field type for the accumulated forecast fields. 117 118 acctime : str 119 The starting time from the accumulated forecasts. 120 121 accmaxstep : str 122 The maximum forecast step for the accumulated forecast fields. 123 124 marsclass : str 125 Characterisation of dataset. 126 127 stream : str 128 Identifies the forecasting system used to generate the data. 129 130 number : str 131 Selects the member in ensemble forecast run. 132 133 resol : str 134 Specifies the desired triangular truncation of retrieved data, 135 before carrying out any other selected post-processing. 136 137 accuracy : str 138 Specifies the number of bits per value to be used in the 139 generated GRIB coded fields. 140 141 addpar : str 142 List of additional parameters to be retrieved. 143 144 level : str 145 Specifies the maximum level. 146 147 expver : str 148 The version of the dataset. 149 150 levelist : str 151 Specifies the required levels. 152 153 glevelist : str 154 Specifies the required levels for gaussian grids. 155 156 gaussian : str 157 This parameter is deprecated and should no longer be used. 158 Specifies the desired type of Gaussian grid for the output. 159 160 grid : str 161 Specifies the output grid which can be either a Gaussian grid 162 or a Latitude/Longitude grid. 163 164 area : str 165 Specifies the desired sub-area of data to be extracted. 166 167 purefc : int 168 Switch for definition of pure forecast mode or not. 169 170 outputfilelist : list of str 171 The final list of FLEXPART ready input files. 172 173 types : dictionary 174 Determines the combination of type of fields, time and forecast step 175 to be retrieved. 176 177 params : dictionary 178 Collection of grid types and their corresponding parameters, 179 levels, level types and the grid definition. 180 181 server : ECMWFService or ECMWFDataServer 182 This is the connection to the ECMWF data servers. 183 184 public : int 185 Decides which Web API Server version is used. 186 187 dates : str 188 Contains start and end date of the retrieval in the format 189 "YYYYMMDD/to/YYYYMMDD" 105 190 ''' 191 106 192 # -------------------------------------------------------------------------- 107 193 # CLASS FUNCTIONS … … 113 199 Parameters: 114 200 ----------- 115 c : :obj:`ControlFile`201 c : ControlFile 116 202 Contains all the parameters of CONTROL file and 117 203 command line. 118 204 119 fluxes : :obj:`boolean`, optional205 fluxes : boolean, optional 120 206 Decides if the flux parameter settings are stored or 121 207 the rest of the parameter list. … … 174 260 Parameters: 175 261 ----------- 176 ftype : :obj:`list` of :obj:`string`262 ftype : list of str 177 263 List of field types. 178 264 179 ftime : :obj:`list` of :obj:`string`265 ftime : list of str 180 266 The time in hours of the field. 181 267 182 fstep : :obj:`string`268 fstep : str 183 269 Specifies the forecast time step from forecast base time. 184 270 Valid values are hours (HH) from forecast base time. … … 267 353 Parameters: 268 354 ----------- 269 gauss : :obj:`integer`355 gauss : int 270 356 Gaussian grid is retrieved. 271 357 272 eta : :obj:`integer`358 eta : int 273 359 Etadot parameter will be directly retrieved. 274 360 275 omega : :obj:`integer`361 omega : int 276 362 The omega paramterwill be retrieved. 277 363 278 cwc : :obj:`integer`364 cwc : int 279 365 The cloud liquid and ice water content will be retrieved. 280 366 281 wrf : :obj:`integer`367 wrf : int 282 368 Additional model level and surface level data will be retrieved for 283 369 WRF/FLEXPART-WRF simulations. … … 374 460 Parameters 375 461 ---------- 376 ftype : :obj:`string`462 ftype : str 377 463 Shortcut name of the type of the field. E.g. AN, FC, PF, ... 378 464 379 param : :obj:`string`465 param : str 380 466 Shortcut of the grid type. E.g. SH__ML, SH__SL, GG__ML, 381 467 GG__SL, OG__ML, OG__SL, OG_OROLSM_SL, OG_acc_SL 382 468 383 date : :obj:`string`469 date : str 384 470 The date period of the grib data to be stored in this file. 385 471 386 472 Return 387 473 ------ 388 targetname : :obj:`string`474 targetname : str 389 475 The target filename for the grib data. 390 476 ''' … … 401 487 Parameters 402 488 ---------- 403 request : :obj:`integer`489 request : int 404 490 Selects the mode of retrieval. 405 491 0: Retrieves the data from ECMWF. … … 407 493 2: Retrieves the data and prints the mars request. 408 494 409 par_dict : :obj:`dictionary`495 par_dict : dictionary 410 496 Contains all parameter which have to be set for creating the 411 497 Mars Retrievals. The parameter are: … … 463 549 Parameters 464 550 ---------- 465 keys : :obj:`dictionary`551 keys : dictionary 466 552 List of parameter names which serves as index. 467 553 468 inputfiles : :obj:`UioFiles`554 inputfiles : UioFiles 469 555 Contains a list of files. 470 556 471 557 Return 472 558 ------ 473 iid : :obj:`codes_index`559 iid : codes_index 474 560 This is a grib specific index structure to access 475 561 messages in a file. 476 562 477 index_vals : :obj:`list`563 index_vals : list of list of str 478 564 Contains the values from the keys used for a distinct selection 479 565 of grib messages in processing the grib files. … … 517 603 Parameters 518 604 ---------- 519 server : :obj:`ECMWFService` or :obj:`ECMWFDataServer`605 server : ECMWFService or ECMWFDataServer 520 606 The connection to the ECMWF server. This is different 521 607 for member state users which have full access and non … … 525 611 for member state users its False (ECMWFService) 526 612 527 dates : :obj:`string`613 dates : str 528 614 Contains start and end date of the retrieval in the format 529 615 "YYYYMMDD/to/YYYYMMDD" 530 616 531 request : :obj:`integer`617 request : int 532 618 Selects the mode of retrieval. 533 619 0: Retrieves the data from ECMWF. … … 535 621 2: Retrieves the data and prints the mars request. 536 622 537 inputdir : :obj:`string`, optional623 inputdir : str, optional 538 624 Path to the directory where the retrieved data is about 539 625 to be stored. The default is the current directory ('.'). … … 723 809 Parameters 724 810 ---------- 725 c : :obj:`ControlFile`811 c : ControlFile 726 812 Contains all the parameters of CONTROL file and 727 813 command line. 728 814 729 filename : :obj:`string`815 filename : str 730 816 Name of the namelist file. 731 817 … … 810 896 Parameters 811 897 ---------- 812 inputfiles : :obj:`UioFiles`898 inputfiles : UioFiles 813 899 Contains the list of files that contain flux data. 814 900 815 c : :obj:`ControlFile`901 c : ControlFile 816 902 Contains all the parameters of CONTROL file and 817 903 command line. … … 837 923 # index_vals[0]: ('20171106', '20171107', '20171108') ; date 838 924 # index_vals[1]: ('0', '600', '1200', '1800') ; time 839 # index_vals[2]: ('0', ' 12', '3', '6', '9') ; stepRange925 # index_vals[2]: ('0', '3', '6', '9', '12') ; stepRange 840 926 841 927 if c.rrint: … … 1096 1182 Parameters 1097 1183 ---------- 1098 ni : :obj:`integer`1184 ni : int 1099 1185 Amount of zonal grid points. 1100 1186 1101 nj : :obj:`integer`1187 nj : int 1102 1188 Amount of meridional grid points. 1103 1189 1104 nt : :obj:`integer`1190 nt : int 1105 1191 Number of time steps. 1106 1192 1107 lsp_np : :obj:`numpy array` of :obj:`float`1193 lsp_np : numpy array of float 1108 1194 The large scale precipitation fields for each time step. 1109 1195 Shape (ni * nj, nt). 1110 1196 1111 cp_np : :obj:`numpy array` of :obj:`float`1197 cp_np : numpy array of float 1112 1198 The convective precipitation fields for each time step. 1113 1199 Shape (ni * nj, nt). 1114 1200 1115 date_list : :obj:`list` of :obj:`datetime`1201 date_list : list of datetime 1116 1202 The list of dates for which the disaggregation is to be done. 1117 1203 1118 step_list : :obj:`list` of :obj:`integer`1204 step_list : list of int 1119 1205 The list of steps for a single forecast time. 1120 1206 Only necessary for pure forecasts. 1121 1207 1122 c : :obj:`ControlFile`1208 c : ControlFile 1123 1209 Contains all the parameters of CONTROL file and 1124 1210 command line. … … 1217 1303 Parameters 1218 1304 ---------- 1219 ifile : :obj:`string`1305 ifile : str 1220 1306 Filename of the input file to read the grib messages from. 1221 1307 1222 inputdir : :obj:`string`, optional1308 inputdir : str, optional 1223 1309 Path to the directory where the retrieved data is stored. 1224 1310 … … 1255 1341 Parameters 1256 1342 ---------- 1257 inputfiles : :obj:`UioFiles`1343 inputfiles : UioFiles 1258 1344 Contains a list of files. 1259 1345 1260 c : :obj:`ControlFile`1346 c : ControlFile 1261 1347 Contains all the parameters of CONTROL file and 1262 1348 command line. … … 1486 1572 Parameters 1487 1573 ---------- 1488 c : :obj:`ControlFile`1574 c : ControlFile 1489 1575 Contains all the parameters of CONTROL file and 1490 1576 command line. … … 1545 1631 Parameters 1546 1632 ---------- 1547 c : :obj:`ControlFile`1633 c : ControlFile 1548 1634 Contains all the parameters of CONTROL file and 1549 1635 command line. -
source/python/classes/MarsRetrieval.py
rbc1720f r6f951ca 17 17 # - added documentation 18 18 # - applied some minor modifications in programming style/structure 19 # - added writing of mars request attributes to a csv file 19 20 # 20 21 # @License: 21 # (C) Copyright 2015-2018. 22 # (C) Copyright 2014-2019. 23 # Anne Philipp, Leopold Haimberger 22 24 # 23 # This software is licensed under the terms of the Apache Licence Version 2.0 24 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 25 # 26 # @Class Description: 27 # A MARS revtrieval has a specific syntax with a selection of keywords and 28 # their corresponding values. This class provides the necessary functions 29 # by displaying the selected parameters and their values and the actual 30 # retrievement of the data through a mars request or a Python web api 31 # interface. The initialization already expects all the keyword values. 32 # 33 # @Class Content: 34 # - __init__ 35 # - display_info 36 # - data_retrieve 37 # 38 # @Class Attributes: 39 # - server 40 # - marsclass 41 # - dtype 42 # - levtype 43 # - levelist 44 # - repres 45 # - date 46 # - resol 47 # - stream 48 # - area 49 # - time 50 # - step 51 # - expver 52 # - number 53 # - accuracy 54 # - grid 55 # - gaussian 56 # - target 57 # - param 58 # 25 # This work is licensed under the Creative Commons Attribution 4.0 26 # International License. To view a copy of this license, visit 27 # http://creativecommons.org/licenses/by/4.0/ or send a letter to 28 # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 59 29 #******************************************************************************* 60 30 … … 73 43 # ------------------------------------------------------------------------------ 74 44 class MarsRetrieval(object): 75 '''Class for submitting MARS retrievals. 45 '''Specific syntax and content for submission of MARS retrievals. 46 47 A MARS revtrieval has a specific syntax with a selection of keywords and 48 their corresponding values. This class provides the necessary functions 49 by displaying the selected parameters and their values and the actual 50 retrievement of the data through a mars request or a Python web api 51 interface. The initialization already expects all the keyword values. 76 52 77 53 A description of MARS keywords/arguments and examples of their … … 79 55 https://software.ecmwf.int/wiki/display/UDOC/\ 80 56 Identification+keywords#Identificationkeywords-class 57 58 Attributes 59 ---------- 60 server : ECMWFService or ECMWFDataServer 61 This is the connection to the ECMWF data servers. 62 63 public : int 64 Decides which Web API Server version is used. 65 66 marsclass : str, optional 67 Characterisation of dataset. 68 69 dataset : str, optional 70 For public datasets there is the specific naming and parameter 71 dataset which has to be used to characterize the type of 72 data. 73 74 type : str, optional 75 Determines the type of fields to be retrieved. 76 77 levtype : str, optional 78 Denotes type of level. 79 80 levelist : str, optional 81 Specifies the required levels. 82 83 repres : str, optional 84 Selects the representation of the archived data. 85 86 date : str, optional 87 Specifies the Analysis date, the Forecast base date or 88 Observations date. 89 90 resol : str, optional 91 Specifies the desired triangular truncation of retrieved data, 92 before carrying out any other selected post-processing. 93 94 stream : str, optional 95 Identifies the forecasting system used to generate the data. 96 97 area : str, optional 98 Specifies the desired sub-area of data to be extracted. 99 100 time : str, optional 101 Specifies the time of the data in hours and minutes. 102 103 step : str, optional 104 Specifies the forecast time step from forecast base time. 105 106 expver : str, optional 107 The version of the dataset. 108 109 number : str, optional 110 Selects the member in ensemble forecast run. 111 112 accuracy : str, optional 113 Specifies the number of bits per value to be used in the 114 generated GRIB coded fields. 115 116 grid : str, optional 117 Specifies the output grid which can be either a Gaussian grid 118 or a Latitude/Longitude grid. 119 120 gaussian : str, optional 121 This parameter is deprecated and should no longer be used. 122 Specifies the desired type of Gaussian grid for the output. 123 124 target : str, optional 125 Specifies a file into which data is to be written after 126 retrieval or manipulation. 127 128 param : str, optional 129 Specifies the meteorological parameter. 81 130 ''' 82 131 … … 96 145 Parameters 97 146 ---------- 98 server : :obj:`ECMWFService`147 server : ECMWFService or ECMWFDataServer 99 148 This is the connection to the ECMWF data servers. 100 149 It is needed for the pythonic access of ECMWF data. 101 150 102 public : :obj:`integer`151 public : int 103 152 Decides which Web API version is used: 104 153 0: member-state users and full archive access … … 107 156 Default is "0" and for member-state users. 108 157 109 marsclass : :obj:`string`, optional158 marsclass : str, optional 110 159 Characterisation of dataset. E.g. EI (ERA-Interim), 111 160 E4 (ERA40), OD (Operational archive), ea (ERA5). 112 161 Default is the ERA-Interim dataset "ei". 113 162 114 dataset : :obj:`string`, optional163 dataset : str, optional 115 164 For public datasets there is the specific naming and parameter 116 165 dataset which has to be used to characterize the type of … … 119 168 Default is an empty string. 120 169 121 type : :obj:`string`, optional170 type : str, optional 122 171 Determines the type of fields to be retrieved. 123 172 Selects between observations, images or fields. … … 126 175 Default is an empty string. 127 176 128 levtype : :obj:`string`, optional177 levtype : str, optional 129 178 Denotes type of level. Has a direct implication on valid 130 179 levelist values! … … 134 183 Default is an empty string. 135 184 136 levelist : :obj:`string`, optional185 levelist : str, optional 137 186 Specifies the required levels. It has to have a valid 138 187 correspondence to the selected levtype. … … 140 189 Default is an empty string. 141 190 142 repres : :obj:`string`, optional191 repres : str, optional 143 192 Selects the representation of the archived data. 144 193 E.g. sh - spherical harmonics, gg - Gaussian grid, … … 146 195 Default is an empty string. 147 196 148 date : :obj:`string`, optional197 date : str, optional 149 198 Specifies the Analysis date, the Forecast base date or 150 199 Observations date. Valid formats are: … … 152 201 Default is an empty string. 153 202 154 resol : :obj:`string`, optional203 resol : str, optional 155 204 Specifies the desired triangular truncation of retrieved data, 156 205 before carrying out any other selected post-processing. … … 169 218 Default is an empty string. 170 219 171 stream : :obj:`string`, optional220 stream : str, optional 172 221 Identifies the forecasting system used to generate the data. 173 222 E.g. oper (Atmospheric model), enfo (Ensemble forecats), ... 174 223 Default is an empty string. 175 224 176 area : :obj:`string`, optional225 area : str, optional 177 226 Specifies the desired sub-area of data to be extracted. 178 227 Areas can be defined to wrap around the globe. … … 192 241 Default is an empty string. 193 242 194 time : :obj:`string`, optional243 time : str, optional 195 244 Specifies the time of the data in hours and minutes. 196 245 Valid values depend on the type of data: Analysis time, … … 202 251 Default is an empty string. 203 252 204 step : :obj:`string`, optional253 step : str, optional 205 254 Specifies the forecast time step from forecast base time. 206 255 Valid values are hours (HH) from forecast base time. It also … … 210 259 Default is an empty string. 211 260 212 expver : :obj:`string`, optional261 expver : str, optional 213 262 The version of the dataset. Each experiment is assigned a 214 263 unique code (version). Production data is assigned 1 or 2, … … 218 267 Default is "1". 219 268 220 number : :obj:`string`, optional269 number : str, optional 221 270 Selects the member in ensemble forecast run. (Only then it 222 271 is necessary.) It has a different meaning depending on … … 225 274 Default is an empty string. 226 275 227 accuracy : :obj:`string`, optional276 accuracy : str, optional 228 277 Specifies the number of bits per value to be used in the 229 278 generated GRIB coded fields. … … 236 285 Default is an empty string. 237 286 238 grid : :obj:`string`, optional287 grid : str, optional 239 288 Specifies the output grid which can be either a Gaussian grid 240 289 or a Latitude/Longitude grid. MARS requests specifying … … 257 306 Default is an empty string. 258 307 259 gaussian : :obj:`string`, optional308 gaussian : str, optional 260 309 This parameter is deprecated and should no longer be used. 261 310 Specifies the desired type of Gaussian grid for the output. … … 265 314 Default is an empty string. 266 315 267 target : :obj:`string`, optional316 target : str, optional 268 317 Specifies a file into which data is to be written after 269 318 retrieval or manipulation. Path names should always be … … 279 328 Default is an empty string. 280 329 281 param : :obj:`string`, optional330 param : str, optional 282 331 Specifies the meteorological parameter. 283 332 The list of meteorological parameters in MARS is extensive. … … 352 401 Parameters 353 402 ---------- 354 inputdir : :obj:`string`403 inputdir : str 355 404 The path where all data from the retrievals are stored. 356 405 357 request_number : :obj:`integer`406 request_number : int 358 407 Number of mars requests for flux and non-flux data. 359 408 -
source/python/classes/UioFiles.py
r5cb0eaa r6f951ca 12 12 # - added pattern search in method list_files 13 13 # 14 # February 2018 - Anne Philipp (University of Vienna):14 # February - December 2018 - Anne Philipp (University of Vienna): 15 15 # - applied PEP8 style guide 16 16 # - added documentation … … 20 20 # - modified the class so that it is initiated with a pattern instead 21 21 # of suffixes. Gives more precision in selection of files. 22 # - added delete method 22 23 # 23 24 # @License: 24 # (C) Copyright 2014-2018. 25 # (C) Copyright 2014-2019. 26 # Anne Philipp, Leopold Haimberger 25 27 # 26 # This software is licensed under the terms of the Apache Licence Version 2.0 27 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 28 # 29 # @Class Decription: 30 # The class is for file manipulation. It is initiated with a regular 31 # expression pattern for this instance and can produce a list of Files 32 # from the given file pattern. These files can be deleted. 33 # 34 # @Class Content: 35 # - __init__ 36 # - __str__ 37 # - __list_files__ 38 # - delete_files 39 # 40 # @Class Attributes: 41 # - pattern 42 # - files 43 # 28 # This work is licensed under the Creative Commons Attribution 4.0 29 # International License. To view a copy of this license, visit 30 # http://creativecommons.org/licenses/by/4.0/ or send a letter to 31 # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 44 32 #******************************************************************************* 45 33 … … 51 39 import fnmatch 52 40 53 # software specific module from flex_extract41 # software specific modules from flex_extract 54 42 sys.path.append('../') 55 #import profiling56 43 from mods.tools import silent_remove, get_list_as_string 57 44 … … 61 48 62 49 class UioFiles(object): 63 '''Class to manipulate files. At initialisation it has the pattern 64 which stores a regular expression pattern for the files, the path 65 to the files and the files already. 50 '''Collection of files matching a specific pattern. 51 52 The pattern can contain regular expressions for the files. 53 The files are listed and can be transformed to a single string or 54 they can be deleted. 55 56 Attributes 57 ---------- 58 path : str 59 Directory where to list the files. 60 61 pattern : str 62 Regular expression pattern. For example: '\*.grb' 63 64 files : list of str 65 List of files matching the pattern in the path. 66 66 ''' 67 67 # -------------------------------------------------------------------------- 68 # CLASS FUNCTIONS68 # CLASS METHODS 69 69 # -------------------------------------------------------------------------- 70 70 def __init__(self, path, pattern): … … 73 73 Parameters 74 74 ---------- 75 path : :obj:`string`75 path : str 76 76 Directory where to list the files. 77 77 78 pattern : :obj:`string`78 pattern : str 79 79 Regular expression pattern. For example: '\*.grb' 80 80 … … 92 92 return 93 93 94 #@profiling.timefn 94 95 95 def _list_files(self, path): 96 96 '''Lists all files in the directory with the matching … … 99 99 Parameters 100 100 ---------- 101 path : :obj:`string`101 path : str 102 102 Path to the files. 103 103 … … 116 116 return 117 117 118 118 119 def __str__(self): 119 120 '''Converts the list of files into a single string. … … 125 126 Return 126 127 ------ 127 files_string : :obj:`string`128 files_string : str 128 129 The content of the list as a single string. 129 130 ''' … … 133 134 134 135 return files_string 136 135 137 136 138 def delete_files(self):
Note: See TracChangeset
for help on using the changeset viewer.