Skip to content

Commit 8307db1

Browse files
authored
add option for varname for mapcube (#415)
* add option for varname for mapcube * update project.toml
1 parent 3b89b6c commit 8307db1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "YAXArrays"
22
uuid = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"
33
authors = ["Fabian Gans <[email protected]>"]
4-
version = "0.5.8"
4+
version = "0.5.9"
55

66
[deps]
77
CFTime = "179af706-886a-5703-950a-314cd64e0468"

src/Cubes/Cubes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ end
490490
Base.read(d::YAXArray) = getindex_all(d)
491491

492492
function formatbytes(x)
493-
exts = ["bytes", "KB", "MB", "GB", "TB"]
493+
exts = ["bytes", "KB", "MB", "GB", "TB","PB"]
494494
i = 1
495495
while x >= 1024
496496
i = i + 1

src/DatasetAPI/Datasets.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,10 @@ function createdataset(DS::Type,axlist; kwargs...)
652652
* `persist::Bool=true` shall the disk data be garbage-collected when the cube goes out of scope?
653653
* `overwrite::Bool=false` overwrite cube if it already exists
654654
* `properties=Dict{String,Any}()` additional cube properties
655+
* `globalproperties=Dict{String,Any}` global attributes to be added to the dataset
655656
* `fillvalue= T>:Missing ? defaultfillval(Base.nonmissingtype(T)) : nothing` fill value
656657
* `datasetaxis="Variable"` special treatment of a categorical axis that gets written into separate zarr arrays
658+
* `layername="layer"` Fallback name of the variable stored in the dataset if no `datasetaxis` is found
657659
"""
658660
function createdataset(
659661
DS,
@@ -665,7 +667,9 @@ function createdataset(
665667
chunkoffset = ntuple(i -> 0, length(axlist)),
666668
overwrite::Bool = false,
667669
properties = Dict{String,Any}(),
670+
globalproperties = Dict{String,Any}(),
668671
datasetaxis = "Variable",
672+
layername = "layer",
669673
kwargs...,
670674
)
671675
if persist === nothing
@@ -698,7 +702,7 @@ function createdataset(
698702
end
699703
end
700704
if groupaxis === nothing
701-
cubenames = ["layer"]
705+
cubenames = [layername]
702706
else
703707
cubenames = DD.lookup(groupaxis)
704708
end
@@ -712,7 +716,7 @@ function createdataset(
712716
dshandle = YAXArrayBase.create_dataset(
713717
DS,
714718
path,
715-
Dict{String,Any}(),
719+
globalproperties,
716720
string.(getproperty.(axdata,:name)),
717721
getproperty.(axdata,:data),
718722
getproperty.(axdata,:attrs),

0 commit comments

Comments
 (0)