JuliaDataCubes / YAXArrays.jl

Yet Another XArray-like Julia package
https://juliadatacubes.github.io/YAXArrays.jl/
Other
103 stars 18 forks source link

subsetcube with BitVector index #122

Open alex-s-gardner opened 2 years ago

alex-s-gardner commented 2 years ago

Is it possible to subset a cube according to a BitVector index along a specific dimension?

felixcremer commented 2 years ago

You could use the following code to subset a cube with a boolean vector index along a given dimension. There might be a better way to do that when https://github.com/meggart/DiskArrays.jl/issues/49 is resolved.

function outerselect(cube, index; dims=:Time)
    indims = InDims(dims)
    oldax = getproperty(cube, dims)
    newax = typeof(oldax)(oldax.values[index])
    outdims = OutDims(newax)
    mapCube(innerselect!, cube, index; indims, outdims)
end

innerselect!(xout, xin, index) = xout .= xin[index]
Zapiano commented 8 months ago

Is this a YAXArray issue or a DimensionalData issue? I also need this, but it seems that this issue should be closed and a new one should be opened at DimensionalData.jl.

felixcremer commented 8 months ago

This is a YAXArray issue, because this works on the DimensionalData level, but it does not work on the interaction of the YAXArray and the underlying DiskArray. The problem is, that YAXArrays tries to be as lazy as possible and then we get an error of trying to taking a view of a chunked DiskArray where we can't determine the chunksize of the underlying view.