-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing a constructed Zarr store to a ZarrDataset
#5
Comments
Here's some code that seems to work preliminarily: function ZarrDatasets.ZarrDataset(store::Zarr.AbstractStore,mode = "r";
parentdataset = nothing,
_omitcode = [404,403],
maskingvalue = missing,
attrib = Dict(),
)
return ZarrDatasets.ZarrDataset(zopen(store, mode); parent_dataset, _omitcode, maskingvalue, attrib)
end
function ZarrDatasets.ZarrDataset(zg::Zarr.ZGroup;
parentdataset = nothing,
_omitcode = [404,403],
maskingvalue = missing,
attrib = Dict(),
)
dimensions = ZarrDatasets.OrderedDict{Symbol,Int}()
iswritable = false
if (zg.storage isa Zarr.HTTPStore) ||
(zg.storage isa Zarr.ConsolidatedStore{Zarr.HTTPStore})
@debug "omit chunks on HTTP error" _omitcode
Zarr.missing_chunk_return_code!(zg.storage,_omitcode)
end
for (varname,zarray) in zg.arrays
for (dimname,dimlen) in zip(reverse(zarray.attrs["_ARRAY_DIMENSIONS"]),size(zarray))
dn = Symbol(dimname)
if haskey(dimensions,dn)
@assert dimensions[dn] == dimlen
else
dimensions[dn] = dimlen
end
end
end
ZarrDatasets.ZarrDataset(parentdataset,zg,dimensions,zg.writeable,maskingvalue)
end |
This looks good to me. Can you make a PR (possibly with a test)? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice to be able to wrap either a constructed
Zarr.AbstractStore
or a fully materializedZarr.ZGroup
in a ZarrDataset, so that CF conventions just work.I'll push a PR shortly that exposes this API.
The text was updated successfully, but these errors were encountered: