Fix gnuplot issue
In some cases (crash, inproper termination) a flowgraph failed to produce a binary file that had exactly the proper number of float numbers in order the gnuplot script to be able to convert it in a matrix representation. The updated script tries to truncate the binary file in such a way so it can be converted into a matrix. This will allow waterfall images to be created even after a crash. System should have the "truncate" command line utility installed which is part of GNU GNU coreutils.
This commit is contained in:
parent
8e172a8e44
commit
efea5fdda1
|
@ -28,6 +28,34 @@ if (!exists("height")) height=800
|
|||
if (!exists("width")) width=800
|
||||
if (!exists("outfile")) outfile='/tmp/waterfall.png'
|
||||
|
||||
################################################################################
|
||||
# Get FFT size and maximum number of records so we can plot the waterfall
|
||||
# even in case the file was not properly closed and contains data that are
|
||||
# not an integer multiple of the FFT size
|
||||
################################################################################
|
||||
|
||||
# Set terminal to unkown so no ploting is performed.
|
||||
set terminal unknown
|
||||
|
||||
# Read the first float to get the FFT size
|
||||
# Then, read until the last float to get the number of floats written in the file.
|
||||
# For strange reasons the STATS_records returns inconcistent size (always the half)
|
||||
plot inputfile binary format='%float32' index 0 every 1:1:0:0:0:0 u (fft_size=$1):1, "" binary format='%float32' using (float_num=$0+1)
|
||||
|
||||
|
||||
# The file contains a float specifying the FFT size the x-axis scale
|
||||
# and then each each pixel line
|
||||
# starts with the time in seconds from the beginning of the capture.
|
||||
# Based on this info the exact number of the fully filled pixel lines can
|
||||
# be retrieved.
|
||||
pixel_lines=int((float_num - fft_size - 1)/(fft_size + 1))
|
||||
new_size=(4 + fft_size*4 + ( (fft_size+1)*pixel_lines)*4)
|
||||
cmd = sprintf("truncate -s %u %s", new_size, inputfile)
|
||||
|
||||
# Truncate properly the file
|
||||
system(cmd)
|
||||
|
||||
set view map
|
||||
set terminal pngcairo size width,height enhanced font 'Verdana,14'
|
||||
set output outfile
|
||||
|
||||
|
@ -41,6 +69,8 @@ set tics nomirror out scale 0.75
|
|||
set xlabel 'Frequency (kHz)'
|
||||
set ylabel 'Time'
|
||||
set cbtics scale 0
|
||||
|
||||
# Spectravue palette and scale
|
||||
set cbtics (-110, -105, -100, -95, -90, -85, -80, -75, -70, -65, -60, -55, -50, -55, -40)
|
||||
|
||||
# palette
|
||||
|
@ -57,6 +87,7 @@ set ylabel 'Time (seconds)'
|
|||
set cbrange [-100:-50]
|
||||
set cblabel 'Power (dB)'
|
||||
|
||||
|
||||
# Get automatically the axis ranges from the file
|
||||
stats inputfile using 1 binary nooutput
|
||||
set xrange [STATS_min*1e-3:STATS_max*1e-3 + 1]
|
||||
|
|
Loading…
Reference in New Issue