#! /bin/bash # Last edited on 2004-12-24 12:41:09 by stolfi name="$1"; shift; num="$1"; shift; seeds=( $@ ) tmp="/tmp/$$" otfile="${tmp}.eps" gpfile="${tmp}.gnuplot" plotmax=200 cat < ${gpfile} set term postscript eps color "TimesRoman" 14 set output "${otfile}" num=(${num}) set logscale x set logscale y set ylabel "t(Z)" set xlabel "Z" EOF printf 'plot ' >> ${gpfile} tpfiles=() sep='' tit='title "A(Z-Z*)^(n/2-1)"' for seed in ${seeds[*]} ; do infile="${name}-${seed}.trs" tpfile="${tmp}-${seed}.dat" printf "${infile} -> ${tpfile}\n" 1>&2 # Number of perms in sample nsmp="`cat ${infile} | wc -l`" # Extract the subsample to be plotted: cat ${infile} \ | gawk '/./{ print $1; }' \ | sort -b +0 -1g \ | head -${plotmax} \ > ${tpfile} tpfiles=( ${tpfiles[*]} ${tpfile} ) # Adjust parameters of approximate formula: parms=( `cat ${tpfile} | compute-parms -v fixexpt=1 -v n="${num}"` ) zref=${parms[0]} coef=${parms[1]} expt=${parms[2]} printf "Zref = %s Coef = %s Expt = %s\n" "${zref}" "${coef}" "${expt}" 1>&2 # Find plotting ranges: zmin="`head -1 ${tpfile}`" zmax="`tail -1 ${tpfile}`" nplot="`cat ${tpfile} | wc -l`" printf "Zmin = %s Zmax = %s Nplot = %s\n" "${zmin}" "${zmax}" "${nplot}" 1>&2 # Issue command to plot the experimental data points: printf "${sep}"' \\'"\n" >> ${gpfile} printf ' "'"${tpfile}"'"' >> ${gpfile} printf ' using (column(1)-'"${zref}"'):(column(0)+1)' >> ${gpfile} printf ' title "'"${seed}"'"' >> ${gpfile} printf ' with points linetype '"${seed}" >> ${gpfile} # Issue command to plot the approximate formula: printf ","' \\'"\n" >> ${gpfile} printf ' ['"${zmin}"':'"${zmax}"'] '"${coef}"'*(x**'"${expt}"')/'"${nsmp}" >> ${gpfile} printf ' '"${tit}" >> ${gpfile} printf ' with lines linetype '"${seed}" >> ${gpfile} sep=',' tit='notitle' done printf "\n" >> ${gpfile} printf "quit\n" >> ${gpfile} gnuplot < ${gpfile} cat ${otfile} /bin/rm ${tpfiles[*]} ${otfile} /bin/rm ${gpfile}