- Timestamp:
- 03/22/12 15:17:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_erai.py
r109 r176 2 2 # -*- coding: iso-8859-1 -*- 3 3 4 __docformat__ = "restructuredtext en" 5 __version__ = '$Id$' 6 4 7 """ 5 8 … … 7 10 =========== 8 11 9 get ERA-Interim reference files 12 get ERA-Interim reference files between two dates 10 13 11 14 SYNOPSIS … … 14 17 :: 15 18 16 $ python get_erai.py 17 19 $ get_erai.py --begin yyyymmdd --end yyyymmdd 20 21 EXAMPLES 22 ======== 23 24 :: 25 26 $ get_erai.py --verbose --begin 20010101 --end 20010330 18 27 19 28 SEE ALSO … … 22 31 :ref:`ecmwf` 23 32 33 for interactif retrieval 34 http://data-portal.ecmwf.int/data/d/interim_daily/ 35 36 http://data-portal.ecmwf.int/data/d/interim_full_daily 37 38 For python script syntax 39 http://data-portal.ecmwf.int/data/d/token/interim_daily/ 40 41 "Please note that these batch scripts are available for download in grib format only. " ... 42 43 MARS language 44 http://www.ecmwf.int/publications/manuals/mars/guide/index.html 45 24 46 TIPS 25 47 ==== 26 48 27 49 To convet a GRIB file to a NetCDF file :: 28 50 29 51 $ cdo -f nc copy data.grib data.nc 30 52 … … 32 54 ==== 33 55 34 make it work for all needed variables 56 make it work for all needed variables 35 57 36 58 produce netcdf files : now grib dispite name of the file target 37 59 38 60 comment 61 62 nb : le champ str (wind stress pourra/devra être récupéré pour faire des comparaisons (cf. 20c3m_erai_str_TROP_1989_2009.nc) 63 64 nb :Mean sea level pressure en a-t-on vraiment besoin ? jusqu'à présent on ne sait pas si pkb l'a utilisé. 39 65 40 66 EVOLUTIONS … … 45 71 $URL$ 46 72 73 - fplod 20120314 74 75 * add parameters 76 77 - fplod 20120306 78 79 * add all param for analyse (it might be better to do a loop to produce 80 one file/field 81 * add retrieve for forecast (only one parameter here) 82 47 83 - fplod 20111130T153500Z cratos (Linux) 48 84 … … 52 88 """ 53 89 90 import os 91 from optparse import OptionParser 92 import time 93 import datetime 94 from dateutil.parser import * 95 54 96 from ecmwf import ECMWFDataServer 55 97 56 server = ECMWFDataServer( 57 'http://data-portal.ecmwf.int/data/d/dataserver/', 58 'd558d095ce964389eeda5e908e9462f3', 59 'francoise.pinsard@locean-ipsl.upmc.fr' 60 ) 61 62 server.retrieve({ 63 'dataset' : "interim_full_daily", 64 'date' : "19790101/to/19790110", 65 'time' : "00:00:00/06:00:00/12:00:00/18:00:00", 66 'grid' : "1/1", 67 'step' : "0", 68 'levtype' : "sfc", 69 'type' : "an", 70 'param' : "167.128", 71 'area' : "60/-120/30/-60", 72 'target' : "t2m.nc" 73 }) 98 def get_option_parser (): 99 """parse CLI arguments 100 101 :returns: parser 102 :rtype: :class:`optparse.OptionParser` 103 """ 104 105 parser = OptionParser('%prog [--verbose] --begin yyyymmdd --end yyymmdd ') 106 107 parser = OptionParser(conflict_handler="resolve") 108 109 parser.add_option ('-V', '--verbose', help='produce verbose output', 110 action='store_true', 111 default=False, 112 dest='is_verbose') 113 114 parser.add_option('--version', 115 action='store_true', 116 dest='version', 117 help='show version number and exit') 118 119 parser.add_option('--begin', 120 help='date (yyyymmdd) of the first date', 121 dest='yyyymmddb', 122 action='store') 123 124 parser.add_option('--end', 125 help='date (yyyymmdd) of the last date', 126 dest='yyyymmdde', 127 action='store') 128 129 return parser 130 131 def get_erai(): 132 """main 133 """ 134 try: 135 parser = get_option_parser () 136 (fromcli, args) = parser.parse_args() 137 except IOError, msg: 138 parser.error(str(msg)) 139 140 yyyymmddb = parse(fromcli.yyyymmddb, ignoretz=True) 141 yyyymmdde = parse(fromcli.yyyymmdde, ignoretz=True) 142 143 # ++ check date validity and interval validity 144 if fromcli.is_verbose == True: 145 print ('yyyymmddb %s' % (yyyymmddb)) 146 print ('yyyymmdde %s' % (yyyymmdde)) 147 148 # build the value of date parameter yyyymmdd/to/yyyymmdd 149 date_param = fromcli.yyyymmddb + '/to/' + fromcli.yyyymmdde 150 151 if fromcli.is_verbose == True: 152 print ('date for erai %s' % (date_param)) 153 154 server = ECMWFDataServer( 155 'http://data-portal.ecmwf.int/data/d/dataserver/', 156 'd558d095ce964389eeda5e908e9462f3', 157 'Francoise.Pinsard@locean-ipsl.upmc.fr' 158 ) 159 160 # Pour les analyses de 161 # 10 metre U wind component 162 # 10 metre V wind component 163 # 2 metre temperature 164 # 2 metre dewpoint temperature 165 # Sea surface temperature 166 # Mean sea level pressure 167 param_param = [] 168 param_param.append("34.128") #Sea surface temperature sstk 169 #param_param.append("151.128") Mean sea level pressure 170 #param_param.append("165.128") 10 metre U wind component u10 171 #param_param.append("166.128") 10 metre V wind component v10 172 #param_param.append("167.128") 2 metre temperature t2 173 #param_param.append("168.128") 2 metre dewpoint temperature d2 174 175 for one_param in param_param: 176 177 if fromcli.is_verbose == True: 178 print('recup de %s ' % one_param) 179 180 server.retrieve({ 181 'dataset' : "interim_full_daily", 182 'date' : date_param, 183 'time' : "00:00:00/06:00:00/12:00:00/18:00:00", 184 'grid' : "1/1", 185 'step' : "0", 186 'levtype' : "sfc", 187 'type' : "an", 188 'param' : one_param, 189 'area' : "60/-120/30/-60", 190 'target' : "toto.grib" 191 }) 192 193 # Pour la "Surface thermal radiation downwards": 194 param_param = [] 195 param_param.append("175.128") # Surface thermal radiation downwards 196 for one_param in param_param: 197 198 if fromcli.is_verbose == True: 199 print('recup de %s' % one_param) 200 201 server.retrieve({ 202 'dataset' : "interim_full_daily", 203 'date' : date_param, 204 'time' : "00:00:00/12:00:00", 205 'grid' : "1/1", 206 'step' : "12", 207 'levtype' : "sfc", 208 'type' : "fc", 209 'param' : param_param, 210 'area' : "60/-120/30/-60", 211 'target' : "fc.grib" 212 }) 213 214 # Run main, if called from the command line 215 if __name__ == '__main__': 216 get_erai() 217
Note: See TracChangeset
for help on using the changeset viewer.