Generic function to convert RMODFLOW objects to tibbles

rmf_as_tibble(...)

# S3 method for cbc
rmf_as_tibble(
  cbc,
  dis,
  i = NULL,
  j = NULL,
  k = NULL,
  l = NULL,
  mask = array(1, dim = c(dis$nrow, dis$ncol, dis$nlay)),
  ijk = NULL,
  prj = rmf_get_prj(dis),
  crs = NULL,
  as_points = FALSE,
  id = "r",
  fluxes = "all",
  ts_time = TRUE,
  ...
)

# S3 method for ddn
rmf_as_tibble(
  ddn,
  dis,
  i = NULL,
  j = NULL,
  k = NULL,
  l = NULL,
  as_points = FALSE,
  ...
)

# S3 method for hed
rmf_as_tibble(
  hed,
  dis,
  i = NULL,
  j = NULL,
  k = NULL,
  l = NULL,
  as_points = FALSE,
  ...
)

# S3 method for rmf_2d_array
rmf_as_tibble(
  array,
  dis,
  mask = array(1, dim = dim(array)),
  prj = rmf_get_prj(dis),
  crs = NULL,
  as_points = FALSE,
  id = "r",
  ...
)

# S3 method for rmf_3d_array
rmf_as_tibble(
  array,
  dis,
  i = NULL,
  j = NULL,
  k = NULL,
  mask = array * 0 + 1,
  prj = rmf_get_prj(dis),
  crs = NULL,
  as_points = FALSE,
  id = "r",
  ...
)

# S3 method for rmf_4d_array
rmf_as_tibble(
  array,
  dis,
  i = NULL,
  j = NULL,
  k = NULL,
  l = NULL,
  mask = array(1, dim = dim(array)[1:3]),
  prj = rmf_get_prj(dis),
  crs = NULL,
  as_points = FALSE,
  id = "r",
  ts_time = TRUE,
  ...
)

# S3 method for rmf_list
rmf_as_tibble(
  obj,
  dis,
  ijk = NULL,
  prj = rmf_get_prj(dis),
  crs = NULL,
  as_points = FALSE,
  id = "r",
  ...
)

Arguments

...

arguments passed to rmf_as_tibble.rmf_4d_array for hed & ddn. Otherwise ignored.

cbc

RMODFLOW cbc object

dis

RMODFLOW dis object

i

optional row number to subset

j

optional column number to subset

k

optional layer number to subset

l

optional time step number to subet. Set negative to subset the final time step.

mask

a 3d array with 0 or FALSE indicating inactive cells; defaults to having all cells active

ijk

optional; a data.frame with i, j and k columns used to select the cells in the final tibble.

prj

optional; a projection object

crs

optional; a crs object

as_points

logical, should cell-centered nodal values be returned or 4 values per cell representing the corners. Defaults to FALSE.

id

either 'r' (default) or 'modflow' specifying the type of cell id to use. MODFLOW uses row-major array ordering whereas R uses column-major ordering.

fluxes

character; denotes which fluxes to read. Defaults to reading all fluxes. See details.

ts_time

logical; should the returned time column represent the cumulative modelled time or the time step numbers. See details. Defaults to TRUE (cumulative modelled time)

ddn

RMODFLOW ddn object

hed

RMODFLOW hed object

array

a rmf_3d_array object

obj

RMODFLOW rmf_list object

Value

rmf_as_tibble.cbc returns a tibble of with the fluxes components of the cbc object

rmf_as_tibble.ddn returns a tibble with columns id, value, x, y, z, top, botm, time, nstp representing the cell id's (either MODFLOW or R style; see the id argument), array value, x, y, z coordinates, cell top & bottom and MODFLOW time and time step. Possible additional columns might include totim, pertim, kper & kstp. If as_points = FALSE, the coordinates represent the 2D cell corners (bottomleft, topleft, topright, bottomright on the XY plane), otherwise the cell center.

rmf_as_tibble.hed returns a tibble with columns id, value, x, y, z, top, botm, time, nstp representing the cell id's (either MODFLOW or R style; see the id argument), array value, x, y, z coordinates, cell top & bottom and MODFLOW time and time step. Possible additional columns might include totim, pertim, kper & kstp. If as_points = FALSE, the coordinates represent the 2D cell corners (bottomleft, topleft, topright, bottomright on the XY plane), otherwise the cell center.

rmf_as_tibble.rmf_2d_array returns a tibble with columns id, value, x, y representing the cell id's (either MODFLOW or R style; see the id argument), array value and x & y coordinates. If as_points = FALSE, the coordinates represent the cell corners (bottomleft, topleft, topright, bottomright on the XY plane), otherwise the cell center.

