Skip to content

Commit

Permalink
Merge pull request #9 from meggart/fix_compression
Browse files Browse the repository at this point in the history
Make compression of netcdf and zarr discoverable in interface
  • Loading branch information
meggart authored Nov 30, 2021
2 parents dca35c8 + 241b36a commit ef90b2b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "YAXArrayBase"
uuid = "90b8fcef-0c2d-428d-9c56-5f86629e9d14"
authors = ["Fabian Gans <fgans@bgc-jena.mpg.de>"]
version = "0.3.0"
version = "0.3.1"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
1 change: 1 addition & 0 deletions src/datasets/netcdf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ end
end
writeblock!(v::NetCDFVariable, aout, r::AbstractUnitRange...) = NetCDF.open(a->writeblock!(a,aout,r...), v.filename, v.varname, mode=NC_WRITE)
readblock!(v::NetCDFVariable, aout, r::AbstractUnitRange...) = NetCDF.open(a->readblock!(a,aout,r...), v.filename, v.varname)
iscompressed(v::NetCDFVariable) = NetCDF.open(v->v.compress > 0, v.filename, v.varname)

Base.size(v::NetCDFVariable) = v.size

Expand Down
3 changes: 2 additions & 1 deletion src/datasets/zarr.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using .Zarr: ZArray, ZGroup, zgroup, zcreate,
to_zarrtype, zopen
to_zarrtype, zopen, Compressor

struct ZarrDataset
g::ZGroup
Expand Down Expand Up @@ -42,3 +42,4 @@ push!(backendregex, r"(.zarr$)|(.zarr/$)"=>ZarrDataset)
allow_parallel_write(::ZarrDataset) = true
allow_missings(::ZarrDataset) = true
to_dataset(g::ZGroup; kwargs...) = ZarrDataset(g)
iscompressed(a::ZArray{<:Any,<:Any,<:Compressor}) = true
2 changes: 2 additions & 0 deletions test/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ vn = get_varnames(ds_nc)
@test get_var_dims(ds_nc, "time_bnds") == ["bnds", "time"]
@test get_var_attrs(ds_nc,"tas")["long_name"] == "air_temperature"
h = get_var_handle(ds_nc, "tas")
@test !YAXArrayBase.iscompressed(h)
@test all(isapprox.(h[1:2,1:2], [215.893 217.168; 215.805 217.03]))
@test allow_parallel_write(ds_nc) == false
@test allow_missings(ds_nc) == false
Expand All @@ -31,6 +32,7 @@ vn = get_varnames(ds_zarr)
@test get_var_dims(ds_zarr, "time_bnds") == ["bnds", "time"]
@test get_var_attrs(ds_zarr,"psl")["long_name"] == "Sea Level Pressure"
h = get_var_handle(ds_zarr, "psl")
@test YAXArrayBase.iscompressed(h)
@test all(isapprox.(h[1:2,1:2,1], [99360.8 99334.9; 99360.8 99335.4]))
@test allow_parallel_write(ds_zarr) == true
@test allow_missings(ds_zarr) == true
Expand Down

2 comments on commit ef90b2b

@meggart
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/49588

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" ef90b2b07e53540d4612711b2f51eeb169dd796c
git push origin v0.3.1

Please sign in to comment.