-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add backend intro and how-to diagram #9175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
d495590
5a7d659
05620d3
bf4ee8e
feb9b5b
ae473e0
47bae21
ef71bec
3758947
0aea569
b9c1e02
94f4987
ec9b53a
1ee7bc3
ead8005
7e2a84b
e94ed66
376f360
d8fe173
72ce1fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,80 @@ format (recommended). | |
|
||
np.random.seed(123456) | ||
|
||
You can `read different types of files <https://docs.xarray.dev/en/stable/user-guide/io.html>`_ | ||
in `xr.open_dataset` by specifying the engine to be used: | ||
|
||
```python | ||
import xarray as xr | ||
xr.open_dataset("my_file.grib" , engine="cfgrib") | ||
``` | ||
JessicaS11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The "engine" provides a set of instructions that tells xarray how | ||
to read the data and pack them into a `dataset` (or `dataarray`). | ||
These instructions are stored in an underlying "backend". | ||
|
||
Xarray comes with several backends that cover many common data formats. | ||
Many more backends are available via external libraries, or you can `write your own <https://docs.xarray.dev/en/stable/internals/how-to-add-new-backend.html>`_. | ||
This diagram aims to help you determine - based on the format of the file you'd like to read - | ||
which type of backend you're using and how to use it. | ||
|
||
The rectangular boxes are clickable for more information. | ||
Following the diagram is detailed information on many popular backends. | ||
You can learn more about using and developing backends in the | ||
`Xarray tutorial JupyterBook <https://tutorial.xarray.dev/advanced/backends/backends.html>_`. | ||
JessicaS11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. mermaid:: | ||
:alt: Flowchart illustrating how to choose the right backend engine to read your data | ||
|
||
flowchart LR | ||
built-in-eng["`Is your data stored in one of these formats? | ||
fa:fa-check-square netCDF4 (**netcdf4**) | ||
fa:fa-check-square netCDF3 (**scipy**) | ||
fa:fa-check-square Zarr (**zarr**) | ||
fa:fa-check-square DODS/OPeNDAP (**pydap**) | ||
fa:fa-check-square HDF5 (**h5netcdf**) | ||
`"] | ||
|
||
built-in("`You're in luck! Xarray bundles a backend for this format. | ||
Open data using *xr.open_dataset()*. We recommend | ||
always setting the engine you want to use.`") | ||
|
||
installed-eng["`One of these formats? | ||
fa:fa-check-square GRIB (**cfgrib**) | ||
fa:fa-check-square TileDB (**tiledb**) | ||
fa:fa-check-square GeoTIFF, JPEG-2000, ESRI-hdf (**rioxarray**, via GDAL) | ||
fa:fa-check-square Sentinel-1 SAFE (**xarray-sentinel**) | ||
fa:fa-check-square ... | ||
`"] | ||
|
||
installed("`Install the package indicated in parentheses | ||
to your Python environment. Restart the kernel | ||
and use *xr.open_dataset(files, engine='rioxarray')*`") | ||
|
||
other("`Ask around to see if someone in your data community | ||
has created an Xarray backend for your data type. | ||
If not, you may need to create your own or consider | ||
exporting your data to a more common format.`") | ||
|
||
built-in-eng -->|Yes| built-in | ||
built-in-eng -->|No| installed-eng | ||
|
||
installed-eng -->|Yes| installed | ||
installed-eng -->|No| other | ||
|
||
click built-in-eng "https://docs.xarray.dev/en/stable/getting-started-guide/faq.html#how-do-i-open-format-x-file-as-an-xarray-dataset" | ||
click installed-eng "https://corteva.github.io/rioxarray/stable/getting_started/getting_started.html#rioxarray" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm looking at https://xray--9175.org.readthedocs.build/en/9175/user-guide/io.html — I think this means that clicking anywhere in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - unfortunately you can only add one link per node. My [hesitant] intent was to give users a clickable example, but if you think it's clearer to not have links embedded in the diagram (and either add them as a list after or not at all) I wouldn't argue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think that's a bit confusing... Any chance it takes markdown links? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It didn't on my first attempt, but it takes html ones! |
||
click other "https://docs.xarray.dev/en/stable/internals/how-to-add-new-backend.html" | ||
|
||
classDef quesNodefmt fill:#9DEEF4,stroke:#206C89,text-align:left | ||
class built-in-eng,installed-eng quesNodefmt | ||
|
||
classDef ansNodefmt fill:#FFAA05,stroke:#E37F17,text-align:left,white-space:nowrap | ||
class built-in,installed,other ansNodefmt | ||
|
||
linkStyle default font-size:20pt,color:#206C89 | ||
|
||
|
||
.. _io.netcdf: | ||
|
||
netCDF | ||
|
Uh oh!
There was an error while loading. Please reload this page.