Changeset a676cf7 in flex_extract.git
- Timestamp:
- Oct 30, 2022, 1:13:24 AM (17 months ago)
- Branches:
- dev
- Children:
- 7271b6f
- Parents:
- ea754d1
- Location:
- Source/Python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Source/Python/Classes/ControlFile.py
r0540bd0 ra676cf7 624 624 self.end_date) 625 625 626 self.basetime = check_basetime(self.basetime)627 628 626 self.levelist, self.level = check_levels(self.levelist, self.level) 629 627 … … 639 637 self.type = check_type(self.type, self.step) 640 638 639 self.purefc = check_purefc(self.type) 640 641 self.basetime, self.time = check_basetime(self.basetime, self.time, self.purefc) 642 641 643 self.time = check_time(self.time) 642 643 self.purefc = check_purefc(self.type)644 644 645 645 self.type, self.time, self.step = check_len_type_time_step(self.type, … … 652 652 653 653 self.acctime = check_acctime(self.acctime, self.marsclass, 654 self.purefc, self.time) 654 self.purefc, self.time, 655 self.basetime, self.oper) 655 656 656 657 self.accmaxstep = check_accmaxstep(self.accmaxstep, self.marsclass, -
Source/Python/Classes/EcFlexpart.py
r365c82a ra676cf7 615 615 616 616 617 def retrieve(self, server, dates, public, request, inputdir='.'):617 def retrieve(self, server, dates, public, purefc, request, inputdir='.'): 618 618 '''Finalizing the retrieval information by setting final details 619 619 depending on grid type. … … 634 634 "YYYYMMDD/to/YYYYMMDD" 635 635 636 public : int 637 Switch to select kind of ECMWF Web API access and the possible data sets. 638 Public data sets (1) and Member states data sets (0). 639 640 purefc : int 641 Switch to decide whether the job is a pure forecast retrieval or 642 coupled with analysis data. 643 636 644 request : int 637 645 Selects the mode of retrieval. … … 652 660 self.public = public 653 661 self.inputdir = inputdir 662 self.purefc = purefc 654 663 oro = False 655 664 … … 739 748 print('CHANGED FC start date to ' + 740 749 sdate.strftime("%Y%m%d") + 741 ' to accom odate TIME=' +750 ' to accommodate TIME=' + 742 751 retr_param_dict['time'][0] + 743 752 ', STEP=' + … … 753 762 # if yes eliminate those fields since they may not 754 763 # be accessible with user's credentials 755 764 dates = retr_param_dict['date'].split('/') 756 765 enddate = retr_param_dict['date'].split('/')[-1] 757 elimit = datetime.strptime(enddate + str(self.basetime), 758 '%Y%m%d%H') 766 elimit = datetime.strptime(enddate, '%Y%m%d') 759 767 760 768 if self.basetime == 12: 761 769 # -------------- flux data ---------------------------- 762 if 'acc' in pk: 763 startdate = retr_param_dict['date'].split('/')[0] 764 enddate = datetime.strftime(elimit - t24h, '%Y%m%d') 765 retr_param_dict['date'] = '/'.join([startdate, 766 'to', 767 enddate]) 770 if 'acc' in pk and not self.purefc: 771 772 retr_param_dict['date'] = dates[0] 773 retr_param_dict['time'] = '12' 774 retr_param_dict['target'] = \ 775 self._mk_targetname(ftype, pk, 776 retr_param_dict['date']) 768 777 769 778 # ******* start retrievement 770 779 self._start_retrievement(request, retr_param_dict) 771 780 772 retr_param_dict['date'] = \ 773 datetime.strftime(elimit - t12h, '%Y%m%d') 781 retr_param_dict['date'] = dates[-1] 782 retr_param_dict['time'] = '00/12' 783 retr_param_dict['target'] = \ 784 self._mk_targetname(ftype, pk, 785 retr_param_dict['date']) 786 787 # ******* start retrievement 788 self._start_retrievement(request, retr_param_dict) 789 790 # -------------- non flux data ------------------------ 791 else: 792 # ******* start retrievement 793 self._start_retrievement(request, retr_param_dict) 794 795 elif self.basetime == 0: 796 # -------------- flux data ---------------------------- 797 if 'acc' in pk and not self.purefc: 798 799 retr_param_dict['date'] = dates[0] 800 retr_param_dict['time'] = '00/12' 801 retr_param_dict['target'] = \ 802 self._mk_targetname(ftype, pk, 803 retr_param_dict['date']) 804 805 # ******* start retrievement 806 self._start_retrievement(request, retr_param_dict) 807 808 retr_param_dict['date'] = dates[-1] 774 809 retr_param_dict['time'] = '00' 775 810 retr_param_dict['target'] = \ … … 779 814 # ******* start retrievement 780 815 self._start_retrievement(request, retr_param_dict) 781 782 # -------------- non flux data ------------------------ 783 else: 816 elif 'acc' in pk and self.purefc: 784 817 # ******* start retrievement 785 818 self._start_retrievement(request, retr_param_dict) 786 787 elif self.basetime == 0: 788 789 timesave = ''.join(retr_param_dict['time']) 790 791 if all(['/' in retr_param_dict['time'], 792 pk != 'OG_OROLSM__SL', 793 'acc' not in pk]): 794 times = retr_param_dict['time'].split('/') 795 steps = retr_param_dict['step'].split('/') 796 797 while int(times[0]) + int(steps[0]) <= 12: 798 times = times[1:] 799 if len(times) > 1: 800 retr_param_dict['time'] = '/'.join(times) 801 else: 802 retr_param_dict['time'] = times[0] 803 804 if all([pk != 'OG_OROLSM__SL', 805 int(retr_param_dict['step'].split('/')[0]) == 0, 806 int(timesave.split('/')[0]) == 0]): 807 808 retr_param_dict['date'] = \ 809 datetime.strftime(elimit, '%Y%m%d') 810 retr_param_dict['time'] = '00' 811 retr_param_dict['step'] = '000' 812 retr_param_dict['target'] = \ 813 self._mk_targetname(ftype, pk, 814 retr_param_dict['date']) 815 816 if ftype.upper() == 'FC' and \ 817 'acc' not in retr_param_dict['target']: 818 819 retr_param_dict['date'] = \ 820 datetime.strftime(elimit - t24h, '%Y%m%d') 821 822 # ******* start retrievement 823 self._start_retrievement(request, retr_param_dict) 819 # -------------- non flux data ------------------------ 820 else: # 'acc' not in pk 821 timesave = ''.join(retr_param_dict['time']) 822 823 if all(['/' in retr_param_dict['time'], 824 pk != 'OG_OROLSM__SL']): 825 times = retr_param_dict['time'].split('/') 826 steps = retr_param_dict['step'].split('/') 827 828 while int(times[0]) + int(steps[0]) <= 12: 829 times = times[1:] 830 if len(times) > 1: 831 retr_param_dict['time'] = '/'.join(times) 832 else: 833 retr_param_dict['time'] = times[0] 834 835 if all([pk != 'OG_OROLSM__SL', 836 int(retr_param_dict['step'].split('/')[0]) == 0, 837 int(timesave.split('/')[0]) == 0]): 838 839 retr_param_dict['date'] = \ 840 datetime.strftime(elimit, '%Y%m%d') 841 retr_param_dict['time'] = '00' 842 retr_param_dict['step'] = '000' 843 retr_param_dict['target'] = \ 844 self._mk_targetname(ftype, pk, 845 retr_param_dict['date']) 846 847 if ftype.upper() == 'FC' and not self.purefc: 848 849 retr_param_dict['date'] = \ 850 datetime.strftime(elimit - t24h, '%Y%m%d') 851 852 # ******* start retrievement 853 self._start_retrievement(request, retr_param_dict) 824 854 else: 825 855 raise ValueError('ERROR: Basetime has an invalid value ' -
Source/Python/Mods/checks.py
r5606fc9 ra676cf7 93 93 else: 94 94 raise ValueError('GRID parameter contains two ' 95 'different values: %s' (grid))95 'different values: %s', grid) 96 96 # # determine grid format 97 97 # if float(grid) / 100. >= 0.5: … … 236 236 return levelist, level 237 237 238 239 238 def check_ppid(c, ppid): 240 239 '''Sets the current PPID. … … 262 261 return 263 262 264 265 263 def check_purefc(ftype): 266 264 '''Check for a pure forecast mode. … … 283 281 284 282 return 0 285 286 283 287 284 def check_step(step): … … 404 401 Valid values are hours (HH) from forecast base time. 405 402 ''' 406 if not len(ftype) == len(ftime) == len(steps):407 raise ValueError('ERROR: The number of field types, times and steps '408 'are not the same! Please check the settings in the '409 'CONTROL file!')410 411 403 # if pure forecast is selected and only one field type/time is set 412 404 # prepare a complete list of type/time/step combination upto maxstep 413 if len(ft ype) == 1 and purefc:405 if len(ftime) == 1 and purefc: 414 406 nftype = [] 415 407 nsteps = [] … … 421 413 return nftype, nftime, nsteps 422 414 415 if not len(ftype) == len(ftime) == len(steps): 416 raise ValueError('ERROR: The number of field types, times and steps ' 417 'are not the same! Please check the settings in the ' 418 'CONTROL file!') 423 419 return ftype, ftime, steps 424 420 … … 605 601 return maxstep 606 602 607 def check_basetime(basetime ):603 def check_basetime(basetime, time, purefc): 608 604 '''Check if basetime is set and contains one of the two 609 605 possible values (0, 12). … … 615 611 retrieved. 616 612 613 time : str 614 The time in hours of the field. 615 616 purefc : int 617 1 if pure forecasts are to be retrieved. 0 if there are 618 analysis fields in between. 619 617 620 Return 618 621 ------ … … 620 623 The time for a half day retrieval. The 12 hours upfront are to be 621 624 retrieved. 625 626 time : str or list of str 627 The time in hours of the field. 622 628 ''' 623 629 if basetime is not None: … … 626 632 raise ValueError('ERROR: Basetime has an invalid value ' 627 633 '-> {}'.format(str(basetime))) 628 return basetime 634 if purefc: 635 time = str(basetime) 636 return basetime, time 629 637 630 638 def check_request(request, marsfile): … … 707 715 return acctype 708 716 709 710 def check_acctime(acctime, marsclass, purefc, time): 717 def check_acctime(acctime, marsclass, purefc, time, basetime, oper): 711 718 '''Guarantees that the accumulation forecast times were set. 712 719 … … 725 732 Switch for definition of pure forecast mode or not. 726 733 734 basetime : int 735 The time for a half day retrieval. The 12 hours upfront are to be 736 retrieved. 737 738 oper : int 739 Switch to prepare the operational job script. Start date, end date and 740 basetime will be prepared with environment variables. 741 727 742 Return 728 743 ------ … … 730 745 The starting time for the accumulated forecasts. 731 746 ''' 747 748 if acctime and basetime and oper: 749 return basetime 732 750 733 751 if not acctime: … … 817 835 if '/' in addpar: 818 836 parlist = addpar.split('/') 819 parlist = [p for p in parlist if p is not'']837 parlist = [p for p in parlist if p != ''] 820 838 else: 821 839 parlist = [addpar] … … 824 842 825 843 return addpar 826 827 844 828 845 def check_job_chunk(job_chunk): … … 853 870 854 871 return job_chunk 855 856 872 857 873 def check_number(number): -
Source/Python/Mods/get_mars_data.py
r365c82a ra676cf7 160 160 start, end, datechunk = mk_dates(c, fluxes=True) 161 161 do_retrievement(c, server, start, end, datechunk, fluxes=True) 162 162 163 163 # -------------- non flux data -------------------------------------------- 164 164 start, end, datechunk = mk_dates(c, fluxes=False) … … 293 293 chunk = timedelta(days=int(c.date_chunk)) 294 294 295 if c.basetime == 0 and not fluxes : # non-fluxes295 if c.basetime == 0 and not fluxes and not c.purefc: # non-fluxes 296 296 start = start - timedelta(days=1) 297 297 298 298 if c.purefc and fluxes and c.maxstep < 24: 299 299 start = start - timedelta(days=1) 300 if not c.oper:301 end = end + timedelta(days=1)300 # if not c.oper: 301 # end = end + timedelta(days=1) 302 302 303 303 if not c.purefc and fluxes: … … 305 305 if not c.oper: 306 306 end = end + timedelta(days=1) 307 elif c.oper and c.basetime == 0:308 end = end - timedelta(days=1)307 # elif c.oper and c.basetime == 0: 308 # end = end - timedelta(days=1) 309 309 310 310 # if we have non-flux forecast data starting at 18 UTC … … 389 389 390 390 try: 391 flexpart.retrieve(server, dates, c.public, c. request, c.inputdir)391 flexpart.retrieve(server, dates, c.public, c.purefc, c.request, c.inputdir) 392 392 except IOError: 393 393 my_error('MARS request failed')
Note: See TracChangeset
for help on using the changeset viewer.