iccsa-21-wind

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

commit c95a535beb32438aacac66c74dc0b891f07bcd99
parent 8b541d32182547c2d64cf781720c78d1d72b9e5b
Author: Ivan Gankevich <i.gankevich@spbu.ru>
Date:   Tue,  6 Apr 2021 14:16:53 +0300

Wind direction distribution.

Diffstat:
Makefile | 19+++++++++++--------
R/minmax.R | 12++++++++++--
gnuplot/direction-dist.gnuplot | 125++++++++++++++++++-------------------------------------------------------------
gnuplot/velocity-xy-dist.gnuplot | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
main.tex | 35++++++++++++++++++++++++-----------
5 files changed, 182 insertions(+), 118 deletions(-)

diff --git a/Makefile b/Makefile @@ -18,8 +18,9 @@ build/main.pdf: build/inkscape/anemometer.eps build/main.pdf: build/daily-stats.eps build/main.pdf: build/daily-rmse.eps build/main.pdf: build/gnuplot/velocity-dist.eps -build/main.pdf: build/gnuplot/direction-dist-max.png -build/main.pdf: build/gnuplot/direction-dist-min.png +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/anemometer.eps #build/main.pdf: build/gnuplot/anemometer.svg build/main.pdf: @@ -56,13 +57,15 @@ build/daily-stats.svg: gnuplot/daily-stats.gnuplot build/daily-stats build/daily-rmse.svg: gnuplot/daily-rmse.gnuplot build/daily-rmse gnuplot -d $< -build/gnuplot/direction-dist-min.svg: gnuplot/direction-dist.gnuplot build/direction/1616497200-hist-xy - gnuplot -d -c gnuplot/direction-dist.gnuplot \ - build/direction/1616497200-hist-xy build/gnuplot/direction-dist-min.svg 0.024544 +build/gnuplot/velocity-xy-dist-min.svg: gnuplot/velocity-xy-dist.gnuplot build/direction/1616497200-hist-xy + gnuplot -d -c gnuplot/velocity-xy-dist.gnuplot \ + build/direction/1616497200-hist-xy build/gnuplot/velocity-xy-dist-min.svg \ + 0.024544 4.495469 -build/gnuplot/direction-dist-max.svg: gnuplot/direction-dist.gnuplot build/direction/1616792400-hist-xy - gnuplot -d -c gnuplot/direction-dist.gnuplot \ - build/direction/1616792400-hist-xy build/gnuplot/direction-dist-max.svg 0.154791 +build/gnuplot/velocity-xy-dist-max.svg: gnuplot/velocity-xy-dist.gnuplot build/direction/1616792400-hist-xy + gnuplot -d -c gnuplot/velocity-xy-dist.gnuplot \ + build/direction/1616792400-hist-xy build/gnuplot/velocity-xy-dist-max.svg \ + 0.154791 0.801432 #build/main.zip: build/gnuplot/*.eps main.tex build/main.zip: main.tex diff --git a/R/minmax.R b/R/minmax.R @@ -33,6 +33,14 @@ with(list(tmp = data[data$z_rmse == max(data$z_rmse), ]), direction_rmse_min = data[data$direction_rmse == min(data$direction_rmse), ] direction_rmse_max = data[data$direction_rmse == max(data$direction_rmse), ] direction_rmse_mean = mean(data$direction_rmse) -printf("Min. direction RMSE = %f (%s), mean direction = %f\n", direction_rmse_min["direction_rmse"], direction_rmse_min["timestamp"], direction_rmse_min["direction"]) -printf("Max. direction RMSE = %f (%s), mean direction = %f\n", direction_rmse_max["direction_rmse"], direction_rmse_max["timestamp"], direction_rmse_max["direction"]) +printf("Min. direction RMSE = %f (%s), mean direction = %f, mean speed = %f\n", + direction_rmse_min["direction_rmse"], + direction_rmse_min["timestamp"], + direction_rmse_min["direction"], + direction_rmse_min["speed"]) +printf("Max. direction RMSE = %f (%s), mean direction = %f, mean speed = %f\n", + direction_rmse_max["direction_rmse"], + direction_rmse_max["timestamp"], + direction_rmse_max["direction"], + direction_rmse_max["speed"]) printf("Mean direction RMSE = %f\n", direction_rmse_mean) diff --git a/gnuplot/direction-dist.gnuplot b/gnuplot/direction-dist.gnuplot @@ -1,105 +1,36 @@ -load 'gnuplot/blues.pal' -set palette defined (0 '#4040c0', 1 '#c0c0c0', 2 '#c04040') -#set palette defined (0 '#c0c0c0', 1 '#c04040') -set terminal svg size 450/2,450/2 font 'Free Serif, 10' enhanced round dynamic -#set terminal png size 450/2,450/2 font 'Free Serif, 10' enhanced +set terminal svg size 450,450/2 font 'Free Serif, 10' enhanced round dynamic set xtics nomirror out offset 0,0.25 set ytics nomirror out offset 0.5,0 -#set border 2+8 -unset border -unset xtics -unset ytics -#set key top center outside Left reverse +set border 1+2 back unset key - -#set xlabel 'υ_x' -#set ylabel 'υ_y' -set cbrange [0:*] -set lmargin 2 -set tmargin 2.5 -set bmargin 1.5 -set rmargin 6 -set size square -#set lmargin at screen 0.05 -#set rmargin at screen 0.85 -#set bmargin at screen 0.1 -#set tmargin at screen 0.9 - -positive(x) = x<=25 ? NaN : x -negative(x) = x>0 ? NaN : x +set output 'build/gnuplot/direction-dist.svg' +set xlabel 'θ' offset 0,1.0 +set xrange [-180:180] +set xtics -180,90 +set yrange [0:4] +set rmargin 1.5 +set tmargin 1 +set title offset 0,-1 +set multiplot layout 1,2 +positive(x) = x<0 ? (1/0) : x +negative(x) = x>0 ? (1/0) : x round(x) = floor(x+0.5) -length(x,y) = sqrt(x**2 + y**2) -angle(x,y) = atan2(y,x) -circle(x,y,z) = length(x,y)>1 ? NaN : z -#circle(x,y,z) = z -max(x,y) = x>y ? x : y - -filename = ARG1 -filename_tmp = sprintf('%s.tmp', filename) -filename_cnt = sprintf('%s.cnt', filename) -filename_out = ARG2 -rmse = ARG3 - -# Min. direction RMSE = 0.024544 (1616497200), mean direction = -2.399689 -# Max. direction RMSE = 0.154791 (1616792400), mean direction = -2.440686 +rad2deg(rad) = (rad * 180) / pi +# Min. direction RMSE = 0.024544 (1616497200), mean direction = -2.399689, mean speed = 4.495469 +# Max. direction RMSE = 0.154791 (1616792400), mean direction = -2.440686, mean speed = 0.801432 # Mean direction RMSE = 0.056350 -## interpolation {{{ -## http://www.gnuplotting.org/circular-heat-map/ -#set table filename_tmp -#set dgrid3d 100,100 -set xrange [-1:1] -set yrange [-1:1] -#splot filename using 1:2:3 -#unset table -## }}} -# -## contours {{{ -#set table filename_cnt -#set contour base -#set cntrparam levels 5 -#set cntrparam order 8 bspline -##set cntrlabel onecolor format '%8.3g' font ',7' start 25 interval -1 -#unset surface -#set dgrid3d 100,100 -#splot filename using 1:2:3 with lines -#unset table -## }}} -set output filename_out -set multiplot - -# polar grid {{{ -# now plot the polar grid only -# https://stackoverflow.com/questions/18792461/gnuplot-2d-polar-plot-with-heatmap-from-3d-dataset-possible -r = 3 -unset contour -set border polar lw 1 lc rgb '#404040' back -set surface -set angles degree -set style line 11 lc rgb '#404040' lw 0.5 dashtype 2 -set grid polar ls 11 nortics back -set polar -set rrange[0:r] -unset raxis -set rtics format '' scale 0 -unset parametric -set for [i=0:330:30] label at first (r+0.40)*cos(i), first (r+0.40)*sin(i) center sprintf('%d', i) -plot NaN w l -unset polar -unset grid -unset border -# }}} -#plot filename_tmp using 1:2:(circle($1,$2,$3)) with image -set border lw 1 1+2+4+8 -unset border -set colorbox user origin 0.900,0.1 size 0.03,0.8 -set cbtics offset -0.5,0 -s = 0.5 -set xrange [-1*s:1*s] -set yrange [-1*s:1*s] -set title offset 0,0.5 sprintf('RMSE = %.0f%%', round(rmse*100)) -#plot filename using 1:2:(positive($3)) with points pt 7 ps 0.25 linecolor palette z -plot filename using 1:2:(positive($3)) with image -#plot filename_cnt using (circle($1,$2,$1)):2 with lines lc '#404040' +set lmargin 5 +set title sprintf('RMSE = %.0f%%, mean speed = %.1fm/s',round(0.154791*100), 0.801432) +plot \ +'build/direction/vonmises/1616792400' index 0 using (rad2deg($1)):2 every 5 with points pt 6 lc '#404040' title 'Observed PDF of υ_x',\ +'' index 0 using (positive(rad2deg($1))):3 with lines lw 2 lc '#c04040' title 'Estimated PDF of positive υ_x',\ +'' index 0 using (negative(rad2deg($1))):3 with lines lw 2 lc '#4040c0' title 'Estimated PDF of negative υ_x' +set lmargin 5 +set title sprintf('RMSE = %.0f%%, mean speed = %.1fm/s',round(0.024544*100), 4.495469) +plot \ +'build/direction/vonmises/1616497200' index 0 using (rad2deg($1)):2 every 5 with points pt 6 lc '#404040' title 'Observed PDF of υ_x',\ +'' index 0 using (positive(rad2deg($1))):3 with lines lw 2 lc '#c04040' title 'Estimated PDF of positive υ_x',\ +'' index 0 using (negative(rad2deg($1))):3 with lines lw 2 lc '#4040c0' title 'Estimated PDF of negative υ_x' diff --git a/gnuplot/velocity-xy-dist.gnuplot b/gnuplot/velocity-xy-dist.gnuplot @@ -0,0 +1,109 @@ +load 'gnuplot/blues.pal' +set palette defined (0 '#4040c0', 1 '#c0c0c0', 2 '#c04040') +#set palette defined (0 '#c0c0c0', 1 '#c04040') +f = 0.90 +set terminal svg size 450/2*f,450/2*f font 'Free Serif, 10' enhanced round dynamic +#set terminal eps size 450/2/72,450/2/72 font 'Free Serif, 10' enhanced round +#set terminal png size 450/2,450/2 font 'Free Serif, 10' enhanced +set xtics nomirror out offset 0,0.25 +set ytics nomirror out offset 0.5,0 +#set border 2+8 +unset border +unset xtics +unset ytics +#set key top center outside Left reverse +unset key + +#set xlabel 'υ_x' +#set ylabel 'υ_y' +set cbrange [0:*] +set lmargin 2 +set tmargin 2.5 +set bmargin 1.5 +set rmargin 6 +set size square +#set lmargin at screen 0.05 +#set rmargin at screen 0.85 +#set bmargin at screen 0.1 +#set tmargin at screen 0.9 + +positive(x) = x<0 ? NaN : x +negative(x) = x>0 ? NaN : x +round(x) = floor(x+0.5) +length(x,y) = sqrt(x**2 + y**2) +angle(x,y) = atan2(y,x) +s = 0.5 +circle(x,y,z) = length(x,y)>s ? NaN : z +#circle(x,y,z) = z +max(x,y) = x>y ? x : y + +filename = ARG1 +filename_tmp = sprintf('%s.tmp', filename) +filename_cnt = sprintf('%s.cnt', filename) +filename_out = ARG2 +rmse = ARG3 + 0 +speed = ARG4 + 0 + +# Min. direction RMSE = 0.024544 (1616497200), mean direction = -2.399689 +# Max. direction RMSE = 0.154791 (1616792400), mean direction = -2.440686 +# Mean direction RMSE = 0.056350 + +## interpolation {{{ +## http://www.gnuplotting.org/circular-heat-map/ +#set table filename_tmp +#set dgrid3d 100,100 +set xrange [-1:1] +set yrange [-1:1] +#splot filename using 1:2:3 +#unset table +## }}} +# +## contours {{{ +#set table filename_cnt +#set contour base +#set cntrparam levels 5 +#set cntrparam order 8 bspline +##set cntrlabel onecolor format '%8.3g' font ',7' start 25 interval -1 +#unset surface +#set dgrid3d 100,100 +#splot filename using 1:2:3 with lines +#unset table +## }}} +set output filename_out +set multiplot + +set border lw 1 1+2+4+8 +unset border +set colorbox user origin 0.900,0.1 size 0.03,0.8 +set cbtics offset -0.5,0 +set xrange [-1*s:1*s] +set yrange [-1*s:1*s] +set title offset 0,0.5 +set title sprintf('RMSE = %.0f%%, mean speed = %.1fm/s', round(rmse*100), speed) +#plot filename using 1:2:(positive($3)) with points pt 7 ps 0.25 linecolor palette z +plot filename using ($1+0.005):2:(circle($1,$2,$3)) with image +#plot filename_cnt using (circle($1,$2,$1)):2 with lines lc '#404040' + +# polar grid {{{ +# now plot the polar grid only +# https://stackoverflow.com/questions/18792461/gnuplot-2d-polar-plot-with-heatmap-from-3d-dataset-possible +r = 3 +unset contour +set border polar lw 4 lc rgb '#404040' back +set surface +set angles degree +set style line 11 lc rgb '#404040' lw 0.5 dashtype 2 +set grid polar ls 11 nortics back +set polar +set rrange[0:r] +unset raxis +set rtics format '' scale 0 +unset parametric +set for [i=0:330:30] label at first (r+0.40)*cos(i), first (r+0.40)*sin(i) center sprintf('%d', i) +plot NaN w l +unset polar +unset grid +unset border +# }}} +#plot filename_tmp using 1:2:(circle($1,$2,$3)) with image + diff --git a/main.tex b/main.tex @@ -326,10 +326,10 @@ and \(y\) axes the distribution for incident flow is taller than the distribution for turbulent flow. Distributions for each axis are presented in figure~\ref{fig-velocity-distributions}. -RMSE of the approximation has negative correlation with wind speed: the larger -the wind speed, the smaller the error and vice versa. Larger error for low wind -speeds is caused by larger skewness and kurtosis (see the first row of -figure~\ref{fig-velocity-distributions}). RMSE is reduced +RMSE of wind speed distribution approximation has positive correlation with +wind speed: the larger the wind speed, the larger the error and vice versa. +Larger error for low wind speeds is caused by larger skewness and kurtosis (see +the first row of figure~\ref{fig-velocity-distributions}). RMSE is reduced when~\eqref{eq-velocity-distribution} is used as the distribution for both low and high wind speeds. TODO @@ -350,17 +350,30 @@ and high wind speeds. TODO \cite{carta2008} +RMSE of wind direction distribution approximation has negative correlation with +wind speed: the larger the wind speed, the smaller the error and vice versa. +Larger error for low wind + \begin{figure} \centering - \includegraphics{build/gnuplot/direction-dist-max.png}~\phantom{x}~ - \includegraphics{build/gnuplot/direction-dist-min.png} + \begin{minipage}{0.49\textwidth} + \centering + \includegraphics{build/gnuplot/velocity-xy-dist-max.eps} + \end{minipage} + \begin{minipage}{0.49\textwidth} + \centering + \includegraphics{build/gnuplot/velocity-xy-dist-min.eps} + \end{minipage} + \vskip\baselineskip + \includegraphics{build/gnuplot/direction-dist.eps} \caption{Bivariate \(x\) and \(y\) velocity distribution - in polar coordinates. Data interval with the largest error (top left), data - interval with the smallest error (top right). + in polar coordinates (first row), wind direction distributions fitted into + von Mises distribution (second row). Data interval with the largest error (left column), data + interval with the smallest error (right column). Red line shows estimated - probability density of positive wind speed projections, blue line shows estimated - probability density of negative wind speed projections and circles denote observed - probability density of wind speed projections. + probability density of positive direction angles, blue line shows estimated + probability density of negative direction angles and circles denote observed + probability density of direction angles. \label{fig-direction-distributions}} \end{figure}