diff --git a/erddapy/core/interfaces.py b/erddapy/core/interfaces.py index aed87866..1fdb8333 100644 --- a/erddapy/core/interfaces.py +++ b/erddapy/core/interfaces.py @@ -17,13 +17,11 @@ import xarray as xr from netCDF4 import Dataset -<<<<<<< HEAD -def to_pandas(url: str, requests_kwargs: Optional[Dict] = None, **kw) -> "pd.DataFrame": -======= def to_pandas( - url: str, requests_kwargs: Optional[Dict] = None, **pandas_kwargs -) -> pd.DataFrame: ->>>>>>> bf7cbb2 (Renaming **kw according to each library) + url: str, + requests_kwargs: Optional[Dict] = None, + pandas_kwargs: Optional[Dict] = None, +) -> "pd.DataFrame": """ Convert a URL to Pandas DataFrame. @@ -33,6 +31,8 @@ def to_pandas( """ if requests_kwargs is None: requests_kwargs = {} + if pandas_kwargs is None: + pandas_kwargs = {} data = urlopen(url, **requests_kwargs) try: return pd.read_csv(data, **pandas_kwargs) @@ -40,15 +40,11 @@ def to_pandas( raise ValueError(f"Could not read url {url} with Pandas.read_csv.") from e -<<<<<<< HEAD -def to_ncCF(url: str, protocol: str = None, **kw) -> "Dataset": - """Convert a URL to a netCDF4 Dataset.""" -======= def to_ncCF( url: str, protocol: str = None, requests_kwargs: Optional[Dict] = None, -) -> Dataset: +) -> "Dataset": """ Convert a URL to a netCDF4 Dataset. @@ -56,7 +52,6 @@ def to_ncCF( protocol: 'griddap' or 'tabledap'. requests_kwargs: arguments to be passed to urlopen method (including auth). """ ->>>>>>> bf7cbb2 (Renaming **kw according to each library) if protocol == "griddap": raise ValueError( f"Cannot use .ncCF with griddap protocol. The URL you tried to access is: '{url}'.", @@ -70,20 +65,22 @@ def to_xarray( url: str, response="opendap", requests_kwargs: Optional[Dict] = None, - **xarray_kwargs, + xarray_kwargs: Optional[Dict] = None, ) -> "xr.Dataset": """ Convert a URL to an xarray dataset. url: URL to request data from. response: type of response to be requested from the server. - requests_kwargs: arguments to be passed to urlopen method + requests_kwargs: arguments to be passed to urlopen method. xarray_kwargs: kwargs to be passed to third-party library (xarray). """ import xarray as xr if requests_kwargs is None: requests_kwargs = {} + if xarray_kwargs is None: + xarray_kwargs = {} if response == "opendap": return xr.open_dataset(url, **xarray_kwargs) else: @@ -91,7 +88,11 @@ def to_xarray( return xr.open_dataset(xr.backends.NetCDF4DataStore(nc), **xarray_kwargs) -def to_iris(url: str, requests_kwargs: Optional[Dict] = None, **iris_kwargs): +def to_iris( + url: str, + requests_kwargs: Optional[Dict] = None, + iris_kwargs: Optional[Dict] = None, +): """ Convert a URL to an iris CubeList. @@ -103,6 +104,8 @@ def to_iris(url: str, requests_kwargs: Optional[Dict] = None, **iris_kwargs): if requests_kwargs is None: requests_kwargs = {} + if iris_kwargs is None: + iris_kwargs = {} data = urlopen(url, **requests_kwargs) with _tempnc(data) as tmp: cubes = iris.load_raw(tmp, **iris_kwargs)