From f1396432f96f07658f6248cdb1675955044629e1 Mon Sep 17 00:00:00 2001 From: Philippe Roy Date: Fri, 13 Sep 2024 12:59:50 -0400 Subject: [PATCH 1/4] Update write.md --- docs/src/UserGuide/write.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/src/UserGuide/write.md b/docs/src/UserGuide/write.md index 3d047041..a043e6e1 100644 --- a/docs/src/UserGuide/write.md +++ b/docs/src/UserGuide/write.md @@ -28,6 +28,17 @@ savedataset(ds, path="ds.zarr", driver=:zarr) nothing # hide ```` +Save a dataset to Zarr format with compression: + +````@example write +using Blosc +n = 7 # compression level +compression = Zarr.BloscCompressor(clevel=n) + +savedataset(ds, path="ds.zarr", driver=:zarr, compressor=compression) +nothing # hide +```` + ## Write NetCDF Save a single YAXArray to a directory: @@ -45,6 +56,14 @@ savedataset(ds, path="ds.nc", driver=:netcdf) nothing # hide ```` +Save a dataset to NetCDF format with compression: + +````@example write +n = 7 # compression level +savedataset(ds, path="ds.zarr", driver=:zarr, compress=n) +nothing # hide +```` + ## Overwrite a Dataset If a path already exists, an error will be thrown. Set `overwrite=true` to delete the existing dataset From fa90f4aad0d9b64c5bd29707f6e94a5c0468f1a8 Mon Sep 17 00:00:00 2001 From: Philippe Roy Date: Fri, 13 Sep 2024 13:04:17 -0400 Subject: [PATCH 2/4] Update write.md --- docs/src/UserGuide/write.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/UserGuide/write.md b/docs/src/UserGuide/write.md index a043e6e1..d3c32289 100644 --- a/docs/src/UserGuide/write.md +++ b/docs/src/UserGuide/write.md @@ -32,7 +32,7 @@ Save a dataset to Zarr format with compression: ````@example write using Blosc -n = 7 # compression level +n = 7 # compression level, number between 0 (no compression) and 9 (max compression) compression = Zarr.BloscCompressor(clevel=n) savedataset(ds, path="ds.zarr", driver=:zarr, compressor=compression) @@ -59,7 +59,7 @@ nothing # hide Save a dataset to NetCDF format with compression: ````@example write -n = 7 # compression level +n = 7 # compression level, number between 0 (no compression) and 9 (max compression) savedataset(ds, path="ds.zarr", driver=:zarr, compress=n) nothing # hide ```` From 96d46c226e9270655190037aedf80ef61708f1ac Mon Sep 17 00:00:00 2001 From: Philippe Roy Date: Fri, 13 Sep 2024 13:57:01 -0400 Subject: [PATCH 3/4] Update docs/src/UserGuide/write.md Co-authored-by: Lazaro Alonso --- docs/src/UserGuide/write.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/write.md b/docs/src/UserGuide/write.md index d3c32289..78fb2b91 100644 --- a/docs/src/UserGuide/write.md +++ b/docs/src/UserGuide/write.md @@ -60,7 +60,7 @@ Save a dataset to NetCDF format with compression: ````@example write n = 7 # compression level, number between 0 (no compression) and 9 (max compression) -savedataset(ds, path="ds.zarr", driver=:zarr, compress=n) +savedataset(ds, path="ds.nc", driver=:netcdf, compress=n) nothing # hide ```` From e3d1cd00657173b92f61136ce8b9cda04ca563d3 Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Sun, 22 Sep 2024 14:37:45 +0200 Subject: [PATCH 4/4] some notes --- docs/src/UserGuide/write.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/src/UserGuide/write.md b/docs/src/UserGuide/write.md index 78fb2b91..faba9ed9 100644 --- a/docs/src/UserGuide/write.md +++ b/docs/src/UserGuide/write.md @@ -27,18 +27,19 @@ Save an entire Dataset to a directory: savedataset(ds, path="ds.zarr", driver=:zarr) nothing # hide ```` - +### zarr compression Save a dataset to Zarr format with compression: ````@example write -using Blosc -n = 7 # compression level, number between 0 (no compression) and 9 (max compression) -compression = Zarr.BloscCompressor(clevel=n) +n = 9 # compression level, number between 0 (no compression) and 9 (max compression) +compression = Zarr.BloscCompressor(; clevel=n) -savedataset(ds, path="ds.zarr", driver=:zarr, compressor=compression) +savedataset(ds; path="ds_c.zarr", driver=:zarr, compressor=compression) nothing # hide ```` +More on [Zarr Compressors](https://juliaio.github.io/Zarr.jl/latest/reference/#Compressors). Also, if you use this option and don't notice a significant improvement, please feel free to open an issue or start a discussion. + ## Write NetCDF Save a single YAXArray to a directory: @@ -56,14 +57,23 @@ savedataset(ds, path="ds.nc", driver=:netcdf) nothing # hide ```` +### netcdf compression Save a dataset to NetCDF format with compression: ````@example write n = 7 # compression level, number between 0 (no compression) and 9 (max compression) -savedataset(ds, path="ds.nc", driver=:netcdf, compress=n) +savedataset(ds, path="ds_c.nc", driver=:netcdf, compress=n) nothing # hide ```` +Comparing it to the default saved file + +````@example write +ds_info = stat("ds.nc") +ds_c_info = stat("ds_c.nc") +println("File size: ", "default: ", ds_info.size, " bytes", ", compress: ", ds_c_info.size, " bytes") +```` + ## Overwrite a Dataset If a path already exists, an error will be thrown. Set `overwrite=true` to delete the existing dataset