Skip to content

Commit

Permalink
Merge pull request #60 from vwmaus/drop-dependencies
Browse files Browse the repository at this point in the history
Drop dependencies
  • Loading branch information
vwmaus authored Sep 21, 2023
2 parents 1eb27b5 + d2f9c56 commit 2aaa9af
Show file tree
Hide file tree
Showing 62 changed files with 1,126 additions and 1,945 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ examples_x64
^LICENSE\.md$
^dtwSat\.Rproj$
^\.github$
^doc$
^Meta$

vignettes.awk
_pkgdown.yml
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
branch: gh-pages
folder: docs
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ CRAN-SUBMISSION
src/symbols.rds
*.o
*.so
/doc/
/Meta/
35 changes: 21 additions & 14 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: dtwSat
Type: Package
Title: Time-Weighted Dynamic Time Warping for Satellite Image Time Series Analysis
Version: 1.0.0
Date: 2023-09-03
Date: 2023-09-21
Authors@R:
c(person(given = "Victor",
family = "Maus",
Expand All @@ -24,18 +24,19 @@ Authors@R:
)
Description: Provides a robust approach to land use mapping using multi-dimensional
(multi-band) satellite image time series. By leveraging the Time-Weighted Dynamic
Time Warping (TWDTW) distance metric in tandem with a 1-NN classifier, the package
provides functions to produce land use maps based on distinct seasonality patterns,
typically observed in the phenological cycles of vegetation. The TWDTW algorithm is
described in Maus et al. (2016) <doi:10.1109/JSTARS.2016.2517118> and
Maus et al. (2019) <doi:10.18637/jss.v088.i05>. A key strength of TWDTW is its ability
to recognize patterns with only a minimal training set, achieving notable accuracy.
The package features tools for generating temporal patterns for various land cover types,
conducting land use mapping, and visualizing the outcomes.
Time Warping (TWDTW) distance metric in tandem with a 1 Nearest-Neighbor (1-NN) Classifier,
this package offers functions to produce land use maps based on distinct seasonality patterns,
commonly observed in the phenological cycles of vegetation. The approach is described in
Maus et al. (2016) <doi:10.1109/JSTARS.2016.2517118> and Maus et al. (2019) <doi:10.18637/jss.v088.i05>.
A primary advantage of TWDTW is its capability to handle irregularly sampled and noisy time series,
while also requiring minimal training sets. The package includes tools for training the 1-NN-TWDTW model,
visualizing temporal patterns, producing land use maps, and visualizing the results.
License: GPL (>= 3)
URL: https://github.com/vwmaus/dtwSat/
BugReports: https://github.com/vwmaus/dtwSat/issues/
Maintainer: Victor Maus <vwmaus1@gmail.com>
VignetteBuilder:
knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Expand All @@ -47,11 +48,17 @@ Depends:
Imports:
mgcv,
stats,
scales,
reshape2,
rlang
tidyr,
proxy
Suggests:
rbenchmark,
stringr,
knitr,
rmarkdown,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Collate:
'plot.R'
'predict.R'
'prepare_time_series.R'
'shift_dates.R'
'train.R'
'zzz.R'
16 changes: 9 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# Generated by roxygen2: do not edit by hand

export(create_patterns)
export(plot_patterns)
S3method(plot,twdtw_knn1)
S3method(predict,twdtw_knn1)
S3method(print,twdtw_knn1)
export(shift_dates)
export(twdtw_knn1)
import(ggplot2)
import(sf)
import(stars)
import(twdtw)
importFrom(mgcv,gam)
importFrom(mgcv,predict.gam)
importFrom(mgcv,s)
importFrom(reshape2,melt)
importFrom(rlang,.data)
importFrom(scales,date_format)
importFrom(scales,percent)
importFrom(scales,pretty_breaks)
importFrom(proxy,dist)
importFrom(stats,as.formula)
importFrom(stats,predict)
importFrom(stats,setNames)
importFrom(tidyr,nest)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,unnest)
146 changes: 0 additions & 146 deletions R/create_patterns.R

This file was deleted.

48 changes: 48 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#' Plot Patterns from twdtw-knn1 model
#'
#' This function visualizes time series patterns from the \code{"twdtw_knn1"} model.
#' It produces a multi-faceted plot, where each facet represents a different time series
#' label from the model's data. Within each facet, different bands or indices (attributes)
#' are plotted as distinct lines, differentiated by color.
#'
#' @param x A model of class \code{"twdtw_knn1"}.
#'
#' @param bands A character vector specifying the bands or indices to plot.
#' If NULL (default), all available bands or indices in the data will be plotted.
#'
#' @param ... Additional arguments passed to \code{\link[ggplot2]{ggplot}}. Currently not used.
#'
#' @return A \code{\link[ggplot2]{ggplot}} object displaying the time series patterns.
#'
#' @seealso twdtw_knn1
#'
#' @inherit twdtw_knn1 examples
#'
#' @export
plot.twdtw_knn1 <- function(x, bands = NULL, ...) {

# Convert the list of time series data into a long-format data.frame
df <- x$data
df$id <- 1:nrow(df)
df <- unnest(df, cols = 'observations')

# Select bands
if(!is.null(bands)){
df <- df[c('id', 'time', 'label', bands)]
}

# Pivote data into long format for ggplot2
df <- pivot_longer(df, !c('id', 'label', 'time'), names_to = "band", values_to = "value")

# Construct the ggplot
gp <- ggplot(df, aes(x = .data$time, y = .data$value, colour = .data$band, group = interaction(.data$id, .data$band))) +
geom_line() +
facet_wrap(~label) +
theme(legend.position = "bottom") +
guides(colour = guide_legend(title = "Bands")) +
ylab("Value") +
xlab("Time")

return(gp)

}
41 changes: 0 additions & 41 deletions R/plot_patterns.R

This file was deleted.

Loading

0 comments on commit 2aaa9af

Please sign in to comment.