#!/usr/local/bin/perl # camitro4.p # Output mapping program for run 1 # read target file and # put through 10**x (max 100) # ALSO # mark suspect lines # Default settings $verbose= 0 ; $sep=0; $strip="36 79 81 113 116 127 192 220" ; $d=1; # DIRECTION 0= forward, 1=backward (backward only) eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; if ( 1 eq $d ) { $_ = $strip ; @s = split ; $ss = ":".join(":",@s).":" ; print STDERR "read row suspects (number $#s)- $ss\n" ; } else { $ss = "" ; } # Read and write $line = 0 ; while ( <> ) { $line ++ ; s/^\s*//; # get rid of initial gap on line s/\n//; # get rid of newline if ( /^\#/ || /^\%/ || ($line<=$skip) ) { $comments ++ ; } else { if("0" eq $sep) { @w=split ; # use default space separator }else{ @w=split($sep, $_) ; } if ( $#w == -1 ) { $blank ++ ; } else { if ( $#w != $lastnum ) { # new block if ( $num_blocks > 0 ) { # report previous block &report () ; # } # $num_blocks ++ ; # $num_lines_same = 0 ; $lastnum = $#w ; # } # $num_lines_same ++ ; # for ($ii = 0 ;$ii<=$#w; $ii++){ print &f($d,$ii,$w[$ii])." " ; } if( ($d eq 1 )&& $ss =~ /:$line:/ ) { # MARK this row as dodgy print " UNCERTAIN" ; } print "\n" ; } } # } # &report () ; if ( $blank + $comments > 0 ) { print STDERR "-----------\n$blank blank lines, $comments comments\n" ; } sub f { local( $d,$i,$w ) = @_ ; # output, error, lower, upper, noise level if ((0 eq $i)||(2 eq $i)||(3 eq $i)) { $ans = exp($w * log(10.0)) ; if($ans>100.0) { $ans = 100.0 ; } $x = sprintf("%8.5g", $ans ) ; } else { $x = $w ; } print " w = $w , x = $x\n" if ($verbose) ; return $x ; } sub report { $lastnum ++ ; print STDERR "Block $num_blocks: $num_lines_same lines, $lastnum entries\n" ; }