iccsa-21-wind

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

commit 1895895637899bca6beecc257289ce4460b28c84
parent 8de7706efd49562eaa0187806597c7feb8908947
Author: Ivan Gankevich <i.gankevich@spbu.ru>
Date:   Sun, 18 Apr 2021 10:49:15 +0300

Anemometer verification.

Diffstat:
Makefile | 1+
R/hold-peak.R | 27++++++++++++++++-----------
gnuplot/hold-peak.gnuplot | 45+++++++++++++++++++++++++++++++++++++++++++++
main.tex | 19+++++++++++++++++++
4 files changed, 81 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile @@ -22,6 +22,7 @@ build/main.pdf: build/gnuplot/velocity-xy-dist-max.eps build/main.pdf: build/gnuplot/velocity-xy-dist-min.eps build/main.pdf: build/gnuplot/direction-dist.eps build/main.pdf: build/gnuplot/acf.eps +build/main.pdf: build/gnuplot/hold-peak.eps #build/main.pdf: build/gnuplot/anemometer.eps #build/main.pdf: build/gnuplot/anemometer.svg build/main.pdf: diff --git a/R/hold-peak.R b/R/hold-peak.R @@ -62,31 +62,36 @@ for (i in 1:nrow(hp_intervals)) { lc_velocity <- all_lc_velocity[all_lc_velocity$timestamp>=t0 & all_lc_velocity$timestamp<=t1,] hp_velocity <- select_hold_peak_samples(t0, t1-t0) velocity <- merge(lc_velocity, hp_velocity, by=c("timestamp")) + velocity$timestamp = velocity$timestamp - min(velocity$timestamp) # scale samples t <- c(1:length(velocity$speed.x)) - reg <- lm(velocity$speed.x-velocity$speed.y~t) - #print(coef(reg)) + model <- nls(speed.y ~ a*speed.x, data=velocity) + velocity$speed.x <- velocity$speed.x * summary(model)$coefficients[[1]] + lo <- loess.smooth(velocity$timestamp, velocity$speed.x, span=0.5) new_row <- nrow(result)+1 result[new_row,"rmse"] <- normalized_rmse(velocity$speed.x, velocity$speed.y) result[new_row,"urmse"] <- rmse(velocity$speed.x, velocity$speed.y) result[new_row,"start"] <- t0 result[new_row,"end"] <- t1 - velocity$speed.x <- velocity$speed.x - reg$fitted.values - #print(lc_velocity) - 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) + scatter.smooth(velocity$timestamp, velocity$speed.x) + #plot(velocity$timestamp, velocity$speed.x) + lines(velocity$timestamp, velocity$speed.y, col='red') + #lines(lo) make_directory(file.path("build","hold-peak")) - write.table(data.frame(timstamp=velocity$timestamp, + filename <- file.path("build","hold-peak",sprintf("%d",t0)) + write.table(data.frame(timestamp=velocity$timestamp, speed_lc=velocity$speed.x, speed_hp=velocity$speed.y), - file.path("build","hold-peak",sprintf("%d",t0)), - row.names=FALSE, quote=FALSE) + filename, row.names=FALSE, quote=FALSE) + write("\n",file=filename,append=TRUE) + write.table(data.frame(timestamp=lo$x,speed=lo$y), filename, + row.names=FALSE, quote=FALSE, append=TRUE) } print(result[result$rmse==max(result$rmse),]) print(result[result$rmse==min(result$rmse),]) sorted_result <- result[order(result$rmse),] +print(sorted_result) gnuplot <- function (file, str, ...) { cat(sprintf(str, ...), file=file, append=TRUE) @@ -106,4 +111,4 @@ gnuplot_all <- function (filename, prefix, rmse_column, row_min, row_max, row_lo gnuplot_all("build/gnuplot/hold_peak_rmse.gnuplot", "speed", "rmse", result[result$rmse == min(result$rmse),], result[result$rmse == max(result$rmse),], - sorted_result[2,]) + result[2,]) diff --git a/gnuplot/hold-peak.gnuplot b/gnuplot/hold-peak.gnuplot @@ -0,0 +1,45 @@ +set terminal svg size 450,450/2 font 'Free Serif, 10' enhanced round dynamic +set xtics nomirror out offset 0,0.5 +set ytics nomirror out offset 0.5,0 +set border 1+2 back +unset key + +set output 'build/gnuplot/hold-peak.svg' + +set xlabel offset 0,1.0 +set xlabel 'Time, s' +set ylabel 'Wind speed, m/s' offset 1.5,0 +set title offset 0,-1 +set lmargin 5 +set rmargin 2 +set tmargin 4.0 +set multiplot layout 1,2 + +round(x) = floor(x+0.5) +filename(timestamp) = sprintf('build/hold-peak/%d', timestamp) + +load "build/gnuplot/hold_peak_rmse.gnuplot" + +set yrange [0:5] +set ytics 0,1,5 +set xtics 0,30 + +set title sprintf('RMSE = %.1f%%', (speed_rmse_max*100)) +plot \ +filename(speed_rmse_max_timestamp) index 0 using 1:2 with points pt 6 lc '#404040',\ +'' index 0 using 1:3 with lines lw 2 lc '#c04040',\ +'' index 1 using 1:2 with lines lw 2 lc '#c0c040' + +set key Left reverse at screen 0.80, screen 1.00 + +set title sprintf('RMSE = %.1f%%', (speed_rmse_min*100)) +plot \ +filename(speed_rmse_min_timestamp) index 0 using 1:2 with points pt 6 lc '#404040' title 'Load cell data',\ +'' index 0 using 1:3 with lines lw 2 lc '#c04040' title 'HP-866A data',\ +'' index 1 using 1:2 with lines lw 2 lc '#c0c040' title 'Smoothed load cell data' + +# set title sprintf('RMSE_x = %.1f%%', (speed_rmse_longest*100)) +# plot \ +# filename(speed_rmse_longest_timestamp) index 0 using 1:2 with points pt 6 lc '#404040',\ +# '' index 0 using 1:3 with lines lw 2 lc '#c04040',\ +# '' index 1 using 1:2 with lines lw 2 lc '#40c040' diff --git a/main.tex b/main.tex @@ -502,6 +502,25 @@ are presented in figure~\ref{fig-direction-distributions}. \label{fig-direction-distributions}} \end{figure} +In order to verify that our anemometer produces correct time series we +performed synchronous measurements with commercial anemometer HP-866A. Two +anemometers were placed in the open field near the shore. The commercial +anemometer directed towards the mean wind direction as it measures the speed +only. The data from the two anemometers was recorded synchronously. From the +data we selected intervals with wind gusts and compared the measurements of the +two anemometers. To compare them we scaled load cell anemometer measurements to +minimise RMSE of the difference between the two time series to compensate for +the errors in calibration coefficients. The results showed that there is good +correspondence between the measurements of the two anemometers +(figure~\ref{fig-hold-peak}). + +\begin{figure} + \centering + \includegraphics{build/gnuplot/hold-peak.eps} + \caption{Comparison of measurements obtained from three-axis and HP-866A + anemometers.\label{fig-hold-peak}} +\end{figure} + %TODO asymmetry Finally, we computed autocovariance for each axis as