#!/usr/bin/perl # hygfull.csv from http://www.astronexus.com/data/hyg.html # info on coloring stars from Mitchell Charity's What color are the stars? # http://www.vendian.org/mncharity/dir3/starcolor/ # # Dinoj Surendran dinoj@cs.uchicago.edu # April 13 2004 # http://astro.uchicago.edu/cosmus/projects/milkyway/ open (IN, "hygfull.csv"); open (CMAP, "spec.cmap"); open (LOGOUT, ">hyg_log.speck"); # uses logs of abs magnitudes open (OUT, ">hyg.speck"); # uses abs magnitudes $index = 0; while ($line = ) { $index++; ($r, $g, $b, $hash, $specval) = split /[\n\t ]+/, $line; $revlookup {$specval} = $index; print "revlookup {>>>$specval<<<} = $index\n"; } $line = ; # cf file should have # # cmap hyg.speck # color colindex exact $a = "datavar 0 absmag datavar 1 colindex datavar 2 txn texturevar txn texture -M 1 halo.sgi "; print LOGOUT $a; print OUT $a; my %spectrums; while ($line = ) { @tmp = split /[\,]/, $line; $start = 0; # while (length($tmp[$start]) == 0) {$start++;} $ra = $tmp[$start+7]; # ra between 0 and 24 $ra = $ra * 360/24; # ra between 0 and 360 $dec= $tmp[$start+8]; # dec between -90 and 90 $psc= $tmp[$start+9]; $absmag = $tmp[$start+11]; $spec = $tmp[$start+12]; $spec =~ s/[ ]+//g; if ($psc < 10000000) # # A value of 10000000 indicates missing or dubious (e.g., negative) parallax data in Hipparcos, from http://www.astronexus.com/3duniv/index.html { if (exists ($revlookup {$spec})) { $x = $psc*cos($ra* 3.1416/180.0)*cos(3.1416/180.0*($dec+90.0)); $y = $psc*sin($ra* 3.1416/180.0)*cos(3.1416/180.0*($dec+90.0)); $z = $psc*sin(3.1416/180.*($dec+90.0)); $c = $revlookup {$spec}; printf LOGOUT "%10.4f %10.4f %10.4f %6.3f %d 1\n", $x, $y, $z, 1 + log (25-$absmag), $c; printf OUT "%10.4f %10.4f %10.4f %6.3f %d 1\n", $x, $y, $z, 25-$absmag, $c; } } }