Add rmf array class to object based on object dimensions
rmf_create_array( obj = NA, dim = NULL, kper = attr(obj, "kper"), dimlabels = attr(obj, "dimlabels") )
obj | object to add class to |
---|---|
dim | the dim attribute for the array to be created; by default, dim(obj) is used |
kper | integer vector specifying the stress periods in which the array is active. Used for defining boundary conditions. Defaults to |
dimlabels | character vector specifying the labels of the dimensions; defaults to |
... |
either a rmf_2d_array
, a rmf_3d_array
or rmf_4d_array
object
subsetting a rmf_array
will return a rmf_array
as long as the object has a dim argument (i.e. has 2 or more dimensions). Atomic vectors are therefore never rmf_arrays
.
When l
is not specified when subsetting a rmf_4d_array
, a rmf_4d_array
will always be returned unless drop = TRUE
.
Furthermore, unlike subsetting arrays
, dimensions with length 1 will not be dropped unless the drop
argument is set to TRUE
.
#> [1] 1 2 3 4 5 6 7 8 9 10# returns rmf_2d_array r[,2:6]#> RMODFLOW 2d array with 10 rows and 5 columns, representing the i & j dimensions. #> Not representing stress period data #> [,1] [,2] [,3] [,4] [,5] #> [1,] 11 21 31 41 51 #> [2,] 12 22 32 42 52 #> [3,] 13 23 33 43 53 #> [4,] 14 24 34 44 54 #> [5,] 15 25 35 45 55 #> [6,] 16 26 36 46 56 #> [7,] 17 27 37 47 57 #> [8,] 18 28 38 48 58 #> [9,] 19 29 39 49 59 #> [10,] 20 30 40 50 60r[,1, drop = FALSE]#> RMODFLOW 2d array with 10 rows and 1 column, representing the i & j dimensions. #> Not representing stress period data #> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3 #> [4,] 4 #> [5,] 5 #> [6,] 6 #> [7,] 7 #> [8,] 8 #> [9,] 9 #> [10,] 10#> [1] 151 152 153 154 155 156 157 158 159 160# returns 2D array r[,,1]#> RMODFLOW 2d array with 10 rows and 10 columns, representing the i & j dimensions. #> Active during stress periods: 1 2 #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100r[,1,]#> RMODFLOW 2d array with 10 rows and 3 columns, representing the i & k dimensions. #> Active during stress periods: 1 2 #> [,1] [,2] [,3] #> [1,] 1 101 201 #> [2,] 2 102 202 #> [3,] 3 103 203 #> [4,] 4 104 204 #> [5,] 5 105 205 #> [6,] 6 106 206 #> [7,] 7 107 207 #> [8,] 8 108 208 #> [9,] 9 109 209 #> [10,] 10 110 210# returns 3D array r[,,1, drop = FALSE]#> RMODFLOW 3d array with 10 rows, 10 columns and 1 layer, representing the i, j & k dimensions. #> Active during stress periods: 1 2 #> , , 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100 #>r[,,1:2]#> RMODFLOW 3d array with 10 rows, 10 columns and 2 layers, representing the i, j & k dimensions. #> Active during stress periods: 1 2 #> , , 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 101 111 121 131 141 151 161 171 181 191 #> [2,] 102 112 122 132 142 152 162 172 182 192 #> [3,] 103 113 123 133 143 153 163 173 183 193 #> [4,] 104 114 124 134 144 154 164 174 184 194 #> [5,] 105 115 125 135 145 155 165 175 185 195 #> [6,] 106 116 126 136 146 156 166 176 186 196 #> [7,] 107 117 127 137 147 157 167 177 187 197 #> [8,] 108 118 128 138 148 158 168 178 188 198 #> [9,] 109 119 129 139 149 159 169 179 189 199 #> [10,] 110 120 130 140 150 160 170 180 190 200 #>#> RMODFLOW 4d array with 10 rows, 10 columns, 1 layer and 2 timesteps, representing the i, j, k & l dimensions. #> Not representing stress period data #> , , 1, 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100 #> #> , , 1, 2 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 301 311 321 331 341 351 361 371 381 391 #> [2,] 302 312 322 332 342 352 362 372 382 392 #> [3,] 303 313 323 333 343 353 363 373 383 393 #> [4,] 304 314 324 334 344 354 364 374 384 394 #> [5,] 305 315 325 335 345 355 365 375 385 395 #> [6,] 306 316 326 336 346 356 366 376 386 396 #> [7,] 307 317 327 337 347 357 367 377 387 397 #> [8,] 308 318 328 338 348 358 368 378 388 398 #> [9,] 309 319 329 339 349 359 369 379 389 399 #> [10,] 310 320 330 340 350 360 370 380 390 400 #>r[,,,1, drop = FALSE]#> RMODFLOW 4d array with 10 rows, 10 columns, 3 layers and 1 timestep representing the i, j, k & l dimensions. #> Not representing stress period data #> , , 1, 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100 #> #> , , 2, 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 101 111 121 131 141 151 161 171 181 191 #> [2,] 102 112 122 132 142 152 162 172 182 192 #> [3,] 103 113 123 133 143 153 163 173 183 193 #> [4,] 104 114 124 134 144 154 164 174 184 194 #> [5,] 105 115 125 135 145 155 165 175 185 195 #> [6,] 106 116 126 136 146 156 166 176 186 196 #> [7,] 107 117 127 137 147 157 167 177 187 197 #> [8,] 108 118 128 138 148 158 168 178 188 198 #> [9,] 109 119 129 139 149 159 169 179 189 199 #> [10,] 110 120 130 140 150 160 170 180 190 200 #> #> , , 3, 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 201 211 221 231 241 251 261 271 281 291 #> [2,] 202 212 222 232 242 252 262 272 282 292 #> [3,] 203 213 223 233 243 253 263 273 283 293 #> [4,] 204 214 224 234 244 254 264 274 284 294 #> [5,] 205 215 225 235 245 255 265 275 285 295 #> [6,] 206 216 226 236 246 256 266 276 286 296 #> [7,] 207 217 227 237 247 257 267 277 287 297 #> [8,] 208 218 228 238 248 258 268 278 288 298 #> [9,] 209 219 229 239 249 259 269 279 289 299 #> [10,] 210 220 230 240 250 260 270 280 290 300 #># returns 3D r[,,,1]#> RMODFLOW 3d array with 10 rows, 10 columns and 3 layers, representing the i, j & k dimensions. #> Not representing stress period data #> , , 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 101 111 121 131 141 151 161 171 181 191 #> [2,] 102 112 122 132 142 152 162 172 182 192 #> [3,] 103 113 123 133 143 153 163 173 183 193 #> [4,] 104 114 124 134 144 154 164 174 184 194 #> [5,] 105 115 125 135 145 155 165 175 185 195 #> [6,] 106 116 126 136 146 156 166 176 186 196 #> [7,] 107 117 127 137 147 157 167 177 187 197 #> [8,] 108 118 128 138 148 158 168 178 188 198 #> [9,] 109 119 129 139 149 159 169 179 189 199 #> [10,] 110 120 130 140 150 160 170 180 190 200 #> #> , , 3 #> #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 201 211 221 231 241 251 261 271 281 291 #> [2,] 202 212 222 232 242 252 262 272 282 292 #> [3,] 203 213 223 233 243 253 263 273 283 293 #> [4,] 204 214 224 234 244 254 264 274 284 294 #> [5,] 205 215 225 235 245 255 265 275 285 295 #> [6,] 206 216 226 236 246 256 266 276 286 296 #> [7,] 207 217 227 237 247 257 267 277 287 297 #> [8,] 208 218 228 238 248 258 268 278 288 298 #> [9,] 209 219 229 239 249 259 269 279 289 299 #> [10,] 210 220 230 240 250 260 270 280 290 300 #># returns 2D r[,,1,1]#> RMODFLOW 2d array with 10 rows and 10 columns, representing the i & j dimensions. #> Not representing stress period data #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 11 21 31 41 51 61 71 81 91 #> [2,] 2 12 22 32 42 52 62 72 82 92 #> [3,] 3 13 23 33 43 53 63 73 83 93 #> [4,] 4 14 24 34 44 54 64 74 84 94 #> [5,] 5 15 25 35 45 55 65 75 85 95 #> [6,] 6 16 26 36 46 56 66 76 86 96 #> [7,] 7 17 27 37 47 57 67 77 87 97 #> [8,] 8 18 28 38 48 58 68 78 88 98 #> [9,] 9 19 29 39 49 59 69 79 89 99 #> [10,] 10 20 30 40 50 60 70 80 90 100# dimensions of length 1 are not automatically dropped r <- rmf_create_array(1:100, dim = c(1, 10, 3)) r[,,1] # 1st dimension not dropped#> RMODFLOW 2d array with 1 row and 10 columns, representing the i & j dimensions. #> Not representing stress period data #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 2 3 4 5 6 7 8 9 10r[,,1, drop = TRUE] # 1st dimension dropped#> [1] 1 2 3 4 5 6 7 8 9 10