rhdf5client
src <- HSDSSource('http://hsdshdflab.hdfgroup.org')
rd <- HSDSDataset(HSDSFile(src, '/home/spollack/testone.h5'), '/group0/group1/group2/data4d')
A <- getData(rd, list(3:4, 8:9, 5:6, 2:3))
sum(A)
## [1] 697
reticulate
and h5pyd
h5pyd <- import("h5pyd")
builtins <- import_builtins()
endpoint <- 'http://hsdshdflab.hdfgroup.org'
domain <- '/home/spollack/testone.h5'
f <- h5pyd$File(endpoint=endpoint, mode='r', domain=domain)
pd <- f$`__getitem__`('/group0/group1/group2/data4d')
scs <- tuple(builtins$slice(2L, 4L, 1L), builtins$slice(7L, 9L, 1L),
builtins$slice(4L, 6L, 1L), builtins$slice(1L, 3L, 1L))
A <- pd$`__getitem__`(scs)
sum(A)
The dimensionality of the http response from the server is somewhat non-intuitive, so we need to test a case in which the single-width slices are dispersed:
With a two-dimensional array, non-adjacent slices work:
f <- HSDSFile(src, '/home/spollack/testtwo.h5')
d <- HSDSDataset(f, '/grpB/grpC/dataC')
print(getData(d, list(1:9, 1:11)))
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
## [1,] 54 31 60 37 20 66 25 63 0 48 44
## [2,] 42 91 1 79 81 25 66 25 28 97 1
## [3,] 5 73 24 54 74 53 4 39 38 8 9
## [4,] 11 55 65 4 76 78 71 64 79 79 10
## [5,] 66 43 18 59 44 78 6 75 19 12 63
## [6,] 16 2 51 44 58 70 98 20 18 29 8
## [7,] 54 10 9 21 42 45 73 93 33 83 70
## [8,] 59 15 95 27 69 43 3 27 47 8 42
## [9,] 68 49 36 51 7 39 66 38 74 9 4
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 42 91 79 25 25 97
## [2,] 5 73 54 53 39 8
## [3,] 66 43 59 78 75 12
## [4,] 54 10 21 45 93 83
d <- HSDSDataset(HSDSFile(src, '/home/spollack/testone.h5'), '/group0/group1/dataR')
X <- getData(d, list(c(5), 3:6, c(2), 2:4))
print(X)
## [,1] [,2] [,3]
## [1,] 4211 4212 4213
## [2,] 4311 4312 4313
## [3,] 4411 4412 4413
## [4,] 4511 4512 4513
d <- HSDSDataset(HSDSFile(src, '/home/spollack/testone.h5'), '/group0/group1/dataR')
BR <- getData(d, list(c(4), 2:6, c(5), 1:3))
print(BR)
## [,1] [,2] [,3]
## [1,] 3140 3141 3142
## [2,] 3240 3241 3242
## [3,] 3340 3341 3342
## [4,] 3440 3441 3442
## [5,] 3540 3541 3542
## [,1] [,2] [,3]
## [1,] 3140 3141 3142
## [2,] 3240 3241 3242
## [3,] 3440 3441 3442
## [4,] 3540 3541 3542
## [,1] [,2] [,3] [,4] [,5]
## [1,] 3140 3141 3142 3143 3144
## [2,] 3240 3241 3242 3243 3244
## [3,] 3340 3341 3342 3343 3344
## [4,] 3440 3441 3442 3443 3444
## [5,] 3540 3541 3542 3543 3544
## [,1] [,2] [,3] [,4]
## [1,] 3140 3141 3143 3144
## [2,] 3240 3241 3243 3244
## [3,] 3440 3441 3443 3444
## [4,] 3540 3541 3543 3544