Skip to content

Commit

Permalink
Prevent running long tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatEmerald committed Oct 18, 2024
1 parent 26daf0a commit 3a838c9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 48 deletions.
2 changes: 2 additions & 0 deletions examples/bfastmonitor.r
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mon <- bfastmonitor(NDVIb, formula = response ~ season,
summary(mon$model)
AIC(mon$model)

\donttest{
## Example for processing raster bricks (satellite image time series of 16-day NDVI images)
f <- system.file("extdata/modisraster.tif", package="bfast")
modisbrick <- terra::rast(f)
Expand Down Expand Up @@ -69,3 +70,4 @@ timeofbreak <- terra::app(modisbrick, fun=xbfastmonitor)

terra::plot(timeofbreak) ## time of break and magnitude of change
terra::plot(timeofbreak,2) ## magnitude of change
}
2 changes: 2 additions & 0 deletions examples/bfastts.r
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bfastts(timedf$y, timedf$dates, type = "16-day")
# Irregular
head(bfastts(timedf$y, timedf$dates, type = "irregular"), 50)

\donttest{
# Example of use with a raster
f <- system.file("extdata/modisraster.tif", package="bfast")
modisbrick <- terra::rast(f)
Expand All @@ -16,3 +17,4 @@ modis_ts = t(modisbrick[1:4])
# Data with multiple columns, 2-4 are external regressors
ndvi <- bfastts(modis_ts, dates, type = c("16-day"))
plot(ndvi/10000)
}
6 changes: 4 additions & 2 deletions man/bfastmonitor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/bfastts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 1 addition & 46 deletions tests/Examples/bfast-Ex.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -581,40 +581,6 @@ F-statistic: 14.82 on 10 and 227 DF, p-value: < 2.2e-16
> AIC(mon$model)
[1] -428.9029
>
> ## Example for processing raster bricks (satellite image time series of 16-day NDVI images)
> f <- system.file("extdata/modisraster.tif", package="bfast")
> modisbrick <- terra::rast(f)
> data <- unlist(modisbrick[1])
> ndvi <- bfastts(data, dates, type = c("16-day"))
> plot(ndvi/10000)
>
> ## derive median NDVI of a NDVI raster brick
> medianNDVI <- terra::app(modisbrick, fun = function(x) median(x, na.rm = TRUE))
> terra::plot(medianNDVI)
>
> ## helper function to be used with the app() function
> xbfastmonitor <- function(x, timestamps = dates) {
+ ndvi <- bfastts(x, timestamps, type = c("16-day"))
+ ndvi <- window(ndvi, end = c(2011, 14))/10000
+ ## delete end of the time to obtain a dataset similar to RSE paper (Verbesselt et al.,2012)
+ bfm <- bfastmonitor(data = ndvi, start = c(2010, 12), history = c("ROC"))
+ return(c(breakpoint = bfm$breakpoint, magnitude = bfm$magnitude))
+ }
>
> ## apply on one pixel for testing
> bfm <- bfastmonitor(data = ndvi, start = c(2010, 12), history = c("ROC"))
> bfm$magnitude
[1] -845.1347
> plot(bfm)
> xbfastmonitor(unlist(modisbrick[1]), dates) ## helper function applied on one pixel
breakpoint magnitude
2011.34782609 -0.08709291
>
> ## apply the bfastmonitor function onto a raster brick
> timeofbreak <- terra::app(modisbrick, fun=xbfastmonitor)
>
> terra::plot(timeofbreak) ## time of break and magnitude of change
> terra::plot(timeofbreak,2) ## magnitude of change
>
>
>
Expand Down Expand Up @@ -767,17 +733,6 @@ Frequency = 365
[31] NA 0.3443 NA NA NA NA NA NA NA NA
[41] NA NA NA NA NA NA NA 0.3216 NA NA
>
> # Example of use with a raster
> f <- system.file("extdata/modisraster.tif", package="bfast")
> modisbrick <- terra::rast(f)
> ndvi <- bfastts(unlist(modisbrick[1]), dates, type = c("16-day")) ## data of pixel 1
> plot(ndvi/10000)
>
> # Time series of 4 pixels
> modis_ts = t(modisbrick[1:4])
> # Data with multiple columns, 2-4 are external regressors
> ndvi <- bfastts(modis_ts, dates, type = c("16-day"))
> plot(ndvi/10000)
>
>
>
Expand Down Expand Up @@ -960,7 +915,7 @@ Frequency = 365
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed: 12.338 0.463 12.034 0 0
Time elapsed: 1.797 0.047 1.844 0 0
> grDevices::dev.off()
null device
1
Expand Down

0 comments on commit 3a838c9

Please sign in to comment.