forked from insarlab/PyAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetoper.py
46 lines (40 loc) · 1.53 KB
/
getoper.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
############################################################
# Program is part of PyAPS #
# Copyright 2012, by the California Institute of Technology#
# Contact: earthdef@gps.caltech.edu #
# Modified by A. Benoit and R. Jolivet 2019 #
# Ecole Normale Superieure, Paris #
# Contact: insar@geologie.ens.fr #
############################################################
#!/usr/bin/python
from ecmwf import ECMWFDataServer
#####Replace with your ECMWF key and email address.
####server = ECMWFDataServer(
#### 'http://data-portal.ecmwf.int/data/d/dataserver/',
#### 'a9a3c89533c035e5a92c5758fbf27875',
#### 'abc@def.com'
#### )
def getfiles(bdate,hr,filedir,humidity='Q')
server = ECMWFDataServer('https://api.ecmwf.int/v1',
'yourkey',
'youremailadress')
# Define humidity param
assert humidity in ('Q','R'), 'Unknown humidity field for ECMWF'
if humidity in 'Q':
humidparam = 133
elif humidity in 'R':
humidparam = 157
for day in bdate:
server.retrieve({
'class' : 'od',
'stream' : 'oper',
'expver' : '1',
'date' : "%s"%(bdate),
'time' : "%s"%(hr),
'step' : "0",
'type' : "an",
'levtype' : "pl",
'levelist' : "all",
'param' : "129/130/%d"%(humidparam),
'target' : "%s/%s_%s_%s.grb"%(fileloc,bdate,hr),
})