rmf_as_tibble.rmf_3d_array returns a tibble with columns id, value, x, y, z, top, botm representing the cell id's (either MODFLOW or R style; see the id argument), array value, x, y, z coordinates and cell top & bottom. If as_points = FALSE, the coordinates represent the 2D cell corners (bottomleft, topleft, topright, bottomright on the XY plane), otherwise the cell center.

Providing either i, j & k can be used to subset the array. If none are supplied, no subsetting is performed and the entire array is converted to a tibble. If as_points = FALSE and i or j are not provided , no z column is returned since in that case it is ambiguous what z should represent (cell center, top or bottom of the layer). Providing i or j can be used for subsetting a cross-section through the array.

rmf_as_tibble.rmf_4d_array tibble with columns id, value, x, y, z, top, botm, time, nstp representing the cell id's (either MODFLOW or R style; see the id argument), array value, x, y, z coordinates, cell top & bottom and MODFLOW time and time step. If as_points = FALSE, the coordinates represent the 2D cell corners (bottomleft, topleft, topright, bottomright on the XY plane), otherwise the cell center.

Providing either i, j, k or l can be used to subset the array. If none are supplied, no subsetting is performed and the entire array is converted to a tibble. If as_points = FALSE and i or j are not provided , no z column is returned since in that case it is ambiguous what z should represent (cell center, top or bottom of the layer). Providing i or j can be used for subsetting a cross-section through the array.

If i, j and k are provided, a tibble of a single cell time series is returned. If l is not provided but i, j or k is, a tibble with a time series of the subsetted array according to i, j or k is returned.

rmf_as_tibble.rmf_list returns a tibble with the columns of obj except i, j, k and columns id, x, y, top, botm representing the cell id's (either MODFLOW or R style; see the id argument), x, y coordinates and cell top & bottom. If as_points = FALSE, the coordinates represent the 2D cell corners (bottomleft, topleft, topright, bottomright on the XY plane), otherwise the cell center. Furthermore, if as_points = TRUE, an additional z column is added representing the cell centers z coordinates.

Details

Fluxes include 'constant_head', 'storage', 'flow_right_face', 'flow_front_face', 'flow_lower_face', 'wells', 'river_leakage', 'recharge', 'drains', 'head_dep_bounds' or any other description as written by MODFLOW.

The time steps (nstp column) are numbered from 1 to dim(array)[4]. Since in some cases, the rmf_4d_array does not represent all time steps of the simulation, (e.g. output is only written during certain time steps), the nstp value might not correspond to the true time step number for which output was written. In those cases, the time column might not give the correct cumulative time values if ts_time = TRUE. A warning will be thrown and the user should consider setting ts_time = FALSE and calculate the exact cumulative modelled time with e.g. rmf_time_steps.

Examples

