-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths1_get_ecmwf_archive.py
57 lines (52 loc) · 1.74 KB
/
s1_get_ecmwf_archive.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import datetime, sys, os
from ecmwfapi import ECMWFService
os.environ['ECMWF_API_KEY'] = "bbfde4b05540eefc786ab64c9f4ea8b7"
os.environ['ECMWF_API_URL'] = "https://api.ecmwf.int/v1"
os.environ['ECMWF_API_EMAIL'] = "[email protected]"
#{
# "url" : "https://api.ecmwf.int/v1",
# "key" : "bbfde4b05540eefc786ab64c9f4ea8b7",
# "email" : "[email protected]"
#}
thisdate = datetime.datetime.strptime(sys.argv[1], '%Y%m%d%H')
ic_source = sys.argv[2]
yyyymmddhh = thisdate.strftime('%Y%m%d%H')
outdir = '/glade/derecho/scratch/sobash/pangu_realtime/%s/%s/'%(yyyymmddhh,ic_source)
outdir = '.'
server = ECMWFService("mars")
if ic_source == 'hres':
server.execute( {
"class": "od",
"date": thisdate.strftime('%Y%m%d'),
"time": thisdate.strftime('%H'),
"stream": "oper",
"type": "fc",
"expver": "1",
"param": ["gh","q","t","u","v","msl","2t","10u","10v"],
"step": "0"
},
"%s/hres_analysis_%s.grib2"%(outdir,yyyymmddhh),
)
elif ic_source[0:3] == 'ens':
mem = int(ic_source[3:])
if mem < 1:
client.retrieve(
date=thisdate.strftime('%Y%m%d'),
time=thisdate.strftime('%H'),
stream="enfo",
type="cf",
param=["gh","q","t","u","v","msl","2t","10u","10v"],
step=0,
target="%s/%s_analysis_%s.grib2"%(outdir,ic_source,yyyymmddhh),
)
else:
client.retrieve(
date=thisdate.strftime('%Y%m%d'),
time=thisdate.strftime('%H'),
stream="enfo",
type="pf",
number=mem,
param=["gh","q","t","u","v","msl","2t","10u","10v"],
step=0,
target="%s/%s_analysis_%s.grib2"%(outdir,ic_source,yyyymmddhh),
)