MCPcopy Index your code
hub / github.com/pydata/xarray / H5NetCDFStore

Class H5NetCDFStore

xarray/backends/h5netcdf_.py:110–455  ·  view source on GitHub ↗

Store for reading and writing data via h5netcdf

Source from the content-addressed store, hash-verified

108
109
110class H5NetCDFStore(WritableCFDataStore):
111 """Store for reading and writing data via h5netcdf"""
112
113 __slots__ = (
114 "_filename",
115 "_group",
116 "_manager",
117 "_mode",
118 "autoclose",
119 "format",
120 "is_remote",
121 "lock",
122 )
123
124 def __init__(
125 self,
126 manager: FileManager | h5netcdf.File | h5netcdf.Group,
127 group=None,
128 mode=None,
129 format="NETCDF4",
130 lock=HDF5_LOCK,
131 autoclose=False,
132 ):
133 import h5netcdf
134
135 if isinstance(manager, h5netcdf.File | h5netcdf.Group):
136 if group is None:
137 root, group = find_root_and_group(manager)
138 else:
139 if type(manager) is not h5netcdf.File:
140 raise ValueError(
141 "must supply a h5netcdf.File if the group argument is provided"
142 )
143 root = manager
144 manager = DummyFileManager(root)
145
146 self._manager = manager
147 self._group = group
148 self._mode = mode
149 self.format = format or "NETCDF4"
150 # todo: utilizing find_root_and_group seems a bit clunky
151 # making filename available on h5netcdf.Group seems better
152 self._filename = find_root_and_group(self.ds)[0].filename
153 self.is_remote = is_remote_uri(self._filename)
154 self.lock = ensure_lock(lock)
155 self.autoclose = autoclose
156
157 def get_child_store(self, group: str) -> Self:
158 if self.format == "NETCDF4_CLASSIC":
159 raise ValueError("Cannot create sub-groups in `NETCDF4_CLASSIC` format.")
160
161 if self._group is not None:
162 group = os.path.join(self._group, group)
163 return type(self)(
164 self._manager,
165 group=group,
166 mode=self._mode,
167 lock=self.lock,

Callers 1

open_groups_as_dictMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…