m <- rmf_read(rmf_example_file('example-model.nam'), output = TRUE, verbose = FALSE) # cbc rmf_as_tibble(m$cbc, m$dis, fluxes = c('wells', 'flow_right_face'))
#> # A tibble: 3,604 x 15 #> id value x y top botm time nstp totim pertim kper kstp #> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl> <int> <int> #> 1 1 38.0 5.51e-14 -100 0.105 -5.11 1 1 1 1 1 1 #> 2 1 38.0 6.12e-14 0 0.105 -5.11 1 1 1 1 1 1 #> 3 1 38.0 1.00e+ 2 0 0.105 -5.11 1 1 1 1 1 1 #> 4 1 38.0 1 e+ 2 -100 0.105 -5.11 1 1 1 1 1 1 #> 5 2 10.6 4.90e-14 -200 0.952 -5.95 1 1 1 1 1 1 #> 6 2 10.6 5.51e-14 -100 0.952 -5.95 1 1 1 1 1 1 #> 7 2 10.6 1 e+ 2 -100 0.952 -5.95 1 1 1 1 1 1 #> 8 2 10.6 1.00e+ 2 -200 0.952 -5.95 1 1 1 1 1 1 #> 9 3 3.74 4.29e-14 -300 1.36 -6.36 1 1 1 1 1 1 #> 10 3 3.74 4.90e-14 -200 1.36 -6.36 1 1 1 1 1 1 #> # ... with 3,594 more rows, and 3 more variables: flux <chr>, iface <dbl>, #> # delt <dbl>
# ddn rmf_as_tibble(m$drawdown, m$dis, k = 1)
#> # A tibble: 400 x 12 #> id value x y top botm time nstp totim pertim kper kstp #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> #> 1 1 0 5.51e-14 -100 0.105 -5.11 1 1 1 1 1 1 #> 2 1 0 6.12e-14 0 0.105 -5.11 1 1 1 1 1 1 #> 3 1 0 1.00e+ 2 0 0.105 -5.11 1 1 1 1 1 1 #> 4 1 0 1 e+ 2 -100 0.105 -5.11 1 1 1 1 1 1 #> 5 2 0.0673 4.90e-14 -200 0.952 -5.95 1 1 1 1 1 1 #> 6 2 0.0673 5.51e-14 -100 0.952 -5.95 1 1 1 1 1 1 #> 7 2 0.0673 1 e+ 2 -100 0.952 -5.95 1 1 1 1 1 1 #> 8 2 0.0673 1.00e+ 2 -200 0.952 -5.95 1 1 1 1 1 1 #> 9 3 0.0942 4.29e-14 -300 1.36 -6.36 1 1 1 1 1 1 #> 10 3 0.0942 4.90e-14 -200 1.36 -6.36 1 1 1 1 1 1 #> # ... with 390 more rows
# hed rmf_as_tibble(m$head, m$dis, i = 2, as_points = TRUE)
#> # A tibble: 90 x 13 #> id value x y z top botm time nstp totim pertim kper #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 2 29.9 50.0 -150. -2.50 0.952 -5.95 1 1 1 1 1 #> 2 12 29.9 150 -150. -2.5 1.20 -6.20 1 1 1 1 1 #> 3 22 29.9 250 -150. -2.5 1.01 -6.01 1 1 1 1 1 #> 4 32 29.9 350 -150. -2.5 1.42 -6.42 1 1 1 1 1 #> 5 42 29.9 450 -150 -2.5 3.32 -8.32 1 1 1 1 1 #> 6 52 29.9 550 -150. -2.5 4.66 -9.66 1 1 1 1 1 #> 7 62 29.9 650 -150. -2.50 5.03 -10.0 1 1 1 1 1 #> 8 72 29.9 750 -150. -2.50 5.02 -10.0 1 1 1 1 1 #> 9 82 30.0 850 -150. -2.5 4.69 -9.69 1 1 1 1 1 #> 10 92 30 950 -150. -2.5 1.34 -6.34 1 1 1 1 1 #> # ... with 80 more rows, and 1 more variable: kstp <dbl>
rmf_as_tibble(m$head, m$dis, l = 1)
#> # A tibble: 3,600 x 12 #> id value x y top botm time nstp totim pertim kper kstp #> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 30 5.51e-14 -100 0.105 -5.11 1 1 1 1 1 1 #> 2 1 30 6.12e-14 0 0.105 -5.11 1 1 1 1 1 1 #> 3 1 30 1.00e+ 2 0 0.105 -5.11 1 1 1 1 1 1 #> 4 1 30 1 e+ 2 -100 0.105 -5.11 1 1 1 1 1 1 #> 5 2 29.9 4.90e-14 -200 0.952 -5.95 1 1 1 1 1 1 #> 6 2 29.9 5.51e-14 -100 0.952 -5.95 1 1 1 1 1 1 #> 7 2 29.9 1 e+ 2 -100 0.952 -5.95 1 1 1 1 1 1 #> 8 2 29.9 1.00e+ 2 -200 0.952 -5.95 1 1 1 1 1 1 #> 9 3 29.9 4.29e-14 -300 1.36 -6.36 1 1 1 1 1 1 #> 10 3 29.9 4.90e-14 -200 1.36 -6.36 1 1 1 1 1 1 #> # ... with 3,590 more rows
rmf_as_tibble(m$head, m$dis, l = 1, j = 5, mask = m$bas$ibound)
#> # A tibble: 360 x 13 #> id value x y z top botm time nstp totim pertim kper #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 41 29.9 450 -100 -6.13 1.13 -6.13 1 1 1 1 1 #> 2 41 29.9 450 -100 1.13 1.13 -6.13 1 1 1 1 1 #> 3 41 29.9 450 0 1.13 1.13 -6.13 1 1 1 1 1 #> 4 41 29.9 450 0 -6.13 1.13 -6.13 1 1 1 1 1 #> 5 42 29.9 450 -200 -8.32 3.32 -8.32 1 1 1 1 1 #> 6 42 29.9 450 -200 3.32 3.32 -8.32 1 1 1 1 1 #> 7 42 29.9 450 -100 3.32 3.32 -8.32 1 1 1 1 1 #> 8 42 29.9 450 -100 -8.32 3.32 -8.32 1 1 1 1 1 #> 9 43 29.9 450 -300 -9.92 4.92 -9.92 1 1 1 1 1 #> 10 43 29.9 450 -300 4.92 4.92 -9.92 1 1 1 1 1 #> # ... with 350 more rows, and 1 more variable: kstp <dbl>
# 2d array rmf_as_tibble(m$dis$top, m$dis, id = FALSE)
#> # A tibble: 400 x 3 #> value x y #> <dbl> <dbl> <dbl> #> 1 0.105 5.51e-14 -100 #> 2 0.105 6.12e-14 0 #> 3 0.105 1.00e+ 2 0 #> 4 0.105 1 e+ 2 -100 #> 5 0.952 4.90e-14 -200 #> 6 0.952 5.51e-14 -100 #> 7 0.952 1 e+ 2 -100 #> 8 0.952 1.00e+ 2 -200 #> 9 1.36 4.29e-14 -300 #> 10 1.36 4.90e-14 -200 #> # ... with 390 more rows
# 3d array rmf_as_tibble(m$lpf$hk, m$dis)
#> # A tibble: 3,600 x 6 #> id value x y top botm #> <int> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 100 5.51e-14 -100 0.105 -5.11 #> 2 1 100 6.12e-14 0 0.105 -5.11 #> 3 1 100 1.00e+ 2 0 0.105 -5.11 #> 4 1 100 1 e+ 2 -100 0.105 -5.11 #> 5 2 100 4.90e-14 -200 0.952 -5.95 #> 6 2 100 5.51e-14 -100 0.952 -5.95 #> 7 2 100 1 e+ 2 -100 0.952 -5.95 #> 8 2 100 1.00e+ 2 -200 0.952 -5.95 #> 9 3 100 4.29e-14 -300 1.36 -6.36 #> 10 3 100 4.90e-14 -200 1.36 -6.36 #> # ... with 3,590 more rows
rmf_as_tibble(m$lpf$hk, m$dis, as_points = TRUE, i = 5)
#> # A tibble: 90 x 7 #> id value x y z top botm #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 5 90.0 50.0 -450 -2.5 1.33 -6.33 #> 2 15 87.2 150 -450 -2.5 1.45 -6.45 #> 3 25 84.4 250 -450 -2.5 4.60 -9.60 #> 4 35 81.6 350 -450 -2.5 5.04 -10.0 #> 5 45 88.0 450 -450 -2.50 7.15 -12.2 #> 6 55 104. 550 -450 -2.50 8.98 -14.0 #> 7 65 119. 650 -450 -2.50 6.77 -11.8 #> 8 75 137. 750 -450 -2.5 5.00 -10.0 #> 9 85 140 850 -450 -2.5 2.34 -7.34 #> 10 95 140 950 -450 -2.5 1.16 -6.16 #> # ... with 80 more rows
# 4d array r <- rmf_create_array(1:prod(dim(m$head)), dim = dim(m$head)) rmf_as_tibble(r, m$dis)
#> # A tibble: 3,600 x 8 #> id value x y top botm time nstp #> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> #> 1 1 1 5.51e-14 -100 0.105 -5.11 1 1 #> 2 1 1 6.12e-14 0 0.105 -5.11 1 1 #> 3 1 1 1.00e+ 2 0 0.105 -5.11 1 1 #> 4 1 1 1 e+ 2 -100 0.105 -5.11 1 1 #> 5 2 2 4.90e-14 -200 0.952 -5.95 1 1 #> 6 2 2 5.51e-14 -100 0.952 -5.95 1 1 #> 7 2 2 1 e+ 2 -100 0.952 -5.95 1 1 #> 8 2 2 1.00e+ 2 -200 0.952 -5.95 1 1 #> 9 3 3 4.29e-14 -300 1.36 -6.36 1 1 #> 10 3 3 4.90e-14 -200 1.36 -6.36 1 1 #> # ... with 3,590 more rows
rmf_as_tibble(r, m$dis, l = 1)
#> # A tibble: 3,600 x 8 #> id value x y top botm time nstp #> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> #> 1 1 1 5.51e-14 -100 0.105 -5.11 1 1 #> 2 1 1 6.12e-14 0 0.105 -5.11 1 1 #> 3 1 1 1.00e+ 2 0 0.105 -5.11 1 1 #> 4 1 1 1 e+ 2 -100 0.105 -5.11 1 1 #> 5 2 2 4.90e-14 -200 0.952 -5.95 1 1 #> 6 2 2 5.51e-14 -100 0.952 -5.95 1 1 #> 7 2 2 1 e+ 2 -100 0.952 -5.95 1 1 #> 8 2 2 1.00e+ 2 -200 0.952 -5.95 1 1 #> 9 3 3 4.29e-14 -300 1.36 -6.36 1 1 #> 10 3 3 4.90e-14 -200 1.36 -6.36 1 1 #> # ... with 3,590 more rows
rmf_as_tibble(r, m$dis, j = 5)
#> # A tibble: 360 x 9 #> id value x y z top botm time nstp #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> #> 1 41 41 450 -100 -6.13 1.13 -6.13 1 1 #> 2 41 41 450 -100 1.13 1.13 -6.13 1 1 #> 3 41 41 450 0 1.13 1.13 -6.13 1 1 #> 4 41 41 450 0 -6.13 1.13 -6.13 1 1 #> 5 42 42 450 -200 -8.32 3.32 -8.32 1 1 #> 6 42 42 450 -200 3.32 3.32 -8.32 1 1 #> 7 42 42 450 -100 3.32 3.32 -8.32 1 1 #> 8 42 42 450 -100 -8.32 3.32 -8.32 1 1 #> 9 43 43 450 -300 -9.92 4.92 -9.92 1 1 #> 10 43 43 450 -300 4.92 4.92 -9.92 1 1 #> # ... with 350 more rows
# rmf_list l <- m$chd$data rmf_as_tibble(l, m$dis)
#> # A tibble: 88 x 10 #> id shead ehead IFACE parameter name x y top botm #> <int> <dbl> <dbl> <dbl> <lgl> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 1 30 30 0 FALSE list_1 5.51e-14 -100 0.105 -5.11 #> 2 1 30 30 0 FALSE list_1 6.12e-14 0 0.105 -5.11 #> 3 1 30 30 0 FALSE list_1 1.00e+ 2 0 0.105 -5.11 #> 4 1 30 30 0 FALSE list_1 1 e+ 2 -100 0.105 -5.11 #> 5 91 0.05 0.05 0 TRUE CHD_Par1 9 e+ 2 -100 1.00 -6.00 #> 6 91 0.05 0.05 0 TRUE CHD_Par1 9 e+ 2 0 1.00 -6.00 #> 7 91 0.05 0.05 0 TRUE CHD_Par1 1 e+ 3 0 1.00 -6.00 #> 8 91 0.05 0.05 0 TRUE CHD_Par1 1 e+ 3 -100. 1.00 -6.00 #> 9 91 0.05 0.05 0 TRUE CHD_Par1 9 e+ 2 0 1.00 -6.00 #> 10 91 0.05 0.05 0 TRUE CHD_Par1 1 e+ 3 0 1.00 -6.00 #> # ... with 78 more rows
rmf_as_tibble(l, m$dis, as_points = TRUE)
#> # A tibble: 12 x 11 #> id shead ehead IFACE parameter name x y z top botm #> <int> <dbl> <dbl> <dbl> <lgl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 91 0.05 0.05 0 TRUE CHD_Par1 950 -50.0 -2.5 1.00 -6.00 #> 2 92 0.15 0.15 0 TRUE CHD_Par1 950 -150. -2.5 1.34 -6.34 #> 3 93 0.25 0.25 0 TRUE CHD_Par1 950 -250 -2.5 1.39 -6.39 #> 4 94 0.35 0.35 0 TRUE CHD_Par1 950 -350 -2.5 1.02 -6.02 #> 5 95 0.45 0.45 0 TRUE CHD_Par1 950 -450 -2.5 1.16 -6.16 #> 6 91 0.95 0.95 0 TRUE CHD_Par2 950 -50.0 -2.5 1.00 -6.00 #> 7 92 0.85 0.85 0 TRUE CHD_Par2 950 -150. -2.5 1.34 -6.34 #> 8 93 0.75 0.75 0 TRUE CHD_Par2 950 -250 -2.5 1.39 -6.39 #> 9 94 0.65 0.65 0 TRUE CHD_Par2 950 -350 -2.5 1.02 -6.02 #> 10 95 0.55 0.55 0 TRUE CHD_Par2 950 -450 -2.5 1.16 -6.16 #> 11 1 30 30 0 FALSE list_1 50.0 -50 -2.50 0.105 -5.11 #> 12 100 29 29 0 FALSE list_1 950 -950 -2.50 -0.764 -4.24