-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
539ae58
commit 135506d
Showing
5 changed files
with
105 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import CommonDataModel: | |
defAttrib, | ||
defVar, | ||
defDim, | ||
defGroup, | ||
dim, | ||
dimnames, | ||
iswritable, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using ZarrDatasets | ||
using Test | ||
|
||
data = rand(Int32,3,5) | ||
data2 = rand(Int8,3,5) | ||
data3 = rand(Int16,4) | ||
|
||
fname = tempname() | ||
mkdir(fname) | ||
|
||
|
||
TDS = ZarrDataset | ||
|
||
#using NCDatasets | ||
#TDS = NCDataset | ||
ds = TDS(fname,"c") | ||
defDim(ds,"lon",3) | ||
defDim(ds,"lat",5) | ||
|
||
attrib = Dict( | ||
"units" => "m/s", | ||
"long_name" => "test", | ||
) | ||
|
||
varname = "var2" | ||
dimensionnames = ("lon","lat") | ||
vtype = Int32 | ||
|
||
zv = defVar(ds,varname,vtype,dimensionnames, attrib = attrib) | ||
zv[:,:] = data | ||
zv.attrib["number"] = 12 | ||
ds.attrib["history"] = "test" | ||
|
||
|
||
group_name = "sub-group" | ||
attrib = Dict("int_attrib" => 42) | ||
|
||
dsg = defGroup(ds,group_name; attrib = attrib) | ||
|
||
defDim(dsg,"time",length(data3)) | ||
|
||
zvg = defVar(dsg,"data2",eltype(data2),("lon","lat")) | ||
zvg[:,:] = data2 | ||
zvg.attrib["standard_name"] = "test" | ||
|
||
zv3 = defVar(dsg,"data3",eltype(data3),("time",)) | ||
zv3[:] = data3 | ||
|
||
|
||
@test_throws Exception defVar(dsg,"data4",Int8,("dimension_does_not_exists",)) | ||
|
||
|
||
io = IOBuffer() | ||
show(io,ds) | ||
s = String(take!(io)) | ||
@test occursin("sub-group",s) | ||
|
||
close(ds) | ||
|
||
# load data from group | ||
|
||
ds = TDS(fname,"r") | ||
|
||
@test ds["var2"][:,:] == data | ||
@test ds.group[group_name]["data2"][:,:] == data2 | ||
@test ds.group[group_name]["data2"].attrib["standard_name"] == "test" | ||
@test ds.group[group_name]["data3"][:] == data3 | ||
|
||
@test ds.group[group_name].attrib["int_attrib"] == 42 | ||
|
||
display(ds) | ||
close(ds) |