File: test_dataset.py

package info (click to toggle)
ecmwf-api-client 1.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: python: 572; makefile: 4
file content (38 lines) | stat: -rwxr-xr-x 895 bytes parent folder | download
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
#!/usr/bin/env python3
import ecmwfapi
import time
import os


def test_dataset():
    while True:
        try:
            c = ecmwfapi.ECMWFDataServer("mars")
            c.retrieve(
                {
                    "dataset": "tigge",
                    "step": "24",
                    "levtype": "sl",
                    "date": "20071001",
                    "time": "00",
                    "origin": "ecmf",
                    "type": "cf",
                    "param": "2t",
                    "target": "tigge.grib",
                }
            )
            assert os.path.getsize("tigge.grib") == 428963
            return

        except ecmwfapi.api.APIException as e:
            print(e)
            msg = str(e)
            if "USER_QUEUED_LIMIT_EXCEEDED" not in msg:
                raise

        time.sleep(120)



if __name__ == "__main__":
    test_dataset()