From 8307db1a09250c1441bcfdb263c9098ea809eddb Mon Sep 17 00:00:00 2001 From: Fabian Gans Date: Wed, 24 Jul 2024 11:33:28 +0200 Subject: [PATCH] add option for varname for mapcube (#415) * add option for varname for mapcube * update project.toml --- Project.toml | 2 +- src/Cubes/Cubes.jl | 2 +- src/DatasetAPI/Datasets.jl | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 9237c45e..8cb69324 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "YAXArrays" uuid = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c" authors = ["Fabian Gans "] -version = "0.5.8" +version = "0.5.9" [deps] CFTime = "179af706-886a-5703-950a-314cd64e0468" diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 8054cad9..0dbff4ba 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -490,7 +490,7 @@ end Base.read(d::YAXArray) = getindex_all(d) function formatbytes(x) - exts = ["bytes", "KB", "MB", "GB", "TB"] + exts = ["bytes", "KB", "MB", "GB", "TB","PB"] i = 1 while x >= 1024 i = i + 1 diff --git a/src/DatasetAPI/Datasets.jl b/src/DatasetAPI/Datasets.jl index 4508da31..d65a27ae 100644 --- a/src/DatasetAPI/Datasets.jl +++ b/src/DatasetAPI/Datasets.jl @@ -652,8 +652,10 @@ function createdataset(DS::Type,axlist; kwargs...) * `persist::Bool=true` shall the disk data be garbage-collected when the cube goes out of scope? * `overwrite::Bool=false` overwrite cube if it already exists * `properties=Dict{String,Any}()` additional cube properties + * `globalproperties=Dict{String,Any}` global attributes to be added to the dataset * `fillvalue= T>:Missing ? defaultfillval(Base.nonmissingtype(T)) : nothing` fill value * `datasetaxis="Variable"` special treatment of a categorical axis that gets written into separate zarr arrays + * `layername="layer"` Fallback name of the variable stored in the dataset if no `datasetaxis` is found """ function createdataset( DS, @@ -665,7 +667,9 @@ function createdataset( chunkoffset = ntuple(i -> 0, length(axlist)), overwrite::Bool = false, properties = Dict{String,Any}(), + globalproperties = Dict{String,Any}(), datasetaxis = "Variable", + layername = "layer", kwargs..., ) if persist === nothing @@ -698,7 +702,7 @@ function createdataset( end end if groupaxis === nothing - cubenames = ["layer"] + cubenames = [layername] else cubenames = DD.lookup(groupaxis) end @@ -712,7 +716,7 @@ function createdataset( dshandle = YAXArrayBase.create_dataset( DS, path, - Dict{String,Any}(), + globalproperties, string.(getproperty.(axdata,:name)), getproperty.(axdata,:data), getproperty.(axdata,:attrs),