bfast2 / bfast

Breaks For Additive Season and Trend
https://bfast2.github.io
GNU General Public License v2.0
41 stars 15 forks source link

DOI

bfast

This fork aims to consolidate all the forks of the bfast package to have a unified, updated package that can be submitted back to CRAN eventually and become the new upstream. The features integrated into this fork so far are:

Parts of the improvements rely on modifications of the strucchange package (see here). You can install both packages with:

install.packages(c("strucchangeRcpp", "bfast"))

To install the development version of the package, run:

library(remotes)
install_github("bfast2/strucchangeRcpp")
install_github("bfast2/bfast")

Enabling performance optimisations

By default, the package makes use of C++ paths for increased performance. Two functions change the behaviour:

set_default_options()    # use modifications, same as set_fast_options()
set_fallback_options()   # use default implementation

The example below runs the first example of the bfastmonitor() documentation for both settings.

library(bfast)
NDVIa <- as.ts(zoo(som$NDVI.a, som$Time))
f <- function() bfastmonitor(NDVIa, start = c(2010, 13)) 

set_fallback_options()
x = f() 
system.time(replicate(100, f()))

set_fast_options()
y = f()
system.time(replicate(100, f()))

par(mfrow = c(1,2))
plot(x) ; plot(y)

Generating evaluation reports

The package comes with R Markdown reports to evaluate the performance modifications thoroughly. The following reports can be found in inst/reports:

To generate html reports, run:

library(rmarkdown)
outdir = getwd()
rmarkdown::render(system.file("reports/report.test.Rmd",package = "bfast"),output_file = paste(outdir,"/report.test.html",sep=""))
rmarkdown::render(system.file("reports/report.benchmark.Rmd",package = "bfast"),output_file = paste(outdir,"/report.benchmark.html",sep=""))
rmarkdown::render(system.file("reports/report.profiling.Rmd",package = "bfast"),output_file = paste(outdir,"/report.profiling.html",sep=""))

Notice that generating the last two reports might take some time.

Details

Most important performance modifications include:

Contribution guidelines:

We always welcome contributions to the package. If you would like to propose a new functionality and/or report an issue, please use GitHub's tracker called Issues.

For development we use the GitHub Flow branching model.

Key steps:

  1. Create a GitHub issue in this repository with description of the work that you plan to do.
  2. Assign yourself to the GitHub issue you are working on, to inform other developers that you are working on it.
  3. Create your own working fork or branch based on the master branch.
  4. Make your changes in that branch.
  5. Commit your changes to your working branch as long as you are not finished with your development.
  6. Make sure that all tests pass (GitHub Actions).
  7. Once your work is finished, create a pull request so that another developer can review your changes before merging them with the dev (or main) branch.

Additional steps for preparing a new release:

  1. Update the NEWS file with most notable changes.
  2. Add new contributors to the DESCRIPTION file if applicable.
  3. Release the package and make it citable (add CITATION.cff including DOI).