#! /usr/bin/perl -w ## decodes 96m mag quality expressions $qual = $ARGV[0]; if ( $qual !~ /[0-9a-f]{8}/ ) { print "\nInput must be in the format 0x12345678 or 12345678\n\n"; exit; } $qbits = ""; $i = 1; while ( $i <= 8 ) { $Q = substr ($qual, -$i, 1); if ( $Q eq "0") { $bits = "0000" } elsif ( $Q eq "1" ) { $bits = "0001" } elsif ( $Q eq "2" ) { $bits = "0010" } elsif ( $Q eq "3" ) { $bits = "0011" } elsif ( $Q eq "4" ) { $bits = "0100" } elsif ( $Q eq "5" ) { $bits = "0101" } elsif ( $Q eq "6" ) { $bits = "0110" } elsif ( $Q eq "7" ) { $bits = "0111" } elsif ( $Q eq "8" ) { $bits = "1000" } elsif ( $Q eq "9" ) { $bits = "1001" } elsif ( $Q eq "a" ) { $bits = "1010" } elsif ( $Q eq "b" ) { $bits = "1011" } elsif ( $Q eq "c" ) { $bits = "1100" } elsif ( $Q eq "d" ) { $bits = "1101" } elsif ( $Q eq "e" ) { $bits = "1110" } elsif ( $Q eq "f" ) { $bits = "1111" } $qbits = $bits . $qbits; $i++; } print "Quality Bits are: $qbits\n"; if ( $qbits eq "00000000000000000000000000000000" ) { print " No problem bits are set for this image\n"; } $ j = 0; while ( $j <= 31 ) { $bit = substr ($qbits, 31 - $j, 1); if ( $bit eq "1" ) { if ( $j == 0 ) { $prob = " Telemetry problem"; print "$prob\n"; } elsif ( $j == 1 ) { $prob = " T_OBS Missing"; print "$prob\n"; } elsif ( $j == 2 ) { $prob = " > 0 Missing"; print "$prob\n"; } elsif ( $j == 3 ) { $prob = " > 0.01 Missing"; print "$prob\n"; } elsif ( $j == 4 ) { $prob = " > 0.1 Missing"; print "$prob\n"; } elsif ( $j == 5 ) { $prob = " > 0.5 Missing"; print "$prob\n"; } elsif ( $j == 6 ) { $prob = " > 0.9 Missing"; print "$prob\n"; } elsif ( $j == 7 ) { $prob = " On-board Processing Error"; print "$prob\n"; } elsif ( $j == 8 ) { $prob = " Pointing Anomaly"; print "$prob\n"; } elsif ( $j == 9 ) { $prob = " MDI Is not in PRIME60"; print "$prob\n"; } elsif ( $j == 10 ) { $prob = " Cosmic Rays"; print "$prob\n"; } elsif ( $j == 11 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 12 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 13 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 14 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 15 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 16 ) { $prob = " Telemetry Dropout"; print "$prob\n"; } elsif ( $j == 17 ) { $prob = " Structure Program Problem"; print "$prob\n"; } elsif ( $j == 18 ) { $prob = " Stored Magnetogram Corruption"; print "$prob\n"; } elsif ( $j == 19 ) { $prob = " Minor Image Fragment OK (<= half the image)"; print "$prob\n"; } elsif ( $j == 20 ) { $prob = " Major Image Fragment OK (> half the image )"; print "$prob\n"; } elsif ( $j == 21 ) { $prob = " Data Statistics Problem"; print "$prob\n"; } elsif ( $j == 22 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 23 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 24 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 25 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 26 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 27 ) { $prob = " This bit is not used...check your input"; print "$prob\n"; } elsif ( $j == 28 ) { $prob = " Override"; print "$prob\n"; } elsif ( $j == 29 ) { $prob = " Warning. OK, but something may be odd"; print "$prob\n"; } elsif ( $j == 30 ) { $prob = " Data Bad"; print "$prob\n"; } elsif ( $j == 31 ) { $prob = " Prob_upd Had Been Run On This Image"; print "$prob\n"; } } $j++; } #print "\nFor more information, see http://soi.stanford.edu/production/QUALITY/\n\n";