#!/usr/local/bin/perl -w $xfile = "kzpoints_2.dat"; $file1 = "res.dat"; $file2 = "g/xy"; $Na=57 ; $plot_t = 0 ; # usage: # xy.p file1=out.dat Na=57 # expected input format is like this: # x , y , sigma (top line) # [1] -3.331E-1 -2.464E-1 -2.281E-1 2.440E-1 5.391E-1 # [6] 4.605E-1 -5.062E-1 -2.453E-1 6.215E-2 1.519E-1 # [11] 1.183E-1 -4.556E-2 8.143E-1 -4.035E-1 -1.163E-1 # etc. # (one blank line) # [1] -1.275E+0 -2.185E+0 -2.377E+0 -4.206E+0 -4.133E+0 # [6] -4.307E+0 -1.102E-1 -2.197E+0 -4.092E+0 -4.162E+0 # [11] -4.145E+0 -3.791E+0 -3.072E+0 -6.463E-1 -3.378E+0 # etc. # (one blank line) # [1] 1.060E+0 1.158E+0 1.177E+0 1.259E+0 1.820E+0 # [6] 1.685E+0 9.900E-1 1.159E+0 1.201E+0 1.194E+0 # [11] 1.190E+0 1.244E+0 2.022E+0 1.001E+0 1.249E+0 # read command line arguments eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; open ( X , "<$xfile" ) ; open ( S , "<$file1" ) ; open ( GNU , ">$file2" ) ; @x= ; # read in the x file. # close(X); print STDERR "read in x,t file: $#x lines\n" ; # assume one item per line $xstart = - 1 ; $tstart = -1 ; for ( $i = 0 ; $i <= $#x ; $i ++ ) { if ( $x[$i] =~ s/list\(x\s*=\s*c\(\s*//g ) { $xstart =$i ; } if ($x[$i] =~ s/\s*t\s*=\s*c\(\s*//g ) { $tstart = $i ; } $x[$i] =~ s/\,//g; $x[$i] =~ s/\(//g; $x[$i] =~ s/\)//g; $x[$i] =~ s/\n//g; } $xmax= $tstart - 1 ; $tmax = $#x ; @xx = @x[$xstart..$xmax] ; @t = @x[$tstart..$tmax] ; print STDERR "looks like x is from line $xstart to $xmax \n" ; print STDERR "looks like t is from line $tstart to $tmax \n" ; print $#xx," " , $#t,"\n" ; #exit(0); $j=0 ; while() { s/E/e/g; s/^[\t\s]*\[[0-9]*\][\t\s]*//; # remove line numbers s/\n//; # ($y[$j],$sigy[$j],$y2[$j],$y97[$j],$med[$j],$n[$j]) = split ; print GNU "$xx[$j]\t $_ \t $t[$j] \n" ; $j ++ ; if ($j == $Na ) { print GNU "\n\n" ;} print STDERR "." ; } print "\n# suggested command:" ; print "# gnuplot\n set nokey \n plot 0 w l 8, '$file2' index 1 u 1:2:4:5 w errorb 1, '$file2' index 0 u 1:2:4:5 w errorb 3" ; if ($plot_t) { print ", '$file2' index 1 u 1:8 w p 5, '$file2' index 0 u 1:8 w p 6\n"; } else { print "\n" ; } close ( S ) ; sub byxx { $a <=> $b ; }