[docs]classTHREDDSMergedSource(DataSourceMixin):"""Merges multiple datasets into a single datasets. This source takes a THREDDS URL and a path to descend down, and calls the combine function on all of the datasets found. Parameters ---------- url : str Location of server path : str, list of str Subcats to follow; include glob characters (*, ?) in here for matching. driver : str Select driver to access data. Choose from 'netcdf' and 'opendap'. xarray_kwargs: dict kwargs to be passed to xr.open_dataset concat_kwargs: dict kwargs to be passed to xr.concat() filled by files opened by xr.open_dataset previously metadata : dict or None To associate with this source. Examples -------- >>> import intake >>> cat_url = 'https://psl.noaa.gov/thredds/catalog.xml' >>> paths = ['Datasets', 'ncep.reanalysis.dailyavgs', 'surface', 'air.sig995.194*.nc'] >>> src = intake.open_thredds_merged(cat_url, paths) >>> src sources: thredds_merged: args: path: - Datasets - ncep.reanalysis.dailyavgs - surface - air*sig995*194*.nc url: https://psl.noaa.gov/thredds/catalog.xml description: '' driver: intake_thredds.source.THREDDSMergedSource metadata: {} """version='1.0'container='xarray'name='thredds_merged'partition_access=Truedef__init__(self,url,path,driver='opendap',xarray_kwargs={},concat_kwargs=None,metadata=None,):super().__init__(metadata=metadata)self.urlpath=urlif'simplecache::'inurl:self.metadata.update({'fsspec_pre_url':'simplecache::'})ifisinstance(path,str):path=[path]ifnotisinstance(path,list):raiseValueError(f'path must be list of str, found {type(path)}')ifnotall(isinstance(item,str)foriteminpath):raiseValueError('path must be list of str')self.path=pathself.driver=driverself.xarray_kwargs=xarray_kwargsself.concat_kwargs=concat_kwargsself._ds=Nonedef_open_dataset(self):importxarrayasxrifself._dsisNone:cat=ThreddsCatalog(self.urlpath,driver=self.driver)foriinrange(len(self.path)):part=self.path[i]if'*'notinpartand'?'notinpart:cat=cat[part](driver=self.driver)else:breakpath=self.path[i:]data=[ds(xarray_kwargs=self.xarray_kwargs).to_dask()fordsintqdm(_match(cat,path),desc='Dataset(s)',ncols=79)]ifself.concat_kwargs:self._ds=xr.concat(data,**self.concat_kwargs)else:self._ds=xr.combine_by_coords(data,combine_attrs='override')