Function extract()
extracts daily or subdaily output and returns it as a tidy data frame.
extract(
x,
level = "forest",
output = NULL,
vars = NULL,
dates = NULL,
subdaily = FALSE
)
An object returned by simulation functions spwb
, pwb
or growth
.
Level of simulation output, either "forest" (stand-level results), "cohort" (cohort-level results), "sunlitleaf" or "shadeleaf" (leaf-level results)
Section of the model output to be explored. See details.
Variables to be extracted (by default, all of them).
A date vector indicating the subset of simulated days for which output is desired.
A flag to indicate that subdaily values are desired (see details).
Function extract()
returns a data frame:
If level = "forest"
, columns are "date" and variable names.
If level = "cohort"
, level = "sunlitleaf"
or level = "shadeleaf"
, columns are "date", "cohorts", "species" and variable names.
If subdaily = TRUE
, columns are "datetime", "cohorts", "species" and variable names.
When subdaily = FALSE
, parameter output
is used to restrict the section in x
where variables are located. For
example output = "Plants"
will correspond to variables "LAI", "LAIlive", "Transpiration", "StemPLC",... as returned by a call
names(x$Plants)
.
Option subdaily = TRUE
only works when simulations have been carried using control option 'subdailyResults = TRUE' (see defaultControl
).
When using subdaily = TRUE
, parameter output
is not taken into account, and options for parameter vars
are the following:
Variables for level = "forest"
: Not allowed. An error is raised.
Variables for level = "cohort"
: "E","Ag","An","dEdP","RootPsi","StemPsi","LeafPsi","StemPLC","StemRWC","LeafRWC","StemSympRWC","LeafSympRWC","PWB".
Variables for level = "shadeleaf"
and level="sunlitleaf"
: "Abs_SWR","Abs_PAR","Net_LWR","E","Ag","An","Ci","Gsw","VPD","Temp","Psi","iWUE".
#Load example daily meteorological data
data(examplemeteo)
#Load example plot plant data
data(exampleforest)
#Default species parameterization
data(SpParamsMED)
#Initialize soil with default soil params (2 layers)
examplesoil = soil(defaultSoilParams(2))
#Initialize control parameters
control = defaultControl("Granier")
#Initialize input
x = forest2spwbInput(exampleforest,examplesoil, SpParamsMED, control)
#Call simulation function (ten days)
S1<-spwb(x, examplemeteo[1:10, ], latitude = 41.82592, elevation = 100)
#> Initial plant water content (mm): 5.25158
#> Initial soil water content (mm): 184.827
#> Initial snowpack content (mm): 0
#> Performing daily simulations
#>
#> [Year 2001]:
#>
#> Final plant water content (mm): 5.25259
#> Final soil water content (mm): 211.845
#> Final snowpack content (mm): 0
#> Change in plant water content (mm): 0.00101086
#> Plant water balance result (mm): 0.00101086
#> Change in soil water content (mm): 27.0186
#> Soil water balance result (mm): 27.0186
#> Change in snowpack water content (mm): 0
#> Snowpack water balance result (mm): 0
#> Water balance components:
#> Precipitation (mm) 39 Rain (mm) 34 Snow (mm) 5
#> Interception (mm) 9 Net rainfall (mm) 25
#> Infiltration (mm) 30 Infiltration excess (mm) 0 Saturation excess (mm) 0 Capillarity rise (mm) 0
#> Soil evaporation (mm) 1 Herbaceous transpiration (mm) 0 Woody plant transpiration (mm) 2
#> Plant extraction from soil (mm) 2 Plant water balance (mm) 0 Hydraulic redistribution (mm) 0
#> Runoff (mm) 0 Deep drainage (mm) 1
#Extracts daily forest-level output as a data frame
extract(S1, level = "forest")
#> date PET Precipitation Rain Snow NetRain Snowmelt
#> 1 2001-01-01 0.8828475 4.869109 4.869109 0.0000 3.4241795 0.0000
#> 2 2001-01-02 1.6375337 2.498292 2.498292 0.0000 1.0717469 0.0000
#> 3 2001-01-03 1.3017026 0.000000 0.000000 0.0000 0.0000000 0.0000
#> 4 2001-01-04 0.5690790 5.796973 5.796973 0.0000 4.3625616 0.0000
#> 5 2001-01-05 1.6760567 1.884401 1.884401 0.0000 0.7539027 0.0000
#> 6 2001-01-06 1.2077028 13.359801 13.359801 0.0000 11.7240275 0.0000
#> 7 2001-01-07 0.6368075 5.377400 0.000000 5.3774 0.0000000 0.0000
#> 8 2001-01-08 0.8318207 0.000000 0.000000 0.0000 0.0000000 0.0000
#> 9 2001-01-09 1.9823797 0.000000 0.000000 0.0000 0.0000000 0.0000
#> 10 2001-01-10 0.8286873 5.117768 5.117768 0.0000 3.6727363 5.3774
#> Infiltration InfiltrationExcess SaturationExcess Runoff DeepDrainage
#> 1 3.4241795 0 0 0 0.06256005
#> 2 1.0717469 0 0 0 0.06297757
#> 3 0.0000000 0 0 0 0.06055364
#> 4 4.3625616 0 0 0 0.06644857
#> 5 0.7539027 0 0 0 0.07965453
#> 6 11.7240275 0 0 0 0.09507779
#> 7 0.0000000 0 0 0 0.00000000
#> 8 0.0000000 0 0 0 0.00000000
#> 9 0.0000000 0 0 0 0.00000000
#> 10 9.0501360 0 0 0 0.11839674
#> CapillarityRise Evapotranspiration Interception SoilEvaporation
#> 1 3.853644e-05 2.0551277 1.444929 0.44789475
#> 2 1.470379e-05 1.7952157 1.426545 0.06737431
#> 3 0.000000e+00 0.2963997 0.000000 0.05685673
#> 4 2.833231e-04 1.6069407 1.434411 0.06781981
#> 5 0.000000e+00 1.4658205 1.130499 0.02660100
#> 6 3.944204e-03 1.8844537 1.635773 0.02621851
#> 7 1.082725e-09 0.1175328 0.000000 0.00000000
#> 8 2.423207e-09 0.1535228 0.000000 0.00000000
#> 9 3.308844e-08 0.3658643 0.000000 0.00000000
#> 10 5.447378e-03 1.6083129 1.445031 0.01034913
#> HerbTranspiration PlantExtraction Transpiration HydraulicRedistribution
#> 1 0.011023432 0.15128020 0.15128020 0.000000000
#> 2 0.020448150 0.28084852 0.28084852 0.000000000
#> 3 0.016254774 0.22328825 0.22328825 0.000000000
#> 4 0.007106179 0.09760341 0.09760341 0.000000000
#> 5 0.020931001 0.28778975 0.28778975 0.002232281
#> 6 0.015082110 0.20737996 0.20737996 0.001492807
#> 7 0.007953578 0.10957922 0.10957922 0.003143374
#> 8 0.010389239 0.14313361 0.14313361 0.004064917
#> 9 0.024759409 0.34110490 0.34110490 0.009558168
#> 10 0.010350058 0.14258232 0.14258232 0.003863895
#> LAI LAIherb LAIlive LAIexpanded LAIdead Cm LgroundPAR
#> 1 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 2 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 3 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 4 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 5 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 6 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 7 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 8 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 9 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> 10 1.758585 0.1736369 1.584948 1.584948 0 1.390485 40.00754
#> LgroundSWR W.1 W.2 ML.1 ML.2 MLTot SaturatedDepth
#> 1 50.73297 1.000000 1.000000 68.17381 116.6530 184.8268 965.8761
#> 2 50.73297 1.026720 1.007971 69.99543 117.5828 187.5782 957.6348
#> 3 50.73297 1.031832 1.010471 70.34389 117.8745 188.2184 961.5616
#> 4 50.73297 1.026538 1.010505 69.98302 117.8784 187.8614 911.0047
#> 5 50.73297 1.068733 1.021197 72.85958 119.1257 191.9853 906.1762
#> 6 50.73297 1.069741 1.023513 72.92833 119.3959 192.3242 766.4960
#> 7 50.73297 1.185804 1.053275 80.84080 122.8676 203.7084 767.8254
#> 8 50.73297 1.184194 1.053208 80.73104 122.8598 203.5909 769.5624
#> 9 50.73297 1.182093 1.053120 80.58782 122.8495 203.4374 773.7037
#> 10 50.73297 1.177093 1.052905 80.24695 122.8245 203.0715 663.8409
#> SWE PlantExt.1 PlantExt.2 HydraulicInput.1 HydraulicInput.2 psi.1
#> 1 0.0000 0.11328728 0.037992928 0 0.000000000 -0.029069690
#> 2 0.0000 0.24518713 0.035661389 0 0.000000000 -0.028370693
#> 3 0.0000 0.19561752 0.027670729 0 0.000000000 -0.029094881
#> 4 0.0000 0.08487201 0.012731392 0 0.000000000 -0.023763052
#> 5 0.0000 0.26030138 0.027488368 0 0.002232281 -0.023647074
#> 6 0.0000 0.18724444 0.020135526 0 0.001492807 -0.012943476
#> 7 5.3774 0.10618667 0.003392552 0 0.003143374 -0.013063234
#> 8 5.3774 0.13856400 0.004569610 0 0.004064917 -0.013220471
#> 9 5.3774 0.32978127 0.011323634 0 0.009558168 -0.013599163
#> 10 0.0000 0.13740991 0.005172412 0 0.003863895 -0.008109121
#> psi.2
#> 1 -0.03177660
#> 2 -0.03140209
#> 3 -0.03139709
#> 4 -0.02984324
#> 5 -0.02951650
#> 6 -0.02560429
#> 7 -0.02561250
#> 8 -0.02562337
#> 9 -0.02564977
#> 10 -0.02243287
#Extracts daily cohort-level output as a data frame
extract(S1, level = "cohort")
#> date cohort species LAI LAIlive FPAR
#> 1 2001-01-01 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 2 2001-01-02 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 3 2001-01-03 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 4 2001-01-04 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 5 2001-01-05 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 6 2001-01-06 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 7 2001-01-07 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 8 2001-01-08 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 9 2001-01-09 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 10 2001-01-10 T1_148 Pinus halepensis 0.84874773 0.84874773 92.18285
#> 11 2001-01-01 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 12 2001-01-02 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 13 2001-01-03 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 14 2001-01-04 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 15 2001-01-05 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 16 2001-01-06 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 17 2001-01-07 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 18 2001-01-08 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 19 2001-01-09 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 20 2001-01-10 T2_168 Quercus ilex 0.70557382 0.70557382 72.36365
#> 21 2001-01-01 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 22 2001-01-02 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 23 2001-01-03 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 24 2001-01-04 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 25 2001-01-05 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 26 2001-01-06 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 27 2001-01-07 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 28 2001-01-08 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 29 2001-01-09 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> 30 2001-01-10 S1_165 Quercus coccifera 0.03062604 0.03062604 44.32407
#> AbsorbedSWRFraction Transpiration GrossPhotosynthesis PlantPsi
#> 1 35.076344 0.092472560 0.89344066 -0.03300000
#> 2 35.076344 0.171676983 1.56121948 -0.02940577
#> 3 35.076344 0.136490828 1.30900282 -0.02874804
#> 4 35.076344 0.059661906 0.59731290 -0.02937995
#> 5 35.076344 0.175917582 1.62021259 -0.02454057
#> 6 35.076344 0.126763646 1.31225315 -0.02439665
#> 7 35.076344 0.066971837 0.74875623 -0.01473718
#> 8 35.076344 0.087479449 0.89467751 -0.01483748
#> 9 35.076344 0.208474492 1.59044046 -0.01496936
#> 10 35.076344 0.087142878 0.85673376 -0.01528776
#> 11 30.444383 0.052754988 0.62572744 -0.03300000
#> 12 30.444383 0.097940635 1.14625755 -0.03035324
#> 13 30.444383 0.077869154 0.92206797 -0.02980838
#> 14 30.444383 0.034038471 0.40703328 -0.03018633
#> 15 30.444383 0.100371338 1.17793732 -0.02665214
#> 16 30.444383 0.072329090 0.87173907 -0.02643577
#> 17 30.444383 0.038233669 0.46958695 -0.01900188
#> 18 30.444383 0.049941099 0.60018366 -0.01906745
#> 19 30.444383 0.119015294 1.34348755 -0.01915362
#> 20 30.444383 0.049748113 0.59240337 -0.01936141
#> 21 2.366131 0.006052657 0.05005525 -0.03300000
#> 22 2.366131 0.011230901 0.08988036 -0.02985412
#> 23 2.366131 0.008928264 0.07353714 -0.02925032
#> 24 2.366131 0.003903028 0.03292026 -0.02976111
#> 25 2.366131 0.011500826 0.09266869 -0.02555150
#> 26 2.366131 0.008287226 0.07122543 -0.02537240
#> 27 2.366131 0.004373719 0.03929395 -0.01685503
#> 28 2.366131 0.005713062 0.04876651 -0.01693666
#> 29 2.366131 0.013615117 0.09953244 -0.01704401
#> 30 2.366131 0.005691332 0.04752129 -0.01730331
#> LeafPLC StemPLC PlantWaterBalance LeafRWC StemRWC LFMC
#> 1 0.0030695571 0 0.000000e+00 0.9979679 0.9998350 125.89003
#> 2 0.0024947451 0 1.700247e-04 0.9981891 0.9998529 125.90534
#> 3 0.0023928338 0 3.111521e-05 0.9982296 0.9998562 125.90814
#> 4 0.0024907250 0 -2.989378e-05 0.9981907 0.9998531 125.90545
#> 5 0.0018427410 0 2.289495e-04 0.9984886 0.9998773 125.92606
#> 6 0.0017456159 0 6.808942e-06 0.9984975 0.9998780 125.92668
#> 7 0.0010933266 0 4.570683e-04 0.9990923 0.9999263 125.96783
#> 8 0.0005086923 0 -4.746961e-06 0.9990861 0.9999258 125.96740
#> 9 0.0005237992 0 -6.241029e-06 0.9990780 0.9999251 125.96684
#> 10 0.0005605195 0 -1.506729e-05 0.9990584 0.9999235 125.96548
#> 11 0.0000000000 0 0.000000e+00 0.9986794 0.9997489 93.07448
#> 12 0.0000000000 0 2.975737e-05 0.9987854 0.9997692 93.08079
#> 13 0.0000000000 0 6.123291e-06 0.9988072 0.9997733 93.08209
#> 14 0.0000000000 0 -4.247426e-06 0.9987921 0.9997705 93.08119
#> 15 0.0000000000 0 3.970107e-05 0.9989335 0.9997975 93.08961
#> 16 0.0000000000 0 2.429374e-06 0.9989422 0.9997991 93.09012
#> 17 0.0000000000 0 8.339870e-05 0.9992397 0.9998558 93.10783
#> 18 0.0000000000 0 -7.350673e-07 0.9992370 0.9998553 93.10767
#> 19 0.0000000000 0 -9.660197e-07 0.9992336 0.9998546 93.10746
#> 20 0.0000000000 0 -2.329420e-06 0.9992253 0.9998531 93.10697
#> 21 0.0000000000 0 3.469447e-18 0.9987207 0.9983684 96.39176
#> 22 0.0000000000 0 3.948775e-06 0.9988426 0.9985238 96.40535
#> 23 0.0000000000 0 7.579335e-07 0.9988660 0.9985537 96.40796
#> 24 0.0000000000 0 -6.411908e-07 0.9988462 0.9985284 96.40576
#> 25 0.0000000000 0 5.284589e-06 0.9990094 0.9987365 96.42395
#> 26 0.0000000000 0 2.248591e-07 0.9990163 0.9987453 96.42472
#> 27 0.0000000000 0 1.069453e-05 0.9993465 0.9991663 96.46154
#> 28 0.0000000000 0 -1.025037e-07 0.9993433 0.9991623 96.46118
#> 29 0.0000000000 0 -1.348117e-07 0.9993392 0.9991570 96.46072
#> 30 0.0000000000 0 -3.256222e-07 0.9993291 0.9991442 96.45960
#> PlantStress
#> 1 0.005808769
#> 2 0.004904910
#> 3 0.004744804
#> 4 0.004898593
#> 5 0.003761551
#> 6 0.003729216
#> 7 0.001778697
#> 8 0.001796514
#> 9 0.001820024
#> 10 0.001877183
#> 11 0.010612890
#> 12 0.009712945
#> 13 0.009528201
#> 14 0.009656333
#> 15 0.008461823
#> 16 0.008388971
#> 17 0.005908693
#> 18 0.005930352
#> 19 0.005958822
#> 20 0.006027503
#> 21 0.003088161
#> 22 0.002711560
#> 23 0.002640579
#> 24 0.002700599
#> 25 0.002215456
#> 26 0.002195311
#> 27 0.001290540
#> 28 0.001298665
#> 29 0.001309369
#> 30 0.001335307
#Select the output tables/variables to be extracted
extract(S1, level ="cohort", output="Plants", vars = c("PlantStress", "StemPLC"))
#> date cohort species PlantStress StemPLC
#> 1 2001-01-01 T1_148 Pinus halepensis 0.005808769 0
#> 2 2001-01-02 T1_148 Pinus halepensis 0.004904910 0
#> 3 2001-01-03 T1_148 Pinus halepensis 0.004744804 0
#> 4 2001-01-04 T1_148 Pinus halepensis 0.004898593 0
#> 5 2001-01-05 T1_148 Pinus halepensis 0.003761551 0
#> 6 2001-01-06 T1_148 Pinus halepensis 0.003729216 0
#> 7 2001-01-07 T1_148 Pinus halepensis 0.001778697 0
#> 8 2001-01-08 T1_148 Pinus halepensis 0.001796514 0
#> 9 2001-01-09 T1_148 Pinus halepensis 0.001820024 0
#> 10 2001-01-10 T1_148 Pinus halepensis 0.001877183 0
#> 11 2001-01-01 T2_168 Quercus ilex 0.010612890 0
#> 12 2001-01-02 T2_168 Quercus ilex 0.009712945 0
#> 13 2001-01-03 T2_168 Quercus ilex 0.009528201 0
#> 14 2001-01-04 T2_168 Quercus ilex 0.009656333 0
#> 15 2001-01-05 T2_168 Quercus ilex 0.008461823 0
#> 16 2001-01-06 T2_168 Quercus ilex 0.008388971 0
#> 17 2001-01-07 T2_168 Quercus ilex 0.005908693 0
#> 18 2001-01-08 T2_168 Quercus ilex 0.005930352 0
#> 19 2001-01-09 T2_168 Quercus ilex 0.005958822 0
#> 20 2001-01-10 T2_168 Quercus ilex 0.006027503 0
#> 21 2001-01-01 S1_165 Quercus coccifera 0.003088161 0
#> 22 2001-01-02 S1_165 Quercus coccifera 0.002711560 0
#> 23 2001-01-03 S1_165 Quercus coccifera 0.002640579 0
#> 24 2001-01-04 S1_165 Quercus coccifera 0.002700599 0
#> 25 2001-01-05 S1_165 Quercus coccifera 0.002215456 0
#> 26 2001-01-06 S1_165 Quercus coccifera 0.002195311 0
#> 27 2001-01-07 S1_165 Quercus coccifera 0.001290540 0
#> 28 2001-01-08 S1_165 Quercus coccifera 0.001298665 0
#> 29 2001-01-09 S1_165 Quercus coccifera 0.001309369 0
#> 30 2001-01-10 S1_165 Quercus coccifera 0.001335307 0