Skip to content

Commit

Permalink
initial cleanup of tests (#273)
Browse files Browse the repository at this point in the history
* initial cleanup of tests

* incorporated PR#274 from @MaxJones.
  • Loading branch information
norlandrhagen authored Sep 27, 2022
1 parent 0c70933 commit 178af15
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmip6_downscaling/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'json': "https://cpdataeuwest.blob.core.windows.net/cp-cmip/training/ERA5-daily-azure.json",
},
"era5_daily_winds": {
'uri': "https://cmip6downscaling.blob.core.windows.net/cmip6/ERA5_daily_winds/",
'uri': "https://cpdataeuwest.blob.core.windows.net/cp-cmip/training/ERA5_daily_winds/",
},
},
'weights': {
Expand Down
2 changes: 1 addition & 1 deletion cmip6_downscaling/data/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def open_era5(variables: str | list[str], time_period: slice) -> xr.Dataset:
ds = xr.concat(
list(cat.search(year=years, cf_variable_name=['tasmax']).to_dataset_dict().values()),
dim='time',
)[variables]
)[non_wind_vars]

for wind_var in wind_vars:
era5_winds = xr.open_zarr(config.get("data_catalog.era5_daily_winds.uri")).rename(
Expand Down
4 changes: 2 additions & 2 deletions tests/methods/common/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
'grid_label': 'gn',
'table_id': 'day',
'scenario': 'ssp370',
"features": ["tasmax"],
'variable': 'tasmax',
"features": ["tasmax", "ua"],
'variable': 'ua',
'latmin': '-2',
'latmax': '2',
'lonmin': '14.5',
Expand Down
18 changes: 18 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
import pytest
from xarray_schema import DataArraySchema, DatasetSchema

from cmip6_downscaling.data.observations import open_era5

params = ['ua', 'va', 'tasmin', 'tasmax', 'pr']


@pytest.mark.parametrize('params', params)
def test_open_era5(params):
ds = open_era5(params, slice('2020', '2020'))
print(ds)
print(params)
schema = DatasetSchema(
{params: DataArraySchema(dtype=np.floating, dims=['time', 'lat', 'lon'])},
)
schema.validate(ds)

1 comment on commit 178af15

@vercel
Copy link

@vercel vercel bot commented on 178af15 Sep 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.