pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.6k stars 1.08k forks source link

Feature request: add opendap/netcdf authorization to backend_kwargs in open_[mf]dataset #4916

Open raybellwaves opened 3 years ago

raybellwaves commented 3 years ago

This is a paraphrase of a SO Q: https://stackoverflow.com/questions/66178846/read-in-authorized-opendap-url-using-xarray

Is your feature request related to a problem? Please describe. I would like to use xarray to read data stored at UCAR's Research Data Archive. To access data you have to create an account with a username and password.

Describe the solution you'd like

url = ""https://rda.ucar.edu/thredds/dodsC/files/g/ds084.1/2020/20200101/gfs.0p25.2020010100.f000.grib2"
ds = xr.open_dataset(url, backend_kwargs={"auth": ("username", "password")})

Describe alternatives you've considered You can read this file by create dot files in your home directory (https://stackoverflow.com/a/66179413/6046019)

Additional context The idea of "auth" comes from siphon (https://unidata.github.io/siphon/latest/examples/Basic_Usage.html#sphx-glr-examples-basic-usage-py).

raybellwaves commented 3 years ago

Just came across some of the xr.backends.PydapDataStore stuff here: http://xarray.pydata.org/en/stable/user-guide/io.html#opendap

Haven't tested on the above example