Skip to contents

These functions extract components from different objects that can be created in ConFluxPro.

Usage

cfp_og_model(x)

# S3 method for class 'cfp_altres'
cfp_og_model(x)

cfp_id_cols(x)

cfp_gases(x)

cfp_modes(x)

cfp_param(x)

cfp_funs(x)

cfp_zero_flux(x)

cfp_zero_limits(x)

cfp_DSD0_optim(x)

cfp_evenness_factor(x)

cfp_known_flux_factor(x)

cfp_runmap_type(x)

cfp_params_df(x)

cfp_n_runs(x)

cfp_layers_different(x)

cfp_layers_from(x)

cfp_layers_altmap(x)

Arguments

x

An object from which to extract the information.

Value

The extracted component, e.g. a data.frame() or character().

Examples

my_data <- ConFluxPro::base_dat |>
  filter(Date == "2021-01-01") # subset for example = faster runtime

### from cfp_dat objects (and derivatives)
cfp_id_cols(my_data)
#> [1] "site" "Date" "gas" 

cfp_gasdata(my_data) |> head()
#> 
#> A cfp_gasdata object 
#> id_cols: site Date gas 
#> 1  unique profiles 
#> 
#>     site       Date gas depth    x_ppm
#> 1 site_a 2021-01-01 CO2     5 422.7419
#> 2 site_a 2021-01-01 CO2     0 552.1412
#> 3 site_a 2021-01-01 CO2     0 555.8525
#> 4 site_a 2021-01-01 CO2     0 556.9315
#> 5 site_a 2021-01-01 CO2   -10 716.4256
#> 6 site_a 2021-01-01 CO2   -10 713.3633
cfp_soilphys(my_data) |> head()
#> 
#> A cfp_soilphys object 
#> id_cols: site Date gas 
#> 1  unique profiles 
#> 
#>     site       Date gas upper lower  TPS    a   b depth       SWC          t
#> 1 site_a 2021-01-01 CO2   -60  -100 0.38 1.20 1.5 -80.0 0.1613528 -0.7899035
#> 2 site_a 2021-01-01 CO2   -40   -60 0.38 1.20 1.5 -50.0 0.1277975 -1.9747588
#> 3 site_a 2021-01-01 CO2   -23   -40 0.38 1.20 1.5 -31.5 0.1082474 -2.7054195
#> 4 site_a 2021-01-01 CO2   -20   -23 0.45 1.05 1.6 -21.5 0.1026943 -4.7785077
#> 5 site_a 2021-01-01 CO2   -15   -20 0.45 1.05 1.6 -17.5 0.1026943 -4.7785077
#> 6 site_a 2021-01-01 CO2   -10   -15 0.45 1.05 1.6 -12.5 0.1211106 -4.9419502
#>      p      AFPS      DSD0           D0           DS    c_air height
#> 1 1013 0.2186472 0.1226866 1.373780e-05 1.685444e-06 44.73588   0.40
#> 2 1013 0.2522025 0.1519866 1.362982e-05 2.071550e-06 44.93134   0.20
#> 3 1013 0.2717526 0.1699972 1.356342e-05 2.305744e-06 45.05273   0.17
#> 4 1013 0.3473057 0.1933430 1.337582e-05 2.586121e-06 45.40075   0.03
#> 5 1013 0.3473057 0.1933430 1.337582e-05 2.586121e-06 45.40075   0.05
#> 6 1013 0.3288894 0.1772022 1.336108e-05 2.367612e-06 45.42842   0.05
cfp_layers_map(my_data) |> head()
#> 
#> 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
my_data$profiles |> head()
#> 
#> A cfp_profile object 
#> id_cols: prof_id 
#> 2  unique profiles 
#> 
#>     site       Date gas gd_id sp_id group_id prof_id
#> 1 site_a 2021-01-01 CO2     1     1        1       1
#> 2 site_b 2021-01-01 CO2    13    13        2       2

