Skip to content

Commit

Permalink
Fix test to show progress bar and to use new version of twdtwClassify
Browse files Browse the repository at this point in the history
  • Loading branch information
vwmaus committed Jun 5, 2017
1 parent 8196886 commit c4c9009
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
16 changes: 10 additions & 6 deletions examples/test_twdtw_raster_analysis.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\dontrun{

# Example of TWDTW analysis using raster files
library(dtwSat)
library(caret)
Expand Down Expand Up @@ -43,22 +43,22 @@ log_fun <- logisticWeight(-0.1, 50)

# Run serial TWDTW analysis
r_twdtw <-
twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test')
twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text')

# or Run parallel TWDTW analysis
beginCluster(n = 4)
beginCluster()
r_twdtw <-
twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test')
twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text')
endCluster()

# Plot TWDTW distances for the first year
plot(r_twdtw, type = "distance", time.levels = 1)

# Classify raster based on the TWDTW analysis
r_lucc <- twdtwClassify(r_twdtw, format = "GTiff", overwrite = TRUE)
r_lucc <- twdtwClassify(r_twdtw, progress = 'text')

# Plot TWDTW classification results
plot(r_lucc, type = "classification")
plot(r_lucc, type = "map")

# Assess classification
twdtw_assess <-
Expand All @@ -71,6 +71,9 @@ plot(twdtw_assess, type = "accuracy")
# Plot area uncertainty
plot(twdtw_assess, type = "area")

# Plot misclassified samples
plot(twdtw_assess, type = "map", samples = "incorrect")

# Get latex table with error matrix
twdtwXtable(twdtw_assess, table.type = "matrix")

Expand All @@ -81,3 +84,4 @@ twdtwXtable(twdtw_assess, table.type = "accuracy")
twdtwXtable(twdtw_assess, table.type = "area")

}

13 changes: 8 additions & 5 deletions tests/test_twdtw_raster_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ log_fun <- logisticWeight(-0.1, 50)

# Run serial TWDTW analysis
r_twdtw <-
twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test')
twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text')

# or Run parallel TWDTW analysis
beginCluster(n = 4)
beginCluster()
r_twdtw <-
twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test')
twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text')
endCluster()

# Plot TWDTW distances for the first year
plot(r_twdtw, type = "distance", time.levels = 1)

# Classify raster based on the TWDTW analysis
r_lucc <- twdtwClassify(r_twdtw, format = "GTiff", overwrite = TRUE)
r_lucc <- twdtwClassify(r_twdtw, progress = 'text')

# Plot TWDTW classification results
plot(r_lucc, type = "classification")
plot(r_lucc, type = "map")

# Assess classification
twdtw_assess <-
Expand All @@ -69,6 +69,9 @@ plot(twdtw_assess, type = "accuracy")
# Plot area uncertainty
plot(twdtw_assess, type = "area")

# Plot misclassified samples
plot(twdtw_assess, type = "map", samples = "incorrect")

# Get latex table with error matrix
twdtwXtable(twdtw_assess, table.type = "matrix")

Expand Down

0 comments on commit c4c9009

Please sign in to comment.