#!/usr/local/bin/perl -w # # bndiperf.p # # goes through code/bndi report files (produced by bnd_iterate; # see ~/neuron/code/SUMMARY) and creates separate # gnuplot files with scatterplots for # successes, failures, and pseudo-successes. # # usage - all these commands are needed to create the files and then do the final gnuplot # in code: # bndiperf.p t=3 bndi/H.3.*.0.*.100000 | gnuplot # bndiperf.p t=4 bndi/H.4.*.0.*.100000 | gnuplot # bndiperf.p t=5 bndi/H.5.*.0.*.100000 | gnuplot # bndiperf.p t=6 bndi/H.6.*.0.*.100000 | gnuplot # bndiperf.p t=8 bndi/H.8.*.0.*.100000 | gnuplot # # repeat , doing SMN # # bndiperf.p t=3 com=1 SMN=1 | gnuplot # bndiperf.p t=4 com=1 SMN=1 | gnuplot # bndiperf.p t=5 SMN=1 com=1 | gnuplot # bndiperf.p t=6 SMN=1 com=1 | gnuplot # bndiperf.p t=8 SMN=1 com=1 | gnuplot # # NB I have hand-edited the files bndips/R... # so rewrite with caution $SMN = 0 ; # if 1, then SMN code results are written. # instead of the original NMN codes. $psfile = "bndips/Rf" ; $verbose = 0 ; $typet = "simple"; $typet1 = "t - 1"; $com=0 ; $t = 3 ; $hmin = 0.0001 ; $itmax = 29 ; $f0 = 0.001 ; $f1= 0.45 ; # range for plot $sizex="0.7"; $size="0.7"; $key=1; $include_decode = 0 ; # t-1 algorithm $include_decode0 = 1 ; # t algorithm $style5 = "w p 1 1" ; $style10 = "w p 5 5" ; $style15 = "w p 3 3" ; # $style20 = "w p 2 2" ; $style29 = "w p 2 2" ; $style29m = "w p 4 4" ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $o=$psfile.".$t." ; $corr5 = "bndips/Rf.$t.5" ; $corr10 = "bndips/Rf.$t.10" ; $corr15 = "bndips/Rf.$t.15" ; # $corr20 = "bndips/Rf.$t.20" ; $corr29 = "bndips/Rf.$t.29" ; $fail29 = "bndips/Rf.$t.29-" ; if ( $com == 0 ) { open ( CORR5 , ">$corr5" ) ; open ( CORR10 , ">$corr10" ) ; open ( CORR15 , ">$corr15" ) ; # open ( CORR20 , ">$corr20" ) ; open ( CORR29 , ">$corr29" ) ; open ( FAIL29 , ">$fail29" ) ; foreach $file ( @ARGV ) { if ( $verbose ) { print STDERR "$file -\n" ; } open ( SOURCE , "<$file" ) ; $succeeded = 0 ; $failed = 0 ; while ((!$succeeded) && ( !$failed ) && ( $_ = )) { s/^\s*// ; s/\n// ; ( $its , $h , $tt , $tr , $f , $n ) = split ; if ( $h <= $hmin ) { $succeeded = 1 ; } elsif ( $its >= $itmax ) { $failed = 1 ; } } close (SOURCE ) ; $Hf = &H2($f) ; $C = 1.0 - $Hf ; $rhop = $tr/$tt ; $rsmn = 1.0 - 1.0 / $rhop ; $r = $tr/$tt - 1.0 ; # $R = $r * $Hf ; $frate = $R / $C ; $frsmn = $rsmn / $C ; $Rfstring = sprintf ("%13.6g %13.6g %s %8.6g %8.6g %8.6g\n" , $R , $frate , $_ , $rhop , $rsmn , $frsmn ) ; if ( $failed ) { print FAIL29 $Rfstring ; } elsif ( $succeeded ) { if ( $its <=5 ) { print CORR5 $Rfstring; } elsif ( $its <=10 ) { print CORR10 $Rfstring; } elsif ( $its <=15 ) { print CORR15 $Rfstring; # } elsif ( $its <=20 ) { # print CORR20 $Rfstring; } elsif ( $its <=29 ) { print CORR29 $Rfstring; } } else { print STDERR " unresolved\n" ; } } close ( CORR5 ) ; close ( CORR10 ) ; close ( CORR15 ) ; # close ( CORR20 ) ; close ( CORR29 ) ; close ( FAIL29 ) ; } if ( $SMN ) { # for decode - print STDOUT " hag(x) = 1 - 1/(x+1)\n" ; $smn = "thru hag(x) "; $fratestring = "not done" ; $ratestring = "2:6" ; $o .= "smn." ; # for bnd stuff $bnd_r_str = "u 7:10" ; $bnd_fr_str = "u 7:11" ; } else { $smn = "" ; $bnd_r_str = "u 7:1" ; $bnd_fr_str = "u 7:2" ; $fratestring = "2:8" ; $ratestring = "2:7" ; } $string = "plot 'bndips/C' u 2:5 t 'Capacity' w l, 'bndips/R0' u 1:2 t 'R0' w l 2" ; # that is the capacity. $pfrate = "plot 'bndips/R0' u 1:3 t 'R0' w l 2" ; $string .= ", '$corr5' $bnd_r_str t '1-5' $style5" ; $string .= ", '$corr10' $bnd_r_str t '6-10' $style10" ; $string .= ", '$corr15' $bnd_r_str t '11-15' $style15" ; # $string .= ", '$corr20' $bnd_r_str t '16-20' $style20" ; $string .= ", '$corr29' $bnd_r_str t '16-29' $style29" ; $string .= ", '$fail29' $bnd_r_str t '?(29+)' $style29m" ; $pfrate .= ", '$corr5' $bnd_fr_str t '1-5' $style5" ; $pfrate .= ", '$corr10' $bnd_fr_str t '6-10' $style10" ; $pfrate .= ", '$corr15' $bnd_fr_str t '11-15' $style15" ; # $pfrate .= ", '$corr20' $bnd_fr_str t '16-20' $style20" ; $pfrate .= ", '$corr29' $bnd_fr_str t '16-29' $style29" ; $pfrate .= ", '$fail29' $bnd_fr_str t '?(29+)' $style29m" ; if ( $include_decode0 ) { $string .= ",'decode0/$t' $smn u $ratestring t '$typet' w l 3" ; $pfrate .= ",'decode0/$t' $smn u $fratestring t '$typet' w l 3" ; } if ( $include_decode ) { $string .= ",'decode/$t' $smn u $ratestring t '$typet1' w l 4" ; $pfrate .= ",'decode/$t' $smn u $fratestring t '$typet1' w l 4" ; } print "# gnuplot\n" ; if ( $key!=0 ) { print STDOUT " set key\n" ;} else { print STDOUT " set nokey\n"; } print "set term post\n" ; print "set size $sizex,$size\n" ; print STDOUT " set yrange [0:1]\n" ; printf STDOUT " set xrange [%9.4g:%9.4g]\n", $f0/1.1 , $f1*1.1 ; print STDOUT " set output '$o"."rates.ps'\n" ; print STDOUT $string, "\n" ; if ( !$SMN ) { print STDOUT " set output '$o"."frates.ps'\n" ; print STDOUT $pfrate, "\n" ; } print STDOUT " set logscale x\n" ; print STDOUT " set output '$o"."rates.l.ps'\n" ; print STDOUT $string, "\n" ; if ( !$SMN ) { print STDOUT " set output '$o"."frates.l.ps'\n" ; print STDOUT $pfrate, "\n" ; } exit(0); ################################################ sub H2 { # binary entropy # usage ( $f ) local ( $f ) = @_ ; local ( $ans ) = - ( $f * log ( $f ) + (1.0 - $f) * log (1.0 - $f ) ) ; return $ans / log(2.0) ; }