-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a first draft for opening zarr data with ZarrDatasets in Rasters
- Loading branch information
1 parent
8fce53b
commit 86417a1
Showing
6 changed files
with
68 additions
and
2 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
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,34 @@ | ||
module RastersZarrDatasetsExt | ||
|
||
@static if isdefined(Base, :get_extension) # julia < 1.9 | ||
using Rasters, ZarrDatasets, CommonDataModel | ||
else | ||
using ..Rasters, ..GRIBDatasets, ..CommonDataModel | ||
end | ||
|
||
import DiskArrays, | ||
FillArrays, | ||
Extents, | ||
GeoInterface, | ||
Missings | ||
|
||
using Dates, | ||
DimensionalData, | ||
GeoFormatTypes | ||
|
||
using Rasters.Lookups | ||
using Rasters.Dimensions | ||
using Rasters: Zarrsource | ||
|
||
using ZarrDatasets | ||
using CommonDataModel: AbstractDataset | ||
|
||
const RA = Rasters | ||
const DD = DimensionalData | ||
const DA = DiskArrays | ||
const GI = GeoInterface | ||
const LA = Lookups | ||
|
||
include("zarrdatasets_source.jl") | ||
|
||
end |
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,21 @@ | ||
const GDS = ZarrDatasets | ||
|
||
function RA.OpenStack(fs::RA.FileStack{Zarrsource,K}) where K | ||
RA.OpenStack{Zarrsource,K}(ZD.ZarrDataset(RA.filename(fs))) | ||
end | ||
|
||
# In ZarrDatasets, the file is open for reading the values and closed afterwards. | ||
Base.close(os::RA.OpenStack{Zarrsource}) = nothing | ||
|
||
function RA._open(f, ::Zarrsource, filename::AbstractString; write=false, kw...) | ||
#isfile(filename) || RA._filenotfound_error(filename) | ||
ds = ZarrDatasets.ZarrDataset(filename) | ||
RA._open(f, Zarrsource(), ds; kw...) | ||
end | ||
|
||
# Hack to get the inner DiskArrays chunks as they are not exposed at the top level | ||
RA._get_eachchunk(var::ZD.ZarrVariable) = DiskArrays.eachchunk(var.zarray) | ||
RA._get_haschunks(var::ZD.ZarrVariable) = DiskArrays.haschunks(var.zarray) | ||
|
||
RA._sourcetrait(::ZD.ZarrVariable) = Zarrsource() | ||
RA._sourcetrait(::ZD.ZarrDataset) = Zarrsource() |
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,2 @@ | ||
using Rasters, Zarr | ||
using ZarrDatasets |