Working with 'Sapfluxnet' Project Data

Access, modify, aggregate and plot data from the 'Sapfluxnet' project (< http://sapfluxnet.creaf.cat>), the first global database of sap flow measurements.


Travis buildstatus

sapfluxnetr provides tools for a tidy data analysis for the first global database of sap flow measurements (Sapfluxnet Project)

Examples

You can work with individual sites:

# load packages
library(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 data
data('ARG_MAZ', package = 'sapfluxnetr')
data('sfn_metadata_ex', package = 'sapfluxnetr')
 
# plot site sapflow measurements versus vpd
sfn_plot(ARG_MAZ, formula_env = ~ vpd)
 
# daily sapflow and environmental metrics
arg_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 aggregations
ggplot(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 sites
data('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 plots
plots_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 metrics
multi_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 aggregations
ggplot(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).

Installation

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

Overview

Please see vignette('sapfluxnetr-quick-guide', package = 'sapfluxnetr') for a detailed overview of the package capabilities.

News

sapfluxnetr 0.0.7

  • Replaced calls of dplyr::funs with list (or rlang::list2 if splicing is needed) as the former is soft deprecated in dplyr 0.8.0
  • One word periods ('daily', 'monthly'...) in sfn_metrics function are soft deprecated. Please use '1 day', '1 month'... instead.
  • Removed all dependencies on 'tibbletime' package
  • Added utils internal functions: .collapse_timestamp and .parse_period
  • Added installation from CRAN to vignette and readme

sapfluxnetr 0.0.6

  • Improved examples in the functions help
  • Updated license file to comply with CRAN policy
  • Cleaning to comply with CRAN checks in windows builds and travis CI
  • Added .accumulated_posix_aware helper function to avoid summing posix objects
  • Added pkgdown support
  • Added Travis CI support
  • Updated sapfluxnetr Not So Quick Guide vignette and README file

sapfluxnetr 0.0.5

  • Cleaning to comply with CRAN checks.
  • Added the "Metadata and data units" vignette.
  • Fixes for the new purrr version.
  • Exported the pipe operator (%>%) from magrittr package. Now loading sapfluxnetr the pipe can be used.
  • Added acummulated_precip as new metric for the default *_metrics functions.
  • Fixed 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).
  • Fixed a bug in sfn_metrics that for special intervals (md, pd, daylight) the filtering step was collecting timestamps above the int_end
  • Fixed bug in metrics function that created min and max time variables as double instead of POSIXct in sites with NAs in the first day of measures
  • Now species metadata variables are returned individually instead of a list
  • Added helper function sfn_sites_in_folder to list the site codes in a folder
  • Deprecated filter_by_var, substituted by filter_sites_by_md
  • Implementation of furrr::future_map in sfn_metrics. After some benchmarking, the benefits in time are solid, so now the user has the ability to perform the metrics in parallel.
  • New logic with performance improvements for metrics_tidyfier (introducing the .sapflow_tidy internal helper function)
  • Added get methods for sfn_data_multi class objects
  • Fixed bug in metrics function that created min and max time variables as double instead of POSIXct in sites with NAs in the first day of measures
  • Now species metadata variables are returned individually instead of in a list

sapfluxnetr 0.0.4

  • Added geom control to sfn_plot function.
  • Refactored sfn_metrics to uniformize interval start and interval end
  • Modified nightly_metrics to return only night interval
  • Created predawn_metrics, midday_metrics and daylight_metrics functions taking leverage in the refactored sfn_metrics functions.
  • Modified daily_metrics and monthly_metrics to return only the general interval metrics, avoiding this way the creation of very big objects.
  • Added tidy argument to *_metrics functions, to skip one step when creating tidy metrics.
  • Updated README file
  • Added bug report link to DESCRIPTION file
  • Updated documentation and vignettes accordingly with the changes made

sapfluxnetr 0.0.3

  • Added metrics_tidyfier function to convert to tidy the metrics results.
  • Added sfn_metadata_ex to Data.
  • Changed all example data names to the original site name.
  • Improved install explanation in quick guide vignette.
  • Added a NEWS.md file to track changes to the package.
  • Added README.md file for new users.

sapfluxnetr 0.0.2

  • Code and Docs cleaning.
  • Added vignettes for flags, classes, quick guide and custom aggregation .
  • Updated big-tests for dplyr-like functions.
  • Refactored metadata cache.
  • Modification of sfn_data show method to include site paper.
  • Added documentation for dplyr-like methods sfn_filter, sfn_mutate and sfn_mutate_at.
  • Added .flag internal function to flag mutated sfn_data objects.

sapfluxnetr 0.0.1

  • Initial version of the package.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sapfluxnetr")

0.0.7 by Victor Granda, 6 months ago


https://github.com/sapfluxnet/sapfluxnetr


Report a bug at https://github.com/sapfluxnet/sapfluxnetr/issues


Browse source code at https://github.com/cran/sapfluxnetr


Authors: Victor Granda [aut, cre] , Rafael Poyatos [aut] , Victor Flo [aut] , Jacob Nelson [ctb] , Sapfluxnet Core Team [cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports assertthat, dplyr, furrr, ggplot2, glue, lubridate, magrittr, methods, purrr, rlang, stats, stringr, tibble, tidyr

Suggests future, knitr, remotes, rmarkdown, testthat, tidyverse, xtable


See at CRAN