#!/bin/bash ## About # Plots a file from the DAQmx frequenzy analyzer software. It is the # amplitude(frequency) and phase(frequency) that is plotted it two seperate pdf # files. # # @author Søren B. Nørgaard # @date 2013-12-12 ## Usage # plot_from_freqanal TSVFILE # plot_from_freqanal TSVFILE TITLE # plot_from_freqanal TSVFILE TITLE YSTART YSTOP ## Dependencies # Gnuplot ## Init tmpfile=/tmp/tmpgnuplot.gpi ## Arguments if [ $# -eq 1 ]; then plottitle="Frequency response"; yrangeset="unset yrange"; elif [ $# -eq 2 ]; then plottitle=$2 yrangeset="unset yrange"; elif [ $# -eq 4 ]; then plottitle=$2 yrangeset="set yrange ["$3":"$4"]"; else echo ' Usage: plot_from_freqanal TSVFILE plot_from_freqanal TSVFILE TITLE plot_from_freqanal TSVFILE TITLE YSTART YSTOP ' exit $E_BADARGS fi infile=$1 outfile_amp=`echo $infile | cut -d\. -f1`"_amp.pdf" outfile_pha=`echo $infile | cut -d\. -f1`"_pha.pdf" ## Gnuplot Code echo ' set term "pdf" size 18cm, 5cm set samples 100000 set grid; set logscale x set xlabel "Frequency [Hz]"; set title "'$plottitle' (Amplitude)"; set output "'$outfile_amp'"; set ylabel "Amplitude [dB]"; '$yrangeset' plot "'$infile'" using 1:2 title "'$plottitle'" w lines linecolor rgb "red"; set title "'$plottitle' (Phase)"; set output "'$outfile_pha'"; set ylabel "Phase [deg]"; set yrange [-180:180] plot "'$infile'" using 1:3 title "'$plottitle'" w lines linecolor rgb "red"; ' > $tmpfile ## Run Gnuplot gnuplot $tmpfile