in pplbench/lib/utils.py [0:0]
def save_dataset(output_dir: str, name_prefix: str, ds: xr.Dataset) -> None:
"""
Saves the dataset in both NetCDF binary format as well as a readable CSV.
The NetCDF files will be written to `output_dir/name_prefix.nc`
A separate CSV file will be written to `output_dir/name_prefix/varname.csv`
for each data variable `varname` in the dataset.
:param output_dir: directory to save dataset
:param name_prefix: prefix to be added before file names
:param ds: dataset to be saved
"""
ds.to_netcdf(os.path.join(output_dir, name_prefix + ".nc"))
subdir = create_subdir(output_dir, name_prefix)
for varname in ds.data_vars.keys():
getattr(ds, str(varname)).to_dataframe().to_csv(
os.path.join(subdir, f"{varname}.csv")
)
LOGGER.info(f"saved {name_prefix}")