Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vwmaus committed Oct 1, 2015
1 parent d00fd0b commit 6542226
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 87 deletions.
94 changes: 50 additions & 44 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ print(alig)
Plot alignments
```{r define-demo-plot-alignments, eval=TRUE, include = TRUE}
library(dtwSat)
library(ggplot2)
library(gridExtra)
gp1 = plot(alig, type="alignment", attribute="evi", alignment=1, shift=0.5) +
ggtitle("Alignment 1") +
Expand All @@ -48,61 +49,66 @@ grid.arrange(gp1,gp2,nrow=2)
Plot path for all classese
```{r define-demo-plot-paths, eval=TRUE, include = TRUE}
library(dtwSat)
library(ggplot)
library(gridExtra)
gp.list = lapply(query.list, function(query){
alig = twdtw(query, template, weight = "logistic", alpha = 0.1, beta = 50,
alignments = 4, keep = TRUE)
alig = twdtw(query, template, weight = "logistic", alpha = 0.1,
beta = 100, alignments = 4, keep = TRUE)
plot(alig, normalize = TRUE, show.dist = TRUE) +
ggtitle(names(query.list)[2]) +
theme(axis.title.x=element_blank(),
legend.position="none")
})
grid.arrange(gp.list[[1]],
gp.list[[2]],
gp.list[[3]],
grid.arrange(gp.list[[1]] + ggtitle(names(query.list)[1]),
gp.list[[2]] + ggtitle(names(query.list)[2]),
gp.list[[3]] + ggtitle(names(query.list)[3]),
nrow=3)
```


<ol>
<li>Plot classification:
<code>
malig = mtwdtw(query.list, template, weight = "logistic",
alpha = 0.1, beta = 100)
Plot classification
```{r define-demo-plot-classification, eval=TRUE, include = TRUE}
library(dtwSat)
library(ggplot2)
library(gridExtra)
malig = mtwdtw(query.list, template, weight = "logistic",
alpha = 0.1, beta = 100)
gp = plot(x=malig, type="classify", attribute="evi", from=as.Date("2009-09-01"),
to=as.Date("2013-09-01"), by = "6 month",
normalized=TRUE, overlap=.7)
gp
</code>
</li>
</ol>
![alt text](README-classify.png "Classification plot")


<ol>
<li>Plot alignments: <code>
df = data.frame(Time=index(template), value=template$evi, variable="Raw")
df = rbind( df, data.frame(Time=index(sy), value=sy$evi, variable="Wavelet filter") )
gp = ggplot(df, aes(x=Time, y=value, group=variable, colour=variable)) +
geom_line() +
theme(legend.position="bottom") +
gp1 = plot(x=malig, type="classify", from=as.Date("2009-09-01"),
to=as.Date("2013-09-01"), by = "6 month",
normalized=TRUE, overlap=.7)
gp2 = plot(x=malig, type="classify", attribute = c("evi","ndvi"),
from=as.Date("2009-09-01"), to=as.Date("2013-09-01"),
by = "6 month", normalized=TRUE, overlap=.7)
grid.arrange(gp1,gp2,nrow=2)
```



Plot wavelet smoothing
```{r define-demo-plot-smoothing, eval=TRUE, include = TRUE}
library(dtwSat)
library(ggplot2)
library(reshape2)
library(gridExtra)
sy = waveletSmoothing(x=template, frequency=8, wf = "la8", J=1,
boundary = "periodic")
df1 = data.frame(Time=index(template), value=template$evi, variable="Raw")
df1 = rbind(df1, data.frame(Time=index(sy), value=sy$evi, variable="Wavelet filter") )
gp1 = ggplot(df1, aes(x=Time, y=value, group=variable, colour=variable)) +
geom_line() +
# theme(legend.position="bottom") +
ylab("EVI")
gp
</code>
</li>
</ol>

![alt text](README-filter.png "Smoothing plot")

<h3>How to build the package:</h3>
<ol>
<li>Clone the project: <code>git clone https//github.com/vwmaus/dtwSat.git</code>.</li>
<li>Open Rstudio, go to File - Open Project and pick the file <code>dtwSat.Rproj</code>.</li>
<li>Install the required packages <code>install.packages(c("roxygen2", "testthat"))</code>.</li>
<li>Go to the <i>Build</i> tab in the upper-right panel and press the button <i>Build & Reload</i>. After this the package is ready to use.</li>
<li>You can also create a source package: Go to the <i>Build</i> tab, display the menu <i>More</i> and select the option <i>Build Source Package</i>.</li>
</ol>
df2 = melt(data.frame(Time=index(sy), sy), id="Time")
gp2 = ggplot(df2, aes(x=Time, y=value, group=variable, colour=variable)) +
geom_line() +
ylab("Value")
gp2
grid.arrange(gp1,gp2,nrow=2)
```



```{r, echo = FALSE}
Expand Down
109 changes: 66 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Plot alignments

```r
library(dtwSat)
library(ggplot2)
library(gridExtra)
gp1 = plot(alig, type="alignment", attribute="evi", alignment=1, shift=0.5) +
ggtitle("Alignment 1") +
Expand All @@ -71,63 +72,85 @@ Plot path for all classese

```r
library(dtwSat)
library(ggplot)
```

```
## Error in library(ggplot): there is no package called 'ggplot'
```

```r
library(gridExtra)
gp.list = lapply(query.list, function(query){
alig = twdtw(query, template, weight = "logistic", alpha = 0.1, beta = 50,
alignments = 4, keep = TRUE)
alig = twdtw(query, template, weight = "logistic", alpha = 0.1,
beta = 100, alignments = 4, keep = TRUE)
plot(alig, normalize = TRUE, show.dist = TRUE) +
ggtitle(names(query.list)[2]) +
theme(axis.title.x=element_blank(),
legend.position="none")
})
grid.arrange(gp.list[[1]],
gp.list[[2]],
gp.list[[3]],
grid.arrange(gp.list[[1]] + ggtitle(names(query.list)[1]),
gp.list[[2]] + ggtitle(names(query.list)[2]),
gp.list[[3]] + ggtitle(names(query.list)[3]),
nrow=3)
```

![plot of chunk define-demo-plot-paths](figure/define-demo-plot-paths-1.png)

Plot classification

<ol>
<li>Plot classification:
<code>
malig = mtwdtw(query.list, template, weight = "logistic",
alpha = 0.1, beta = 100)
```r
library(dtwSat)
library(ggplot2)
library(gridExtra)
malig = mtwdtw(query.list, template, weight = "logistic",
alpha = 0.1, beta = 100)

gp = plot(x=malig, type="classify", attribute="evi", from=as.Date("2009-09-01"),
to=as.Date("2013-09-01"), by = "6 month",
normalized=TRUE, overlap=.7)
gp
</code>
</li>
</ol>
![alt text](README-classify.png "Classification plot")


<ol>
<li>Plot alignments: <code>
df = data.frame(Time=index(template), value=template$evi, variable="Raw")
df = rbind( df, data.frame(Time=index(sy), value=sy$evi, variable="Wavelet filter") )
gp = ggplot(df, aes(x=Time, y=value, group=variable, colour=variable)) +
geom_line() +
theme(legend.position="bottom") +
gp1 = plot(x=malig, type="classify", from=as.Date("2009-09-01"),
to=as.Date("2013-09-01"), by = "6 month",
normalized=TRUE, overlap=.7)

gp2 = plot(x=malig, type="classify", attribute = c("evi","ndvi"),
from=as.Date("2009-09-01"), to=as.Date("2013-09-01"),
by = "6 month", normalized=TRUE, overlap=.7)

grid.arrange(gp1,gp2,nrow=2)
```

![plot of chunk define-demo-plot-classification](figure/define-demo-plot-classification-1.png)



Plot wavelet smoothing

```r
library(dtwSat)
library(ggplot2)
library(reshape2)
library(gridExtra)
sy = waveletSmoothing(x=template, frequency=8, wf = "la8", J=1,
boundary = "periodic")
df1 = data.frame(Time=index(template), value=template$evi, variable="Raw")
df1 = rbind(df1, data.frame(Time=index(sy), value=sy$evi, variable="Wavelet filter") )
gp1 = ggplot(df1, aes(x=Time, y=value, group=variable, colour=variable)) +
geom_line() +
# theme(legend.position="bottom") +
ylab("EVI")
gp
</code>
</li>
</ol>

![alt text](README-filter.png "Smoothing plot")

<h3>How to build the package:</h3>
<ol>
<li>Clone the project: <code>git clone https//github.com/vwmaus/dtwSat.git</code>.</li>
<li>Open Rstudio, go to File - Open Project and pick the file <code>dtwSat.Rproj</code>.</li>
<li>Install the required packages <code>install.packages(c("roxygen2", "testthat"))</code>.</li>
<li>Go to the <i>Build</i> tab in the upper-right panel and press the button <i>Build & Reload</i>. After this the package is ready to use.</li>
<li>You can also create a source package: Go to the <i>Build</i> tab, display the menu <i>More</i> and select the option <i>Build Source Package</i>.</li>
</ol>

df2 = melt(data.frame(Time=index(sy), sy), id="Time")
gp2 = ggplot(df2, aes(x=Time, y=value, group=variable, colour=variable)) +
geom_line() +
ylab("Value")
gp2
```

![plot of chunk define-demo-plot-smoothing](figure/define-demo-plot-smoothing-1.png)

```r
grid.arrange(gp1,gp2,nrow=2)
```

![plot of chunk define-demo-plot-smoothing](figure/define-demo-plot-smoothing-2.png)




Binary file added figure/define-demo-plot-classification-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figure/define-demo-plot-paths-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/define-demo-plot-smoothing-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/define-demo-plot-smoothing-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/testthat/test_dtwSat.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sy = waveletSmoothing(x=template, frequency=8, wf = "la8", J=1,


# Plot raw EVI and filtered EVI

df = data.frame(Time=index(template), value=template$evi, variable="Raw")
df = rbind( df, data.frame(Time=index(sy), value=sy$evi, variable="Wavelet filter") )
gp = ggplot(df, aes(x=Time, y=value, group=variable, colour=variable)) +
Expand Down

0 comments on commit 6542226

Please sign in to comment.