iccsa-21-wind

git clone https://git.igankevich.com/iccsa-21-wind.git
Log | Files | Refs

commit 8de7706efd49562eaa0187806597c7feb8908947
parent f877df31ca13b4b7001976a1e7c783261983c5f2
Author: Ivan Gankevich <i.gankevich@spbu.ru>
Date:   Sun, 18 Apr 2021 09:18:13 +0300

Make directory R function.

Diffstat:
R/acf-min-max.R | 4+++-
R/anal.R | 10+++++-----
R/common.R | 4++++
R/direction-min-max.R | 2+-
R/hold-peak.R | 2+-
5 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/R/acf-min-max.R b/R/acf-min-max.R @@ -1,10 +1,12 @@ +library(gplots) # hist2d + source("R/common.R") time_delta = 60*60*2 for (timestamp in c(1614920400, 1615388400, 1614135600, 1616058000, 1614430800, 1614452400)) { velocity <- select_samples(timestamp, time_delta) path <- file.path('build', 'acf') - dir.create(path, recursive=TRUE) + make_directory(path) filename <- file.path(path, sprintf("%d-hist-xy", timestamp)) print(filename) # add corner points with mean speed diff --git a/R/anal.R b/R/anal.R @@ -266,7 +266,7 @@ fit_velocity_pdf_bilateral <- function (velocity, axis="x", timestamp=0, dist="w lines(dist_right$x, dist_right$estimated_density, col='blue', lwd=2) #printf("RMSE %f\n", rmse(estimated_density, actual_density)) path <- file.path('build', 'velocity', axis, dist) - dir.create(path, recursive=TRUE) + make_directory(path) filename <- file.path(path, sprintf("%d", timestamp)) write.table(data.frame(x=x,actual=actual_density,estimated=estimated_density), filename, row.names=FALSE, quote=FALSE) @@ -304,7 +304,7 @@ fit_velocity_acf <- function (velocity, plot=TRUE, axis="x", timestamp=0, write= } if (write) { path <- file.path('build', 'acf', axis) - dir.create(path, recursive=TRUE) + make_directory(path) filename <- file.path(path, sprintf("%d", timestamp)) write.table(data.frame(lag=acf_x$lag,actual=acf_x$acf,estimated=acf_est), filename, row.names=FALSE, quote=FALSE) @@ -328,7 +328,7 @@ fit_velocity_acf_bilateral <- function (velocity, axis="x", timestamp=0, plot=TR lines(-model_1$lag, model_2$estimated, col='red', lwd=2) lines(model_2$lag, model_2$estimated, col='blue', lwd=2) path <- file.path('build', 'acf', axis) - dir.create(path, recursive=TRUE) + make_directory(path) filename <- file.path(path, sprintf("%d", timestamp)) #write.table(data.frame(lag=lag,actual=actual,estimated=estimated), # filename, row.names=FALSE, quote=FALSE) @@ -402,7 +402,7 @@ fit_direction_bilateral <- function (direction, plot=TRUE, timestamp=0, dist="vo } #printf("RMSE %f\n", rmse(estimated_density, actual_density)) path <- file.path('build', 'direction', dist) - dir.create(path, recursive=TRUE) + make_directory(path) filename <- file.path(path, sprintf("%d", timestamp)) write.table(data.frame(x=x,actual=actual_density,estimated=estimated_density), filename, row.names=FALSE, quote=FALSE) @@ -526,7 +526,7 @@ cumulative_data <- foreach (timestamp=timestamps, .combine=rbind, .errorhandling direction_hist <- hist(velocity$direction, plot=FALSE, breaks=100) direction_hist <- data.frame(direction=direction_hist$density, angle=direction_hist$mids) #path <- file.path('build', 'direction') - #dir.create(path, recursive=TRUE) + #make_directory(path) #filename <- file.path(path, sprintf("%d-hist-xy", timestamp)) ## add corner points with mean speed #x_max = max(abs(velocity$x)) diff --git a/R/common.R b/R/common.R @@ -99,3 +99,7 @@ select_samples <- function (timestamp, time_delta, url="samples/load-cell.sqlite time_string_to_timestamp <- function(str) { as.integer(as.POSIXct(strptime(str, datetime_format))) } + +make_directory <- function (path) { + dir.create(path, recursive=TRUE, showWarnings=FALSE) +} diff --git a/R/direction-min-max.R b/R/direction-min-max.R @@ -9,7 +9,7 @@ time_delta = 60*60*2 for (timestamp in c(t_min_rmse, t_max_rmse)) { velocity <- select_samples(timestamp, time_delta) path <- file.path('build', 'direction') - dir.create(path, recursive=TRUE) + make_directory(path) filename <- file.path(path, sprintf("%d-hist-xy", timestamp)) print(filename) # add corner points with mean speed diff --git a/R/hold-peak.R b/R/hold-peak.R @@ -76,7 +76,7 @@ for (i in 1:nrow(hp_intervals)) { t_origin <- max(min(velocity$timestamp),min(velocity$timestamp)) plot(velocity$timestamp-t_origin, velocity$speed.x) lines(velocity$timestamp-t_origin, velocity$speed.y) - dir.create(file.path("build","hold-peak"), recursive=TRUE, showWarnings=FALSE) + make_directory(file.path("build","hold-peak")) write.table(data.frame(timstamp=velocity$timestamp, speed_lc=velocity$speed.x, speed_hp=velocity$speed.y),