#!/usr/bin/perl open (SPEC, "spectrum.dat"); open (MITCH, "starcolors.txt"); open (OUT,">spec.cmap"); open (OUTSTILL,">todo.cmap"); $numstarsleft = 0; while ($x=) { next if ($x =~m/^\#/); @a = split /[\t\n ]+/, $x; $rgb = sprintf ("%0.4f %0.4f %0.4f", $a[4]/255, $a[5]/255, $a[6]/255); @b = split /[\(\)]/, $a[1]; # print $b[0], "_", $b[1], "_", $b[2],"_\n"; $st = $b[0].$b[1]; $colors{$st} = $rgb; # print "$x ... $st $rgb \n"; } while ($line = ) { chomp $line; @tmp = split /[\n\t ]+/, $line; $spec = $tmp[0]; $num = $tmp[1]; $spec =~ s/[\+abc:\.CN]+//g; @x = split /[\/\-]+/, $spec; @classes = (); @types = (); $i = 0; while ($i <= $#x) { $y = ""; $a = $x[$i]; if ($a =~ m/IV/) {$y = "IV";} elsif ($a =~ m/III/) {$y = "III";} elsif ($a =~ m/II/) {$y = "II";} elsif ($a =~ m/I/) {$y = "I";} elsif ($a =~ m/V/) {$y = "V";} if ($y ne "") { $types[ length(@types) ] = $y; } $y = $x[$i]; $y =~ s/[IV\s]+//g; if ($y ne "") { $classes[ length(@classes) ] = $y; } $i++; } if ((length(@types) == 0) | ( (length(@types) == 1) && (0 == length ($types[1])) )) { # print ">>>>> ", length ($types[0]), " >>>",length ($types[1]), " >>>", @types, "<<<\n"; $types[2] = "V"; } $found = 0; for ($j = 0; $j <= $#types; $j++) { for ($i = 0; $i <= $#classes; $i++) { $spec = $classes[$i] . $types [$j]; # print "$line ---> $spec\n"; if (exists($colors{$spec}) & (0 == $found)) { $found = 1; print OUT $colors{$spec}," # $line ... mapped as $spec\n"; break; } } if (1 == $found) { break; } } if (0 == $found) { print OUTSTILL " $line \n"; $numstarsleft += $num; } } print "\n stars left to deal with = $numstarsleft \n";