@@ -39,8 +39,8 @@ struct Pyramid{T,N,D,A,B<:DD.AbstractDimArray{T,N,D,A},L, Me} <: DD.AbstractDimA
3939 metadata:: Me
4040end
4141
42- function Pyramid (data:: DD.AbstractDimArray ; resampling_method= mean ∘ skipmissing, kwargs... )
43- pyrdata, pyraxs = getpyramids (resampling_method, data; kwargs... )
42+ function Pyramid (data:: DD.AbstractDimArray ; resampling_method= mean ∘ skipmissing, eltype = nothing , kwargs... )
43+ pyrdata, pyraxs = getpyramids (resampling_method, data; eltype, kwargs... )
4444 levels = DD. DimArray .(pyrdata, pyraxs)
4545 meta = Dict (deepcopy (DD. metadata (data)))
4646 push! (meta, " resampling_method" => " mean_skipmissing" )
@@ -352,7 +352,8 @@ function buildpyramids(path::AbstractString; resampling_method=mean, recursive=t
352352 # tfunc = typeof(resampling_method(zeros(eltype(org), 2,2)))
353353 # t = Missing <: eltype(org) ? Union{Missing, tfunc} : tfunc
354354
355- t = Base. infer_return_type (resampling_method, (Matrix{nonmissingtype (eltype (org))},))
355+ t = Base. infer_return_type (resampling_method, (Matrix{eltype (org)},))
356+
356357 n_level = compute_nlevels (org)
357358 input_axes = DD. dims (org, spatial_dims)
358359 outarrs = [output_zarr (n, DD. dims (org), t, joinpath (path, string (n)),input_axes) for n in 1 : n_level]
414415Compute the data of the pyramids of a given data cube `ras`.
415416This returns the data of the pyramids and the dimension values of the aggregated axes.
416417"""
417- function getpyramids (reducefunc, ras;recursive= true , tilesize= 256 , spatial_dims= SpatialDim)
418+ function getpyramids (reducefunc, ras;recursive= true , tilesize= 256 , spatial_dims= SpatialDim, eltype = nothing )
418419 input_axes = DD. dims (ras)
419420 n_level = compute_nlevels (ras, tilesize)
420421 if iszero (n_level)
@@ -423,7 +424,11 @@ function getpyramids(reducefunc, ras;recursive=true, tilesize=256, spatial_dims=
423424 end
424425 pyramid_sizes = [ceil .(Int, size (ras) ./ 2 ^ i) for i in 1 : n_level]
425426 pyramid_axes = [agg_axis .(input_axes,2 ^ i) for i in 1 : n_level]
426- outtype = Base. infer_return_type (reducefunc, (Matrix{eltype (ras)},))
427+ if isnothing (eltype)
428+ outtype = Base. infer_return_type (reducefunc, (Matrix{eltype (ras)},))
429+ else
430+ outtype = eltype
431+ end
427432 # outtype = Missing <: eltype(ras) ? Union{Missing, outtypefunc} : outtypefunc
428433 outmin = output_arrays (pyramid_sizes, outtype)
429434 ispatial_dims = DD. dimnum (DD. dims (ras),spatial_dims)
0 commit comments