Skip to content

Commit

Permalink
Merge pull request #113 from kthyng/open_mfdataset
Browse files Browse the repository at this point in the history
added mfdataset to opendap
  • Loading branch information
martindurant committed Feb 1, 2022
2 parents 71360fe + 472786b commit 77bd753
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions intake_xarray/opendap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 17 additions & 0 deletions intake_xarray/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 77bd753

Please sign in to comment.