#! /usr/bin/perl -w ## runs qual_upd for magnetograms, using user bit input @bits=(); print "\nEnter Day Number: "; chomp( $day = ); #while ( ($day > 1216) || ($day < 10000) ) { # print "Oops...Enter Day Number: "; # chomp( $day = ); #} print "Enter Image Number (0-14): "; chomp( $image = ); while ( ($image < 0) || ($image > 14) ) { print "Oops...Enter Image Number (0-14): "; chomp( $image = ); } print "Enter Quality Bit (0-31, 'q' to quit): "; chomp( $bit = ); while ($bit ne "q") { if ( ($bit =~ /\d{1,2}/ ) && ($bit >= 0) && ($bit <= 31) ) { @bits = ($bit,@bits); print "Enter Quality Bit (0-31, 'q' to quit): "; chomp( $bit = ); } else { print "Oops...Enter Quality Bit (0-31, 'q' to quit): "; chomp( $bit = ); } } %seen = (); @uniq = (); foreach $item ( @bits ) { unless ($seen{$item}) { $seen{$item} = 1; push (@uniq,$item); } } if ( $#uniq == -1 ) { print "\nNo bits set for Day $day, Image $image\n\n"; } else { print "\nBit(s) "; foreach $i (sort{$a<=>$b}@uniq) { print "$i "; } print "will be set for Day $day, Image $image\n"; print "Is that correct (y|n)? "; chomp ($proceed = ); print "\n"; } if ( $proceed ne 'y' ) { exit; } else { $i = 0; while ( $i <= 31 ) { $qual{$i} = 0; $i++; } foreach $bit ( @bits ) { $qual{$bit} = 1; } $i = 31; print "\n"; while ( $i >= 0 ) { print "$qual{$i}"; $i--; } print "\n\n"; $j = 0; $k = 1; @bit_value = (); while ( $k <= 8 ) { $total = (1*$qual{$j}) + (2*$qual{$j+1}) + (4*$qual{$j+2}) + (8*$qual{$j+3}); if ( $total > 9 ) { $total = "a" if ( $total == 10 ); $total = "b" if ( $total == 11 ); $total = "c" if ( $total == 12 ); $total = "d" if ( $total == 13 ); $total = "e" if ( $total == 14 ); $total = "f" if ( $total == 15 ); } @bit_value = ($total, @bit_value); $j = $j + 4; $k++; } } print "\n\n"; print "Do you want to add a short note (y|n)? "; chomp ($note = ); if ( $note eq 'y' ) { print "Enter note: "; chomp ($notes = ); } print "Quality expression is "; $n = 0; while ( $n <= 7) { print "$bit_value[$n]"; $quality = $quality.$bit_value[$n]; $n++; } print "\n$quality: \n"; system ("decode $quality" ); print "\nNote: $notes\n\n" if $notes ; print "\nRemove old quality bits (y|n)? "; chomp ($remove = ); if ($remove eq 'y' ) { $options = "-v -r"; } else { $options = "-v"; } print "\nOK to update quality information (y|n)? "; chomp ($ok = ); if ( $ok eq 'y' ) { $com = "prob_upd $options \"prog:mdi,level:lev1.5,series:fd_Ic_6h_01d[$day],sel:[$image]\" 0X$quality 0X$quality \"$notes\"\n"; print "$com"; system ( "$com" ); print "quality info updated\n"; } else { print "quality info NOT updated\n"; exit; }