Access, modify, aggregate and plot data from the 'Sapfluxnet' project (< http://sapfluxnet.creaf.cat>), the first global database of sap flow measurements.
sapfluxnetr provides tools for a tidy data analysis for the first
global database of sap flow measurements (Sapfluxnet
Project)
You can work with individual sites:
# load packageslibrary(sapfluxnetr)# install.packages("tidyverse")library(tidyverse)#> ── Attaching packages ─────────────────────────── tidyverse 1.2.1 ──#> ✔ ggplot2 3.1.0 ✔ purrr 0.3.2#> ✔ tibble 2.1.1 ✔ dplyr 0.8.0.1#> ✔ tidyr 0.8.3 ✔ stringr 1.4.0#> ✔ readr 1.3.1 ✔ forcats 0.4.0#> ── Conflicts ────────────────────────────── tidyverse_conflicts() ──#> ✖ dplyr::filter() masks stats::filter()#> ✖ dplyr::lag() masks stats::lag()# ARG_MAZ example site datadata('ARG_MAZ', package = 'sapfluxnetr')data('sfn_metadata_ex', package = 'sapfluxnetr')# plot site sapflow measurements versus vpdsfn_plot(ARG_MAZ, formula_env = ~ vpd)
# daily sapflow and environmental metricsarg_maz_metrics <- daily_metrics(ARG_MAZ, tidy = TRUE, metadata = sfn_metadata_ex)#> [1] "Crunching data for ARG_MAZ. In large datasets this could take a while"#> [1] "General data for ARG_MAZ"# plot daily aggregationsggplot(arg_maz_metrics, aes(x = vpd_q_95, y = sapflow_q_95, colour = pl_code)) +geom_point()
And you can work with multiple sites:
# ARG_TRE and AUS_CAN_ST2_MIX example sitesdata('ARG_TRE', package = 'sapfluxnetr')data('AUS_CAN_ST2_MIX', package = 'sapfluxnetr')multi_sfn <- sfn_data_multi(ARG_TRE, ARG_MAZ, AUS_CAN_ST2_MIX)# plotting the individual sites. It creates a list of plotsplots_list <- sfn_plot(multi_sfn, formula_env = ~ vpd)plots_list[['AUS_CAN_ST2_MIX']]#> Warning: Removed 526066 rows containing missing values (geom_point).
# daily sapflow standard metricsmulti_metrics <- daily_metrics(multi_sfn, tidy = TRUE, metadata = sfn_metadata_ex)#> [1] "Crunching data for ARG_TRE. In large datasets this could take a while"#> [1] "General data for ARG_TRE"#> [1] "Crunching data for ARG_MAZ. In large datasets this could take a while"#> [1] "General data for ARG_MAZ"#> [1] "Crunching data for AUS_CAN_ST2_MIX. In large datasets this could take a while"#> [1] "General data for AUS_CAN_ST2_MIX"# plot daily aggregationsggplot(multi_metrics, aes(x = vpd_q_95, y = sapflow_q_95, colour = si_code)) +geom_point(alpha = 0.2)#> Warning: Removed 10966 rows containing missing values (geom_point).
You can install sapfluxnetr from CRAN:
install.packages('sapfluxnetr')
Be advised, sapfluxnetr is in active development and can contain
undiscovered bugs. If you find something not working as expected fill a
bug at https://github.com/sapfluxnet/sapfluxnetr/issues
Please see vignette('sapfluxnetr-quick-guide', package = 'sapfluxnetr') for a detailed overview of the package capabilities.
sfn_metrics function are
soft deprecated. Please use '1 day', '1 month'... instead.purrr version.%>%) from magrittr package. Now loading
sapfluxnetr the pipe can be used.acummulated_precip as new metric for the default *_metrics functions.data_coverage function. Now it returns the real coverage based on the
timestep, the period to summarise for and the timestamp values. This only will
work within the wrapper metrics functions (using internally the
.fixed_metrics_funtions function).sfn_sites_in_folder to list the site codes in a folderfilter_by_var, substituted by filter_sites_by_mdsfn_metrics. After some
benchmarking, the benefits in time are solid, so now the user has the ability
to perform the metrics in parallel.sfn_plot function.sfn_metrics to uniformize interval start and interval endnightly_metrics to return only night intervalpredawn_metrics, midday_metrics and daylight_metrics functions
taking leverage in the refactored sfn_metrics functions.daily_metrics and monthly_metrics to return only the general
interval metrics, avoiding this way the creation of very big objects.tidy argument to *_metrics functions, to skip one step when creating
tidy metrics.NEWS.md file to track changes to the package.README.md file for new users.