Changeset 8209738 in flex_extract.git for Source/Python/Mods/checks.py
- Timestamp:
- May 7, 2020, 3:32:03 PM (4 years ago)
- Branches:
- master, ctbto, dev
- Children:
- b936fd3
- Parents:
- 05e9362
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Source/Python/Mods/checks.py
r50f9ca6 r8209738 119 119 '''Defines the correct area string. 120 120 121 Checks on the format of the four area components. Wether it is of 122 the order of 1000 or 1. Also checks wether area was already set by command 123 line, then the four components are overwritten. 121 Checks the format of the four area components wether it is on 122 the order of 1000 or 1. 123 Also checks wether area was already set on command line, 124 then the four components are overwritten. 124 125 Convert to correct format of the order of magnitude "1" and sets the 125 126 area parameter (North/West/South/East). … … 135 136 136 137 upper : str 137 The northern 138 The northernmost latitude. 138 139 139 140 lower : str 140 The souther 141 The southernmost latitude. 141 142 142 143 left : str 143 The western 144 The westernmost longitude. 144 145 145 146 right : str 146 The eastern most longiude.147 The easternmost longitude. 147 148 148 149 Return 149 150 ------ 150 151 grid : str 151 Contains grid in format Lat/lon. E.g. 0.1/0.1152 Contains grid in format lat/lon. E.g. 0.1/0.1 152 153 ''' 153 154 if 'N' in grid: # Gaussian output grid … … 180 181 float(right)) 181 182 else: 182 raise ValueError(' The area components have different'183 raise ValueError('Area components have inconsisten or unrecognised ' 183 184 'formats (upper, lower, left, right): ' 184 185 '{}/{}/{}/{}'.format(str(upper), str(lower), … … 209 210 level : str 210 211 Specifies the maximum level. It has to be one of the 211 available maximum level number as contained in the variable212 MAX_LEVEL_LIST in "_config" . E.g.[16, 19, 31, 40, 50, 60, 62, 91, 137]212 available maximum level numbers as contained in the variable 213 MAX_LEVEL_LIST in "_config": [16, 19, 31, 40, 50, 60, 62, 91, 137] 213 214 214 215 ''' … … 346 347 for i, val in enumerate(ftype): 347 348 if ftype[i] == 'AN' and int(steps[i]) != 0: 348 print(' Analysis retrievals must have STEP = 0 (now set to 0)')349 print('For analysis data, STEP = 0 is needed. Setting to 0 now.)') 349 350 ftype[i] = 0 350 351 … … 386 387 maxstep : int 387 388 The maximum forecast time step in hours from the forecast base time. 388 This is the maximum step for non flux (accumulated) forecast data.389 This is the maximum step for non-flux (not accumulated) forecast data. 389 390 390 391 purefc : int … … 405 406 if not len(ftype) == len(ftime) == len(steps): 406 407 raise ValueError('ERROR: The number of field types, times and steps ' 407 'are not the same! Please check the setting in the '408 'are not the same! Please check the settings in the ' 408 409 'CONTROL file!') 409 410 … … 423 424 424 425 def check_mail(mail): 425 '''Check the string of mail addresses, sep erate them and convert to alist.426 '''Check the string of mail addresses, separate them and convert to list. 426 427 427 428 Parameters … … 529 530 530 531 def check_dates(start, end): 531 '''Checks if there is at least a start date for a one 532 '''Checks if there is at least a start date for a one-day retrieval. 532 533 533 534 Checks if end date lies after start date and end date is set. … … 628 629 629 630 def check_request(request, marsfile): 630 '''Check if there is an old mars request file andremove it.631 '''Check if there is an old MARS request file; if so, remove it. 631 632 632 633 Parameters … … 651 652 652 653 def check_public(public, dataset): 653 '''Check wether the dataset parameter is set fora654 public data set retrieval.654 '''Check wether the dataset parameter is set to a 655 public data set. 655 656 656 657 Parameters … … 667 668 ''' 668 669 if public and not dataset: 669 raise ValueError('ERROR: If public mars data wantsto be retrieved, '670 'the "dataset"-parameter has to be set too!')670 raise ValueError('ERROR: If public MARS data are to be retrieved, ' 671 'the "dataset"-parameter has to be set, too!') 671 672 return 672 673 … … 674 675 '''Guarantees that the accumulation field type is set. 675 676 676 If not set, it is deriv ated as inthe old method (TYPE[1]).677 If not set, it is derived with the old method (TYPE[1]). 677 678 678 679 Parameters … … 710 711 '''Guarantees that the accumulation forecast times were set. 711 712 712 If it is not set, it tries to set the value for some of the713 most commonly used data sets. Otherwise it raises an error.713 If not set, setting the value to some of the most commonly used data sets 714 is attempted. Otherwise, an eror is raised. 714 715 715 716 Parameters 716 717 ---------- 717 718 acctime : str 718 The starting time f romthe accumulated forecasts.719 The starting time for the accumulated forecasts. 719 720 720 721 marsclass : str … … 727 728 ------ 728 729 acctime : str 729 The starting time f romthe accumulated forecasts.730 The starting time for the accumulated forecasts. 730 731 ''' 731 732 732 733 if not acctime: 733 print('... Control parameter ACCTIME was not defined.')734 print('... Control parameter ACCTIME was not set.') 734 735 print('... Value will be set depending on field type:\n ' 735 736 '\t\t EA=06/18\n\t\t EI/OD=00/12\n\t\t EP=18') … … 745 746 acctime = time[0] 746 747 else: 747 raise ValueError('ERROR: Accumulation forecast time can not '748 ' automatically be derived!')748 raise ValueError('ERROR: Accumulation forecast time can not be' 749 'derived automatically!') 749 750 return acctime 750 751 751 752 def check_accmaxstep(accmaxstep, marsclass, purefc, maxstep): 752 '''Guarantees that the accumulation forecast step w ereset.753 '''Guarantees that the accumulation forecast step was set. 753 754 754 755 Parameters … … 765 766 maxstep : str 766 767 The maximum forecast time step in hours from the forecast base time. 767 This is the maximum step for non 768 This is the maximum step for non-flux (accumulated) forecast data. 768 769 769 770 Return … … 773 774 ''' 774 775 if not accmaxstep: 775 print('... Control parameter ACCMAXSTEP was not defined.')776 print('... Control parameter ACCMAXSTEP was not set.') 776 777 print('... Value will be set depending on field type/time: ' 777 778 '\n\t\t EA/EI/OD=12\n\t\t EP=24') … … 785 786 print('... For pure forecast mode, the accumulated forecast must ' 786 787 'have the same maxstep as the normal forecast fields!\n' 787 '\t\t A ccmaxstep was set to maxstep!')788 '\t\t ACCMAXSTEP was set to MAXSTEP!') 788 789 else: 789 raise ValueError('ERROR: Accumulation forecast step can not '790 ' automatically be derived!')790 raise ValueError('ERROR: Accumulation forecast step can not be' 791 'derived automatically!') 791 792 else: 792 793 if purefc and int(accmaxstep) != int(maxstep): … … 794 795 print('... For pure forecast mode, the accumulated forecast must ' 795 796 'have the same maxstep as the normal forecast fields!\n' 796 '\t\t A ccmaxstep was set to maxstep!')797 '\t\t ACCMAXSTEP was set to MAXSTEP!') 797 798 return accmaxstep 798 799 799 800 def check_addpar(addpar): 800 801 '''Check that addpar has correct format of additional parameters in 801 a single string, so that it can be easily appended to the hard 802 parameters that areretrieved in any case.802 a single string, so that it can be easily appended to the hard-coded 803 parameters retrieved in any case. 803 804 804 805 Parameters … … 826 827 827 828 def check_job_chunk(job_chunk): 828 '''Checks that if job chunk is set, the number is positive and non 829 '''Checks that if job chunk is set, the number is positive and nonzero. 829 830 830 831 Parameters … … 844 845 845 846 if job_chunk < 0: 846 raise ValueError('ERROR: The number of job chunk is negative!\n'847 raise ValueError('ERROR: The number of job chunks is negative!\n' 847 848 'It has to be a positive number!') 848 849 elif job_chunk == 0:
Note: See TracChangeset
for help on using the changeset viewer.