@@ -221,10 +221,26 @@ def build(self) -> Dataset:
221221
222222 return make_dataset (all_variables , metadata )
223223
224+ def to_mdio (
225+ self ,
226+ store : str ,
227+ mode : str = "w" ,
228+ compute : bool = False ,
229+ ** kwargs : Mapping [str , str | int | float | bool ],
230+ ) -> Dataset :
231+ """Write the dataset to a Zarr store and return the constructed mdio.Dataset.
232+
233+ This function constructs an mdio.Dataset from the MDIO dataset and writes its metadata
234+ to a Zarr store. The actual data is not written, only the metadata structure is created.
235+ """
236+ return write_mdio_metadata (self .build (), store , mode , compute , ** kwargs )
237+
224238
225239def write_mdio_metadata (
226240 mdio_ds : Dataset ,
227241 store : str ,
242+ mode : str = "w" ,
243+ compute : bool = False ,
228244 ** kwargs : Mapping [str , str | int | float | bool ],
229245) -> mdio .Dataset :
230246 """Write MDIO metadata to a Zarr store and return the constructed mdio.Dataset.
@@ -234,7 +250,9 @@ def write_mdio_metadata(
234250
235251 Args:
236252 mdio_ds: The MDIO dataset to serialize
237- store: Path to the Zarr store
253+ store: Path to the Zarr or .mdio store
254+ mode: Write mode to pass to to_mdio(), e.g. 'w' or 'a'
255+ compute: Whether to compute (write) array chunks (True) or only metadata (False)
238256 **kwargs: Additional arguments to pass to to_mdio()
239257
240258 Returns:
@@ -270,11 +288,11 @@ def _generate_encodings() -> dict:
270288
271289 ds .to_mdio (
272290 store ,
273- mode = "w" ,
291+ mode = mode ,
274292 zarr_format = 2 ,
275293 consolidated = True ,
276294 safe_chunks = False ,
277- compute = False ,
295+ compute = compute ,
278296 encoding = _generate_encodings (),
279297 ** kwargs ,
280298 )
0 commit comments