forked from rom-py/rompy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_intake_driver.py
86 lines (76 loc) · 2.42 KB
/
test_intake_driver.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import os
from datetime import datetime, timedelta
import pytest
import rompy
from rompy.core import BaseGrid, DataBlob, DataGrid
# round now to the nearest 6 hours
cycle = datetime.utcnow().replace(
hour=0, minute=0, second=0, microsecond=0
) - timedelta(days=2)
@pytest.fixture
def gfs():
return DataGrid(
id="gfs_wind",
catalog=os.path.join(rompy.__path__[0], "catalogs", "gfs.yml"),
dataset="gfs_glob05",
params={"cycle": cycle},
filter={
"crop": {
"time": slice(
cycle,
cycle + timedelta(days=1),
), # Change dates to available dates
"lat": slice(0, 10),
"lon": slice(0, 10),
},
"subset": {"data_vars": ["ugrd10m", "vgrd10m"]},
},
)
@pytest.fixture
def csiro():
return DataGrid(
id="TODO",
catalog=os.path.join(rompy.__path__[0], "catalogs", "gfs.yml"),
dataset="TODO",
params={"cycle": cycle},
filter={
"crop": {
"time": slice(
cycle,
cycle + timedelta(days=1),
), # Change dates to available dates
"lat": slice(0, 10),
"lon": slice(0, 10),
},
"subset": {"data_vars": ["ugrd10m", "vgrd10m"]},
},
)
# mark as slow
@pytest.mark.skipif(
"not config.getoption('--run-slow')",
reason="Only run when --run-slow is given",
)
def test_gfs(tmpdir, gfs):
"""Test that the GFS catalog works"""
assert gfs.ds.lat.max() == 10
assert gfs.ds.lat.min() == 0
assert gfs.ds.lon.max() == 10
assert gfs.ds.lon.min() == 0
downloaded = gfs.get(tmpdir)
assert downloaded.ds.lat.max() == 10
assert downloaded.ds.lat.min() == 0
assert downloaded.ds.lon.max() == 10
assert downloaded.ds.lon.min() == 0
@pytest.mark.skip(reason="Not yet implemented - Ben to have a look")
def test_csiro(tmpdir, csiro):
"""Test that the CSIRO catalog works"""
assert csiro.ds.lat.max() == 10
assert csiro.ds.lat.min() == 0
assert csiro.ds.lon.max() == 10
assert csiro.ds.lon.min() == 0
downloaded = gfs.get(tmpdir)
# These may not be exact, may need to fine tune
# assert downloaded.ds.lat.max() == 10
# assert downloaded.ds.lat.min() == 0
# assert downloaded.ds.lon.max() == 10
# assert downloaded.ds.lon.min() == 0