### from cfp_pfmod or cfp_pfres objects
PROFLUX <- my_data |> pro_flux()
cfp_zero_flux(PROFLUX)
#> [1] TRUE
cfp_zero_limits(PROFLUX)
#> [1] -Inf  Inf
cfp_DSD0_optim(PROFLUX) #deprecated
#> [1] FALSE
cfp_evenness_factor(PROFLUX)
#> [1] 0
cfp_known_flux_factor(PROFLUX)
#> [1] 0
PROFLUX$PROFLUX |> head()
#> 
#> A cfp_layered_profile object 
#> id_cols: prof_id 
#> 2  unique profiles 
#> 
#>   upper lower step_id prof_id sp_id pmap       flux F0       prod     conc
#> 1   -60  -100       1       1     1    1 0.03881889  0 0.09704722 45120.83
#> 2   -60  -100       1       2    13    1 0.02162444  0 0.05406110 44810.55
#> 3   -40   -60       2       1     1    1 0.05822833  0 0.09704722 40436.06
#> 4   -40   -60       2       2    13    1 0.03243666  0 0.05406110 41696.66
#> 5   -23   -40       3       1     1    1 0.07472636  0 0.09704722 35534.76
#> 6   -20   -23       4       1     1    1 0.07763778  0 0.09704722 34651.02
#>         RMSE
#> 1 0.01988220
#> 2 0.01960087
#> 3 0.01988220
#> 4 0.01960087
#> 5 0.01988220
#> 6 0.01988220

### from cfp_fgmod or cfp_fgres objects
FLUX <- my_data |> fg_flux()
#> 
#> validating datasets
#> id_cols: site, Date, gas
#> 2 unique profiles

cfp_gases(FLUX)
#> [1] "CO2"
cfp_modes(FLUX)
#> [1] "LL"
cfp_param(FLUX)
#> [1] "c_air" "DS"   
cfp_funs(FLUX)
#> [1] "arith" "harm" 
FLUX$FLUX |> head()
#> 
#> A cfp_layered_profile object 
#> id_cols: prof_id mode 
#> 2  unique profiles 
#> 
#>   prof_id upper lower depth layer gas mode       flux     flux_sd   dcdz_ppm
#> 1       1     5     0   2.5     2 CO2   LL 0.33911308 0.007440940 -2644.6628
#> 2       1     0  -100 -50.0     1 CO2   LL 0.04330173 0.004201945  -481.5574
#> 3       2     7     0   3.5     2 CO2   LL 0.27251404 0.004201454 -2112.1249
#> 4       2     0  -100 -50.0     1 CO2   LL 0.02823777 0.002426925  -454.3658
#>    dcdz_sd    dc_ppm    c_air           DS        r2
#> 1 58.03013 -132.2331 45.60490 2.811660e-06 0.9990380
#> 2 46.72972 -481.5574 44.98772 1.998771e-06 0.9139388
#> 3 32.56345 -147.8487 45.60413 2.829210e-06 0.9995248
#> 4 39.05094 -454.3658 44.97122 1.381943e-06 0.9312138

### from cfp_run_map
set.seed(42)
my_run_map <-
cfp_run_map(
  PROFLUX,
  list("TPS" = c(0.9, 1.1)),
  "factor",
  n_runs = 2)

cfp_params_df(my_run_map)
#>   param param_id
#> 1   TPS        1
cfp_n_runs(my_run_map)
#> [1] 2
cfp_layers_from(my_run_map)
#> [1] "layers_map"
cfp_layers_different(my_run_map)
#> [1] FALSE
cfp_runmap_type(my_run_map)
#> [1] "base"
cfp_layers_altmap(my_run_map)
#> NULL

### from cfp_altres
my_altres <-
alternate(
  x = PROFLUX,
  f = \(x) complete_soilphys(x, "a+AFPS^b", quiet = TRUE),
  run_map = my_run_map)

cfp_og_model(my_altres)
cfp_run_map(my_altres)
#> 
#> A cfp_run_map to be used in alternate(). 
#> number of runs:  2 
#> parameters to alternate:
#>   param param_id
#> 1   TPS        1
#>   run_id param    value   type gas param_id
#> 1      1   TPS 1.082961 factor CO2        1
#> 2      2   TPS 1.087415 factor CO2        1