Skip to content

Commit ef90b2b

Browse files
authored
Merge pull request #9 from meggart/fix_compression
Make compression of netcdf and zarr discoverable in interface
2 parents dca35c8 + 241b36a commit ef90b2b

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "YAXArrayBase"
22
uuid = "90b8fcef-0c2d-428d-9c56-5f86629e9d14"
33
authors = ["Fabian Gans <[email protected]>"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"

src/datasets/netcdf.jl

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ end
3232
end
3333
writeblock!(v::NetCDFVariable, aout, r::AbstractUnitRange...) = NetCDF.open(a->writeblock!(a,aout,r...), v.filename, v.varname, mode=NC_WRITE)
3434
readblock!(v::NetCDFVariable, aout, r::AbstractUnitRange...) = NetCDF.open(a->readblock!(a,aout,r...), v.filename, v.varname)
35+
iscompressed(v::NetCDFVariable) = NetCDF.open(v->v.compress > 0, v.filename, v.varname)
3536

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

src/datasets/zarr.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using .Zarr: ZArray, ZGroup, zgroup, zcreate,
2-
to_zarrtype, zopen
2+
to_zarrtype, zopen, Compressor
33

44
struct ZarrDataset
55
g::ZGroup
@@ -42,3 +42,4 @@ push!(backendregex, r"(.zarr$)|(.zarr/$)"=>ZarrDataset)
4242
allow_parallel_write(::ZarrDataset) = true
4343
allow_missings(::ZarrDataset) = true
4444
to_dataset(g::ZGroup; kwargs...) = ZarrDataset(g)
45+
iscompressed(a::ZArray{<:Any,<:Any,<:Compressor}) = true

test/datasets.jl

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ vn = get_varnames(ds_nc)
1616
@test get_var_dims(ds_nc, "time_bnds") == ["bnds", "time"]
1717
@test get_var_attrs(ds_nc,"tas")["long_name"] == "air_temperature"
1818
h = get_var_handle(ds_nc, "tas")
19+
@test !YAXArrayBase.iscompressed(h)
1920
@test all(isapprox.(h[1:2,1:2], [215.893 217.168; 215.805 217.03]))
2021
@test allow_parallel_write(ds_nc) == false
2122
@test allow_missings(ds_nc) == false
@@ -31,6 +32,7 @@ vn = get_varnames(ds_zarr)
3132
@test get_var_dims(ds_zarr, "time_bnds") == ["bnds", "time"]
3233
@test get_var_attrs(ds_zarr,"psl")["long_name"] == "Sea Level Pressure"
3334
h = get_var_handle(ds_zarr, "psl")
35+
@test YAXArrayBase.iscompressed(h)
3436
@test all(isapprox.(h[1:2,1:2,1], [99360.8 99334.9; 99360.8 99335.4]))
3537
@test allow_parallel_write(ds_zarr) == true
3638
@test allow_missings(ds_zarr) == true

0 commit comments

Comments
 (0)