Skip to content

Commit 19660b3

Browse files
felixcremerFelix Cremer
authored andcommitted
Forward kwargs from construtor to get pyramids
Forward metadata from base to the pyramid struct change plotting to heatmap instead of image!
1 parent f877d68 commit 19660b3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/PyramidScheme.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ struct Pyramid{T,N,D,A,B<:DD.AbstractDimArray{T,N,D,A},L, Me} <: DD.AbstractDimA
4444
metadata::Me
4545
end
4646

47-
function Pyramid(data::DD.AbstractDimArray)
48-
pyrdata, pyraxs = getpyramids(mean skipmissing, data, recursive=false)
47+
function Pyramid(data::DD.AbstractDimArray; resampling_method=mean skipmissing, kwargs...)
48+
pyrdata, pyraxs = getpyramids(resampling_method, data; kwargs...)
4949
levels = DD.DimArray.(pyrdata, pyraxs)
5050
meta = Dict(deepcopy(DD.metadata(data)))
5151
push!(meta, "resampling_method" => "mean_skipmissing")
@@ -72,10 +72,10 @@ function _pyramid_gdal end
7272
function _pyramid_zarr(path)
7373
g = zopen(path)
7474
allkeys = collect(keys(g.groups))
75-
base = Cube(path)[Ti=1] # This getindex should be unnecessary and I should rather fix my data on disk
75+
base = Cube(path) # This getindex should be unnecessary and I should rather fix my data on disk
7676
levavail = extrema(parse.(Int,allkeys[contains.(allkeys, r"\d")]))
7777
clevels = [Cube(open_dataset(g[string(l)])) for l in 1:last(levavail)]
78-
Pyramid(base, clevels, Dict())
78+
Pyramid(base[Ti=1], clevels, DD.metadata(base))
7979
end
8080
# refdims
8181
# name
@@ -124,7 +124,6 @@ end
124124
function Base.map(f, A::Pyramid)
125125
newbase = map(f, parent(A))
126126
newlevels = [map(f, levels(A,i)) for i in 1:nlevels(A)]
127-
@show typeof(newlevels)
128127
Pyramid(newbase, newlevels, DD.metadata(A)) # This should handle metadata better.
129128
end
130129

@@ -315,7 +314,7 @@ The different scales are written according to the GeoZarr spec and a multiscales
315314
The data is aggregated with the specified `resampling_method`.
316315
Keyword arguments are forwarded to the `fill_pyramids` function.
317316
"""
318-
function buildpyramids(path; resampling_method=mean, recursive=true, runner=LocalRunner, verbose=false)
317+
function buildpyramids(path::AbstractString; resampling_method=mean, recursive=true, runner=LocalRunner, verbose=false)
319318
if YAB.backendfrompath(path) != YAB.ZarrDataset
320319
throw(ArgumentError("$path is not a Zarr dataset therefore we can't build the Pyramids inplace"))
321320
end
@@ -441,7 +440,7 @@ ykey(keyext) = DD.dim2key(DD.dims(keyext, YDim))
441440
Internal function
442441
443442
### Extended help
444-
Return an Extent with the limits from `dataext` on the keys of `keyext`.
443+
Return an Extent with the limits from `dataext` and the keys of `keyext`.
445444
We assume that dataext has keys X, and Y and the keys of keyext are XDim and YDim from DimensionalData
446445
"""
447446
function switchkeys(dataext, keyext)
@@ -484,7 +483,7 @@ function plot!(ax, pyramid::Pyramid;interp=false, kwargs...)#; rastercrs=crs(par
484483
notify(data)
485484
end
486485
#@show typeof(data)
487-
hmap = image!(ax, data; interpolate=interp, kwargs...)
486+
hmap = heatmap!(ax, data; interpolate=interp, kwargs...)
488487
end
489488

490489
"""

0 commit comments

Comments
 (0)