2
私は64×64の画像の千枚のスライスを持っていた場合、私はこのような64x64x1チャンクに書くことができます:ndimsが実行時に変化する可能性がある場合、juliaでHDF5を使ってチャンクを書き込む方法は?
using HDF5
filename = "test.h5"
# open file
fmode ="w"
# get a file object
fid = h5open(filename, fmode)
# matrix to write in chunks
B = rand(64,64,1000)
# figure out its dimensions
sizeTuple = size(B)
ndims = length(sizeTuple)
# set up to write in chunks of sizeArray
sizeArray = ones(Int, ndims)
[sizeArray[i] = sizeTuple[i] for i in 1:(ndims-1)] # last value of size array is :...:,1
# create a dataset models within root
dset = d_create(fid, "models", datatype(Float64), dataspace(size(B)), "chunk", sizeArray)
[dset[:,:,i] = slicedim(B, ndims, i) for i in 1:size(B, ndims)]
close(fid)
そして、これはうまく動作しますが、DSETの中に代入構文[:、:、i]が固有のものですndims = 3.実行時に任意のハイパーレクタングルの1000個のスライスを指定した場合、どのように変更できますか?たとえば、B = rand(64,64,3,1000)またはrand(64,64,64,3,1000)の場合は?
おかげ