2929from .region import _from_region
3030from .utils import (
3131 _add_cartesian_coordinates ,
32+ _check_filetype ,
3233 _get_bounding_surfaces ,
3334 _split_into_restarts ,
3435)
@@ -719,8 +720,7 @@ def remove_yboundaries(self, **kwargs):
719720 new_metadata = variables [- 1 ].metadata
720721 elif ycoord in self .data [v ].dims :
721722 raise ValueError (
722- f"{ v } only has a { ycoord } -dimension so cannot split "
723- f"into regions."
723+ f"{ v } only has a { ycoord } -dimension so cannot split into regions."
724724 )
725725 else :
726726 variable = self .data [v ]
@@ -788,6 +788,9 @@ def save(
788788 ----------
789789 savepath : str, optional
790790 filetype : str, optional
791+ netCDF format passed to xarray. NOT THE SAME as "engine", which
792+ defaults to h5netcdf via ``_check_filetype()``.
793+ See https://docs.xarray.dev/en/latest/generated/xarray.Dataset.to_netcdf.html
791794 variables : list of str, optional
792795 Variables from the dataset to save. Default is to save all of them.
793796 separate_vars: bool, optional
@@ -910,6 +913,7 @@ def dict_to_attrs(obj, section):
910913 single_var_ds .to_netcdf (
911914 path = str (var_savepath ),
912915 format = filetype ,
916+ engine = _check_filetype (Path (var_savepath )),
913917 compute = True ,
914918 encoding = var_encoding ,
915919 )
@@ -923,7 +927,11 @@ def dict_to_attrs(obj, section):
923927 print ("Saving data..." )
924928 with ProgressBar ():
925929 to_save .to_netcdf (
926- path = savepath , format = filetype , compute = True , encoding = encoding
930+ path = savepath ,
931+ engine = _check_filetype (Path (savepath )),
932+ format = filetype ,
933+ compute = True ,
934+ encoding = encoding ,
927935 )
928936
929937 return
@@ -992,7 +1000,12 @@ def to_restart(
9921000 )
9931001
9941002 with ProgressBar ():
995- xr .save_mfdataset (restart_datasets , paths , compute = True )
1003+ xr .save_mfdataset (
1004+ restart_datasets ,
1005+ paths ,
1006+ compute = True ,
1007+ engine = _check_filetype (paths [0 ]),
1008+ )
9961009
9971010 def animate_list (
9981011 self ,
0 commit comments