#!/usr/bin/perl # $Id: selectcy.pl,v 1.1.1.1 2002/04/29 15:58:50 knowlesr Exp $ # # Program: select.pl # # Usage: Permits rapid viewing of astro files and integrated # plotting and saving of data sets (save not implemented yet) # # Author: Rich Knowles # Oxford, OH # # History: # # Date INI Purpose # ==================================================================== # 020426 RNK Initial write # 020426 RNK Cleaning up graphing, making JD more amenable to display # 020426 RNK Added positioning capability and fixed >1000 problem # 020427 RNK Added command line passing of the target filename # # ==================================================================== # Using the program: To use this program you must first edit the setups # below to reflect your configuration. When the program runs you will # be asked to select one of several command options. To see them # type 'h'. # # a = Advance to an ID number # h = print help file # n = go to next item # p = plot the item # q = quit # s = save the settings # d = save the plot (yet) # $lastid = 0; # # User setups # $plotpkg = "wgnuplot"; # select the plot package your are using #$plotpkg = "gnuplot"; $vpoints = 7; $ipoints = 6; $homdir = "/home/rknowles/astro"; $rawfil = "$homdir/raw"; $tmpfil = "$homdir/holder"; # file that holds the unsorted measurement $tmpfil1 = "$homdir/holder.dat"; # file that holds the sorted measurement $infil = "$homdir/Stars2285.dat"; # temporarily points at the input data file $plotctl = "$homdir/plotz"; # name of the plot file created $pras = "0.0000"; # previous selection RAS $pdecl = "0.0000"; # previous seleciton DECL $prompt = "SelectCy-1.0>"; # command prompt $cmd = " "; # ================================================================= # Start here # # Check to see if the input file was passed in via the command line # if ( length( $ARGV[0]) != 0 ) { $infil = "$ARGV[0]"; print "Loading stars from $ARGV[0]\n"; } # ================================================================= # Open some files # unless ( open (INPDAT, "$infil")) { die("Sorry, can't find input file\n"); } unless ( open ( HOLDER, ">$tmpfil")) { die("Sorry, cannot open temp file\n"); } # ================================================================= # Main loop, get a line and act accordingly # while ( $inpline = ) { chop( $inpline ); # routine to take care of leading spaces problem $lead = substr($inpline,0,1); # find out if there are leading if ($lead == " ") { # which is a problem ( $fill, $id, $count, $ras, $decl, $jd, $vid, $vmag, $unc, $vq, $iid, $imag, $iunc, $iq ) = split /\s+/, $inpline; } else { ( $id, $count, $ras, $decl, $jd, $vid, $vmag, $unc, $vq, $iid, $imag, $iunc, $iq ) = split /\s+/, $inpline; } # Fix the julian date for later use ( $jd1, $jd2 ) = split /[.]/, $jd; # Are we finished with loading all of the set of events? # if ( $id > $lastid ) { close HOLDER; close RAW; system ( "sort --output=$tmpfil1 $tmpfil" ); print "$prompt"; LINE: while ( $cmd = <> ) { chop $cmd; # ---- Plot function # if ( $cmd eq "p" ) { unless ( open ( PC, ">$plotctl")) { die("Sorry, cannot open plot file\n"); } print PC "set yrange [ $ymax:$ymin ]\n"; print PC "set grid\n"; print PC "set ylabel 'Magnitude'\n"; print PC "set xlabel 'Julian Date'\n"; print PC "set title 'JD:$pjd1 Object: $pras $pdecl' \n"; print PC "plot 'holder.dat' using 5:8 t 'imag'w points $ipoints, '' using 5:7 t 'vmag' with points $vpoints\n"; close ( PC ); system( "$plotpkg plotz -" ); print "$prompt"; } # ---- Help function # elsif ( $cmd eq "h" ) { print "h = help\n"; print "a = advance to: \n"; print "p = plot\n"; print "s = save\n"; print "q = quit\n"; print "n = next dataset\n"; print "$prompt"; } # ---- Save function # elsif ( $cmd eq "s" ) { print "Filename to copy to: "; $savefile = <>; system ("cat $rawfil >>$savefile"); print "done.\n"; print "$prompt"; } # ---- Advance function # elsif ( $cmd eq "a" ) { print "Advance to record set#?>"; $valid_target = 0; while ( $valid_target == 0 ) { $target = <>; if ( $target > $id ) { $valid_target = 1; } else { print "Invalid target \n"; print "Advance to record set#?>"; } } print "Advancing to target id # $target\n"; $at_target = 0; while ( $at_target == 0 ) { $inpline = ; $lead = substr($inpline,0,1); if ($lead == " ") { ( $fill, $id, $count, $ras, $decl, $jd, $vid, $vmag, $unc, $vq, $iid, $imag, $iunc, $iq ) = split /\s+/, $inpline; } else { ( $id, $count, $ras, $decl, $jd, $vid, $vmag, $unc, $vq, $iid, $imag, $iunc, $iq ) = split /\s+/, $inpline; } if ( $id == $target ) { $at_target = 1; } } print "$prompt"; } # ---- quitting the loop # elsif ( $cmd eq "q" ) { print "done"; exit; } elsif ( ($cmd eq "n") || ( length($cmd) eq 0 ) ) { unless ( open ( HOLDER, ">$tmpfil" )) { die("Sorry, cannot open temp file\n"); } unless ( open ( RAW, ">$rawfil" )) { die("Sorry, cannot open raw data file\n"); } print HOLDER "$id $count $ras $decl $jd2 $jd1 $vmag $imag\n"; last LINE; print RAW "$id $count $ras $decl $jd $vid $vmag $unc $vq $iid $imag $iunc $iq\n"; } } } else { print HOLDER "$id $count $ras $decl $jd2 $jd1 $vmag $imag\n"; print RAW "$id $count $ras $decl $jd $vid $vmag $unc $vq $iid $imag $iunc $iq\n"; $pras = $ras; $pdecl = $decl; $pvmag = $vmag; $pjd1 = $jd1; # previous julian date (high) $pimag = $imag; # plotting range definitions if ( $pvmag < $pimag ) { $ymin = ( $pvmag * 0.9 ); $ymax = ( $pimag * 1.1 ); } else { $ymin = ( $pimag * 0.9 ); $ymax = ( $pvmag * 1.1 ); } } $lastid = $id; print "$id $count $ras $decl $jd $vmag $imag\n"; }