YAXArrays.jl icon indicating copy to clipboard operation
YAXArrays.jl copied to clipboard

subsetcube with BitVector index

Open alex-s-gardner opened this issue 3 years ago • 3 comments

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

alex-s-gardner avatar Apr 12 '22 21:04 alex-s-gardner

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]

felixcremer avatar Apr 19 '22 09:04 felixcremer

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.

Zapiano avatar Feb 26 '24 06:02 Zapiano

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.

felixcremer avatar Feb 26 '24 12:02 felixcremer