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)
## [1] 697
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:
BR <- getData(rd, list(c(4), 1:11, c(5), 1:3))
scs <- tuple(builtins$slice(3L, 4L, 1L), builtins$slice(0L, 12L, 1L),
builtins$slice(4L, 5L, 1L), builtins$slice(0L, 3L, 1L))
BP <- pd$`__getitem__`(scs)
print(BR)
## [,1] [,2] [,3]
## [1,] 56 30 11
## [2,] 99 65 58
## [3,] 41 81 80
## [4,] 2 68 48
## [5,] 66 89 91
## [6,] 75 39 56
## [7,] 88 84 14
## [8,] 57 2 16
## [9,] 51 17 28
## [10,] 79 21 71
## [11,] 81 8 39
## [1] TRUE
BR <- getData(rd, list(c(5), 1:11, 1:7, c(2)))
scs <- tuple(builtins$slice(4L, 5L, 1L), builtins$slice(0L, 12L, 1L),
builtins$slice(0L, 7L, 1L), builtins$slice(1L, 2L, 1L))
BP <- pd$`__getitem__`(scs)
print(BR)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 73 98 19 71 33 90 12
## [2,] 4 72 61 79 92 9 5
## [3,] 27 9 1 1 49 38 9
## [4,] 1 46 67 94 45 43 7
## [5,] 3 14 41 32 42 6 20
## [6,] 81 69 60 27 99 88 85
## [7,] 24 84 65 86 65 69 42
## [8,] 59 24 94 64 6 1 20
## [9,] 70 20 17 10 81 81 81
## [10,] 26 4 46 22 10 51 51
## [11,] 40 98 36 93 53 90 58
## [1] TRUE
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