A function to create a cfp_layers_map object that defines the
layers of both fg_flux()
and pro_flux()
models.
Usage
cfp_layers_map(x, ...)
# S3 method for class 'cfp_dat'
cfp_layers_map(x, ...)
# S3 method for class 'data.frame'
cfp_layers_map(
x,
id_cols,
gas = NULL,
lowlim = NULL,
highlim = NULL,
layer_couple = 0,
...
)
Arguments
- x
(data.frame) That defines the layers for which the production or flux is modeled. Note that some parameters can also be provided directly to the function call instead (see Details).
id_cols
the relevant id_cols (see below)gas
, the gas that is modelled.upper
,lower
the upper and lower boundaries of each layerlowlim
,highlim
as the lower and upper limits of the production rate to be modeled in \(\mu~mol~m^{-3}\)the parameter
layer_couple
, that indicates how strongly the layer should be linked to the one below it (0 for no coupling)
- ...
not used
- id_cols
Column names in data.frame that uniquely identify each profile.
- gas
(character vector) of gas names to be added to x which is then repeated for each gas.
- lowlim
(numeric vector) the same length as
gas
with the lower limit of possible production allowed inpro_flux()
models.- highlim
(numeric vector) the same length as gas with the upper limit of possible production allowed in
pro_flux()
models.- layer_couple
(numeric_vector) A vector the same length as gas that indicates how strongly the layer should be linked to the one below it (0 for no coupling, the default).
Value
A cfp_layered_profile()
data.frame
with the columns
described above as well as layer
and pmap
columns that identify
each layer with an integer (ascending from bottom to top).
Add lowlim and highlim for multiple gases
Sometimes it is practical to model different gases with different limits. For example, it is a reasonable assumption that CO2 is not consumed in relevant amounts in most soils, whereas CH4 may be both produced or consumed. Therefore we may want to limit production rates of CO2 to only positive values, whereas allowing for negative CH4 production rates (i.e. consumption) as well.
To make this setup easy, you can provide a gas
vector to the function
together with highlim
and lowlim
vectors of the same length.
The provided layers_map
data.frame
will then be replicated for
each gas with the respective values of the production limits provided.
See also
Other data formats:
cfp_dat()
,
cfp_gasdata()
,
cfp_layered_profile()
,
cfp_profile()
,
cfp_soilphys()
Examples
cfp_layers_map(
ConFluxPro::layers_map,
gas = "CO2",
lowlim = 0,
highlim = 1000,
id_cols = "site")
#>
#> added 'gas' to id_cols
#>
#> A cfp_layers_map object
#> id_cols: site gas
#> 2 unique profiles
#>
#> site upper lower gas lowlim highlim layer_couple layer pmap
#> 1 site_a 0 -100 CO2 0 1000 0 1 1
#> 2 site_b 0 -100 CO2 0 1000 0 1 1
#> 3 site_a 5 0 CO2 0 1000 0 2 2
#> 4 site_b 7 0 CO2 0 1000 0 2 2
### add multiple gases at once
cfp_layers_map(
ConFluxPro::layers_map,
id_cols = "site",
gas = c("CO2", "CH4"),
lowlim = c(0, -1000),
highlim = c(1000, 1000))
#>
#> added 'gas' to id_cols
#>
#> A cfp_layers_map object
#> id_cols: site gas
#> 4 unique profiles
#>
#> site upper lower gas lowlim highlim layer_couple layer pmap
#> 1 site_a 0 -100 CO2 0 1000 0 1 1
#> 2 site_b 0 -100 CO2 0 1000 0 1 1
#> 3 site_a 0 -100 CH4 -1000 1000 0 1 1
#> 4 site_b 0 -100 CH4 -1000 1000 0 1 1
#> 5 site_a 5 0 CO2 0 1000 0 2 2
#> 6 site_a 5 0 CH4 -1000 1000 0 2 2
#> 7 site_b 7 0 CO2 0 1000 0 2 2
#> 8 site_b 7 0 CH4 -1000 1000 0 2 2
### Extract from an existing cfp_dat
cfp_layers_map(ConFluxPro::base_dat)
#>
#> A cfp_layers_map object
#> id_cols: site gas
#> 2 unique profiles
#>
#> site upper lower gas lowlim highlim layer_couple layer pmap
#> 1 site_a 0 -100 CO2 0 1000 0 1 1
#> 2 site_b 0 -100 CO2 0 1000 0 1 1
#> 3 site_a 5 0 CO2 0 1000 0 2 2
#> 4 site_b 7 0 CO2 0 1000 0 2 2