diff --git a/tools/deriv.awk b/tools/deriv.awk index 5736b62..b7faf5a 100755 --- a/tools/deriv.awk +++ b/tools/deriv.awk @@ -3,33 +3,26 @@ BEGIN { firstline = 1 } # Calculates the first derivative of columns 2 and 3 wrt column 1 $0 !~ /^#/ { - t = $1 - x = $2 - y = $3 + $1 /= 1000000.0 if (firstline == 1) { - old_tx = old_ty = t - old_x = x - old_y = y - dy_dt = dx_dt = 0 + for ( i=1; i<=NF; i++) { + prev_t[i] = $1 + prev_x[i] = $i + deriv[i] = 0 + } firstline = 0 } else { - dx = old_x - x - dy = old_y - y - - if ( dx != 0) { - dt = old_tx - t - dx_dt = dx/dt - old_tx = t - old_x = x - } - if ( dy != 0) { - dt = old_ty - t - dy_dt = dy/dt - old_ty = t - old_y = y - } - if ( dx != 0 || dy != 0 ) { - print t, " ", x, " ", y, " ", dx_dt, " ", dy_dt + printf $1 + for ( i=2; i<=NF; i++) { + if ( $i != prev_x[i] ) { + dx = $i - prev_x[i] + dt = $1 - prev_t[i] + deriv[i] = dx/dt + prev_t[i] = $1 + prev_x[i] = $i + } + printf " %s %0f", $i, deriv[i] } + print "" } } diff --git a/tools/velocity_plot.sh b/tools/velocity_plot.sh index e2d9fed..f3c7504 100755 --- a/tools/velocity_plot.sh +++ b/tools/velocity_plot.sh @@ -24,7 +24,14 @@ gnuplot --persist -e " set y2label 'Velocity (mm/minute)'; set ytics nomirror ; set y2tics; set samples 10000 ; - plot '${VELOC}' u (\$1/1000000):(\$2/$MM_PER_STEP) with lines t \"X-position\" , '' u (\$1/1000000):(\$3/$MM_PER_STEP) with lines t \"Y-position\" - , '' u (\$1/1000000):(60000000.0*\$4/$MM_PER_STEP) with lines t \"X-velocity\" axes x1y2 - , '' u (\$1/1000000):(60000000.0*\$5/$MM_PER_STEP) with lines t \"Y-velocity\" axes x1y2 + plot '${VELOC}' u (\$1):(60.0*\$3/$MM_PER_STEP) with lines t \"X-velocity\" axes x1y2 + , '' u (\$1):(60.0*\$5/$MM_PER_STEP) with lines t \"Y-velocity\" axes x1y2 + , '' u (\$1):(60.0*\$7/$MM_PER_STEP) with lines t \"Z-velocity\" axes x1y2 + , '' u (\$1):(60.0*\$9/$MM_PER_STEP) with lines t \"E-velocity\" axes x1y2 + , '' u (\$1):(\$2/$MM_PER_STEP) with lines t \"X-position\" + , '' u (\$1):(\$4/$MM_PER_STEP) with lines t \"Y-position\" + , '' u (\$1):(\$6/$MM_PER_STEP) with lines t \"Z-position\" + , '' u (\$1):(\$8/$MM_PER_STEP) with lines t \"E-position\" + , '' u (\$1):(\$10/$MM_PER_STEP) with steps t \"X-Step\" + , '' u (\$1):(\$10/$MM_PER_STEP) with steps t \"Y-Step\" "