#!/usr/local/bin/perl # ~/bin/ignorance2.p # P(1) - denotes parent record - A1 # A(3-5) - parent atomic number - I3 # Z(7-9) - parent atomic number - I3 # DCMD(11-12) - decay mode - A2 # THALF(14-24) - half-life - F11.5 # DTHALF(26-36) - half-life uncertainty - F11.5 # HUNIT(38-39) - half-life unit - A2 # BR_M(41-43) - alphanumeric BR modifier, see below - A3 # DNR(45-54) - NR percent uncertainty - E10.4 # DNT(56-65) - NT percent uncertainty - E10.4 # DBR(67-76) - BR percent uncertainty - E10.4 sub bynumber { $a <=> $b; } $verbose = 0 ; $write = 1 ; $rescale = 1 ; $f=1; $t=2; $w=7; $th=-1.0; $show=0; $left=0; $smallest=0; $abs=0; $out="tcounts" ; $tol = 0.1 ; $o = 4 ; $endnewline = 0 ; # How to override min and max values with command line eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $f--; $t--; if ($t<$f) { $t = $f ; } $num = $t - $f + 1 ; for ( $i = 10 ; $i <= 99 ; $i ++ ) { $c{$i} = 0 ; } for ( $i = $f ; $i <= $t ; $i++) { for ( $i = 0 ; $i <= 9 ; $i ++ ) { $c{$char,$i} = 0 ; } } if($th > 0.0 || $show > 0 ) { $spacer = "." x ($w) ; } $white = " " x ($w) ; LOOP: while (<>) { $status = 0 ; if ( /^P/ ) { # read parent records only $name = substr($_, 1, 12) ; if ( $alreadyseen{$name} ) { next LOOP ; } else { $alreadyseen{$name} = 1 ; # } $halflife = substr($_, 13+$o, 11) ; $error = substr($_, 25+$o, 11) ; $unit = substr($_, 37+$o, 2 ) ; print "$halflife : $error : $unit " if $verbose ; if ( ! ($error > 0.0) ) { $status -- ; } else { if ( ( $error / $halflife ) < $tol ) { $status -- ; } if ( $unit =~ /GY/ ) { $halflife *= 1e9 * 365.25 * 24 * 3600 ; # } elsif ( $unit =~ /PY/ ) { #? also EY, VY, PY, IY $halflife *= 1e15 * 365.25 * 24 * 3600 ; # } elsif ( $unit =~ /EY/ ) { #? also EY, VY, PY, IY $halflife *= 1e18 * 365.25 * 24 * 3600 ; # } elsif ( $unit =~ /TY/ ) { #? also EY, VY, PY, IY $halflife *= 1e12 * 365.25 * 24 * 3600 ; } elsif ( $unit =~ /MY/ ) { $halflife *= 1000000 * 365.25 * 24 * 3600 ; } elsif ( $unit =~ /KY/ ) { $halflife *= 1000 * 365.25 * 24 * 3600 ; } elsif ( $unit =~ /\sY/ ) { # $halflife *= 365.25 * 24 * 3600 ; } elsif ( $unit =~ /D/ ) { $halflife *= 24 * 3600 ; } elsif ( $unit =~ /\sM/ ) { $halflife *= 60 ; } elsif ( $unit =~ /\sH/ ) { $halflife *= 60 * 60 ; } elsif ( $unit =~ /MS/ ) { $halflife *= 0.001 ; } elsif ( $unit =~ /NS/ ) { $halflife *= 0.000000001 ; # } elsif ( $unit =~ /PS/ ) { $halflife *= 1e-12 ; } elsif ( $unit =~ /AS/ ) { $halflife *= 1e-18 ; } elsif ( $unit =~ /US/ ) { $halflife *= 0.000001 ; # ? also RS and IY } elsif ( $unit =~ /\sS/ ) { } else { print STDERR "unknown unit $unit\n" ; $status = -1 ; } } $halflife = sprintf("%10.6g", $halflife * $rescale ) ; $_ = $halflife ; if ($status >= 0 ) { # throw away decimal point s/\s+//g ; # append some zeroes to exponent and mantissa! $_ .= "000" ; s/e/000e/ ; s/0\.0*//g; s/\.//g; @fields = split('',$_); $string = "" ; for ( $i = $f ; $i <= $t ; $i++) { print $fields[$i] ; print " "; $string .= $fields[$i] ; $c{$i,$fields[$i]} ++ ; } print $string ; $c{$string} ++ ; $tot ++ ; print " $halflife" ; print "\n" ; if ($string < 10 || $string > 99 ) { print STDERR "strange string $string\n" ; } } } # end if P } if ( $endnewline ) { print "\n" ; } if ($write) { open (O,"> $out") ; $tot2 = 0 ; for ( $i = 10 ; $i <= 99 ; $i ++ ) { $tot2 += $c{$i} ; $f = sprintf("%10.4f", $c{$i} / $tot ) ; $p = sprintf("%10.4f", log(($i+1.0)/($i))/log(10.0) * $tot ) ; print O "$i $c{$i} \t $p \t $f \n" ; } for ($char = $f ; $char <= $t ; $char ++ ) { # write files for each char also open (O,"> $out.$char") ; for ( $i = 1 ; $i <= 9 ; $i ++ ) { $this = $c{$char,$i} ; $tot[$char] += $this ; $f = sprintf("%10.4f", $this / $tot ) ; $p = sprintf("%10.4f", log(($i+1.0)/($i))/log(10.0) * $tot ) ; print O "$i $c{$i} \t $p \t $f \n" ; } } } print STDERR $tot,"\n" ; print STDERR $tot2,"\n" ;