Changeset 0a75335 in flex_extract.git
- Timestamp:
- Jul 10, 2020, 8:20:31 AM (4 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 8028176
- Parents:
- bbbe1e1
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Source/Python/Classes/ControlFile.py
r5f67883 r0a75335 616 616 os.path.join(self.inputdir, _config.FILE_MARS_REQUESTS)) 617 617 618 check_public(self.public, self.dataset )618 check_public(self.public, self.dataset, self.marsclass) 619 619 620 620 self.type = check_type(self.type, self.step) -
Source/Python/Classes/MarsRetrieval.py
r026b359 r0a75335 446 446 447 447 return 448 449 def _convert_to_cdsera5_sfc_request(self, attrs): 450 ''' 451 The keywords and values for the single level download 452 with CDS API is different from MARS. This function 453 converts the old request keywords to the new ones. 454 455 Example request for single level downloads in CDS API 456 457 retrieve( 458 'reanalysis-era5-single-levels', 459 { 460 'product_type': 'reanalysis', 461 'variable': 'total_precipitation', 462 'year': '2019', 463 'month': '01', 464 'day': '01', 465 'time': '00:00', 466 'format': 'grib', 467 'grid':[1.0, 1.0], 468 'area': [ 469 45, 0, 43, 470 12, 471 ], 472 }, 473 'download.grib') 474 475 Parameters 476 ---------- 477 attrs : dict 478 Dictionary of the mars request parameters. 479 480 Return 481 ------ 482 483 ''' 484 from datetime import datetime, timedelta 485 newattrs = {} 486 487 if '/' in attrs['date']: 488 year = set() 489 month = set() 490 day = set() 491 start,end = attrs['date'].split('/')[::2] 492 sdate = datetime.strptime(start, '%Y%m%d') 493 edate = datetime.strptime(end, '%Y%m%d') 494 date = sdate 495 while date <= edate: 496 year.add(date.year) 497 month.add(date.month) 498 day.add(date.day) 499 date = date + timedelta(days=1) 500 newattrs['year'] =list(year) 501 newattrs['month'] = list(month) 502 newattrs['day'] = list(day) 503 else: 504 date = datetime.strptime(attrs['date'], '%Y%m%d') 505 newattrs['year'] = date.year 506 newattrs['month'] = date.month 507 newattrs['day'] = date.day 508 509 newattrs['product_type'] = 'reanalysis' 510 newattrs['area'] = attrs['area'].split('/') 511 newattrs['grid'] = list(map(float,attrs['grid'].split('/'))) 512 newattrs['param'] = attrs['param'].split('/') 513 newattrs['time'] = list(map(str,range(0,24,3))) 514 newattrs['format'] = 'grib' 515 516 return newattrs 448 517 449 518 def data_retrieve(self): … … 479 548 del attrs['target'] 480 549 print('target: ' + target) 481 550 482 551 # find all keys without a value and convert all other values to strings 483 552 empty_keys = [] … … 498 567 try: 499 568 if cds_api and isinstance(self.server, cdsapi.Client): 569 # distinguish between model (ECMWF MARS access) 570 # and surface level (CS3 online access) 571 if attrs['levtype'].lower() == 'ml': 572 dataset = _config.CDS_DATASET_ML 573 else: 574 dataset = _config.CDS_DATASET_SFC 575 attrs = self._convert_to_cdsera5_sfc_request(attrs) 500 576 print('RETRIEVE ERA5 WITH CDS API!') 501 self.server.retrieve( _config.CDS_DATASET,577 self.server.retrieve(dataset, 502 578 attrs, target) 503 579 elif ec_api and isinstance(self.server, ecmwfapi.ECMWFDataServer): -
Source/Python/Mods/checks.py
rf61e1df r0a75335 651 651 return 652 652 653 def check_public(public, dataset ):653 def check_public(public, dataset, marsclass): 654 654 '''Check wether the dataset parameter is set to a 655 655 public data set. … … 667 667 668 668 ''' 669 if public and not dataset :669 if public and not dataset and not (marsclass.upper() == 'EA'): 670 670 raise ValueError('ERROR: If public MARS data are to be retrieved, ' 671 671 'the "dataset"-parameter has to be set, too!') -
Source/Python/_config.py
r98f09d2 r0a75335 46 46 INSTALL_TARGETS = ['local', 'ecgate', 'cca', 'ccb'] 47 47 48 CDS_DATASET = 'reanalysis-era5-complete' 48 CDS_DATASET_ML = 'reanalysis-era5-complete' 49 CDS_DATASET_SFC = 'reanalysis-era5-single-levels' 49 50 50 51 # up-to-date available maximum level numbers at ECMWF, 05.10.2018 -
Testing/Installation/Api_testscripts/test_cdsapi_modellevel.py
r5bf163a r0a75335 13 13 'type' : 'fc', 14 14 'step' : '3/to/12/by/3', 15 'param' : ' 130.128',15 'param' : 't', 16 16 'levtype' : 'ml', 17 17 'levelist': '135/to/137', -
Testing/Installation/Api_testscripts/test_ecmwfapi_public.py
r5bf163a r0a75335 17 17 'type' : "an", 18 18 'class' : "ep", 19 'number' : "0", 19 20 'target' : "download_cera20c_ecmwfapi.grib" 20 21 })
Note: See TracChangeset
for help on using the changeset viewer.