1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
[...]
s = Session()
noaaUrl = 'https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_1p00.pl'
params = {
'file': 'file',
'lev_10_m_above_ground': 'on',
'var_UGRD': 'on',
'var_VGRD': 'on',
'leftlon': '0',
'rightlon': '360',
'toplat': '90',
'bottomlat': '-90',
'dir': 'dir'
}
[...]
for c_tm in range(6, 387, 3):
params['file'] = 'gfs.t' + cpo_tz(c_h)[1] + 'z.pgrb2.1p00.f' + f'{c_tm:03}'
params['dir'] = '/gfs.' + cpo_tz(c_h)[0] + '/' + cpo_tz(c_h)[1]
grb2file = 'GFS1_' + cpo_tz(c_h)[0] + '_' + cpo_tz(c_h)[1] + '_' + f'{c_tm:03}' + '.grb2'
grbfile = 'GFS1_' + cpo_tz(c_h)[0] + '_' + cpo_tz(c_h)[1] + '_' + f'{c_tm:03}' + '.grb'
ncfile = 'GFS1_' + cpo_tz(c_h)[0] + '_' + cpo_tz(c_h)[1] + '_' + f'{c_tm:03}' + '.nc1'
r = s.get(noaaUrl, params=params)
while True:
if r.status_code != 200:
print('Waiting ...')
sleep(60)
break
r = s.get(noaaUrl, params=params)
with open(join(path_c_tz_grb2, grb2file), 'wb') as f:
f.write(r.content)
[...] |
Partager