Commit 112a9839 authored by BorjaEst's avatar BorjaEst
Browse files

Integrating attrs tests

parent 70de597a
......@@ -10,7 +10,8 @@ def tco3(year_range):
xr.Dataset(
data_vars=dict(
tco3=(["longitude", "latitude", "time"],
np.random.rand(21, 11, 12))
np.random.rand(21, 11, 12),
dict(description="Test tco3 xarray"))
),
coords=dict(
longitude=coordinate.lon(num=21),
......@@ -18,7 +19,7 @@ def tco3(year_range):
pressure_level=coordinate.plev(num=4),
time=coordinate.time(num=12, start=year)
),
attrs=dict(description="Test tco3 dataset")
attrs=dict(description="Test ozone dataset")
).to_netcdf("tco3_{}.nc".format(year))
......@@ -27,7 +28,8 @@ def vmro3(year_range):
xr.Dataset(
data_vars=dict(
vmro3=(["longitude", "latitude", "pressure_level", "time"],
np.random.rand(21, 11, 4, 12))
np.random.rand(21, 11, 4, 12),
dict(description="Test vmro3 xarray"))
),
coords=dict(
longitude=coordinate.lon(num=21),
......@@ -35,7 +37,7 @@ def vmro3(year_range):
pressure_level=coordinate.plev(num=4),
time=coordinate.time(num=12, start=year)
),
attrs=dict(description="Test vmro3 dataset")
attrs=dict(description="Test ozone dataset")
).to_netcdf("vmro3_{}.nc".format(year))
......@@ -44,9 +46,11 @@ def combined(year_range):
xr.Dataset(
data_vars=dict(
tco3=(["longitude", "latitude", "time"],
np.random.rand(21, 11, 12)),
np.random.rand(21, 11, 12),
dict(description="Test tco3 xarray")),
vmro3=(["longitude", "latitude", "pressure_level", "time"],
np.random.rand(21, 11, 4, 12))
np.random.rand(21, 11, 4, 12),
dict(description="Test vmro3 xarray"))
),
coords=dict(
longitude=coordinate.lon(num=21),
......
......@@ -38,13 +38,21 @@ class TestSkimming_NoGroup:
@pytest.mark.parametrize('model_name', conftest.models_tco3, indirect=True)
@pytest.mark.parametrize('year', [None], indirect=True)
def test_skimmed_tco3(self, skimmed_model):
def test_skimmed_tco3_coords(self, skimmed_model):
assert 'tco3_zm' in skimmed_model.var()
assert 'time' in skimmed_model.coords
assert not 'plev' in skimmed_model.coords
assert 'lat' in skimmed_model.coords
assert not 'lon' in skimmed_model.coords
@pytest.mark.parametrize('model_name', conftest.models_tco3, indirect=True)
@pytest.mark.parametrize('year', [None], indirect=True)
def test_skimmed_tco3_attrs(self, skimmed_model):
expected_ds_attrs = dict(description="Test ozone dataset")
assert skimmed_model.attrs == expected_ds_attrs
expected_tco3_attrs = dict(description="Test tco3 xarray")
assert skimmed_model.tco3_zm.attrs == expected_tco3_attrs
@pytest.mark.parametrize('groupby', ['year'], indirect=True)
class TestSkimming_ByYear:
......@@ -56,13 +64,21 @@ class TestSkimming_ByYear:
@pytest.mark.parametrize('model_name', conftest.models_tco3, indirect=True)
@pytest.mark.parametrize('year', list(conftest.year_line), indirect=True)
def test_skimmed_tco3(self, skimmed_model):
def test_skimmed_tco3_coords(self, skimmed_model):
assert 'tco3_zm' in skimmed_model.var()
assert 'time' in skimmed_model.coords
assert not 'plev' in skimmed_model.coords
assert 'lat' in skimmed_model.coords
assert not 'lon' in skimmed_model.coords
@pytest.mark.parametrize('model_name', conftest.models_tco3, indirect=True)
@pytest.mark.parametrize('year', list(conftest.year_line), indirect=True)
def test_skimmed_tco3_attrs(self, skimmed_model):
expected_ds_attrs = dict(description="Test ozone dataset")
assert skimmed_model.attrs == expected_ds_attrs
expected_tco3_attrs = dict(description="Test tco3 xarray")
assert skimmed_model.tco3_zm.attrs == expected_tco3_attrs
@pytest.mark.parametrize('groupby', ['decade'], indirect=True)
class TestSkimming_ByDecade:
......@@ -79,13 +95,21 @@ class TestSkimming_ByDecade:
@pytest.mark.parametrize('model_name', conftest.models_tco3, indirect=True)
@pytest.mark.parametrize('year', [y for y in conftest.year_line if y % 10 == 0], indirect=True)
def test_skimmed_tco3(self, skimmed_model):
def test_skimmed_tco3_coords(self, skimmed_model):
assert 'tco3_zm' in skimmed_model.var()
assert 'time' in skimmed_model.coords
assert not 'plev' in skimmed_model.coords
assert 'lat' in skimmed_model.coords
assert not 'lon' in skimmed_model.coords
@pytest.mark.parametrize('model_name', conftest.models_tco3, indirect=True)
@pytest.mark.parametrize('year', [y for y in conftest.year_line if y % 10 == 0], indirect=True)
def test_skimmed_tco3_attrs(self, skimmed_model):
expected_ds_attrs = dict(description="Test ozone dataset")
assert skimmed_model.attrs == expected_ds_attrs
expected_tco3_attrs = dict(description="Test tco3 xarray")
assert skimmed_model.tco3_zm.attrs == expected_tco3_attrs
@pytest.mark.parametrize('groupby', [None, 'year', 'decade'], indirect=True)
class TestSkimming_Common:
......
......@@ -39,13 +39,21 @@ class TestSkimming_NoGroup:
@pytest.mark.parametrize('model_name', conftest.models_vmro3, indirect=True)
@pytest.mark.parametrize('year', [None], indirect=True)
def test_skimmed_vmro3(self, skimmed_model):
def test_skimmed_vmro3_coords(self, skimmed_model):
assert 'vmro3_zm' in skimmed_model.var()
assert 'time' in skimmed_model.coords
assert 'plev' in skimmed_model.coords
assert 'lat' in skimmed_model.coords
assert not 'lon' in skimmed_model.coords
@pytest.mark.parametrize('model_name', conftest.models_vmro3, indirect=True)
@pytest.mark.parametrize('year', [None], indirect=True)
def test_skimmed_vmro3_attrs(self, skimmed_model):
expected_ds_attrs = dict(description="Test ozone dataset")
assert skimmed_model.attrs == expected_ds_attrs
expected_vmro3_attrs = dict(description="Test vmro3 xarray")
assert skimmed_model.vmro3_zm.attrs == expected_vmro3_attrs
@pytest.mark.parametrize('groupby', ['year'], indirect=True)
class TestSkimming_ByYear:
......@@ -57,13 +65,21 @@ class TestSkimming_ByYear:
@pytest.mark.parametrize('model_name', conftest.models_vmro3, indirect=True)
@pytest.mark.parametrize('year', list(conftest.year_line), indirect=True)
def test_skimmed_vmro3(self, skimmed_model):
def test_skimmed_vmro3_coords(self, skimmed_model):
assert 'vmro3_zm' in skimmed_model.var()
assert 'time' in skimmed_model.coords
assert 'plev' in skimmed_model.coords
assert 'lat' in skimmed_model.coords
assert not 'lon' in skimmed_model.coords
@pytest.mark.parametrize('model_name', conftest.models_vmro3, indirect=True)
@pytest.mark.parametrize('year', list(conftest.year_line), indirect=True)
def test_skimmed_vmro3_attrs(self, skimmed_model):
expected_ds_attrs = dict(description="Test ozone dataset")
assert skimmed_model.attrs == expected_ds_attrs
expected_vmro3_attrs = dict(description="Test vmro3 xarray")
assert skimmed_model.vmro3_zm.attrs == expected_vmro3_attrs
@pytest.mark.parametrize('groupby', ['decade'], indirect=True)
class TestSkimming_ByDecade:
......@@ -80,13 +96,21 @@ class TestSkimming_ByDecade:
@pytest.mark.parametrize('model_name', conftest.models_vmro3, indirect=True)
@pytest.mark.parametrize('year', [y for y in conftest.year_line if y % 10 == 0], indirect=True)
def test_skimmed_vmro3(self, skimmed_model):
def test_skimmed_vmro3_coords(self, skimmed_model):
assert 'vmro3_zm' in skimmed_model.var()
assert 'time' in skimmed_model.coords
assert 'plev' in skimmed_model.coords
assert 'lat' in skimmed_model.coords
assert not 'lon' in skimmed_model.coords
@pytest.mark.parametrize('model_name', conftest.models_vmro3, indirect=True)
@pytest.mark.parametrize('year', [y for y in conftest.year_line if y % 10 == 0], indirect=True)
def test_skimmed_vmro3_attrs(self, skimmed_model):
expected_ds_attrs = dict(description="Test ozone dataset")
assert skimmed_model.attrs == expected_ds_attrs
expected_vmro3_attrs = dict(description="Test vmro3 xarray")
assert skimmed_model.vmro3_zm.attrs == expected_vmro3_attrs
@pytest.mark.parametrize('groupby', [None, 'year', 'decade'], indirect=True)
class TestSkimming_Common:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment