loop.awk revision 54359
154359Sroberto# awk program to scan loopstats files and report errors/statistics 254359Sroberto# 354359Sroberto# usage: awk -f loop.awk loopstats 454359Sroberto# 554359Sroberto# format of loopstats record 654359Sroberto# MJD sec time (s) freq (ppm) poll 754359Sroberto# 49235 3.943 0.000016 22.4716 6 854359Sroberto# 954359Sroberto# format of output dataset (time values in milliseconds, freq in ppm) 1054359Sroberto# loopstats.19960706 1154359Sroberto# loop 1180, 0+/-11.0, rms 2.3, freq -24.45+/-0.045, var 0.019 1254359Sroberto# 1354359SrobertoBEGIN { 1454359Sroberto loop_tmax = loop_fmax = -1e9 1554359Sroberto loop_tmin = loop_fmin = 1e9 1654359Sroberto} 1754359Sroberto# 1854359Sroberto# scan all records in file 1954359Sroberto# 2054359Sroberto{ 2154359Sroberto if (NF >= 5) { 2254359Sroberto loop_count++ 2354359Sroberto if ($3 > loop_tmax) 2454359Sroberto loop_tmax = $3 2554359Sroberto if ($3 < loop_tmin) 2654359Sroberto loop_tmin = $3 2754359Sroberto if ($4 > loop_fmax) 2854359Sroberto loop_fmax = $4 2954359Sroberto if ($4 < loop_fmin) 3054359Sroberto loop_fmin = $4 3154359Sroberto loop_time += $3 3254359Sroberto loop_time_rms += $3 * $3 3354359Sroberto loop_freq += $4 3454359Sroberto loop_freq_rms += $4 * $4 3554359Sroberto } 3654359Sroberto} END { 3754359Sroberto if (loop_count > 0) { 3854359Sroberto loop_time /= loop_count 3954359Sroberto loop_time_rms = sqrt(loop_time_rms / loop_count - loop_time * loop_time) 4054359Sroberto loop_freq /= loop_count 4154359Sroberto loop_freq_rms = sqrt(loop_freq_rms / loop_count - loop_freq * loop_freq) 4254359Sroberto printf "loop %d, %.0f+/-%.1f, rms %.1f, freq %.2f+/-%0.3f, var %.3f\n", loop_count, (loop_tmax + loop_tmin) / 2 * 1e6, (loop_tmax - loop_tmin) / 2 * 1e6, loop_time_rms * 1e6, (loop_fmax + loop_fmin) / 2, (loop_fmax - loop_fmin) / 2, loop_freq_rms 4354359Sroberto } 4454359Sroberto} 4554359Sroberto 46