diff --git a/intake_xarray/opendap.py b/intake_xarray/opendap.py index 3c1fc7e..6c072ab 100644 --- a/intake_xarray/opendap.py +++ b/intake_xarray/opendap.py @@ -90,5 +90,9 @@ def _get_store(self): def _open_dataset(self): import xarray as xr - store = self._get_store() - self._ds = xr.open_dataset(store, chunks=self.chunks, **self._kwargs) + + if isinstance(self.urlpath, list): + self._ds = xr.open_mfdataset(self.urlpath, chunks=self.chunks, **self._kwargs) + else: + store = self._get_store() + self._ds = xr.open_dataset(store, chunks=self.chunks, **self._kwargs) \ No newline at end of file diff --git a/intake_xarray/tests/test_network.py b/intake_xarray/tests/test_network.py index 4526b39..a01210e 100644 --- a/intake_xarray/tests/test_network.py +++ b/intake_xarray/tests/test_network.py @@ -64,3 +64,20 @@ def test_open_netcdf_s3_simplecache(): ds = source.to_dask() assert isinstance(ds._file_obj, xr.backends.h5netcdf_.H5NetCDFStore) assert isinstance(ds, xr.core.dataarray.Dataset) + + +def test_open_opendap(): + url = 'https://www.ncei.noaa.gov/thredds/dodsC/model-cbofs-files/2021/12/nos.cbofs.fields.n001.20211231.t18z.nc' + + source = intake.open_opendap(url, engine='netcdf4', chunks={'time': 1}) + ds = source.to_dask() + assert isinstance(ds, xr.core.dataarray.Dataset) + + +def test_open_list_opendap(): + url1 = 'https://www.ncei.noaa.gov/thredds/dodsC/model-cbofs-files/2021/12/nos.cbofs.fields.n001.20211231.t18z.nc' + url2 = 'https://www.ncei.noaa.gov/thredds/dodsC/model-cbofs-files/2021/12/nos.cbofs.fields.n002.20211231.t18z.nc' + + source = intake.open_opendap([url1, url2], engine='netcdf4', chunks={'time': 1}) + ds = source.to_dask() + assert isinstance(ds, xr.core.dataarray.Dataset)