Skip to content

Commit 0a75d13

Browse files
authored
Backends descriptions (#7200)
* add backendEntrypoints descriptions * add zarr and store backends * add docstrings to backend classes * add to whats.new
1 parent be6594e commit 0a75d13

File tree

11 files changed

+230
-6
lines changed

11 files changed

+230
-6
lines changed

doc/api-hidden.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@
483483
backends.NetCDF4DataStore.is_remote
484484
backends.NetCDF4DataStore.lock
485485

486+
backends.NetCDF4BackendEntrypoint.available
487+
backends.NetCDF4BackendEntrypoint.description
488+
backends.NetCDF4BackendEntrypoint.url
489+
backends.NetCDF4BackendEntrypoint.guess_can_open
490+
backends.NetCDF4BackendEntrypoint.open_dataset
491+
486492
backends.H5NetCDFStore.autoclose
487493
backends.H5NetCDFStore.close
488494
backends.H5NetCDFStore.encode
@@ -510,6 +516,27 @@
510516
backends.H5NetCDFStore.sync
511517
backends.H5NetCDFStore.ds
512518

519+
backends.H5netcdfBackendEntrypoint.available
520+
backends.H5netcdfBackendEntrypoint.description
521+
backends.H5netcdfBackendEntrypoint.url
522+
backends.H5netcdfBackendEntrypoint.guess_can_open
523+
backends.H5netcdfBackendEntrypoint.open_dataset
524+
525+
backends.PseudoNetCDFDataStore.close
526+
backends.PseudoNetCDFDataStore.get_attrs
527+
backends.PseudoNetCDFDataStore.get_dimensions
528+
backends.PseudoNetCDFDataStore.get_encoding
529+
backends.PseudoNetCDFDataStore.get_variables
530+
backends.PseudoNetCDFDataStore.open
531+
backends.PseudoNetCDFDataStore.open_store_variable
532+
backends.PseudoNetCDFDataStore.ds
533+
534+
backends.PseudoNetCDFBackendEntrypoint.available
535+
backends.PseudoNetCDFBackendEntrypoint.description
536+
backends.PseudoNetCDFBackendEntrypoint.url
537+
backends.PseudoNetCDFBackendEntrypoint.guess_can_open
538+
backends.PseudoNetCDFBackendEntrypoint.open_dataset
539+
513540
backends.PydapDataStore.close
514541
backends.PydapDataStore.get_attrs
515542
backends.PydapDataStore.get_dimensions
@@ -519,6 +546,12 @@
519546
backends.PydapDataStore.open
520547
backends.PydapDataStore.open_store_variable
521548

549+
backends.PydapBackendEntrypoint.available
550+
backends.PydapBackendEntrypoint.description
551+
backends.PydapBackendEntrypoint.url
552+
backends.PydapBackendEntrypoint.guess_can_open
553+
backends.PydapBackendEntrypoint.open_dataset
554+
522555
backends.ScipyDataStore.close
523556
backends.ScipyDataStore.encode
524557
backends.ScipyDataStore.encode_attribute
@@ -541,6 +574,39 @@
541574
backends.ScipyDataStore.sync
542575
backends.ScipyDataStore.ds
543576

577+
backends.ScipyBackendEntrypoint.available
578+
backends.ScipyBackendEntrypoint.description
579+
backends.ScipyBackendEntrypoint.url
580+
backends.ScipyBackendEntrypoint.guess_can_open
581+
backends.ScipyBackendEntrypoint.open_dataset
582+
583+
backends.ZarrStore.close
584+
backends.ZarrStore.encode_attribute
585+
backends.ZarrStore.encode_variable
586+
backends.ZarrStore.get_attrs
587+
backends.ZarrStore.get_dimensions
588+
backends.ZarrStore.get_variables
589+
backends.ZarrStore.open_group
590+
backends.ZarrStore.open_store_variable
591+
backends.ZarrStore.set_attributes
592+
backends.ZarrStore.set_dimensions
593+
backends.ZarrStore.set_variables
594+
backends.ZarrStore.store
595+
backends.ZarrStore.sync
596+
backends.ZarrStore.ds
597+
598+
backends.ZarrBackendEntrypoint.available
599+
backends.ZarrBackendEntrypoint.description
600+
backends.ZarrBackendEntrypoint.url
601+
backends.ZarrBackendEntrypoint.guess_can_open
602+
backends.ZarrBackendEntrypoint.open_dataset
603+
604+
backends.StoreBackendEntrypoint.available
605+
backends.StoreBackendEntrypoint.description
606+
backends.StoreBackendEntrypoint.url
607+
backends.StoreBackendEntrypoint.guess_can_open
608+
backends.StoreBackendEntrypoint.open_dataset
609+
544610
backends.FileManager.acquire
545611
backends.FileManager.acquire_context
546612
backends.FileManager.close

doc/api.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,12 +1109,28 @@ arguments for the ``load_store`` and ``dump_to_store`` Dataset methods:
11091109

11101110
backends.NetCDF4DataStore
11111111
backends.H5NetCDFStore
1112+
backends.PseudoNetCDFDataStore
11121113
backends.PydapDataStore
11131114
backends.ScipyDataStore
1115+
backends.ZarrStore
11141116
backends.FileManager
11151117
backends.CachingFileManager
11161118
backends.DummyFileManager
11171119

1120+
These BackendEntrypoints provide a basic interface to the most commonly
1121+
used filetypes in the xarray universe.
1122+
1123+
.. autosummary::
1124+
:toctree: generated/
1125+
1126+
backends.NetCDF4BackendEntrypoint
1127+
backends.H5netcdfBackendEntrypoint
1128+
backends.PseudoNetCDFBackendEntrypoint
1129+
backends.PydapBackendEntrypoint
1130+
backends.ScipyBackendEntrypoint
1131+
backends.StoreBackendEntrypoint
1132+
backends.ZarrBackendEntrypoint
1133+
11181134
Deprecated / Pending Deprecation
11191135
================================
11201136

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Documentation
6666
By `Tom Nicholas <https://github.com/TomNicholas>`_.
6767
- Rename ``axes`` to ``axs`` in plotting to align with ``matplotlib.pyplot.subplots``. (:pull:`7194`)
6868
By `Jimmy Westling <https://github.com/illviljan>`_.
69+
- Add documentation of specific BackendEntrypoints (:pull:`7200`).
70+
By `Michael Niklas <https://github.com/headtr1ck>`_.
6971

7072
Internal Changes
7173
~~~~~~~~~~~~~~~~

xarray/backends/__init__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
from .cfgrib_ import CfGribDataStore
77
from .common import AbstractDataStore, BackendArray, BackendEntrypoint
88
from .file_manager import CachingFileManager, DummyFileManager, FileManager
9-
from .h5netcdf_ import H5NetCDFStore
9+
from .h5netcdf_ import H5netcdfBackendEntrypoint, H5NetCDFStore
1010
from .memory import InMemoryDataStore
11-
from .netCDF4_ import NetCDF4DataStore
11+
from .netCDF4_ import NetCDF4BackendEntrypoint, NetCDF4DataStore
1212
from .plugins import list_engines
13-
from .pseudonetcdf_ import PseudoNetCDFDataStore
14-
from .pydap_ import PydapDataStore
13+
from .pseudonetcdf_ import PseudoNetCDFBackendEntrypoint, PseudoNetCDFDataStore
14+
from .pydap_ import PydapBackendEntrypoint, PydapDataStore
1515
from .pynio_ import NioDataStore
16-
from .scipy_ import ScipyDataStore
17-
from .zarr import ZarrStore
16+
from .scipy_ import ScipyBackendEntrypoint, ScipyDataStore
17+
from .store import StoreBackendEntrypoint
18+
from .zarr import ZarrBackendEntrypoint, ZarrStore
1819

1920
__all__ = [
2021
"AbstractDataStore",
@@ -32,5 +33,12 @@
3233
"H5NetCDFStore",
3334
"ZarrStore",
3435
"PseudoNetCDFDataStore",
36+
"H5netcdfBackendEntrypoint",
37+
"NetCDF4BackendEntrypoint",
38+
"PseudoNetCDFBackendEntrypoint",
39+
"PydapBackendEntrypoint",
40+
"ScipyBackendEntrypoint",
41+
"StoreBackendEntrypoint",
42+
"ZarrBackendEntrypoint",
3543
"list_engines",
3644
]

xarray/backends/h5netcdf_.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,32 @@ def close(self, **kwargs):
352352

353353

354354
class H5netcdfBackendEntrypoint(BackendEntrypoint):
355+
"""
356+
Backend for netCDF files based on the h5netcdf package.
357+
358+
It can open ".nc", ".nc4", ".cdf" files but will only be
359+
selected as the default if the "netcdf4" engine is not available.
360+
361+
Additionally it can open valid HDF5 files, see
362+
https://h5netcdf.org/#invalid-netcdf-files for more info.
363+
It will not be detected as valid backend for such files, so make
364+
sure to specify ``engine="h5netcdf"`` in ``open_dataset``.
365+
366+
For more information about the underlying library, visit:
367+
https://h5netcdf.org
368+
369+
See Also
370+
--------
371+
backends.H5NetCDFStore
372+
backends.NetCDF4BackendEntrypoint
373+
backends.ScipyBackendEntrypoint
374+
"""
375+
355376
available = has_h5netcdf
377+
description = (
378+
"Open netCDF (.nc, .nc4 and .cdf) and most HDF5 files using h5netcdf in Xarray"
379+
)
380+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.H5netcdfBackendEntrypoint.html"
356381

357382
def guess_can_open(self, filename_or_obj):
358383
magic_number = try_read_magic_number_from_file_or_path(filename_or_obj)

xarray/backends/netCDF4_.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,32 @@ def close(self, **kwargs):
516516

517517

518518
class NetCDF4BackendEntrypoint(BackendEntrypoint):
519+
"""
520+
Backend for netCDF files based on the netCDF4 package.
521+
522+
It can open ".nc", ".nc4", ".cdf" files and will be choosen
523+
as default for these files.
524+
525+
Additionally it can open valid HDF5 files, see
526+
https://h5netcdf.org/#invalid-netcdf-files for more info.
527+
It will not be detected as valid backend for such files, so make
528+
sure to specify ``engine="netcdf4"`` in ``open_dataset``.
529+
530+
For more information about the underlying library, visit:
531+
https://unidata.github.io/netcdf4-python
532+
533+
See Also
534+
--------
535+
backends.NetCDF4DataStore
536+
backends.H5netcdfBackendEntrypoint
537+
backends.ScipyBackendEntrypoint
538+
"""
539+
519540
available = has_netcdf4
541+
description = (
542+
"Open netCDF (.nc, .nc4 and .cdf) and most HDF5 files using netCDF4 in Xarray"
543+
)
544+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.NetCDF4BackendEntrypoint.html"
520545

521546
def guess_can_open(self, filename_or_obj):
522547
if isinstance(filename_or_obj, str) and is_remote_uri(filename_or_obj):

xarray/backends/pseudonetcdf_.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,35 @@ def close(self):
104104

105105

106106
class PseudoNetCDFBackendEntrypoint(BackendEntrypoint):
107+
"""
108+
Backend for netCDF-like data formats in the air quality field
109+
based on the PseudoNetCDF package.
110+
111+
It can open:
112+
- CAMx
113+
- RACM2 box-model outputs
114+
- Kinetic Pre-Processor outputs
115+
- ICARTT Data files (ffi1001)
116+
- CMAQ Files
117+
- GEOS-Chem Binary Punch/NetCDF files
118+
- and many more
119+
120+
This backend is not selected by default for any files, so make
121+
sure to specify ``engine="pseudonetcdf"`` in ``open_dataset``.
122+
123+
For more information about the underlying library, visit:
124+
https://pseudonetcdf.readthedocs.io
125+
126+
See Also
127+
--------
128+
backends.PseudoNetCDFDataStore
129+
"""
130+
107131
available = has_pseudonetcdf
132+
description = (
133+
"Open many atmospheric science data formats using PseudoNetCDF in Xarray"
134+
)
135+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.PseudoNetCDFBackendEntrypoint.html"
108136

109137
# *args and **kwargs are not allowed in open_backend_dataset_ kwargs,
110138
# unless the open_dataset_parameters are explicitly defined like this:

xarray/backends/pydap_.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,24 @@ def get_dimensions(self):
139139

140140

141141
class PydapBackendEntrypoint(BackendEntrypoint):
142+
"""
143+
Backend for steaming datasets over the internet using
144+
the Data Access Protocol, also known as DODS or OPeNDAP
145+
based on the pydap package.
146+
147+
This backend is selected by default for urls.
148+
149+
For more information about the underlying library, visit:
150+
https://www.pydap.org
151+
152+
See Also
153+
--------
154+
backends.PydapDataStore
155+
"""
156+
142157
available = has_pydap
158+
description = "Open remote datasets via OPeNDAP using pydap in Xarray"
159+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.PydapBackendEntrypoint.html"
143160

144161
def guess_can_open(self, filename_or_obj):
145162
return isinstance(filename_or_obj, str) and is_remote_uri(filename_or_obj)

xarray/backends/scipy_.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,29 @@ def close(self):
241241

242242

243243
class ScipyBackendEntrypoint(BackendEntrypoint):
244+
"""
245+
Backend for netCDF files based on the scipy package.
246+
247+
It can open ".nc", ".nc4", ".cdf" and ".gz" files but will only be
248+
selected as the default if the "netcdf4" and "h5netcdf" engines are
249+
not available. It has the advantage that is is a lightweight engine
250+
that has no system requirements (unlike netcdf4 and h5netcdf).
251+
252+
Additionally it can open gizp compressed (".gz") files.
253+
254+
For more information about the underlying library, visit:
255+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.netcdf_file.html
256+
257+
See Also
258+
--------
259+
backends.ScipyDataStore
260+
backends.NetCDF4BackendEntrypoint
261+
backends.H5netcdfBackendEntrypoint
262+
"""
263+
244264
available = has_scipy
265+
description = "Open netCDF files (.nc, .nc4, .cdf and .gz) using scipy in Xarray"
266+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.ScipyBackendEntrypoint.html"
245267

246268
def guess_can_open(self, filename_or_obj):
247269

xarray/backends/store.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
class StoreBackendEntrypoint(BackendEntrypoint):
99
available = True
10+
description = "Open AbstractDataStore instances in Xarray"
11+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.StoreBackendEntrypoint.html"
1012

1113
def guess_can_open(self, filename_or_obj):
1214
return isinstance(filename_or_obj, AbstractDataStore)

xarray/backends/zarr.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,20 @@ def open_zarr(
808808

809809

810810
class ZarrBackendEntrypoint(BackendEntrypoint):
811+
"""
812+
Backend for ".zarr" files based on the zarr package.
813+
814+
For more information about the underlying library, visit:
815+
https://zarr.readthedocs.io/en/stable
816+
817+
See Also
818+
--------
819+
backends.ZarrStore
820+
"""
821+
811822
available = has_zarr
823+
description = "Open zarr files (.zarr) using zarr in Xarray"
824+
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.ZarrBackendEntrypoint.html"
812825

813826
def guess_can_open(self, filename_or_obj):
814827
try:

0 commit comments

Comments
 (0)