#!/usr/local/bin/perl -w # for Solaris. # #!/usr/bin/perl -w # for Linux. # #use strict; #use blib; # ############################################################################### # # GS_SEARCH - Search on-line catalogs for NIFS wave front sensor guide stars. # # Copyright Peter J. McGregor # # Research School of Astronomy and Astrophysics # Institute of Advanced Studies # Australian National University # # Usage: ./gs_search [-df] file_name # # -d Display on screen. # -p Generate postscipt file. # -g Generate gif file. # -f Force reacquisition of image files. # -n Report NGS and LGS Y,?,N statistics. # # Requires PGPerl from http://www.aao.gov.au/local/www/kgb/pgperl/ and # CFITSIO.pm from http://hea-www.harvard.edu/~rpete/cfitsio/. # # Modification history: # # 24-OCT-00 PJM Creation. # 05-DEC-00 PJM Added -n command line option. # 17-JAN-01 PJM Added g cursor option to overlay FOV grid. # 18-JAN-01 PJM Fixed bug in cursor position of magnitude measurement. # ############################################################################### # Include packages. use IO::Socket; use CFITSIO qw( :longnames ); use PGPLOT; # Define constants. $rlim = 19.0; # Check if environment variables are defined. if ($ENV{'PRINTER'} eq "") { $printer = ""; } else { $printer = $ENV{'PRINTER'}; } # Define initial values (1 = .true.). $dcod = 0; $pcod = 0; $gcod = 0; $fcod = 0; $ncod = 0; $but_title_1_sta = 0; $but_title_2_sta = 0; $but_title_3_sta = 0; $but_title_4_sta = 0; @ngs = (0,0,0); @lgs = (0,0,0); # Read data file name from command line. if ($#ARGV < 0) { die "GS_SEARCH.PL: Usage: ./gs_search.pl [-df] file_name\n". " -d Display on screen.\n". " -p Generate postscript file.\n". " -g Generate gif file.\n". " -f Force reacquisition of image files.\n". " -n Report NGS and LGS Y,?,N statistics.\n"; } elsif ($#ARGV == 0) { ($lis) = @ARGV; } elsif ($#ARGV == 1) { ($cmd,$lis) = @ARGV; if (substr($cmd,0,1) ne "-") { die "GS_SEARCH.PL: Invalid command line arguments!\n"; } else { $cmd = substr($cmd,1); } while ($cmd ne "") { $cod = substr($cmd,0,1); if ($cod eq "d") { $dcod = 1; # .true. } elsif ($cod eq "p") { $pcod = 1; # .true. } elsif ($cod eq "g") { $gcod = 1; # .true. } elsif ($cod eq "f") { $fcod = 1; # .true. } elsif ($cod eq "n") { $ncod = 1; # .true. } else { die "GS_SEARCH.PL: Invalid command line options!\n"; } $cmd = substr($cmd,1); } } else { die "GS_SEARCH.PL: Too many command line arguments!\n"; } # Open list file and loop through entries. open (LIS,"$lis") or die "GS_SEARCH.PL: Cannot open list file $lis.\n"; while () { # Skip comment lines. $str = substr($_,0,1); if ($str eq "#") { next; } # Form object and file names. chomp; $obj = substr($_, 0,15); $fil = lc($obj); $fil =~ s/\s{1}//g; if (length > 39) { $str = substr($_,16,23); if ($str eq " ") {$str = "";} } else { $str = ""; } # Accumulate NGS and LGS statistics. if (substr($_,45,1) eq "Y" or substr($_,45,1) eq "y") { $ngs[0] += 1; } elsif (substr($_,45,1) eq "?") { $ngs[1] += 1; } elsif (substr($_,45,1) eq "N" or substr($_,45,1) eq "n") { $ngs[2] += 1; } if (substr($_,47,1) eq "Y" or substr($_,47,1) eq "y") { $lgs[0] += 1; } elsif (substr($_,47,1) eq "?") { $lgs[1] += 1; } elsif (substr($_,47,1) eq "N" or substr($_,47,1) eq "n") { $lgs[2] += 1; } # Create image directories. if (! -d "images") {mkdir ("images",0777);} if (! -d "images/$fil") {mkdir ("images/$fil",0777);} # Read object data file if present. Otherwise, get on-line images unless (Read_Data($fil) and ! $fcod) { print "$obj"; $col_tab = 1; $col_con = 0.1; $col_bri = 0.5; $dat_dss2_got = 0; $dat_2mass_got = 0; $dat_wfpc2_got = 0; $dat_nicmos_got = 0; $dat_usno_got = 0; $dat_aowfs_got = 0; $dat_aowfs_ra = -100; $dat_aowfs_dec = -100; $dat_oiwfs_got = 0; $dat_oiwfs_ra = -100; $dat_oiwfs_dec = -100; $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; $ima_dss2_x_zoom = 1; $ima_dss2_y_zoom = 1; $ima_dss2_min = 1; $ima_dss2_max = 0; $ima_dss2_grid = 0; $ima_dss2_grot = 0; $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; $ima_2mass_x_zoom = 1; $ima_2mass_y_zoom = 1; $ima_2mass_min = 1; $ima_2mass_max = 0; $ima_2mass_grid = 0; $ima_2mass_grot = 0; $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; $ima_wfpc2_x_zoom = 1; $ima_wfpc2_y_zoom = 1; $ima_wfpc2_min = 1; $ima_wfpc2_max = 0; $ima_wfpc2_grid = 0; $ima_wfpc2_grot = 0; $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; $ima_nicmos_x_zoom = 1; $ima_nicmos_y_zoom = 1; $ima_nicmos_min = 1; $ima_nicmos_max = 0; $ima_nicmos_grid = 0; $ima_nicmos_grot = 0; # Resolve object name if necessary. if ($str eq "") { # Use NED to resolve object name. Get_NED_Coords($obj,$ra,$dec); } else { $rh = substr($_,16, 2); $rh =~ s/\s{1}/0/g; $rm = substr($_,19, 2); $rm =~ s/\s{1}/0/g; $rs = substr($_,22, 5); $rs =~ s/\s{1}/0/g; $dc = substr($_,28, 1); $dc =~ s/\s{1}/+/g; $dd = substr($_,29, 2); $dd =~ s/\s{1}/0/g; $dm = substr($_,32, 2); $dm =~ s/\s{1}/0/g; $ds = substr($_,35, 4); $ds =~ s/\s{1}/0/g; $ra = "$rh:$rm:$rs"; $dec = "$dc$dd:$dm:$ds"; } print " $ra $dec\n"; # Get 3'x3' DSS-2 red image. Get_DSS2_Red($fil,$ra,$dec); # Get 3'x3' 2MASS K image. Get_2MASS_K($fil,$ra,$dec); # Get optimal WFPC2 image. Get_WFPC2($fil,$ra,$dec); # Get optimal NICMOS K image. Get_NICMOS($fil,$ra,$dec); # Get USNO catalog stars. Get_USNO($fil,$ra,$dec); } # if (! $dat_dss2_got) { # print "GS_SEARCH.PL: Attempting to retreived DSS-2 red image for $obj.\n"; # # Get 3'x3' DSS-2 red image. # # Get_DSS2_Red($fil,$ra,$dec); # # } $dat_dss2_read = 0; $dat_2mass_read = 0; $dat_wfpc2_read = 0; $dat_nicmos_read = 0; $ima_dss2_sky = 0; $ima_2mass_sky = 0; $ima_wfpc2_sky = 0; $ima_nicmos_sky = 0; # Generate screen display. if ($dcod) {Display_Images($fil,$ra,$dec,1);} # Generate postscipt file. if ($pcod) {Display_Images($fil,$ra,$dec,2);} # Generate gif file. if ($gcod) {Display_Images($fil,$ra,$dec,3);} # Write object data file. Write_Data($fil); } close (LIS); # Report NGS and LGS Y,?,N statistics. if ($ncod) { print "\nGuide Star Statistics:\n"; print "NGS system: Y=$ngs[0]; ?=$ngs[1]; N=$ngs[2]\n"; print "LGS system: Y=$lgs[0]; ?=$lgs[1]; N=$lgs[2]\n\n"; } exit; # Routine to use NED to resolve object coordinates. sub Get_NED_Coords { my ($obj) = @_; $obj =~ s/\s{1}//g; my ($host) = "archive.stsci.edu"; my ($prompt) = "/cgi-bin/dss_form?target=$obj&resolver=NED"; my ($EOL) = "\015\012"; my ($BLANK) = $EOL x 2; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); print $remote "GET $prompt HTTP/1.0" . $BLANK; while (<$remote>) { if (/name=r/) { $ra = substr($_,index($_,"value=")+7,11); $ra =~ s/\s{1}/:/g; } if (/name=d/) { $dec = substr($_,index($_,"value=")+7,11); $dec =~ s/\s{1}/:/g; } } close $remote; return; } # Routine to access DSS-2 red image. sub Get_DSS2_Red { my ($fil,$ra,$dec) = @_; my ($fits) = "images/$fil/$fil"."_dss2_r.fits"; if (! -f "$fits" or $fcod) { my ($ok) = 0; my ($host) = "archive.eso.org"; my ($prompt) = "/dss/dss/image?ra=$ra&dec=$dec&equinox=J2000&x=3&y=3&Sky-Survey=DSS2-red&mime-type=download-fits"; my ($EOL) = "\015\012"; my ($BLANK) = $EOL x 2; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); print $remote "GET $prompt HTTP/1.0" . $BLANK; while (<$remote>) { if (/SIMPLE =/) { open (OUT,">$fits") or die "GS_SEARCH.PL: Cannot open output file $fits!\n"; $ok = 1; } if ($ok) { print OUT $_; } } if ($ok) { close (OUT); $dat_dss2_got = 1; } else { print "GS_SEARCH.PL: DSS2 red image for $fil is unavailable.\n"; } close $remote; } return; } # Routine to access 2MASS K image. sub Get_2MASS_K { my ($fil,$ra,$dec) = @_; my ($fits) = "images/$fil/$fil"."_2mass_k.fits"; if (! -f "$fits" or $fcod) { $ra =~ s/:/h/; $ra =~ s/:/m/; $ra = $ra."s"; $dec =~ s/:/d/; $dec =~ s/:/m/; $dec = $dec."s"; my ($ok, $prompt, $image, $overlay); my ($host) = "irsa.ipac.caltech.edu"; my ($EOL) = "\015\012"; my ($BLANK) = $EOL x 2; # Request coadds. $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); $prompt = "/cgi-bin/2MASS/ReleaseVis/nph-surveyvis?locstr=$ra+$dec+Equ+J2000&coadds=1&date=&hemisphere=&scan=&coadd=&show=coadd&coaddsize=180&band=K"; print $remote "GET $prompt HTTP/1.0" . $BLANK; $ok = 0; while (<$remote>) { if (/Data:<\/b>/) { while (<$remote>) { if (/href=/) { $image = substr($_, index($_,"href=")+6); $image = substr($image, 0, index($image,">")-1); $ok = 1; # print "Image file $image\n"; while (<$remote>) { if (/href=/) { $overlay = substr($_, index($_,"href=")+6); $overlay = substr($overlay, 0, index($overlay,">")-1); # print "Overlay file $overlay\n"; } } } } } } close $remote; # Request FITS image. if ($ok) { $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); print $remote "GET $image HTTP/1.0" . $BLANK; $ok = 0; while (<$remote>) { if (/SIMPLE =/) { open (OUT,">$fits") or die "GS_SEARCH.PL: Cannot open output file $fits!\n"; $ok = 1; } if ($ok) { print OUT $_; } } close $remote; } if ($ok) { close (OUT); $dat_2mass_got = 1; } else { print "GS_SEARCH.PL: 2MASS K image for $fil is unavailable.\n"; } } return; } # Routine to access WFPC2 image. sub Get_WFPC2 { my ($fil,$ra,$dec) = @_; my ($fits) = "images/$fil/$fil"."_wfpc2.fits"; if (! -f "$fits" or $fcod) { my ($ok, $prompt, $dataset, $score, $max_score); my ($set, $sra, $sdec, $sep, $cen, $exp); my ($host) = "archive.stsci.edu"; my ($EOL) = "\015\012"; my ($BLANK) = $EOL x 2; # Get dataset name. $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); $prompt = "/cgi-bin/nph-hst?SEARCH_TYPE=none&target=&resolver=NONE&ra=$ra&dec=$dec&radius=1.0&equinox=J2000&obsdate=&exptime=&pi_name=&pep_id=&target_description=&dataset_name=&action=SEARCH&release_date=&archive_date=&bandwidth_type=Central+wavelength+falls+in+this+range+%28%C5+..+%C5%29%3A+&band=&output_cols=default&custom_output_columns=stdads_mark&sort1=ang_sep&sort2=sci_targname&sort3=sci_data_set_name&max_rows=100&output_equinox=J2000&imagers=WFPC2"; print $remote "GET $prompt HTTP/1.0" . $BLANK; $ok = 0; $max_score = 0.1; while (<$remote>) { if (/hst_preview_form/) { $score = 0.0; # Subset name. $set = substr($_,index($_,"?name=")+6); $set = substr($set,0,index($set,'"')); $_ = <$remote>; # RA. $sra = substr($_,15,11); $sra =~ s/\s{1}/:/g; $_ = <$remote>; # Dec. $sdec = substr($_,15,12); $sdec =~ s/\s{1}/:/g; $_ = <$remote>; # Angular separation in arcmin. $sep = substr($_,29,index($_,"")-29); $score = $score+(1.0-$sep); $_ = <$remote>; $_ = <$remote>; $_ = <$remote>; # Filter central wavelength in Angstroms. $cen = substr($_,29,index($_,"")-29); if ($cen == 7940.00) { # F814W $score += 15.0; } elsif ($cen == 7829.00) { # F791W $score += 12.0; } elsif ($cen == 6895.00) { # F702W $score += 11.0; } elsif ($cen == 6714.00) { # F675W $score += 10.5; } elsif ($cen == 6170.00) { # F622W $score += 10.0; } elsif ($cen == 5957.00) { # F606W $score += 9.00; } elsif ($cen == 5623.00) { # F569W $score += 1.00; } elsif ($cen == 5407.00) { # F555W $score += 0.90; } elsif ($cen == 4520.00) { # F450W $score += 0.50; } elsif ($cen == 4300.00) { # F439W $score += 0.40; } elsif ($cen == 3344.00) { # F336W $score += 0.10; } elsif ($cen == 2159.00) { # F218W $score += 0.01; } elsif ($cen == 9124.00) { # F850LP $score += 6.00; } elsif ($cen == 8674.00) { # F785LP $score += 5.00; } elsif ($cen == 10201.0) { # F1042M $score += 4.00; } elsif ($cen == 5479.00) { # F547M $score += 5.00; } elsif ($cen == 4669.00) { # F467M $score += 3.00; } elsif ($cen == 9534.00) { # F953N $score += 0.11; } elsif ($cen == 6800.00) { # FR680N $score += 0.10; } elsif ($cen == 6732.00) { # F673N $score += 0.10; } elsif ($cen == 6563.00) { # F656N $score += 0.20; } elsif ($cen == 6590.00) { # F658N $score += 0.10; } elsif ($cen == 6283.00) { # F631N $score += 0.09; } elsif ($cen == 5893.00) { # F588N $score += 0.05; } elsif ($cen == 5400.00) { # FR533N $score += 0.01; } elsif ($cen == 4200.00) { # FR533N33 $score += 0.01; } elsif ($cen == 5013.00) { # F502N $score += 0.01; } elsif ($cen == 4866.00) { # F487N $score += 0.01; } elsif ($cen == 4694.00) { # F469N $score += 0.01; } elsif ($cen == 4369.00) { # F437N $score += 0.01; } elsif ($cen == 3737.00) { # F375N $score += 0.01; } elsif ($cen == 3424.00) { # F343N $score += 0.01; } elsif ($cen == 1523.00) { # F160BW $score += 0.00; } elsif ($cen < 4000.00) { # Anything blue $score += 0.00; } elsif ($cen == 0.00) { # BLANK $score += 0.00; } elsif ($cen == 4090.00) { # Non-existant filter. $score += 0.00; } else { die "GS_SEARCH.PL: Unidentified WFPC2 filter $cen!\n"; } $_ = <$remote>; # Exposure time in seconds. $exp = substr($_,29,index($_,"")-29); $exp = sprintf("%5.0f",$exp); $score = $score+$exp/1000.; $score = sprintf("%6.2f",$score); print "$obj $set $sra $sdec $sep $cen $exp $score\n"; if ($score > $max_score) { $max_score = $score; $dataset = $set; $ok = 1; } } } close $remote; # Download dataset. if ($ok) { # Retrieve dataset preview. $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); $prompt = "/cgi-bin/hst_preview_search?name=$dataset&imfmt=fits&xfer=log&pc=off&shrink=off&ne=off"; print $remote "GET $prompt HTTP/1.0" . $BLANK; $ok = 0; while (<$remote>) { if (/SIMPLE =/) { open (OUT,">$fits") or die "GS_SEARCH.PL: Cannot open output file $fits!\n"; $ok = 1; } if ($ok) { print OUT $_; } } close $remote; } if ($ok) { close (OUT); $dat_wfpc2_got = 1; } else { print "GS_SEARCH.PL: WFPC2 image for $fil is unavailable.\n"; } } return; } # Routine to access NICMOS image. sub Get_NICMOS { my ($fil,$ra,$dec) = @_; my ($fits) = "images/$fil/$fil"."_nicmos.fits"; if (! -f "$fits" or $fcod) { my ($ok, $prompt, $dataset, $score, $max_score); my ($set, $sra, $sdec, $sep, $cen, $exp); my ($host) = "archive.stsci.edu"; my ($EOL) = "\015\012"; my ($BLANK) = $EOL x 2; # Get dataset name. $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); $prompt = "/cgi-bin/nph-hst?SEARCH_TYPE=none&target=&resolver=NONE&ra=$ra&dec=$dec&radius=0.3&equinox=J2000&obsdate=&exptime=&pi_name=&pep_id=&target_description=&dataset_name=&action=SEARCH&release_date=&archive_date=&bandwidth_type=Central+wavelength+falls+in+this+range+%28%C5+..+%C5%29%3A+&band=&output_cols=default&custom_output_columns=stdads_mark&sort1=ang_sep&sort2=sci_targname&sort3=sci_data_set_name&max_rows=100&output_equinox=J2000&imagers=NICMOS"; print $remote "GET $prompt HTTP/1.0" . $BLANK; $ok = 0; $max_score = 0.1; while (<$remote>) { if (/hst_preview_form/) { $score = 0.0; # Subset name. $set = substr($_,index($_,"?name=")+6); $set = substr($set,0,index($set,'"')); $_ = <$remote>; # RA. $sra = substr($_,15,11); $sra =~ s/\s{1}/:/g; $_ = <$remote>; # Dec. $sdec = substr($_,15,12); $sdec =~ s/\s{1}/:/g; $_ = <$remote>; # Angular separation in arcmin. $sep = substr($_,29,4); $score = $score+(1.0-$sep); $_ = <$remote>; $_ = <$remote>; $_ = <$remote>; # Filter central wavelength in Angstroms. $cen = substr($_,29); $cen =~ s\\\; $cen = sprintf ("%6.0f",$cen); if ($cen == 20714) { # F205W, NIC2 $score = $score+15.0*2; } elsif ($cen == 18718) { # F187W, NIC2 $score = $score+10.0*2; } elsif ($cen == 18360) { # F175W, NIC3 $score = $score+10.0*3; } elsif ($cen == 16071) { # F160W, NIC1 $score = $score+10.0*1; } elsif ($cen == 16060) { # F160W, NIC2 $score = $score+10.0*2; } elsif ($cen == 16078) { # F160W, NIC3 $score = $score+10.0*3; } elsif ($cen == 16071) { # F160W, NIC1 $score = $score+10.0*1; } elsif ($cen == 15484) { # F150W, NIC3 $score = $score+6.00*3; } elsif ($cen == 14399) { # F140W, NIC1 $score = $score+6.00*1; } elsif ($cen == 11264) { # F110W, NIC3 $score = $score+5.00*3; } elsif ($cen == 11285) { # F110W, NIC2 $score = $score+5.00*2; } elsif ($cen == 11292) { # F110W, NIC1 $score = $score+5.00*1; } elsif ($cen == 23696) { # F237M, NIC2 $score = $score+10.0*2; } elsif ($cen == 23969) { # F240M, NIC3 $score = $score+10.0*2; } elsif ($cen == 23695) { # F237M, NIC2 $score = $score+10.0*2; } elsif ($cen == 22182) { # F222M, NIC2 $score = $score+10.0*2; } elsif ($cen == 22184) { # F222M, NIC3 $score = $score+10.0*3; } elsif ($cen == 22183) { # F222M, NIC3 $score = $score+10.0*3; } elsif ($cen == 22181) { # F220M, NIC2 $score = $score+10.0*2; } elsif ($cen == 20824) { # F207M, NIC2 $score = $score+9.5*2; } elsif ($cen == 20355) { # F204M, NIC2 $score = $score+9.0*2; } elsif ($cen == 17971) { # F180M, NIC2 $score = $score+5.30*2; } elsif ($cen == 17212) { # F171M, NIC2 $score = $score+5.20*2; } elsif ($cen == 17067) { # F170M $score = $score+5.20; } elsif ($cen == 16516) { # F165M,NIC2 $score = $score+5.10*2; } elsif ($cen == 16489) { # F165M,NIC1 $score = $score+5.10*1; } elsif ($cen == 14557) { # F145M $score = $score+5.00; } elsif ($cen == 11026) { # F110M $score = $score+2.00; } elsif ($cen == 9041) { # F090M, NIC1 $score = $score+1.90; } elsif ($cen == 21641) { # F216N, NIC2 $score = $score+2.00*2; } elsif ($cen == 21487) { # F215N, NIC2 $score = $score+2.00*2; } elsif ($cen == 21488) { # F215N, NIC2 $score = $score+2.00*2; } elsif ($cen == 21213) { # F212N, NIC2 $score = $score+2.00*2; } elsif ($cen == 19975) { # F200N $score = $score+2.00; } elsif ($cen == 19639) { # F196N $score = $score+2.00; } elsif ($cen == 18986) { # F190N, NIC1 $score = $score+1.00*1; } elsif ($cen == 19003) { # F190N, NIC2 $score = $score+2.00*2; } elsif ($cen == 19004) { # F190N, NIC3 $score = $score+3.00*3; } elsif ($cen == 18748) { # F187N, NIC1 $score = $score+1.00*1; } elsif ($cen == 18740) { # F187N, NIC2 $score = $score+2.00*2; } elsif ($cen == 18748) { # F187N, NIC3 $score = $score+3.00*3; } elsif ($cen == 16460) { # F164N, NIC2 $score = $score+0.50*2; } elsif ($cen == 16607) { # F166N, NIC1 $score = $score+0.10*1; } elsif ($cen == 16583) { # F166N, NIC3 $score = $score+0.50*3; } elsif ($cen == 11284) { # F113N, NIC3 $score = $score+0.20*3; } elsif ($cen == 11298) { # F113N, NIC1 $score = $score+0.20*1; } elsif ($cen == 10800) { # F108N, NIC3 $score = $score+0.19*3; } elsif ($cen == 10799) { # F108N, NIC3 $score = $score+0.19*3; } elsif ($cen == 10816) { # F108N, NIC1 $score = $score+0.19*1; } elsif ($cen == 9716) { # F097N $score = $score+0.01; } elsif ($cen == 9537) { # F095N $score = $score+0.01; } elsif ($cen == 20007) { # POL0L $score = $score+0.00; } elsif ($cen == 10602) { # POL0S $score = $score+0.00; } elsif ($cen == 0) { # ?? $score = $score+0.00; } else { die "GS_SEARCH.PL: Unidentified NICMOS filter $cen!\n"; } $_ = <$remote>; # Exposure time in seconds. $exp = substr($_,29); $exp =~ s\\\; $exp = sprintf ("%7.2f",$exp); $exp = sprintf("%5.0f",$exp); $score = $score+$exp/1000.; $score = sprintf("%6.2f",$score); print "$obj $set $sra $sdec $sep $cen $exp $score\n"; if ($score > $max_score) { $max_score = $score; $dataset = $set; $ok = 1; } } } close $remote; # Download dataset. if ($ok) { # Retrieve dataset preview. $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); $prompt = "/cgi-bin/hst_preview_search?name=$dataset&imfmt=fits&xfer=log&pc=off&shrink=off&ne=off"; print $remote "GET $prompt HTTP/1.0" . $BLANK; $ok = 0; while (<$remote>) { if (/SIMPLE =/) { open (OUT,">$fits") or die "GS_SEARCH.PL: Cannot open output file $fits!\n"; $ok = 1; } if ($ok) { print OUT $_; } } close $remote; } if ($ok) { close (OUT); $dat_nicmos_got = 1; } else { print "GS_SEARCH.PL: NICMOS image for $fil is unavailable.\n"; } } return; } # Routine to access ESO USNO catalog. sub Get_USNO { my ($fil,$ra,$dec) = @_; my ($usno) = "images/$fil/$fil.usno"; if (! -f "$usno" or $fcod) { $ra =~ s/:/+/g; $dec =~ s/:/+/g; my ($prompt, $theta, $r); my ($host) = "archive.eso.org"; my ($EOL) = "\015\012"; my ($BLANK) = $EOL x 2; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)" ); unless ($remote) { die "GS_SEARCH.PL: Cannot connect to http daemon on $host!\n"; } $remote->autoflush(1); $prompt = "/skycat/servers/usnoa_res?catalogue=usnoa&epoch=2000.0&chart=0&ra=$ra&dec=$dec&object=&radmax=1.5&magbright=0&magfaint=100.0&format=3&sort=d%27&nout=100"; print $remote "GET $prompt HTTP/1.0" . $BLANK; open (OUT,">$usno") or die "GS_SEARCH.PL: Cannot open output file $usno!\n"; while (<$remote>) { if (/r_mag b_mag/) { $_ = substr($_,3); print OUT $_; print $_; $_ = <$remote>; chomp; $_ = substr($_,4); while ($_ ne "") { $theta = substr($_,56,8); $r = substr($_,45,5); print "$_\n"; if ($theta < 1.5 and $r <= $rlim) { print OUT "$_\n"; print "$_\n"; } $_ = <$remote>; chomp; } } } close (OUT); $dat_usno_got = 1; close $remote; } return; } # Routine to access local version of USNO catalog. #sub Get_USNO_Local { # my ($fil,$ra,$dec) = @_; # my ($usno) = "$fil/$fil.usno"; # Check environment variables have been defined. # if ($ENV{'SNSEARCH' } eq "") {die "SNSEARCH not set. Source gs_search.csh!\n";} # $sns = $ENV{'SNSEARCH'}; # if (! -f "$usno" or $fcod) { # open (LOC,"$sns/mink.bin/scat -j -p -c ua2 -r -60.0 -n 200 $ra $dec J2000.0 |"); # open (OUT,">$usno") or # die "GS_SEARCH.PL: Cannot open output file $usno!\n"; # while () { # my ($theta) = /^\s*\S+\s*\S+\s*\S+\s*\S+\s*\S+\s*\S+\s*(\S+)/; # my ($r) = substr($_,47,4); # if ($theta < 60.0 and $r <= $rlim) {print OUT $_;} # } # close (OUT); # $dat_usno_got = 1; # close (LOC); # } # return; #} # Routine to display downloaded images. sub Display_Images { my ($fil,$ra,$dec,$cod) = @_; my ($dis); $but_dss2_1_sta = 0; $but_dss2_2_sta = 0; $but_dss2_3_sta = 0; $but_dss2_4_sta = 0; $but_dss2_5_sta = 0; $but_2mass_1_sta = 0; $but_2mass_2_sta = 0; $but_2mass_3_sta = 0; $but_2mass_4_sta = 0; $but_2mass_5_sta = 0; $but_wfpc2_1_sta = 0; $but_wfpc2_2_sta = 0; $but_wfpc2_3_sta = 0; $but_wfpc2_4_sta = 0; $but_wfpc2_5_sta = 0; $but_nicmos_1_sta = 0; $but_nicmos_2_sta = 0; $but_nicmos_3_sta = 0; $but_nicmos_4_sta = 0; $but_nicmos_5_sta = 0; # Form display device name and open plot file. if ($cod == 1) { $dis = "/xserve"; $pltid = pgopen($dis); if ($pltid <= 0) {die "GS_SEARCH.PL: Unable to open plot device!";} } elsif ($cod == 2) { $dis = "images/$fil/$fil.ps/ps"; $prtid = pgopen($dis); if ($prtid <= 0) {die "GS_SEARCH.PL: Unable to open postscript file!";} } elsif ($cod == 3) { $dis = "images/$fil/$fil.gif/gif"; $gifid = pgopen($dis); if ($gifid <= 0) {die "GS_SEARCH.PL: Unable to open gif file!";} } else { print "GS_SEARCH.PL: Invalid display code!\n"; return; } # Define colors. if ($cod == 1) { pgscr(0,0,0.7,1); pgscr(1,0,0,0); } elsif ($cod == 2) { pgscr(10,1,1,1); } elsif ($cod == 3) { pgscr(0,0,0.7,1); pgscr(1,0,0,0); } Color_Table($col_tab,$col_con,$col_bri); # Plot title. Plt_Title($obj,$ra,$dec); # Plot DSS2 red image. Plt_DSS2_R($fil,$ra,$dec); # Plot 2MASS K image. Plt_2MASS_K($fil,$ra,$dec); # Plot WFPC2 image. Plt_WFPC2($fil,$ra,$dec); # Plot NICMOS image. Plt_NICMOS($fil,$ra,$dec); # Interactively adjust plot parameters. if ($cod == 1) { Adjust_Plt($fil); } pgclos; return; } # Routine to write object data file. sub Write_Data { my ($fil) = @_; my $dat = "images/$fil/$fil.dat"; open (DAT,">$dat") or die "GS_SEARCH.PL: Cannot open object data file $dat.\n"; print DAT "$obj\n"; print DAT "$ra\n"; print DAT "$dec\n"; print DAT "$col_tab\n"; print DAT "$col_bri\n"; print DAT "$col_con\n"; print DAT "$dat_dss2_got\n"; print DAT "$ima_dss2_x_off\n"; print DAT "$ima_dss2_y_off\n"; print DAT "$ima_dss2_x_zoom\n"; print DAT "$ima_dss2_y_zoom\n"; print DAT "$ima_dss2_min\n"; print DAT "$ima_dss2_max\n"; print DAT "$dat_2mass_got\n"; print DAT "$ima_2mass_x_off\n"; print DAT "$ima_2mass_y_off\n"; print DAT "$ima_2mass_x_zoom\n"; print DAT "$ima_2mass_y_zoom\n"; print DAT "$ima_2mass_min\n"; print DAT "$ima_2mass_max\n"; print DAT "$dat_wfpc2_got\n"; print DAT "$ima_wfpc2_x_off\n"; print DAT "$ima_wfpc2_y_off\n"; print DAT "$ima_wfpc2_x_zoom\n"; print DAT "$ima_wfpc2_y_zoom\n"; print DAT "$ima_wfpc2_min\n"; print DAT "$ima_wfpc2_max\n"; print DAT "$dat_nicmos_got\n"; print DAT "$ima_nicmos_x_off\n"; print DAT "$ima_nicmos_y_off\n"; print DAT "$ima_nicmos_x_zoom\n"; print DAT "$ima_nicmos_y_zoom\n"; print DAT "$ima_nicmos_min\n"; print DAT "$ima_nicmos_max\n"; print DAT "$dat_usno_got\n"; print DAT "$dat_aowfs_got\n"; print DAT "$dat_aowfs_ra\n"; print DAT "$dat_aowfs_dec\n"; print DAT "$dat_oiwfs_got\n"; print DAT "$dat_oiwfs_ra\n"; print DAT "$dat_oiwfs_dec\n"; print DAT "$ima_dss2_grid\n"; print DAT "$ima_dss2_grot\n"; print DAT "$ima_2mass_grid\n"; print DAT "$ima_2mass_grot\n"; print DAT "$ima_wfpc2_grid\n"; print DAT "$ima_wfpc2_grot\n"; print DAT "$ima_nicmos_grid\n"; print DAT "$ima_nicmos_grot\n"; close (DAT); return; } # Routine to read object data file. sub Read_Data { my ($fil) = @_; my $dat = "images/$fil/$fil.dat"; open (DAT,"<$dat") or return 0; $obj = ; chomp $obj; $obj = sprintf("%-15.15s",$obj); $ra = ; chomp $ra; $dec = ; chomp $dec; print "$obj $ra $dec\n"; $col_tab = ; chomp $col_tab; $col_bri = ; chomp $col_bri; $col_con = ; chomp $col_con; $dat_dss2_got = ; chomp $dat_dss2_got; $ima_dss2_x_off = ; chomp $ima_dss2_x_off; $ima_dss2_y_off = ; chomp $ima_dss2_y_off; $ima_dss2_x_zoom = ; chomp $ima_dss2_x_zoom; $ima_dss2_y_zoom = ; chomp $ima_dss2_y_zoom; $ima_dss2_min = ; chomp $ima_dss2_min; $ima_dss2_max = ; chomp $ima_dss2_max; $dat_2mass_got = ; chomp $dat_2mass_got; $ima_2mass_x_off = ; chomp $ima_2mass_x_off; $ima_2mass_y_off = ; chomp $ima_2mass_y_off; $ima_2mass_x_zoom = ; chomp $ima_2mass_x_zoom; $ima_2mass_y_zoom = ; chomp $ima_2mass_y_zoom; $ima_2mass_min = ; chomp $ima_2mass_min; $ima_2mass_max = ; chomp $ima_2mass_max; $dat_wfpc2_got = ; chomp $dat_wfpc2_got; $ima_wfpc2_x_off = ; chomp $ima_wfpc2_x_off; $ima_wfpc2_y_off = ; chomp $ima_wfpc2_y_off; $ima_wfpc2_x_zoom = ; chomp $ima_wfpc2_x_zoom; $ima_wfpc2_y_zoom = ; chomp $ima_wfpc2_y_zoom; $ima_wfpc2_min = ; chomp $ima_wfpc2_min; $ima_wfpc2_max = ; chomp $ima_wfpc2_max; $dat_nicmos_got = ; chomp $dat_nicmos_got; $ima_nicmos_x_off = ; chomp $ima_nicmos_x_off; $ima_nicmos_y_off = ; chomp $ima_nicmos_y_off; $ima_nicmos_x_zoom = ; chomp $ima_nicmos_x_zoom; $ima_nicmos_y_zoom = ; chomp $ima_nicmos_y_zoom; $ima_nicmos_min = ; chomp $ima_nicmos_min; $ima_nicmos_max = ; chomp $ima_nicmos_max; $dat_usno_got = ; chomp $dat_usno_got; # The remaining entries were added recently and may not be # present for all objects. $dat_aowfs_got = ; if (defined($dat_aowfs_got)){ chomp $dat_aowfs_got; } else { $dat_aowfs_got = 0; } $dat_aowfs_ra = ; if (defined($dat_aowfs_ra)){ chomp $dat_aowfs_ra; } else { $dat_aowfs_ra = 0; } $dat_aowfs_dec = ; if (defined($dat_aowfs_dec)){ chomp $dat_aowfs_dec; } else { $dat_aowfs_dec = 0; } $dat_oiwfs_got = ; if (defined($dat_oiwfs_got)){ chomp $dat_oiwfs_got; } else { $dat_oiwfs_got = 0; } $dat_oiwfs_ra = ; if (defined($dat_oiwfs_ra)){ chomp $dat_oiwfs_ra; } else { $dat_oiwfs_ra = 0; } $dat_oiwfs_dec = ; if (defined($dat_oiwfs_dec)){ chomp $dat_oiwfs_dec; } else { $dat_oiwfs_dec = 0; } $ima_dss2_grid = ; if (defined($ima_dss2_grid)){ chomp $ima_dss2_grid; } else { $ima_dss2_grid = 0; } $ima_dss2_grot = ; if (defined($ima_dss2_grot)){ chomp $ima_dss2_grot; } else { $ima_dss2_grot = 0; } $ima_2mass_grid = ; if (defined($ima_2mass_grid)){ chomp $ima_2mass_grid; } else { $ima_2mass_grid = 0; } $ima_2mass_grot = ; if (defined($ima_2mass_grot)){ chomp $ima_2mass_grot; } else { $ima_2mass_grot = 0; } $ima_wfpc2_grid = ; if (defined($ima_wfpc2_grid)){ chomp $ima_wfpc2_grid; } else { $ima_wfpc2_grid = 0; } $ima_wfpc2_grot = ; if (defined($ima_wfpc2_grot)){ chomp $ima_wfpc2_grot; } else { $ima_wfpc2_grot = 0; } $ima_nicmos_grid = ; if (defined($ima_nicmos_grid)){ chomp $ima_nicmos_grid; } else { $ima_nicmos_grid = 0; } $ima_nicmos_grot = ; if (defined($ima_nicmos_grot)){ chomp $ima_nicmos_grot; } else { $ima_nicmos_grot = 0; } close (DAT); return 1; } # Routine to plot title. sub Plt_Title { my ($obj,$ra,$dec) = @_; pgsvp(0,0.5,0.9,1); pgswin(0,1,0,1); pgsci(0); pgrect(0,1,0,1); pgsci(1); pgsci(1); # Set color index (default). pgslw(2); # Set line width (1=default). pgscf(2); # Set character font (1=default; 2=roman). pgsch(2); # Set character height. pgptxt(0.0,0.65,0.0,0.0,$obj); pgsch(1.5); pgptxt(0.0,0.2,0.0,0.0,"$ra $dec J2000"); pgslw(1); pgsch(1); # Draw "Color" button. $but_title_1_x_vst = 0.50; $but_title_1_x_vsp = 0.61; $but_title_1_y_vst = 0.94; $but_title_1_y_vsp = 0.99; $but_title_1_lab = "Color"; Plt_Button($but_title_1_x_vst, $but_title_1_x_vsp, $but_title_1_y_vst, $but_title_1_y_vsp, $but_title_1_lab, $but_title_1_sta); # Draw "Print" button. $but_title_2_x_vst = 0.63; $but_title_2_x_vsp = 0.74; $but_title_2_y_vst = 0.94; $but_title_2_y_vsp = 0.99; $but_title_2_lab = "Print"; Plt_Button($but_title_2_x_vst, $but_title_2_x_vsp, $but_title_2_y_vst, $but_title_2_y_vsp, $but_title_2_lab, $but_title_2_sta); # Draw "Next" button. $but_title_3_x_vst = 0.76; $but_title_3_x_vsp = 0.87; $but_title_3_y_vst = 0.94; $but_title_3_y_vsp = 0.99; $but_title_3_lab = "Next"; Plt_Button($but_title_3_x_vst, $but_title_3_x_vsp, $but_title_3_y_vst, $but_title_3_y_vsp, $but_title_3_lab, $but_title_3_sta); # Draw "Quit" button. $but_title_4_x_vst = 0.89; $but_title_4_x_vsp = 1.00; $but_title_4_y_vst = 0.94; $but_title_4_y_vsp = 0.99; $but_title_4_lab = "Quit"; Plt_Button($but_title_4_x_vst, $but_title_4_x_vsp, $but_title_4_y_vst, $but_title_4_y_vsp, $but_title_4_lab, $but_title_4_sta); return; } # Routine to plot DSS2 red image. sub Plt_DSS2_R { my ($fil,$ra,$dec) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); my ($xscale, $yscale, $coord, $size); my ($tr) = [0,1,0,0,0,1]; my ($fits) = "images/$fil/$fil"."_dss2_r.fits"; my ($usno) = "images/$fil/$fil.usno"; $ima_dss2_x_vst = 0.01; $ima_dss2_x_vsp = 0.35; $ima_dss2_y_vst = 0.47; $ima_dss2_y_vsp = 0.85; $but_dss2_1_x_vst = 0.36; $but_dss2_1_x_vsp = 0.47; $but_dss2_1_y_vst = 0.80; $but_dss2_1_y_vsp = 0.85; $but_dss2_1_lab = "Zoom"; $but_dss2_2_x_vst = 0.36; $but_dss2_2_x_vsp = 0.47; $but_dss2_2_y_vst = 0.72; $but_dss2_2_y_vsp = 0.77; $but_dss2_2_lab = "Unzoom"; $but_dss2_3_x_vst = 0.36; $but_dss2_3_x_vsp = 0.47; $but_dss2_3_y_vst = 0.64; $but_dss2_3_y_vsp = 0.69; $but_dss2_3_lab = "Center"; $but_dss2_4_x_vst = 0.36; $but_dss2_4_x_vsp = 0.47; $but_dss2_4_y_vst = 0.56; $but_dss2_4_y_vsp = 0.61; $but_dss2_4_lab = "Range"; $but_dss2_5_x_vst = 0.36; $but_dss2_5_x_vsp = 0.47; $but_dss2_5_y_vst = 0.48; $but_dss2_5_y_vsp = 0.53; $but_dss2_5_lab = "Reset"; pgsci(1); # Set color index (default). pgslw(1); # Set line width (1=default). pgscf(2); # Set character font (1=default; 2=roman). pgsch(1.0); # Set character height. # Draw bounding box. pgsvp(0.00,0.50,0.45,0.90); pgswin(0,1,0,1); pgsci(0); pgrect(0,1,0,1); pgsci(1); pgbox('BC',0.0,0,'BC',0.0,0); pgptxt(0.5,0.92,0.0,0.5,"DSS-2 Red"); # Read FITS file. if (! $dat_dss2_read) { ($dat_dss2_got,$dat_dss2_data,$dat_dss2_nx,$dat_dss2_ny, $dat_dss2_hdr,$dat_dss2_min,$dat_dss2_max) = Read_FITS($fits); if ($ima_dss2_min > $ima_dss2_max) { $ima_dss2_min = $dat_dss2_min; $ima_dss2_max = $dat_dss2_max; } $dat_dss2_read = 1; # .true. } if (! $dat_dss2_got) { pgptxt(0.5,0.5,0.0,0.5,"No DSS-2 Red image available."); return; } # Plot image. pgsch(0.5); pgsvp($ima_dss2_x_vst,$ima_dss2_x_vsp, $ima_dss2_y_vst,$ima_dss2_y_vsp); $rh = substr($ra, 0,2); $rm = substr($ra, 3,2); $rs = substr($ra, 6,5); $dc = substr($dec,0,1); $dd = substr($dec,1,2); $dm = substr($dec,4,2); $ds = substr($dec,7,4); ($ima_dss2_x_cen,$ima_dss2_y_cen) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$dat_dss2_hdr); # Image scale in arcsec/pixel. # $xscale = $dat_dss2_hdr->{'PLTSCALE'}*$dat_dss2_hdr->{'XPIXELSZ'}/1000; # $yscale = $dat_dss2_hdr->{'PLTSCALE'}*$dat_dss2_hdr->{'YPIXELSZ'}/1000; $xscale = abs($dat_dss2_hdr->{'CDELT1'}*3600); $yscale = abs($dat_dss2_hdr->{'CDELT2'}*3600); $ima_dss2_x_wst = $ima_dss2_x_cen+$ima_dss2_x_off -90/$ima_dss2_x_zoom/$xscale; $ima_dss2_x_wsp = $ima_dss2_x_cen+$ima_dss2_x_off +90/$ima_dss2_x_zoom/$xscale; $ima_dss2_y_wst = $ima_dss2_y_cen+$ima_dss2_y_off -90/$ima_dss2_y_zoom/$yscale; $ima_dss2_y_wsp = $ima_dss2_y_cen+$ima_dss2_y_off +90/$ima_dss2_y_zoom/$yscale; pgwnad($ima_dss2_x_wst,$ima_dss2_x_wsp, $ima_dss2_y_wst,$ima_dss2_y_wsp); pgqvp(0,$ima_dss2_x_vst,$ima_dss2_x_vsp, $ima_dss2_y_vst,$ima_dss2_y_vsp); pgsci(0); pgrect($ima_dss2_x_wst,$ima_dss2_x_wsp, $ima_dss2_y_wst,$ima_dss2_y_wsp); pgsci(1); pgimag($dat_dss2_data,$dat_dss2_nx,$dat_dss2_ny,1,$dat_dss2_nx, 1,$dat_dss2_ny,$ima_dss2_max,$ima_dss2_min,$tr); pgbox('BCNST',0.0,0,'BCNST',0.0,0); # Draw 3"x3" NIFS field. pgsci(3); pgsfs(2); pgrect($ima_dss2_x_cen-1.5/$xscale,$ima_dss2_x_cen+1.5/$xscale, $ima_dss2_y_cen-1.5/$yscale,$ima_dss2_y_cen+1.5/$yscale); pgsfs(1); # Draw NIFS FOV grid. if ($ima_dss2_grid) { pgsci(3); pgsfs(2); foreach $i (-60..61) { $x = $ima_dss2_x_cen-1.5/$xscale+$i*3.0/$xscale; if ($x > 0 and $x < $dat_dss2_nx) { pgmove($x,0); pgdraw($x,$dat_dss2_ny); } } foreach $i (-60..61) { $y = $ima_dss2_y_cen-1.5/$yscale+$i*3.0/$yscale; if ($y > 0 and $y < $dat_dss2_ny) { pgmove(0,$y); pgdraw($dat_dss2_nx,$y); } } pgsfs(1); } # Draw 60" radius ALTAIR field. pgsci(2); Plt_Circle($ima_dss2_x_cen,$ima_dss2_y_cen,60.0/$xscale); # Draw 90" radius OIWFS field. pgsci(2); Plt_Circle($ima_dss2_x_cen,$ima_dss2_y_cen,90.0/$xscale); # Draw 12.7" radius pickoff mirror field. pgsci(2); Plt_Circle($ima_dss2_x_cen,$ima_dss2_y_cen,12.7/$xscale); $x = $ima_dss2_x_cen+12.7/$xscale; $y = $ima_dss2_y_cen; pgmove($x,$y); $y = $ima_dss2_y_cen-90.0/$yscale; pgdraw($x,$y); $x = $ima_dss2_x_cen-12.7/$xscale; $y = $ima_dss2_y_cen; pgmove($x,$y); $y = $ima_dss2_y_cen-90.0/$yscale; pgdraw($x,$y); # Draw 20" radius NGS field. pgsci(4); Plt_Circle($ima_dss2_x_cen,$ima_dss2_y_cen,20.0/$xscale); # Draw 30" radius LGS field. pgsci(4); Plt_Circle($ima_dss2_x_cen,$ima_dss2_y_cen,30.0/$xscale); pgsci(1); # Overlay USNO stars. if ($dat_usno_got) { open (IN,"$usno") or die "GS_SEARCH.PL: Cannot open input file $usno!\n"; $size = 5/$xscale; $_ = ; while () { $coord = substr($_,21,23); Mark_USNO($coord,$size,$dat_dss2_hdr); } close (IN); } # Overlay AOWFS guide star. if ($dat_aowfs_got) { $size = 3/$xscale; $coord = "$dat_aowfs_ra $dat_aowfs_dec"; Mark_AOWFS($coord,$size,$dat_dss2_hdr); } # Overlay OIWFS guide star. if ($dat_oiwfs_got) { $size = 3.0/$xscale; $coord = "$dat_oiwfs_ra $dat_oiwfs_dec"; Mark_OIWFS($coord,$size,$dat_dss2_hdr); } # Draw "Zoom" button. Plt_Button($but_dss2_1_x_vst, $but_dss2_1_x_vsp, $but_dss2_1_y_vst, $but_dss2_1_y_vsp, $but_dss2_1_lab, $but_dss2_1_sta); # Draw "Unzoom" button. Plt_Button($but_dss2_2_x_vst, $but_dss2_2_x_vsp, $but_dss2_2_y_vst, $but_dss2_2_y_vsp, $but_dss2_2_lab, $but_dss2_2_sta); # Draw "Center" button. Plt_Button($but_dss2_3_x_vst, $but_dss2_3_x_vsp, $but_dss2_3_y_vst, $but_dss2_3_y_vsp, $but_dss2_3_lab, $but_dss2_3_sta); # Draw "Range" button. Plt_Button($but_dss2_4_x_vst, $but_dss2_4_x_vsp, $but_dss2_4_y_vst, $but_dss2_4_y_vsp, $but_dss2_4_lab, $but_dss2_4_sta); # Draw "Reset" button. Plt_Button($but_dss2_5_x_vst, $but_dss2_5_x_vsp, $but_dss2_5_y_vst, $but_dss2_5_y_vsp, $but_dss2_5_lab, $but_dss2_5_sta); pgsvp(0,1,0,1); pgswin(0,1,0,1); return; } # Routine to plot 2MASS K image. sub Plt_2MASS_K { my ($fil,$ra,$dec) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); my ($xscale, $yscale, $coord, $size); my ($tr) = [0,1,0,0,0,1]; my ($fits) = "images/$fil/$fil"."_2mass_k.fits"; my ($usno) = "images/$fil/$fil.usno"; $ima_2mass_x_vst = 0.51; $ima_2mass_x_vsp = 0.85; $ima_2mass_y_vst = 0.47; $ima_2mass_y_vsp = 0.85; $but_2mass_1_x_vst = 0.86; $but_2mass_1_x_vsp = 0.97; $but_2mass_1_y_vst = 0.80; $but_2mass_1_y_vsp = 0.85; $but_2mass_1_lab = "Zoom"; $but_2mass_2_x_vst = 0.86; $but_2mass_2_x_vsp = 0.97; $but_2mass_2_y_vst = 0.72; $but_2mass_2_y_vsp = 0.77; $but_2mass_2_lab = "Unzoom"; $but_2mass_3_x_vst = 0.86; $but_2mass_3_x_vsp = 0.97; $but_2mass_3_y_vst = 0.64; $but_2mass_3_y_vsp = 0.69; $but_2mass_3_lab = "Center"; $but_2mass_4_x_vst = 0.86; $but_2mass_4_x_vsp = 0.97; $but_2mass_4_y_vst = 0.56; $but_2mass_4_y_vsp = 0.61; $but_2mass_4_lab = "Range"; $but_2mass_5_x_vst = 0.86; $but_2mass_5_x_vsp = 0.97; $but_2mass_5_y_vst = 0.48; $but_2mass_5_y_vsp = 0.53; $but_2mass_5_lab = "Reset"; pgsci(1); # Set color index (default). pgslw(1); # Set line width (1=default). pgscf(2); # Set character font (1=default; 2=roman). pgsch(1.0); # Set character height. # Draw bounding box. pgsvp(0.50,1.00,0.45,0.90); pgswin(0,1,0,1); pgsci(0); pgrect(0,1,0,1); pgsci(1); pgbox('BC',0.0,0,'BC',0.0,0); pgptxt(0.5,0.92,0.0,0.5,"2MASS K"); # Read FITS file. if (! $dat_2mass_read) { ($dat_2mass_got,$dat_2mass_data,$dat_2mass_nx,$dat_2mass_ny, $dat_2mass_hdr,$dat_2mass_min,$dat_2mass_max) = Read_FITS($fits); if ($ima_2mass_min > $ima_2mass_max) { $ima_2mass_min = $dat_2mass_min; $ima_2mass_max = $dat_2mass_max; } $dat_2mass_read = 1; # .true. } if (! $dat_2mass_got) { pgptxt(0.5,0.5,0.0,0.5,"No 2MASS K image available."); $ima_2mass_min = 0; $ima_2mass_max = 0; return; } # Plot image. pgsch(0.5); pgsvp($ima_2mass_x_vst,$ima_2mass_x_vsp, $ima_2mass_y_vst,$ima_2mass_y_vsp); $rh = substr($ra, 0,2); $rm = substr($ra, 3,2); $rs = substr($ra, 6,5); $dc = substr($dec,0,1); $dd = substr($dec,1,2); $dm = substr($dec,4,2); $ds = substr($dec,7,4); ($ima_2mass_x_cen,$ima_2mass_y_cen) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$dat_2mass_hdr); # Image scale in arcsec/pixel. $xscale = abs($dat_2mass_hdr->{'CDELT1'}*3600); $yscale = abs($dat_2mass_hdr->{'CDELT2'}*3600); $ima_2mass_x_wst = $ima_2mass_x_cen+$ima_2mass_x_off -90/$ima_2mass_x_zoom/$xscale; $ima_2mass_x_wsp = $ima_2mass_x_cen+$ima_2mass_x_off +90/$ima_2mass_x_zoom/$xscale; $ima_2mass_y_wst = $ima_2mass_y_cen+$ima_2mass_y_off -90/$ima_2mass_y_zoom/$yscale; $ima_2mass_y_wsp = $ima_2mass_y_cen+$ima_2mass_y_off +90/$ima_2mass_y_zoom/$yscale; pgwnad($ima_2mass_x_wst,$ima_2mass_x_wsp, $ima_2mass_y_wst,$ima_2mass_y_wsp); pgqvp(0,$ima_2mass_x_vst,$ima_2mass_x_vsp, $ima_2mass_y_vst,$ima_2mass_y_vsp); pgsci(0); pgrect($ima_2mass_x_wst,$ima_2mass_x_wsp, $ima_2mass_y_wst,$ima_2mass_y_wsp); pgsci(1); pgimag($dat_2mass_data,$dat_2mass_nx,$dat_2mass_ny,1,$dat_2mass_nx, 1,$dat_2mass_ny,$ima_2mass_max,$ima_2mass_min,$tr); pgbox('BCNST',0.0,0,'BCNST',0.0,0); # Draw 3"x3" NIFS field. pgsci(3); pgsfs(2); pgrect($ima_2mass_x_cen-1.5/$xscale,$ima_2mass_x_cen+1.5/$xscale, $ima_2mass_y_cen-1.5/$yscale,$ima_2mass_y_cen+1.5/$yscale); pgsfs(1); # Draw NIFS FOV grid. if ($ima_2mass_grid) { pgsci(3); pgsfs(2); foreach $i (-60..61) { $x = $ima_2mass_x_cen-1.5/$xscale+$i*3.0/$xscale; if ($x > 0 and $x < $dat_2mass_nx) { pgmove($x,0); pgdraw($x,$dat_2mass_ny); } } foreach $i (-60..61) { $y = $ima_2mass_y_cen-1.5/$yscale+$i*3.0/$yscale; if ($y > 0 and $y < $dat_2mass_ny) { pgmove(0,$y); pgdraw($dat_2mass_nx,$y); } } pgsfs(1); } # Draw 60" radius ALTAIR field. pgsci(2); Plt_Circle($ima_2mass_x_cen,$ima_2mass_y_cen,60.0/$xscale); # Draw 90" radius OIWFS field. pgsci(2); Plt_Circle($ima_2mass_x_cen,$ima_2mass_y_cen,90.0/$xscale); # Draw 12.7" radius pickoff mirror field. pgsci(2); Plt_Circle($ima_2mass_x_cen,$ima_2mass_y_cen,12.7/$xscale); $x = $ima_2mass_x_cen+12.7/$xscale; $y = $ima_2mass_y_cen; pgmove($x,$y); $y = $ima_2mass_y_cen-90.0/$yscale; pgdraw($x,$y); $x = $ima_2mass_x_cen-12.7/$xscale; $y = $ima_2mass_y_cen; pgmove($x,$y); $y = $ima_2mass_y_cen-90.0/$yscale; pgdraw($x,$y); # Draw 20" radius NGS field. pgsci(4); Plt_Circle($ima_2mass_x_cen,$ima_2mass_y_cen,20.0/$xscale); # Draw 30" radius LGS field. pgsci(4); Plt_Circle($ima_2mass_x_cen,$ima_2mass_y_cen,30.0/$xscale); pgsci(1); # Overlay USNO stars. if ($dat_usno_got) { open (IN,"$usno") or die "GS_SEARCH.PL: Cannot open input file $usno!\n"; $size = 5/$xscale; $_ = ; while () { $coord = substr($_,21,23); Mark_USNO($coord,$size,$dat_2mass_hdr); } close (IN); } # Overlay AOWFS guide star. if ($dat_aowfs_got) { $size = 3/$xscale; $coord = "$dat_aowfs_ra $dat_aowfs_dec"; Mark_AOWFS($coord,$size,$dat_2mass_hdr); } # Overlay OIWFS guide star. if ($dat_oiwfs_got) { $size = 3/$xscale; $coord = "$dat_oiwfs_ra $dat_oiwfs_dec"; Mark_OIWFS($coord,$size,$dat_2mass_hdr); } # Draw "Zoom" button. Plt_Button($but_2mass_1_x_vst, $but_2mass_1_x_vsp, $but_2mass_1_y_vst, $but_2mass_1_y_vsp, $but_2mass_1_lab, $but_2mass_1_sta); # Draw "Unzoom" button. Plt_Button($but_2mass_2_x_vst, $but_2mass_2_x_vsp, $but_2mass_2_y_vst, $but_2mass_2_y_vsp, $but_2mass_2_lab, $but_2mass_2_sta); # Draw "Center" button. Plt_Button($but_2mass_3_x_vst, $but_2mass_3_x_vsp, $but_2mass_3_y_vst, $but_2mass_3_y_vsp, $but_2mass_3_lab, $but_2mass_3_sta); # Draw "Range" button. Plt_Button($but_2mass_4_x_vst, $but_2mass_4_x_vsp, $but_2mass_4_y_vst, $but_2mass_4_y_vsp, $but_2mass_4_lab, $but_2mass_4_sta); # Draw "Reset" button. Plt_Button($but_2mass_5_x_vst, $but_2mass_5_x_vsp, $but_2mass_5_y_vst, $but_2mass_5_y_vsp, $but_2mass_5_lab, $but_2mass_5_sta); pgsvp(0,1,0,1); pgswin(0,1,0,1); return; } # Routine to plot a WFPC2 image. sub Plt_WFPC2 { my ($fil,$ra,$dec) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); my ($xscale, $yscale, $coord, $size, $crota2, $dec_rad, $title); my ($tr) = [0,1,0,0,0,1]; my ($fits) = "images/$fil/$fil"."_wfpc2.fits"; my ($usno) = "images/$fil/$fil.usno"; my ($pi) = 3.14159265359; $ima_wfpc2_x_vst = 0.01; $ima_wfpc2_x_vsp = 0.35; $ima_wfpc2_y_vst = 0.02; $ima_wfpc2_y_vsp = 0.40; $but_wfpc2_1_x_vst = 0.36; $but_wfpc2_1_x_vsp = 0.47; $but_wfpc2_1_y_vst = 0.35; $but_wfpc2_1_y_vsp = 0.40; $but_wfpc2_1_lab = "Zoom"; $but_wfpc2_2_x_vst = 0.36; $but_wfpc2_2_x_vsp = 0.47; $but_wfpc2_2_y_vst = 0.27; $but_wfpc2_2_y_vsp = 0.32; $but_wfpc2_2_lab = "Unzoom"; $but_wfpc2_3_x_vst = 0.36; $but_wfpc2_3_x_vsp = 0.47; $but_wfpc2_3_y_vst = 0.19; $but_wfpc2_3_y_vsp = 0.24; $but_wfpc2_3_lab = "Center"; $but_wfpc2_4_x_vst = 0.36; $but_wfpc2_4_x_vsp = 0.47; $but_wfpc2_4_y_vst = 0.11; $but_wfpc2_4_y_vsp = 0.16; $but_wfpc2_4_lab = "Range"; $but_wfpc2_5_x_vst = 0.36; $but_wfpc2_5_x_vsp = 0.47; $but_wfpc2_5_y_vst = 0.03; $but_wfpc2_5_y_vsp = 0.08; $but_wfpc2_5_lab = "Reset"; pgsci(1); # Set color index (default). pgslw(1); # Set line width (1=default). pgscf(2); # Set character font (1=default; 2=roman). pgsch(1.0); # Set character height. # Draw bounding box. pgsvp(0.00,0.50,0.00,0.45); pgswin(0,1,0,1); pgsci(0); pgrect(0,1,0,1); pgsci(1); pgbox('BC',0.0,0,'BC',0.0,0); # Read FITS file. if (! $dat_wfpc2_read) { ($dat_wfpc2_got,$dat_wfpc2_data,$dat_wfpc2_nx,$dat_wfpc2_ny, $dat_wfpc2_hdr,$dat_wfpc2_min,$dat_wfpc2_max) = Read_FITS($fits); if ($ima_wfpc2_min > $ima_wfpc2_max) { $ima_wfpc2_min = $dat_wfpc2_min; $ima_wfpc2_max = $dat_wfpc2_max; } $dat_wfpc2_read = 1; # .true. } if (! $dat_wfpc2_got) { pgptxt(0.5,0.92,0.0,0.5,"WFPC2"); pgptxt(0.5,0.5,0.0,0.5,"No WFPC2 image available."); $ima_wfpc2_min = 0; $ima_wfpc2_max = 0; return; } else { $title = $dat_wfpc2_hdr->{'FILTNAM1'}; $title = substr($title,1,length($title)-2); $title =~ s/\s{1}//g; pgptxt(0.5,0.92,0.0,0.5,"WFPC2 $title"); } # Plot image. pgsch(0.5); pgsvp($ima_wfpc2_x_vst,$ima_wfpc2_x_vsp, $ima_wfpc2_y_vst,$ima_wfpc2_y_vsp); $rh = substr($ra, 0,2); $rm = substr($ra, 3,2); $rs = substr($ra, 6,5); $dc = substr($dec,0,1); $dd = substr($dec,1,2); $dm = substr($dec,4,2); $ds = substr($dec,7,4); $dec_rad = ($dd+$dm/60+$ds/3600)*$pi/180; if ($dc eq "-") {$dec_rad *= -1;} ($ima_wfpc2_x_cen,$ima_wfpc2_y_cen) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$dat_wfpc2_hdr); # Image scale in arcsec/pixel. $crota2 = atan2($dat_wfpc2_hdr->{'CD2_1'},$dat_wfpc2_hdr->{'CD1_1'}); $xscale = abs($dat_wfpc2_hdr->{'CD1_1'}/cos($crota2)*3600); $yscale = abs($dat_wfpc2_hdr->{'CD2_2'}/cos($crota2)*3600); $ima_wfpc2_x_wst = $ima_wfpc2_x_cen+$ima_wfpc2_x_off -90/$ima_wfpc2_x_zoom/$xscale; $ima_wfpc2_x_wsp = $ima_wfpc2_x_cen+$ima_wfpc2_x_off +90/$ima_wfpc2_x_zoom/$xscale; $ima_wfpc2_y_wst = $ima_wfpc2_y_cen+$ima_wfpc2_y_off -90/$ima_wfpc2_y_zoom/$yscale; $ima_wfpc2_y_wsp = $ima_wfpc2_y_cen+$ima_wfpc2_y_off +90/$ima_wfpc2_y_zoom/$yscale; pgwnad($ima_wfpc2_x_wst,$ima_wfpc2_x_wsp, $ima_wfpc2_y_wst,$ima_wfpc2_y_wsp); pgqvp(0,$ima_wfpc2_x_vst,$ima_wfpc2_x_vsp, $ima_wfpc2_y_vst,$ima_wfpc2_y_vsp); pgsci(0); pgrect($ima_wfpc2_x_wst,$ima_wfpc2_x_wsp, $ima_wfpc2_y_wst,$ima_wfpc2_y_wsp); pgsci(1); pgimag($dat_wfpc2_data,$dat_wfpc2_nx,$dat_wfpc2_ny,1,$dat_wfpc2_nx, 1,$dat_wfpc2_ny,$ima_wfpc2_max,$ima_wfpc2_min,$tr); pgbox('BCNST',0.0,0,'BCNST',0.0,0); # Draw 3"x3" NIFS field. pgsci(3); pgsfs(2); pgrect($ima_wfpc2_x_cen-1.5/$xscale,$ima_wfpc2_x_cen+1.5/$xscale, $ima_wfpc2_y_cen-1.5/$yscale,$ima_wfpc2_y_cen+1.5/$yscale); pgsfs(1); # Draw NIFS FOV grid. if ($ima_wfpc2_grid) { pgsci(3); pgsfs(2); foreach $i (-60..61) { $x = $ima_wfpc2_x_cen-1.5/$xscale+$i*3.0/$xscale; if ($x > 0 and $x < $dat_wfpc2_nx) { pgmove($x,0); pgdraw($x,$dat_wfpc2_ny); } } foreach $i (-60..61) { $y = $ima_wfpc2_y_cen-1.5/$yscale+$i*3.0/$yscale; if ($y > 0 and $y < $dat_wfpc2_ny) { pgmove(0,$y); pgdraw($dat_wfpc2_nx,$y); } } pgsfs(1); } # Draw 60" radius ALTAIR field. pgsci(2); Plt_Circle($ima_wfpc2_x_cen,$ima_wfpc2_y_cen,60.0/$xscale); # Draw 90" radius OIWFS field. pgsci(2); Plt_Circle($ima_wfpc2_x_cen,$ima_wfpc2_y_cen,90.0/$xscale); # Draw 12.7" radius pickoff mirror field. pgsci(2); Plt_Circle($ima_wfpc2_x_cen,$ima_wfpc2_y_cen,12.7/$xscale); $x = $ima_wfpc2_x_cen+12.7/$xscale; $y = $ima_wfpc2_y_cen; pgmove($x,$y); $y = $ima_wfpc2_y_cen-90.0/$yscale; pgdraw($x,$y); $x = $ima_wfpc2_x_cen-12.7/$xscale; $y = $ima_wfpc2_y_cen; pgmove($x,$y); $y = $ima_wfpc2_y_cen-90.0/$yscale; pgdraw($x,$y); # Draw 20" radius NGS field. pgsci(4); Plt_Circle($ima_wfpc2_x_cen,$ima_wfpc2_y_cen,20.0/$xscale); # Draw 30" radius LGS field. pgsci(4); Plt_Circle($ima_wfpc2_x_cen,$ima_wfpc2_y_cen,30.0/$xscale); pgsci(1); # Overlay USNO stars. if ($dat_usno_got) { open (IN,"$usno") or die "GS_SEARCH.PL: Cannot open input file $usno!\n"; $size = 5/$xscale; $_ = ; while () { $coord = substr($_,21,23); Mark_USNO($coord,$size,$dat_wfpc2_hdr); } close (IN); } # Overlay AOWFS guide star. if ($dat_aowfs_got) { $size = 3/$xscale; $coord = "$dat_aowfs_ra $dat_aowfs_dec"; Mark_AOWFS($coord,$size,$dat_wfpc2_hdr); } # Overlay OIWFS guide star. if ($dat_oiwfs_got) { $size = 3/$xscale; $coord = "$dat_oiwfs_ra $dat_oiwfs_dec"; Mark_OIWFS($coord,$size,$dat_wfpc2_hdr); } # Draw "Zoom" button. Plt_Button($but_wfpc2_1_x_vst, $but_wfpc2_1_x_vsp, $but_wfpc2_1_y_vst, $but_wfpc2_1_y_vsp, $but_wfpc2_1_lab, $but_wfpc2_1_sta); # Draw "Unzoom" button. Plt_Button($but_wfpc2_2_x_vst, $but_wfpc2_2_x_vsp, $but_wfpc2_2_y_vst, $but_wfpc2_2_y_vsp, $but_wfpc2_2_lab, $but_wfpc2_2_sta); # Draw "Center" button. Plt_Button($but_wfpc2_3_x_vst, $but_wfpc2_3_x_vsp, $but_wfpc2_3_y_vst, $but_wfpc2_3_y_vsp, $but_wfpc2_3_lab, $but_wfpc2_3_sta); # Draw "Range" button. Plt_Button($but_wfpc2_4_x_vst, $but_wfpc2_4_x_vsp, $but_wfpc2_4_y_vst, $but_wfpc2_4_y_vsp, $but_wfpc2_4_lab, $but_wfpc2_4_sta); # Draw "Reset" button. Plt_Button($but_wfpc2_5_x_vst, $but_wfpc2_5_x_vsp, $but_wfpc2_5_y_vst, $but_wfpc2_5_y_vsp, $but_wfpc2_5_lab, $but_wfpc2_5_sta); pgsvp(0,1,0,1); pgswin(0,1,0,1); return; } # Routine to plot a NICMOS image. sub Plt_NICMOS { my ($fil,$ra,$dec) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); my ($xscale, $yscale, $coord, $size, $crota2); my ($tr) = [0,1,0,0,0,1]; my ($fits) = "images/$fil/$fil"."_nicmos.fits"; my ($usno) = "images/$fil/$fil.usno"; $ima_nicmos_x_vst = 0.51; $ima_nicmos_x_vsp = 0.85; $ima_nicmos_y_vst = 0.02; $ima_nicmos_y_vsp = 0.40; $but_nicmos_1_x_vst = 0.86; $but_nicmos_1_x_vsp = 0.97; $but_nicmos_1_y_vst = 0.35; $but_nicmos_1_y_vsp = 0.40; $but_nicmos_1_lab = "Zoom"; $but_nicmos_2_x_vst = 0.86; $but_nicmos_2_x_vsp = 0.97; $but_nicmos_2_y_vst = 0.27; $but_nicmos_2_y_vsp = 0.32; $but_nicmos_2_lab = "Unzoom"; $but_nicmos_3_x_vst = 0.86; $but_nicmos_3_x_vsp = 0.97; $but_nicmos_3_y_vst = 0.19; $but_nicmos_3_y_vsp = 0.24; $but_nicmos_3_lab = "Center"; $but_nicmos_4_x_vst = 0.86; $but_nicmos_4_x_vsp = 0.97; $but_nicmos_4_y_vst = 0.11; $but_nicmos_4_y_vsp = 0.16; $but_nicmos_4_lab = "Range"; $but_nicmos_5_x_vst = 0.86; $but_nicmos_5_x_vsp = 0.97; $but_nicmos_5_y_vst = 0.03; $but_nicmos_5_y_vsp = 0.08; $but_nicmos_5_lab = "Reset"; pgsci(1); # Set color index (default). pgslw(1); # Set line width (1=default). pgscf(2); # Set character font (1=default; 2=roman). pgsch(1.0); # Set character height. # Draw bounding box. pgsvp(0.50,1.00,0.00,0.45); pgswin(0,1,0,1); pgsci(0); pgrect(0,1,0,1); pgsci(1); pgbox('BC',0.0,0,'BC',0.0,0); # Read FITS file. if (! $dat_nicmos_read) { ($dat_nicmos_got,$dat_nicmos_data,$dat_nicmos_nx,$dat_nicmos_ny, $dat_nicmos_hdr,$dat_nicmos_min,$dat_nicmos_max) = Read_FITS($fits); if ($ima_nicmos_min > $ima_nicmos_max) { $ima_nicmos_min = $dat_nicmos_min; $ima_nicmos_max = $dat_nicmos_max; } $dat_nicmos_read = 1; # .true. } if (! $dat_nicmos_got) { pgptxt(0.5,0.92,0.0,0.5,"NICMOS"); pgptxt(0.5,0.5,0.0,0.5,"No NICMOS image available."); $ima_nicmos_min = 0; $ima_nicmos_max = 0; return; } else { $title = $dat_nicmos_hdr->{'FILTER'}; $title = substr($title,1,length($title)-2); $title =~ s/\s{1}//g; pgptxt(0.5,0.92,0.0,0.5,"NICMOS $title"); } # Plot image. pgsch(0.5); pgsvp($ima_nicmos_x_vst,$ima_nicmos_x_vsp, $ima_nicmos_y_vst,$ima_nicmos_y_vsp); $rh = substr($ra, 0,2); $rm = substr($ra, 3,2); $rs = substr($ra, 6,5); $dc = substr($dec,0,1); $dd = substr($dec,1,2); $dm = substr($dec,4,2); $ds = substr($dec,7,4); ($ima_nicmos_x_cen,$ima_nicmos_y_cen) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$dat_nicmos_hdr); # Image scale in arcsec/pixel. $crota2 = atan2($dat_nicmos_hdr->{'CD2_1'},$dat_nicmos_hdr->{'CD1_1'}); $xscale = abs($dat_nicmos_hdr->{'CD1_1'}/cos($crota2)*3600); $yscale = abs($dat_nicmos_hdr->{'CD2_2'}/cos($crota2)*3600); $ima_nicmos_x_wst = $ima_nicmos_x_cen+$ima_nicmos_x_off -90/$ima_nicmos_x_zoom/$xscale; $ima_nicmos_x_wsp = $ima_nicmos_x_cen+$ima_nicmos_x_off +90/$ima_nicmos_x_zoom/$xscale; $ima_nicmos_y_wst = $ima_nicmos_y_cen+$ima_nicmos_y_off -90/$ima_nicmos_y_zoom/$yscale; $ima_nicmos_y_wsp = $ima_nicmos_y_cen+$ima_nicmos_y_off +90/$ima_nicmos_y_zoom/$yscale; pgwnad($ima_nicmos_x_wst,$ima_nicmos_x_wsp, $ima_nicmos_y_wst,$ima_nicmos_y_wsp); pgqvp(0,$ima_nicmos_x_vst,$ima_nicmos_x_vsp, $ima_nicmos_y_vst,$ima_nicmos_y_vsp); pgsci(0); pgrect($ima_nicmos_x_wst,$ima_nicmos_x_wsp, $ima_nicmos_y_wst,$ima_nicmos_y_wsp); pgsci(1); pgimag($dat_nicmos_data,$dat_nicmos_nx,$dat_nicmos_ny,1,$dat_nicmos_nx, 1,$dat_nicmos_ny,$ima_nicmos_max,$ima_nicmos_min,$tr); pgbox('BCNST',0.0,0,'BCNST',0.0,0); # Draw 3"x3" NIFS field. pgsci(3); pgsfs(2); pgrect($ima_nicmos_x_cen-1.5/$xscale,$ima_nicmos_x_cen+1.5/$xscale, $ima_nicmos_y_cen-1.5/$yscale,$ima_nicmos_y_cen+1.5/$yscale); # NIFS_Grid($ima_nicmos_x_cen,$ima_nicmos_y_cen,$xscale,$yscale); pgsfs(1); # Draw NIFS FOV grid. if ($ima_nicmos_grid) { pgsci(3); pgsfs(2); foreach $i (-60..61) { $x = $ima_nicmos_x_cen-1.5/$xscale+$i*3.0/$xscale; if ($x > 0 and $x < $dat_nicmos_nx) { pgmove($x,0); pgdraw($x,$dat_nicmos_ny); } } foreach $i (-60..61) { $y = $ima_nicmos_y_cen-1.5/$yscale+$i*3.0/$yscale; if ($y > 0 and $y < $dat_nicmos_ny) { pgmove(0,$y); pgdraw($dat_nicmos_nx,$y); } } pgsfs(1); } # Draw 60" radius ALTAIR field. pgsci(2); Plt_Circle($ima_nicmos_x_cen,$ima_nicmos_y_cen,60.0/$xscale); # Draw 90" radius OIWFS field. pgsci(2); Plt_Circle($ima_nicmos_x_cen,$ima_nicmos_y_cen,90.0/$xscale); # Draw 12.7" radius pickoff mirror field. pgsci(2); Plt_Circle($ima_nicmos_x_cen,$ima_nicmos_y_cen,12.7/$xscale); $x = $ima_nicmos_x_cen+12.7/$xscale; $y = $ima_nicmos_y_cen; pgmove($x,$y); $y = $ima_nicmos_y_cen-90.0/$yscale; pgdraw($x,$y); $x = $ima_nicmos_x_cen-12.7/$xscale; $y = $ima_nicmos_y_cen; pgmove($x,$y); $y = $ima_nicmos_y_cen-90.0/$yscale; pgdraw($x,$y); # Draw 20" radius NGS field. pgsci(4); Plt_Circle($ima_nicmos_x_cen,$ima_nicmos_y_cen,20.0/$xscale); # Draw 30" radius LGS field. pgsci(4); Plt_Circle($ima_nicmos_x_cen,$ima_nicmos_y_cen,30.0/$xscale); pgsci(1); # Overlay USNO stars. if ($dat_usno_got) { open (IN,"$usno") or die "GS_SEARCH.PL: Cannot open input file $usno!\n"; $size = 5/$xscale; $_ = ; while () { $coord = substr($_,21,23); Mark_USNO($coord,$size,$dat_nicmos_hdr); } close (IN); } # Overlay AOWFS guide star. if ($dat_aowfs_got) { $size = 3/$xscale; $coord = "$dat_aowfs_ra $dat_aowfs_dec"; Mark_AOWFS($coord,$size,$dat_nicmos_hdr); } # Overlay OIWFS guide star. if ($dat_oiwfs_got) { $size = 3/$xscale; $coord = "$dat_oiwfs_ra $dat_oiwfs_dec"; Mark_OIWFS($coord,$size,$dat_nicmos_hdr); } # Draw "Zoom" button. Plt_Button($but_nicmos_1_x_vst, $but_nicmos_1_x_vsp, $but_nicmos_1_y_vst, $but_nicmos_1_y_vsp, $but_nicmos_1_lab, $but_nicmos_1_sta); # Draw "Unzoom" button. Plt_Button($but_nicmos_2_x_vst, $but_nicmos_2_x_vsp, $but_nicmos_2_y_vst, $but_nicmos_2_y_vsp, $but_nicmos_2_lab, $but_nicmos_2_sta); # Draw "Center" button. Plt_Button($but_nicmos_3_x_vst, $but_nicmos_3_x_vsp, $but_nicmos_3_y_vst, $but_nicmos_3_y_vsp, $but_nicmos_3_lab, $but_nicmos_3_sta); # Draw "Range" button. Plt_Button($but_nicmos_4_x_vst, $but_nicmos_4_x_vsp, $but_nicmos_4_y_vst, $but_nicmos_4_y_vsp, $but_nicmos_4_lab, $but_nicmos_4_sta); # Draw "Reset" button. Plt_Button($but_nicmos_5_x_vst, $but_nicmos_5_x_vsp, $but_nicmos_5_y_vst, $but_nicmos_5_y_vsp, $but_nicmos_5_lab, $but_nicmos_5_sta); pgsvp(0,1,0,1); pgswin(0,1,0,1); return; } # Routine to interactively adjust plot parameters. sub Adjust_Plt { my ($fil) = @_; my ($x,$y,$key,$tmp); my ($tab, $con, $bri, $sign); my ($px,$py,$val,$wav,$f0,$cam,$rh,$rm,$rs,$dc,$dd,$dm,$ds); my ($new_ra, $new_dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); $x = ($but_title_3_x_vsp+$but_title_3_x_vst)/2; $y = ($but_title_3_y_vsp+$but_title_3_y_vst)/2; pgcurs($x,$y,$key); while ($key ne "n") { # Title button 1. if ($x > $but_title_1_x_vst and $x < $but_title_1_x_vsp and $y > $but_title_1_y_vst and $y < $but_title_1_y_vsp) { if ($but_title_1_sta == 0) { $but_title_1_sta = 1; Plt_Button($but_title_1_x_vst, $but_title_1_x_vsp, $but_title_1_y_vst, $but_title_1_y_vsp, $but_title_1_lab, $but_title_1_sta); $x = 0.5; $y = 0.1; $tab = $col_tab; $con = $col_con; $bri = $col_bri; $sign = 1; while ($key ne "q" and $key ne "Q") { pgcurs($x,$y,$key); if ($key eq "q" or $key eq "Q") { next; } elsif ($key eq "?") { print "Use cursor to adjust color table:\n". " Key T cycles through available color tables.\n". " Keys 1,2,3,4,5 select different color tables.\n". " Key C changes contrast and brightness, with:\n". " Cursor x position setting brightness and\n". " Cursor y position setting contrast\n". " Hold down C key while moving cursor to change\n". " contrast and brightness continuously.\n". " Key R resets contrast=1.0 and brightness=0.5.\n". " Key - reverses color palette.\n"; } elsif ($key eq "c" or $key eq "C") { $bri = $x; if ($bri < 0) {$bri = 0;} if ($bri > 1) {$bri = 1;} $con = $y; if ($con < 0) {$con = 0;} if ($con > 1) {$con = 1;} } elsif ($key eq "r" or $key eq "R") { $bri = 0.5; $con = 0.1; $x = 0.5; $y = 0.1; } elsif ($key eq "-") { $sign *= -1; } elsif ($key eq "1") { $tab = 1; } elsif ($key eq "2") { $tab = 2; } elsif ($key eq "3") { $tab = 3; } elsif ($key eq "4") { $tab = 4; } elsif ($key eq "5") { $tab = 5; } elsif ($key eq "t" or $key eq "T") { $tab += 1; if ($tab > 5) {$tab = 1;} } elsif ($x > $but_title_1_x_vst and $x < $but_title_1_x_vsp and $y > $but_title_1_y_vst and $y < $but_title_1_y_vsp) { $key = "q"; next; } else { next; } $col_tab = $tab; $col_con = $sign*$con; $col_bri = $bri; Color_Table($col_tab,$col_con,$col_bri); } $but_title_1_sta = 0; Plt_Button($but_title_1_x_vst, $but_title_1_x_vsp, $but_title_1_y_vst, $but_title_1_y_vsp, $but_title_1_lab, $but_title_1_sta); } } # Title button 2. if ($x > $but_title_2_x_vst and $x < $but_title_2_x_vsp and $y > $but_title_2_y_vst and $y < $but_title_2_y_vsp) { if ($but_title_2_sta == 0) { $but_title_2_sta = 1; Plt_Button($but_title_2_x_vst, $but_title_2_x_vsp, $but_title_2_y_vst, $but_title_2_y_vsp, $but_title_2_lab, $but_title_2_sta); # Plot to postscript file. Display_Images($fil,$ra,$dec,2); # Reset plot device to screen. pgslct($pltid); # Send postscript file to printer. if ($printer eq "") { system("lpr images/$fil/$fil.ps"); } else { system("lpr -P$printer images/$fil/$fil.ps"); } $but_title_2_sta = 0; Plt_Button($but_title_2_x_vst, $but_title_2_x_vsp, $but_title_2_y_vst, $but_title_2_y_vsp, $but_title_2_lab, $but_title_2_sta); } } # Title button 3. if ($x > $but_title_3_x_vst and $x < $but_title_3_x_vsp and $y > $but_title_3_y_vst and $y < $but_title_3_y_vsp) { $key = "n"; if ($but_title_3_sta == 0) { $but_title_3_sta = 1; Plt_Button($but_title_3_x_vst, $but_title_3_x_vsp, $but_title_3_y_vst, $but_title_3_y_vsp, $but_title_3_lab, $but_title_3_sta); next; } } # Title button 4. if ($x > $but_title_4_x_vst and $x < $but_title_4_x_vsp and $y > $but_title_4_y_vst and $y < $but_title_4_y_vsp) { # Write object data file. Write_Data($fil); # Report NGS and LGS Y,?,N statistics. if ($ncod) { print "\nGuide Star Statistics:\n"; print "NGS system: Y=$ngs[0]; ?=$ngs[1]; N=$ngs[2]\n"; print "LGS system: Y=$lgs[0]; ?=$lgs[1]; N=$lgs[2]\n\n"; } exit; } # DSS2 image. if ($x > $ima_dss2_x_vst and $x < $ima_dss2_x_vsp and $y > $ima_dss2_y_vst and $y < $ima_dss2_y_vsp) { if (! $dat_dss2_got) {next;} if ($key eq "A") { # Recenter display. $ima_dss2_x_off = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst)-$ima_dss2_x_cen; $ima_dss2_y_off = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst)-$ima_dss2_y_cen; pgbbuf; Plt_DSS2_R($fil,$ra,$dec); pgebuf; } elsif ($key eq "X") { # Print RA and Dec. $px = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst); $py = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst); ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_dss2_hdr); print " $rh:$rm:$rs $dc$dd:$dm:$ds"; if ($px < 0 or $px > $dat_dss2_nx or $py < 0 or $py > $dat_dss2_ny) { print "\n"; } else { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_dss2_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $px $py $val\n"; } } elsif ($key eq "D") { # Change display center coordinate. $px = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst); $py = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst); if ($px > 0 and $px < $dat_dss2_nx or $py > 0 and $py < $dat_dss2_ny) { ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_dss2_hdr); $ra = "$rh:$rm:$rs"; $dec = "$dc$dd:$dm:$ds"; $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_dss2_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $ra $dec $px $py $val\n"; # Replot display. $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; pgbbuf; Plt_Title($obj,$ra,$dec); Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "s") { # Set sky value. $px = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst); $py = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst); if ($px > 0 and $px < $dat_dss2_nx or $py > 0 and $py < $dat_dss2_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $ima_dss2_sky = $dat_dss2_data->[$py][$px]; print "Sky value = $ima_dss2_sky\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "m") { # Report magnitude. $px = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst); $py = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst); if ($px > 0 and $px < $dat_dss2_nx or $py > 0 and $py < $dat_dss2_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_dss2_data->[$py][$px]; $val = -2.5*log10($val-$ima_dss2_sky); # +$dat_dss2_hdr->{'MAGZP'}; print "Surface brightness = $val magnitudes/pixel.\n"; $val = $val-2.5*log10(abs($dat_dss2_hdr->{'CDELT1'})*3600* abs($dat_dss2_hdr->{'CDELT2'})*3600); print " = $val magnitudes/arcsec^2.\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "a") { # Mark AOWFS star. $px = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst); $py = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst); if ($px > 0 and $px < $dat_dss2_nx or $py > 0 and $py < $dat_dss2_ny) { # Get AOWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_dss2_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_aowfs_ra and $new_dec ne $dat_aowfs_dec) { $dat_aowfs_got = 1; $dat_aowfs_ra = $new_ra; $dat_aowfs_dec = $new_dec; } else { $dat_aowfs_got = 0; $dat_aowfs_ra = -100; $dat_aowfs_dec = -100; } } else { $dat_aowfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "o") { # Mark OIWFS star. $px = $ima_dss2_x_wst+($x-$ima_dss2_x_vst)/ ($ima_dss2_x_vsp-$ima_dss2_x_vst)* ($ima_dss2_x_wsp-$ima_dss2_x_wst); $py = $ima_dss2_y_wst+($y-$ima_dss2_y_vst)/ ($ima_dss2_y_vsp-$ima_dss2_y_vst)* ($ima_dss2_y_wsp-$ima_dss2_y_wst); if ($px > 0 and $px < $dat_dss2_nx or $py > 0 and $py < $dat_dss2_ny) { # Get OIWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_dss2_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_oiwfs_ra and $new_dec ne $dat_oiwfs_dec) { $dat_oiwfs_got = 1; $dat_oiwfs_ra = $new_ra; $dat_oiwfs_dec = $new_dec; } else { $dat_oiwfs_got = 0; $dat_oiwfs_ra = -100; $dat_oiwfs_dec = -100; } } else { $dat_oiwfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "g") { # Draw FOV grid. if ($ima_dss2_grid) { $ima_dss2_grid = 0; } else { $ima_dss2_grid = 1; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "$key\n"; } } # DSS2 button 1. if ($x > $but_dss2_1_x_vst and $x < $but_dss2_1_x_vsp and $y > $but_dss2_1_y_vst and $y < $but_dss2_1_y_vsp) { if (! $dat_dss2_got) {next;} if ($but_dss2_1_sta == 0) { $but_dss2_1_sta = 1; Plt_Button($but_dss2_1_x_vst, $but_dss2_1_x_vsp, $but_dss2_1_y_vst, $but_dss2_1_y_vsp, $but_dss2_1_lab, $but_dss2_1_sta); pgbbuf; $ima_dss2_x_zoom *= 2; $ima_dss2_y_zoom *= 2; Plt_DSS2_R($fil,$ra,$dec); $but_dss2_1_sta = 0; pgebuf; Plt_Button($but_dss2_1_x_vst, $but_dss2_1_x_vsp, $but_dss2_1_y_vst, $but_dss2_1_y_vsp, $but_dss2_1_lab, $but_dss2_1_sta); } } # DSS2 button 2. if ($x > $but_dss2_2_x_vst and $x < $but_dss2_2_x_vsp and $y > $but_dss2_2_y_vst and $y < $but_dss2_2_y_vsp) { if (! $dat_dss2_got) {next;} if ($but_dss2_2_sta == 0) { $but_dss2_2_sta = 1; Plt_Button($but_dss2_2_x_vst, $but_dss2_2_x_vsp, $but_dss2_2_y_vst, $but_dss2_2_y_vsp, $but_dss2_2_lab, $but_dss2_2_sta); pgbbuf; $ima_dss2_x_zoom /= 2; $ima_dss2_y_zoom /= 2; Plt_DSS2_R($fil,$ra,$dec); $but_dss2_2_sta = 0; pgebuf; Plt_Button($but_dss2_2_x_vst, $but_dss2_2_x_vsp, $but_dss2_2_y_vst, $but_dss2_2_y_vsp, $but_dss2_2_lab, $but_dss2_2_sta); } } # DSS2 button 3. if ($x > $but_dss2_3_x_vst and $x < $but_dss2_3_x_vsp and $y > $but_dss2_3_y_vst and $y < $but_dss2_3_y_vsp) { if (! $dat_dss2_got) {next;} if ($but_dss2_3_sta == 0) { $but_dss2_3_sta = 1; Plt_Button($but_dss2_3_x_vst, $but_dss2_3_x_vsp, $but_dss2_3_y_vst, $but_dss2_3_y_vsp, $but_dss2_3_lab, $but_dss2_3_sta); pgbbuf; $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; Plt_DSS2_R($fil,$ra,$dec); pgebuf; $but_dss2_3_sta = 0; Plt_Button($but_dss2_3_x_vst, $but_dss2_3_x_vsp, $but_dss2_3_y_vst, $but_dss2_3_y_vsp, $but_dss2_3_lab, $but_dss2_3_sta); } } # DSS2 button 4. if ($x > $but_dss2_4_x_vst and $x < $but_dss2_4_x_vsp and $y > $but_dss2_4_y_vst and $y < $but_dss2_4_y_vsp) { if (! $dat_dss2_got) {next;} if ($but_dss2_4_sta == 0) { $but_dss2_4_sta = 1; Plt_Button($but_dss2_4_x_vst, $but_dss2_4_x_vsp, $but_dss2_4_y_vst, $but_dss2_4_y_vsp, $but_dss2_4_lab, $but_dss2_4_sta); print "Enter minimum value [$ima_dss2_min]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_dss2_min = $tmp; } print "Enter maximum value [$ima_dss2_max]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_dss2_max = $tmp; } pgbbuf; Plt_DSS2_R($fil,$ra,$dec); pgebuf; $but_dss2_4_sta = 0; Plt_Button($but_dss2_4_x_vst, $but_dss2_4_x_vsp, $but_dss2_4_y_vst, $but_dss2_4_y_vsp, $but_dss2_4_lab, $but_dss2_4_sta); } } # DSS2 button 5. if ($x > $but_dss2_5_x_vst and $x < $but_dss2_5_x_vsp and $y > $but_dss2_5_y_vst and $y < $but_dss2_5_y_vsp) { if (! $dat_dss2_got) {next;} if ($but_dss2_5_sta == 0) { $but_dss2_5_sta = 1; Plt_Button($but_dss2_5_x_vst, $but_dss2_5_x_vsp, $but_dss2_5_y_vst, $but_dss2_5_y_vsp, $but_dss2_5_lab, $but_dss2_5_sta); pgbbuf; $col_tab = 1; $col_con = 0.1; $col_bri = 0.5; Color_Table($col_tab,$col_con,$col_bri); $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; $ima_dss2_x_zoom = 1; $ima_dss2_y_zoom = 1; $ima_dss2_min = $dat_dss2_min; $ima_dss2_max = $dat_dss2_max; Plt_DSS2_R($fil,$ra,$dec); $but_dss2_5_sta = 0; pgebuf; Plt_Button($but_dss2_5_x_vst, $but_dss2_5_x_vsp, $but_dss2_5_y_vst, $but_dss2_5_y_vsp, $but_dss2_5_lab, $but_dss2_5_sta); } } # 2MASS image. if ($x > $ima_2mass_x_vst and $x < $ima_2mass_x_vsp and $y > $ima_2mass_y_vst and $y < $ima_2mass_y_vsp) { if (! $dat_2mass_got) {next;} if ($key eq "A") { # Recenter display. $ima_2mass_x_off = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst)-$ima_2mass_x_cen; $ima_2mass_y_off = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst)-$ima_2mass_y_cen; pgbbuf; Plt_2MASS_K($fil,$ra,$dec); pgebuf; } elsif ($key eq "X") { # Print RA and Dec. $px = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst); $py = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst); ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_2mass_hdr); print " $rh:$rm:$rs $dc$dd:$dm:$ds"; if ($px < 0 or $px > $dat_2mass_nx or $py < 0 or $py > $dat_2mass_ny) { print "\n"; } else { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_2mass_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $px $py $val\n"; } } elsif ($key eq "D") { # Change display center coordinate. $px = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst); $py = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst); if ($px > 0 and $px < $dat_2mass_nx or $py > 0 and $py < $dat_2mass_ny) { ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_2mass_hdr); $ra = "$rh:$rm:$rs"; $dec = "$dc$dd:$dm:$ds"; $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_2mass_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $ra $dec $px $py $val\n"; # Replot display. $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; pgbbuf; Plt_Title($obj,$ra,$dec); Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "s") { # Set sky value. $px = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst); $py = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst); if ($px > 0 and $px < $dat_2mass_nx or $py > 0 and $py < $dat_2mass_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $ima_2mass_sky = $dat_2mass_data->[$py][$px]; print "Sky value = $ima_2mass_sky\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "m") { # Report magnitude. $px = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst); $py = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst); if ($px > 0 and $px < $dat_2mass_nx or $py > 0 and $py < $dat_2mass_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_2mass_data->[$py][$px]; $val = -2.5*log10($val-$ima_2mass_sky)+ $dat_2mass_hdr->{'MAGZP'}; print "Surface brightness = $val magnitudes/pixel.\n"; $val = $val-2.5*log10(abs($dat_2mass_hdr->{'CDELT1'})*3600* abs($dat_2mass_hdr->{'CDELT2'})*3600); print " = $val magnitudes/arcsec^2.\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "a") { # Mark AOWFS star. $px = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst); $py = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst); if ($px > 0 and $px < $dat_2mass_nx or $py > 0 and $py < $dat_2mass_ny) { # Get AOWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_2mass_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_aowfs_ra and $new_dec ne $dat_aowfs_dec) { $dat_aowfs_got = 1; $dat_aowfs_ra = $new_ra; $dat_aowfs_dec = $new_dec; } else { $dat_aowfs_got = 0; $dat_aowfs_ra = -100; $dat_aowfs_dec = -100; } } else { $dat_aowfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "o") { # Mark OIWFS star. $px = $ima_2mass_x_wst+($x-$ima_2mass_x_vst)/ ($ima_2mass_x_vsp-$ima_2mass_x_vst)* ($ima_2mass_x_wsp-$ima_2mass_x_wst); $py = $ima_2mass_y_wst+($y-$ima_2mass_y_vst)/ ($ima_2mass_y_vsp-$ima_2mass_y_vst)* ($ima_2mass_y_wsp-$ima_2mass_y_wst); if ($px > 0 and $px < $dat_2mass_nx or $py > 0 and $py < $dat_2mass_ny) { # Get OIWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_2mass_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_oiwfs_ra and $new_dec ne $dat_oiwfs_dec) { $dat_oiwfs_got = 1; $dat_oiwfs_ra = $new_ra; $dat_oiwfs_dec = $new_dec; } else { $dat_oiwfs_got = 0; $dat_oiwfs_ra = -100; $dat_oiwfs_dec = -100; } } else { $dat_oiwfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "g") { # Draw FOV grid. if ($ima_2mass_grid) { $ima_2mass_grid = 0; } else { $ima_2mass_grid = 1; } # Replot display. pgbbuf; Plt_2MASS_K($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "$key\n"; } } # 2MASS button 1. if ($x > $but_2mass_1_x_vst and $x < $but_2mass_1_x_vsp and $y > $but_2mass_1_y_vst and $y < $but_2mass_1_y_vsp) { if (! $dat_2mass_got) {next;} if ($but_2mass_1_sta == 0) { $but_2mass_1_sta = 1; Plt_Button($but_2mass_1_x_vst, $but_2mass_1_x_vsp, $but_2mass_1_y_vst, $but_2mass_1_y_vsp, $but_2mass_1_lab, $but_2mass_1_sta); pgbbuf; $ima_2mass_x_zoom *= 2; $ima_2mass_y_zoom *= 2; Plt_2MASS_K($fil,$ra,$dec); $but_2mass_1_sta = 0; pgebuf; Plt_Button($but_2mass_1_x_vst, $but_2mass_1_x_vsp, $but_2mass_1_y_vst, $but_2mass_1_y_vsp, $but_2mass_1_lab, $but_2mass_1_sta); } } # 2MASS button 2. if ($x > $but_2mass_2_x_vst and $x < $but_2mass_2_x_vsp and $y > $but_2mass_2_y_vst and $y < $but_2mass_2_y_vsp) { if (! $dat_2mass_got) {next;} if ($but_2mass_2_sta == 0) { $but_2mass_2_sta = 1; Plt_Button($but_2mass_2_x_vst, $but_2mass_2_x_vsp, $but_2mass_2_y_vst, $but_2mass_2_y_vsp, $but_2mass_2_lab, $but_2mass_2_sta); pgbbuf; $ima_2mass_x_zoom /= 2; $ima_2mass_y_zoom /= 2; Plt_2MASS_K($fil,$ra,$dec); $but_2mass_2_sta = 0; pgebuf; Plt_Button($but_2mass_2_x_vst, $but_2mass_2_x_vsp, $but_2mass_2_y_vst, $but_2mass_2_y_vsp, $but_2mass_2_lab, $but_2mass_2_sta); } } # 2MASS button 3. if ($x > $but_2mass_3_x_vst and $x < $but_2mass_3_x_vsp and $y > $but_2mass_3_y_vst and $y < $but_2mass_3_y_vsp) { if (! $dat_2mass_got) {next;} if ($but_2mass_3_sta == 0) { $but_2mass_3_sta = 1; Plt_Button($but_2mass_3_x_vst, $but_2mass_3_x_vsp, $but_2mass_3_y_vst, $but_2mass_3_y_vsp, $but_2mass_3_lab, $but_2mass_3_sta); pgbbuf; $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; Plt_2MASS_K($fil,$ra,$dec); pgebuf; $but_2mass_3_sta = 0; Plt_Button($but_2mass_3_x_vst, $but_2mass_3_x_vsp, $but_2mass_3_y_vst, $but_2mass_3_y_vsp, $but_2mass_3_lab, $but_2mass_3_sta); } } # 2MASS button 4. if ($x > $but_2mass_4_x_vst and $x < $but_2mass_4_x_vsp and $y > $but_2mass_4_y_vst and $y < $but_2mass_4_y_vsp) { if (! $dat_2mass_got) {next;} if ($but_2mass_4_sta == 0) { $but_2mass_4_sta = 1; Plt_Button($but_2mass_4_x_vst, $but_2mass_4_x_vsp, $but_2mass_4_y_vst, $but_2mass_4_y_vsp, $but_2mass_4_lab, $but_2mass_4_sta); print "Enter minimum value [$ima_2mass_min]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_2mass_min = $tmp; } print "Enter maximum value [$ima_2mass_max]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_2mass_max = $tmp; } pgbbuf; Plt_2MASS_K($fil,$ra,$dec); pgebuf; $but_2mass_4_sta = 0; Plt_Button($but_2mass_4_x_vst, $but_2mass_4_x_vsp, $but_2mass_4_y_vst, $but_2mass_4_y_vsp, $but_2mass_4_lab, $but_2mass_4_sta); } } # 2MASS button 5. if ($x > $but_2mass_5_x_vst and $x < $but_2mass_5_x_vsp and $y > $but_2mass_5_y_vst and $y < $but_2mass_5_y_vsp) { if (! $dat_2mass_got) {next;} if ($but_2mass_5_sta == 0) { $but_2mass_5_sta = 1; Plt_Button($but_2mass_5_x_vst, $but_2mass_5_x_vsp, $but_2mass_5_y_vst, $but_2mass_5_y_vsp, $but_2mass_5_lab, $but_2mass_5_sta); pgbbuf; $col_tab = 1; $col_con = 0.1; $col_bri = 0.5; Color_Table($col_tab,$col_con,$col_bri); $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; $ima_2mass_x_zoom = 1; $ima_2mass_y_zoom = 1; $ima_2mass_min = $dat_2mass_min; $ima_2mass_max = $dat_2mass_max; Plt_2MASS_K($fil,$ra,$dec); $but_2mass_5_sta = 0; pgebuf; Plt_Button($but_2mass_5_x_vst, $but_2mass_5_x_vsp, $but_2mass_5_y_vst, $but_2mass_5_y_vsp, $but_2mass_5_lab, $but_2mass_5_sta); } } # WFPC2 image. if ($x > $ima_wfpc2_x_vst and $x < $ima_wfpc2_x_vsp and $y > $ima_wfpc2_y_vst and $y < $ima_wfpc2_y_vsp) { if (! $dat_wfpc2_got) {next;} if ($key eq "A") { # Recenter display. $ima_wfpc2_x_off = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst)-$ima_wfpc2_x_cen; $ima_wfpc2_y_off = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst)-$ima_wfpc2_y_cen; pgbbuf; Plt_WFPC2($fil,$ra,$dec); pgebuf; } elsif ($key eq "X") { # Print RA and Dec. $px = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst); $py = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst); ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_wfpc2_hdr); print " $rh:$rm:$rs $dc$dd:$dm:$ds"; if ($px < 0 or $px > $dat_wfpc2_nx or $py < 0 or $py > $dat_wfpc2_ny) { print "\n"; } else { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_wfpc2_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $px $py $val\n"; } } elsif ($key eq "D") { # Change display center coordinate. $px = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst); $py = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst); if ($px > 0 and $px < $dat_wfpc2_nx or $py > 0 and $py < $dat_wfpc2_ny) { ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_wfpc2_hdr); $ra = "$rh:$rm:$rs"; $dec = "$dc$dd:$dm:$ds"; $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_wfpc2_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $ra $dec $px $py $val\n"; # Replot display. $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; pgbbuf; Plt_Title($obj,$ra,$dec); Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "s") { # Set sky value. $px = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst); $py = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst); if ($px > 0 and $px < $dat_wfpc2_nx or $py > 0 and $py < $dat_wfpc2_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $ima_wfpc2_sky = $dat_wfpc2_data->[$py][$px]; print "Sky value = $ima_wfpc2_sky\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "m") { # Report magnitude. $px = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst); $py = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst); if ($px > 0 and $px < $dat_wfpc2_nx or $py > 0 and $py < $dat_wfpc2_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_wfpc2_data->[$py][$px]; $val = -2.5*log10($val-$ima_wfpc2_sky)+ $dat_wfpc2_hdr->{'PHOTZPT'}; print "Surface brightness = $val magnitudes/pixel.\n"; # $val = $val-2.5*log10(abs($dat_wfpc2_hdr->{'CDELT1'})*3600* # abs($dat_wfpc2_hdr->{'CDELT2'})*3600); # print " = $val magnitudes/arcsec^2.\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "a") { # Mark AOWFS star. $px = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst); $py = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst); if ($px > 0 and $px < $dat_wfpc2_nx or $py > 0 and $py < $dat_wfpc2_ny) { # Get AOWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_wfpc2_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_aowfs_ra and $new_dec ne $dat_aowfs_dec) { $dat_aowfs_got = 1; $dat_aowfs_ra = $new_ra; $dat_aowfs_dec = $new_dec; } else { $dat_aowfs_got = 0; $dat_aowfs_ra = -100; $dat_aowfs_dec = -100; } } else { $dat_aowfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "o") { # Mark OIWFS star. $px = $ima_wfpc2_x_wst+($x-$ima_wfpc2_x_vst)/ ($ima_wfpc2_x_vsp-$ima_wfpc2_x_vst)* ($ima_wfpc2_x_wsp-$ima_wfpc2_x_wst); $py = $ima_wfpc2_y_wst+($y-$ima_wfpc2_y_vst)/ ($ima_wfpc2_y_vsp-$ima_wfpc2_y_vst)* ($ima_wfpc2_y_wsp-$ima_wfpc2_y_wst); if ($px > 0 and $px < $dat_wfpc2_nx or $py > 0 and $py < $dat_wfpc2_ny) { # Get OIWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_wfpc2_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_oiwfs_ra and $new_dec ne $dat_oiwfs_dec) { $dat_oiwfs_got = 1; $dat_oiwfs_ra = $new_ra; $dat_oiwfs_dec = $new_dec; } else { $dat_oiwfs_got = 0; $dat_oiwfs_ra = -100; $dat_oiwfs_dec = -100; } } else { $dat_oiwfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "g") { # Draw FOV grid. if ($ima_wfpc2_grid) { $ima_wfpc2_grid = 0; } else { $ima_wfpc2_grid = 1; } # Replot display. pgbbuf; Plt_WFPC2($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "$key\n"; } } # WFPC2 button 1. if ($x > $but_wfpc2_1_x_vst and $x < $but_wfpc2_1_x_vsp and $y > $but_wfpc2_1_y_vst and $y < $but_wfpc2_1_y_vsp) { if (! $dat_wfpc2_got) {next;} if ($but_wfpc2_1_sta == 0) { $but_wfpc2_1_sta = 1; Plt_Button($but_wfpc2_1_x_vst, $but_wfpc2_1_x_vsp, $but_wfpc2_1_y_vst, $but_wfpc2_1_y_vsp, $but_wfpc2_1_lab, $but_wfpc2_1_sta); pgbbuf; $ima_wfpc2_x_zoom *= 2; $ima_wfpc2_y_zoom *= 2; Plt_WFPC2($fil,$ra,$dec); $but_wfpc2_1_sta = 0; pgebuf; Plt_Button($but_wfpc2_1_x_vst, $but_wfpc2_1_x_vsp, $but_wfpc2_1_y_vst, $but_wfpc2_1_y_vsp, $but_wfpc2_1_lab, $but_wfpc2_1_sta); } } # WFPC2 button 2. if ($x > $but_wfpc2_2_x_vst and $x < $but_wfpc2_2_x_vsp and $y > $but_wfpc2_2_y_vst and $y < $but_wfpc2_2_y_vsp) { if (! $dat_wfpc2_got) {next;} if ($but_wfpc2_2_sta == 0) { $but_wfpc2_2_sta = 1; Plt_Button($but_wfpc2_2_x_vst, $but_wfpc2_2_x_vsp, $but_wfpc2_2_y_vst, $but_wfpc2_2_y_vsp, $but_wfpc2_2_lab, $but_wfpc2_2_sta); pgbbuf; $ima_wfpc2_x_zoom /= 2; $ima_wfpc2_y_zoom /= 2; Plt_WFPC2($fil,$ra,$dec); $but_wfpc2_2_sta = 0; pgebuf; Plt_Button($but_wfpc2_2_x_vst, $but_wfpc2_2_x_vsp, $but_wfpc2_2_y_vst, $but_wfpc2_2_y_vsp, $but_wfpc2_2_lab, $but_wfpc2_2_sta); } } # WFPC2 button 3. if ($x > $but_wfpc2_3_x_vst and $x < $but_wfpc2_3_x_vsp and $y > $but_wfpc2_3_y_vst and $y < $but_wfpc2_3_y_vsp) { if (! $dat_wfpc2_got) {next;} if ($but_wfpc2_3_sta == 0) { $but_wfpc2_3_sta = 1; Plt_Button($but_wfpc2_3_x_vst, $but_wfpc2_3_x_vsp, $but_wfpc2_3_y_vst, $but_wfpc2_3_y_vsp, $but_wfpc2_3_lab, $but_wfpc2_3_sta); pgbbuf; $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; Plt_WFPC2($fil,$ra,$dec); pgebuf; $but_wfpc2_3_sta = 0; Plt_Button($but_wfpc2_3_x_vst, $but_wfpc2_3_x_vsp, $but_wfpc2_3_y_vst, $but_wfpc2_3_y_vsp, $but_wfpc2_3_lab, $but_wfpc2_3_sta); } } # WFPC2 button 4. if ($x > $but_wfpc2_4_x_vst and $x < $but_wfpc2_4_x_vsp and $y > $but_wfpc2_4_y_vst and $y < $but_wfpc2_4_y_vsp) { if (! $dat_wfpc2_got) {next;} if ($but_wfpc2_4_sta == 0) { $but_wfpc2_4_sta = 1; Plt_Button($but_wfpc2_4_x_vst, $but_wfpc2_4_x_vsp, $but_wfpc2_4_y_vst, $but_wfpc2_4_y_vsp, $but_wfpc2_4_lab, $but_wfpc2_4_sta); print "Enter minimum value [$ima_wfpc2_min]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_wfpc2_min = $tmp; } print "Enter maximum value [$ima_wfpc2_max]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_wfpc2_max = $tmp; } pgbbuf; Plt_WFPC2($fil,$ra,$dec); pgebuf; $but_wfpc2_4_sta = 0; Plt_Button($but_wfpc2_4_x_vst, $but_wfpc2_4_x_vsp, $but_wfpc2_4_y_vst, $but_wfpc2_4_y_vsp, $but_wfpc2_4_lab, $but_wfpc2_4_sta); } } # WFPC2 button 5. if ($x > $but_wfpc2_5_x_vst and $x < $but_wfpc2_5_x_vsp and $y > $but_wfpc2_5_y_vst and $y < $but_wfpc2_5_y_vsp) { if (! $dat_wfpc2_got) {next;} if ($but_wfpc2_5_sta == 0) { $but_wfpc2_5_sta = 1; Plt_Button($but_wfpc2_5_x_vst, $but_wfpc2_5_x_vsp, $but_wfpc2_5_y_vst, $but_wfpc2_5_y_vsp, $but_wfpc2_5_lab, $but_wfpc2_5_sta); pgbbuf; $col_tab = 1; $col_con = 0.1; $col_bri = 0.5; Color_Table($col_tab,$col_con,$col_bri); $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; $ima_wfpc2_x_zoom = 1; $ima_wfpc2_y_zoom = 1; $ima_wfpc2_min = $dat_wfpc2_min; $ima_wfpc2_max = $dat_wfpc2_max; Plt_WFPC2($fil,$ra,$dec); $but_wfpc2_5_sta = 0; pgebuf; Plt_Button($but_wfpc2_5_x_vst, $but_wfpc2_5_x_vsp, $but_wfpc2_5_y_vst, $but_wfpc2_5_y_vsp, $but_wfpc2_5_lab, $but_wfpc2_5_sta); } } # NICMOS image. if ($x > $ima_nicmos_x_vst and $x < $ima_nicmos_x_vsp and $y > $ima_nicmos_y_vst and $y < $ima_nicmos_y_vsp) { if (! $dat_nicmos_got) {next;} if ($key eq "A") { # Recenter display. $ima_nicmos_x_off = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst)-$ima_nicmos_x_cen; $ima_nicmos_y_off = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst)-$ima_nicmos_y_cen; pgbbuf; Plt_NICMOS($fil,$ra,$dec); pgebuf; } elsif ($key eq "X") { # Print RA and Dec. $px = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst); $py = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst); ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_nicmos_hdr); print " $rh:$rm:$rs $dc$dd:$dm:$ds"; if ($px < 0 or $px > $dat_nicmos_nx or $py < 0 or $py > $dat_nicmos_ny) { print "\n"; } else { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_nicmos_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $px $py $val\n"; } } elsif ($key eq "D") { # Change display center coordinate. $px = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst); $py = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst); if ($px > 0 and $px < $dat_nicmos_nx or $py > 0 and $py < $dat_nicmos_ny) { ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_nicmos_hdr); $ra = "$rh:$rm:$rs"; $dec = "$dc$dd:$dm:$ds"; $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_nicmos_data->[$py][$px]; $px += 1; $py += 1; $px = sprintf("%3.0d",$px); $py = sprintf("%3.0d",$py); print " $ra $dec $px $py $val\n"; # Replot display. $ima_dss2_x_off = 0; $ima_dss2_y_off = 0; $ima_2mass_x_off = 0; $ima_2mass_y_off = 0; $ima_wfpc2_x_off = 0; $ima_wfpc2_y_off = 0; $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; pgbbuf; Plt_Title($obj,$ra,$dec); Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "s") { # Set sky value. $px = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst); $py = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst); if ($px > 0 and $px < $dat_nicmos_nx or $py > 0 and $py < $dat_nicmos_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $ima_nicmos_sky = $dat_nicmos_data->[$py][$px]; print "Sky value = $ima_nicmos_sky\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "m") { # Report magnitude. $px = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst); $py = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst); if ($px > 0 and $px < $dat_nicmos_nx or $py > 0 and $py < $dat_nicmos_ny) { $px = int($px+0.5)-1; $py = int($py+0.5)-1; $val = $dat_nicmos_data->[$py][$px]; $cam = substr($dat_nicmos_hdr->{'APERTURE'},1,4); $val = ($val-$ima_nicmos_sky)*$dat_nicmos_hdr->{'PHOTFNU'}; $wav = $dat_nicmos_hdr->{'PHOTPLAM'}/10000.0; $f0 = 5513.15/$wav**3/(exp(1.2848/$wav)-1.0); $val = -2.5*log10($val/$f0); if ($cam eq "NIC1") { $val += 6.833; } elsif ($cam eq "NIC2") { $val += 5.625; } elsif ($cam eq "NIC3") { $val += 3.495; } else { die "GS_SEARCH.PL: Invalid NICMOS camera $cam.\n"; } $val = sprintf("%6.3f",$val); print "Surface brightness = $val magnitudes/pixel.\n"; if ($cam eq "NIC1") { $val -= 6.833; } elsif ($cam eq "NIC2") { $val -= 5.625; } elsif ($cam eq "NIC3") { $val -= 3.495; } else { die "GS_SEARCH.PL: Invalid NICMOS camera $cam.\n"; } $val = sprintf("%6.3f",$val); print " = $val magnitudes/arcsec^2.\n"; $val += 3.495; $val = sprintf("%6.3f",$val); print " = $val magnitudes/0.2\"x0.2\".\n"; } else { print "GS_SEARCH.PL: Coordinate is outside image!\n"; } } elsif ($key eq "a") { # Mark AOWFS star. $px = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst); $py = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst); if ($px > 0 and $px < $dat_nicmos_nx or $py > 0 and $py < $dat_nicmos_ny) { # Get AOWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_nicmos_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_aowfs_ra and $new_dec ne $dat_aowfs_dec) { $dat_aowfs_got = 1; $dat_aowfs_ra = $new_ra; $dat_aowfs_dec = $new_dec; } else { $dat_aowfs_got = 0; $dat_aowfs_ra = -100; $dat_aowfs_dec = -100; } } else { $dat_aowfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "o") { # Mark OIWFS star. $px = $ima_nicmos_x_wst+($x-$ima_nicmos_x_vst)/ ($ima_nicmos_x_vsp-$ima_nicmos_x_vst)* ($ima_nicmos_x_wsp-$ima_nicmos_x_wst); $py = $ima_nicmos_y_wst+($y-$ima_nicmos_y_vst)/ ($ima_nicmos_y_vsp-$ima_nicmos_y_vst)* ($ima_nicmos_y_wsp-$ima_nicmos_y_wst); if ($px > 0 and $px < $dat_nicmos_nx or $py > 0 and $py < $dat_nicmos_ny) { # Get OIWFS star RA and Dec. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = XY2RaDec_CD($px,$py,$dat_nicmos_hdr); $new_ra = "$rh:$rm:$rs"; $new_dec = "$dc$dd:$dm:$ds"; if ($new_ra ne $dat_oiwfs_ra and $new_dec ne $dat_oiwfs_dec) { $dat_oiwfs_got = 1; $dat_oiwfs_ra = $new_ra; $dat_oiwfs_dec = $new_dec; } else { $dat_oiwfs_got = 0; $dat_oiwfs_ra = -100; $dat_oiwfs_dec = -100; } } else { $dat_oiwfs_got = 0; } # Replot display. pgbbuf; Plt_DSS2_R($fil,$ra,$dec); Plt_2MASS_K($fil,$ra,$dec); Plt_WFPC2($fil,$ra,$dec); Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } elsif ($key eq "g") { # Draw FOV grid. if ($ima_nicmos_grid) { $ima_nicmos_grid = 0; } else { $ima_nicmos_grid = 1; } # Replot display. pgbbuf; Plt_NICMOS($fil,$ra,$dec); pgsvp(0,1,0,1); pgswin(0,1,0,1); pgebuf; } else { print "$key\n"; } } # NICMOS button 1. if ($x > $but_nicmos_1_x_vst and $x < $but_nicmos_1_x_vsp and $y > $but_nicmos_1_y_vst and $y < $but_nicmos_1_y_vsp) { if (! $dat_nicmos_got) {next;} if ($but_nicmos_1_sta == 0) { $but_nicmos_1_sta = 1; Plt_Button($but_nicmos_1_x_vst, $but_nicmos_1_x_vsp, $but_nicmos_1_y_vst, $but_nicmos_1_y_vsp, $but_nicmos_1_lab, $but_nicmos_1_sta); pgbbuf; $ima_nicmos_x_zoom *= 2; $ima_nicmos_y_zoom *= 2; Plt_NICMOS($fil,$ra,$dec); $but_nicmos_1_sta = 0; pgebuf; Plt_Button($but_nicmos_1_x_vst, $but_nicmos_1_x_vsp, $but_nicmos_1_y_vst, $but_nicmos_1_y_vsp, $but_nicmos_1_lab, $but_nicmos_1_sta); } } # NICMOS button 2. if ($x > $but_nicmos_2_x_vst and $x < $but_nicmos_2_x_vsp and $y > $but_nicmos_2_y_vst and $y < $but_nicmos_2_y_vsp) { if (! $dat_nicmos_got) {next;} if ($but_nicmos_2_sta == 0) { $but_nicmos_2_sta = 1; Plt_Button($but_nicmos_2_x_vst, $but_nicmos_2_x_vsp, $but_nicmos_2_y_vst, $but_nicmos_2_y_vsp, $but_nicmos_2_lab, $but_nicmos_2_sta); pgbbuf; $ima_nicmos_x_zoom /= 2; $ima_nicmos_y_zoom /= 2; Plt_NICMOS($fil,$ra,$dec); $but_nicmos_2_sta = 0; pgebuf; Plt_Button($but_nicmos_2_x_vst, $but_nicmos_2_x_vsp, $but_nicmos_2_y_vst, $but_nicmos_2_y_vsp, $but_nicmos_2_lab, $but_nicmos_2_sta); } } # NICMOS button 3. if ($x > $but_nicmos_3_x_vst and $x < $but_nicmos_3_x_vsp and $y > $but_nicmos_3_y_vst and $y < $but_nicmos_3_y_vsp) { if (! $dat_nicmos_got) {next;} if ($but_nicmos_3_sta == 0) { $but_nicmos_3_sta = 1; Plt_Button($but_nicmos_3_x_vst, $but_nicmos_3_x_vsp, $but_nicmos_3_y_vst, $but_nicmos_3_y_vsp, $but_nicmos_3_lab, $but_nicmos_3_sta); pgbbuf; $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; Plt_NICMOS($fil,$ra,$dec); pgebuf; $but_nicmos_3_sta = 0; Plt_Button($but_nicmos_3_x_vst, $but_nicmos_3_x_vsp, $but_nicmos_3_y_vst, $but_nicmos_3_y_vsp, $but_nicmos_3_lab, $but_nicmos_3_sta); } } # NICMOS button 4. if ($x > $but_nicmos_4_x_vst and $x < $but_nicmos_4_x_vsp and $y > $but_nicmos_4_y_vst and $y < $but_nicmos_4_y_vsp) { if (! $dat_nicmos_got) {next;} if ($but_nicmos_4_sta == 0) { $but_nicmos_4_sta = 1; Plt_Button($but_nicmos_4_x_vst, $but_nicmos_4_x_vsp, $but_nicmos_4_y_vst, $but_nicmos_4_y_vsp, $but_nicmos_4_lab, $but_nicmos_4_sta); print "Enter minimum value [$ima_nicmos_min]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_nicmos_min = $tmp; } print "Enter maximum value [$ima_nicmos_max]: "; $tmp = ; if ($tmp ne "\n") { chomp $tmp; $ima_nicmos_max = $tmp; } pgbbuf; Plt_NICMOS($fil,$ra,$dec); pgebuf; $but_nicmos_4_sta = 0; Plt_Button($but_nicmos_4_x_vst, $but_nicmos_4_x_vsp, $but_nicmos_4_y_vst, $but_nicmos_4_y_vsp, $but_nicmos_4_lab, $but_nicmos_4_sta); } } # NICMOS button 5. if ($x > $but_nicmos_5_x_vst and $x < $but_nicmos_5_x_vsp and $y > $but_nicmos_5_y_vst and $y < $but_nicmos_5_y_vsp) { if (! $dat_nicmos_got) {next;} if ($but_nicmos_5_sta == 0) { $but_nicmos_5_sta = 1; Plt_Button($but_nicmos_5_x_vst, $but_nicmos_5_x_vsp, $but_nicmos_5_y_vst, $but_nicmos_5_y_vsp, $but_nicmos_5_lab, $but_nicmos_5_sta); pgbbuf; $col_tab = 1; $col_con = 0.1; $col_bri = 0.5; Color_Table($col_tab,$col_con,$col_bri); $ima_nicmos_x_off = 0; $ima_nicmos_y_off = 0; $ima_nicmos_x_zoom = 1; $ima_nicmos_y_zoom = 1; $ima_nicmos_min = $dat_nicmos_min; $ima_nicmos_max = $dat_nicmos_max; Plt_NICMOS($fil,$ra,$dec); $but_nicmos_5_sta = 0; pgebuf; Plt_Button($but_nicmos_5_x_vst, $but_nicmos_5_x_vsp, $but_nicmos_5_y_vst, $but_nicmos_5_y_vsp, $but_nicmos_5_lab, $but_nicmos_5_sta); } } pgcurs($x,$y,$key); } $but_title_3_sta = 0; Plt_Button($but_title_3_x_vst, $but_title_3_x_vsp, $but_title_3_y_vst, $but_title_3_y_vsp, $but_title_3_lab, $but_title_3_sta); return; } # Routine to draw a circle. sub Plt_Circle { my ($x0,$y0,$rad) = @_; my ($i,$x,$y); $x = $x0; $y = $y0+$rad; pgmove($x,$y); foreach $i (0..360) { $x = $x0+$rad*sin($i/180.0*3.1415925); $y = $y0+$rad*cos($i/180.0*3.1415925); pgdraw($x,$y); } return; } sub Plt_Button { my ($xst,$xsp,$yst,$ysp,$label,$mode) = @_; my ($vx1,$vx2,$vy1,$vy2); my ($wx1,$wx2,$wy1,$wy2); # Save current viewport and window. pgqvp(0,$vx1,$vx2,$vy1,$vy2); pgqwin($wx1,$wx2,$wy1,$wy2); # Set viewport and window. pgsvp($xst,$xsp,$yst,$ysp); pgswin(0,1,0,1); # Plot button. pgsch(1); if ($mode == 0) { pgsci(10); pgsfs(1); pgrect(0,1,0,1); pgsci(1); pgsfs(2); pgrect(0,1,0,1); pgptxt(0.5,0.3,0.0,0.5,$label); } else { pgsci(1); pgsfs(1); pgrect(0,1,0,1); pgsci(10); pgptxt(0.5,0.3,0.0,0.5,$label); } pgsci(1); pgsfs(1); pgsch(1); # Reset viewport and window. pgsvp($vx1,$vx2,$vy1,$vy2); pgswin($wx1,$wx2,$wy1,$wy2); return; } # Routine to mark USNO stars on image. sub Mark_USNO { my ($coord,$size,$header) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); $rh = substr($coord, 0,2); $rm = substr($coord, 3,2); $rs = substr($coord, 6,5); $dc = substr($coord,12,1); $dd = substr($coord,13,2); $dm = substr($coord,16,2); $ds = substr($coord,19,4); ($x,$y) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$header); pgsci(8); pgslw(2); pgmove($x-$size,$y-$size); pgdraw($x+$size,$y-$size); pgdraw($x+$size,$y+$size); pgdraw($x-$size,$y+$size); pgdraw($x-$size,$y-$size); pgsci(1); pgslw(1); return; } # Routine to mark AOWFS star on image. sub Mark_AOWFS { my ($coord,$size,$header) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); $rh = substr($coord, 0,2); $rm = substr($coord, 3,2); $rs = substr($coord, 6,5); $dc = substr($coord,12,1); $dd = substr($coord,13,2); $dm = substr($coord,16,2); $ds = substr($coord,19,4); ($x,$y) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$header); pgsci(3); pgslw(2); pgmove($x-$size/2.0,$y-0.289*$size); pgdraw($x+$size/2.0,$y-0.289*$size); pgdraw($x,$y+$size/1.732); pgdraw($x-$size/2.0,$y-0.289*$size); pgsci(1); pgslw(1); return; } # Routine to mark OIWFS star on image. sub Mark_OIWFS { my ($coord,$size,$header) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$x,$y); $rh = substr($coord, 0,2); $rm = substr($coord, 3,2); $rs = substr($coord, 6,5); $dc = substr($coord,12,1); $dd = substr($coord,13,2); $dm = substr($coord,16,2); $ds = substr($coord,19,4); ($x,$y) = RaDec2XY_CD($rh,$rm,$rs,$dc,$dd,$dm,$ds,$header); pgsci(3); pgslw(2); Plt_Circle($x,$y,$size/2.0); pgsci(1); pgslw(1); return; } # Routine to read a FITS format file. sub Read_FITS { my ($file) = @_; my ($array,$naxis1,$naxis2,$header); my ($fptr, $naxes, $anynul); my ($min) = 1; my ($max) = 0; my ($status) = 0; # Open FITS file. $fptr = CFITSIO::open_file($file,CFITSIO::READONLY(),$status); Check_Status($status) or return (0,$array,$naxis1,$naxis2,$header,$min,$max); # Read image dimensions. $fptr->get_img_parm(undef,undef,$naxes,$status); Check_Status($status) or return (0,$array,$naxis1,$naxis2,$header,$min,$max); ($naxis1,$naxis2) = @{$naxes}; # Read data array. $fptr->read_2d_lng(1,0,$naxis1,$naxis1,$naxis2,$array,$anynul,$status); Check_Status($status) or return (0,$array,$naxis1,$naxis2,$header,$min,$max); # Read header key/value to a hash. ($header,$status) = $fptr->read_header; Check_Status($status) or return (0,$array,$naxis1,$naxis2,$header,$min,$max); # Close FITS file. $fptr->close_file($status); Check_Status($status) or return (0,$array,$naxis1,$naxis2,$header,$min,$max); ($min,$max) = MinMax($array,$naxis1,$naxis1); # print "Size of FITS array $#$array\n"; return (1,$array,$naxis1,$naxis2,$header,$min,$max); } # Routine to check CFITSIO status. sub Check_Status { my ($status) = shift; my ($error); if ($status != 0) { return 0; } return 1; } # Routine to return the minimum and maximum data value. sub MinMax { my ($array,$nx,$ny) = @_; my ($val, $mean, $sigma); my ($n) = 0; my ($sum) = 0; my ($sumsq) = 0; my ($min) = +1.e+30; my ($max) = -1.e+30; foreach my $i (0..$nx-1) { foreach my $j (0..$ny-1) { if (defined($array->[$j][$i])) { $val = $array->[$j][$i]; $n += 1; $sum += $val; $sumsq += $val*$val; if ($val < $min) {$min = $val;} if ($val > $max) {$max = $val;} } } } if ($n > 2) { $mean = $sum/$n; $sigma = sqrt(($sumsq-$n*$mean**2)/($n-1)); $min = $mean-5*$sigma; $val = $mean+10*$sigma; if ($val < $max) {$max = $val;} } return ($min,$max); } # Routine to convert pixel number to RA and Dec using FITS CD matrix. sub XY2RaDec_CD { my ($x,$y,$header) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds); my ($cd1_1, $cd1_2, $cd2_1, $cd2_2); my ($cdelt1, $cdelt2, $crota1, $crota2); my ($ra, $dec); my ($pi) = 3.14159265359; # Get CD matrix elements. # Get CD matrix elements. if (defined ($header->{'CD1_1'}) and defined ($header->{'CD2_2'})) { $cd1_1 = $header->{'CD1_1'}; $cd2_2 = $header->{'CD2_2'}; if (defined ($header->{'CD1_2'})) { $cd1_2 = $header->{'CD1_2'}; } else { $cd1_2 = 0.0; } if (defined ($header->{'CD2_1'})) { $cd2_1 = $header->{'CD2_1'}; } else { $cd2_1 = 0.0; } } elsif (defined ($header->{'CDELT1'}) and defined ($header->{'CDELT2'})) { $cdelt1 = $header->{'CDELT1'}; $cdelt2 = $header->{'CDELT2'}; if (defined ($header->{'CROTA1'})) { $crota1 = $header->{'CROTA1'}; } else { $crota1 = 0.0; } if (defined ($header->{'CROTA2'})) { $crota2 = $header->{'CROTA2'}; } else { $crota2 = 0.0; } $cd1_1 = $cdelt1*cos($crota2*$pi/180); $cd1_2 = -$cdelt2*sin($crota2*$pi/180); $cd2_1 = $cdelt1*sin($crota2*$pi/180); $cd2_2 = $cdelt2*cos($crota2*$pi/180); } else { print "GS_SEARCH.PL: Cannot access WCS information!\n"; $rh = 0; $rm = 0; $rs = 0; $dc = '-'; $dd = 0; $dm = 0; $ds = 0; return ($rh,$rm,$rs,$dc,$dd,$dm,$ds); } # Convert to pixel coordinates relative to the reference pixel. $x -= $header->{'CRPIX1'}; $y -= $header->{'CRPIX2'}; # Use CD matrix to convert to RA and Dec offsets in degrees. if (substr($header->{'CTYPE1'},1,4) eq "RA--") { $ra = $cd1_1*$x+$cd1_2*$y; $dec = $cd2_1*$x+$cd2_2*$y; } else { $ra = $cd2_1*$x+$cd2_2*$y; $dec = $cd1_1*$x+$cd1_2*$y; } # Convert to absolute RA and Dec. if (substr($header->{'CTYPE1'},1,4) eq "RA--") { $dec += $header->{'CRVAL2'}; $ra /= cos($dec*$pi/180); $ra += $header->{'CRVAL1'}; } else { $dec += $header->{'CRVAL1'}; $ra /= cos($dec*$pi/180); $ra += $header->{'CRVAL2'}; } # Convert RA and Dec from degrees to hms. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = Deg2HMS($ra,$dec); $rh = sprintf ("%02.0d",$rh); $rm = sprintf ("%02.0d",$rm); $rs = sprintf ("%05.2f",$rs); $dd = sprintf ("%02.0d",$dd); $dm = sprintf ("%02.0d",$dm); $ds = sprintf ("%04.1f",$ds); return ($rh,$rm,$rs,$dc,$dd,$dm,$ds); } # Routine to convert RA and Dec to pixel number using FITS CD matrix. sub RaDec2XY_CD { my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$header) = @_; my ($x,$y); my ($cd1_1, $cd1_2, $cd2_1, $cd2_2); my ($iv1_1, $iv1_2, $iv2_1, $iv2_2); my ($cdelt1, $cdelt2, $crota1, $crota2); my ($ra, $dec, $det); my ($pi) = 3.14159265359; # Get CD matrix elements. if (defined ($header->{'CD1_1'}) and defined ($header->{'CD2_2'})) { $cd1_1 = $header->{'CD1_1'}; $cd2_2 = $header->{'CD2_2'}; if (defined ($header->{'CD1_2'})) { $cd1_2 = $header->{'CD1_2'}; } else { $cd1_2 = 0.0; } if (defined ($header->{'CD2_1'})) { $cd2_1 = $header->{'CD2_1'}; } else { $cd2_1 = 0.0; } } elsif (defined ($header->{'CDELT1'}) and defined ($header->{'CDELT2'})) { $cdelt1 = $header->{'CDELT1'}; $cdelt2 = $header->{'CDELT2'}; if (defined ($header->{'CROTA1'})) { $crota1 = $header->{'CROTA1'}; } else { $crota1 = 0.0; } if (defined ($header->{'CROTA2'})) { $crota2 = $header->{'CROTA2'}; } else { $crota2 = 0.0; } $cd1_1 = $cdelt1*cos($crota2*$pi/180); $cd1_2 = -$cdelt2*sin($crota2*$pi/180); $cd2_1 = $cdelt1*sin($crota2*$pi/180); $cd2_2 = $cdelt2*cos($crota2*$pi/180); } else { print "GS_SEARCH.PL: Cannot access WCS information!\n"; $x = 0; $y = 0; return ($x,$y); } # Form inverse of CD matrix. $det = $cd1_1*$cd2_2-$cd1_2*$cd2_1; $iv1_1 = $cd2_2/$det; $iv1_2 = -$cd1_2/$det; $iv2_1 = -$cd2_1/$det; $iv2_2 = $cd1_1/$det; # Convert RA and Dec to degrees. $ra = $rh+$rm/60+$rs/3600; $ra *= 15; if ($ra >= 360) {$ra -= 360} $dec = $dd+$dm/60+$ds/3600; if ($dc eq "-") {$dec *= -1;} # Convert to RA and Dec relative to the reference pixel. if (substr($header->{'CTYPE1'},1,4) eq "RA--") { $ra -= $header->{'CRVAL1'}; $ra *= cos($dec*$pi/180); $dec -= $header->{'CRVAL2'}; } else { $ra -= $header->{'CRVAL2'}; $ra *= cos($dec*$pi/180); $dec -= $header->{'CRVAL1'}; } # Use IV matrix to convert to X,Y pixel offsets. if (substr($header->{'CTYPE1'},1,4) eq "RA--") { $x = $iv1_1*$ra+$iv1_2*$dec; $y = $iv2_1*$ra+$iv2_2*$dec; } else { $x = $iv1_1*$dec+$iv1_2*$ra; $y = $iv2_1*$dec+$iv2_2*$ra; } # Convert to absolute pixel coordinates. $x += $header->{'CRPIX1'}; $y += $header->{'CRPIX2'}; return ($x,$y); } # Routine to convert pixel number on a DSS-2 FITS image to RA and Dec. sub XY2RaDec_DSS { my ($x,$y,$header) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds); my ($arcsec_per_radian) = 206264.80625; my ($pi) = 3.14159265359; # Convert to DSS pixel coordinates relative to the plate center. my ($ox) = $x+$header->{'CNPIX1'}+0.5; my ($oy) = $y+$header->{'CNPIX2'}+0.5; # Convert from pixels to mm from plate center. $ox = ($header->{'PPO3'}-$ox*$header->{'XPIXELSZ'})/1000; $oy = ($oy*$header->{'YPIXELSZ'}-$header->{'PPO6'})/1000; my ($ox2) = $ox*$ox; my ($oy2) = $oy*$oy; my ($ox3) = $ox*$ox2; my ($oy3) = $oy*$oy2; # Compute standard coordinates, xi and eta in arcsec, from X,Y and # plate model. my ($obj_xi) = $header->{'AMDX1' }*$ox + $header->{'AMDX2' }*$oy + $header->{'AMDX3' } + $header->{'AMDX4' }*$ox2 + $header->{'AMDX5' }*$ox*$oy + $header->{'AMDX6' }*$oy2 + $header->{'AMDX7' }*($ox2+$oy2) + $header->{'AMDX8' }*$ox3 + $header->{'AMDX9' }*$ox2*$oy + $header->{'AMDX10'}*$ox*$oy2 + $header->{'AMDX11'}*$oy3 + $header->{'AMDX12'}*$ox*($ox2+$oy2) + $header->{'AMDX13'}*$ox*($ox2+$oy2)*($ox2*$oy2); my ($obj_eta) = $header->{'AMDY1' }*$oy + $header->{'AMDY2' }*$ox + $header->{'AMDY3' } + $header->{'AMDY4' }*$oy2 + $header->{'AMDY5' }*$oy*$ox + $header->{'AMDY6' }*$ox2 + $header->{'AMDY7' }*($oy2+$ox2) + $header->{'AMDY8' }*$oy3 + $header->{'AMDY9' }*$oy2*$ox + $header->{'AMDY10'}*$oy*$ox2 + $header->{'AMDY11'}*$ox3 + $header->{'AMDY12'}*$oy*($oy2+$ox2) + $header->{'AMDY13'}*$oy*($oy2+$ox2)*($oy2*$ox2); # Convert xi and eta to radians. $obj_xi /= $arcsec_per_radian; $obj_eta /= $arcsec_per_radian; # Convert plate center RA and Dec to radians. my ($rac_rad) = $header->{'PLTRAH'}+ $header->{'PLTRAM'}/60+ $header->{'PLTRAS'}/3600; $rac_rad *= $pi/12; if ($rac_rad > $pi) {$rac_rad -= 2*$pi;} my ($decc_rad) = $header->{'PLTDECD'}+ $header->{'PLTDECM'}/60+ $header->{'PLTDECS'}/3600; if ($header->{'PLTDECSN'} eq "-") {$decc_rad *= -1}; $decc_rad *= $pi/180; # Convert standard coordinates to RA and Dec. my ($num) = $obj_xi/cos($decc_rad); my ($den) = 1-$obj_eta*tan($decc_rad); my ($ra) = atan2($num,$den)+$rac_rad; if ($ra < 0) {$ra += 2*$pi;} $num = cos($ra-$rac_rad); $den = (1-$obj_eta*tan($decc_rad))/($obj_eta+tan($decc_rad)); my $dec = atan($num,$den); # Convert RA and Dec from radians to hms. ($rh,$rm,$rs,$dc,$dd,$dm,$ds) = Rad2HMS($ra,$dec); return ($rh,$rm,$rs,$dc,$dd,$dm,$ds); } # Routine to convert RA and Dec to pixel number on a DSS-2 FITS image. sub RaDec2XY_DSS { my ($rh,$rm,$rs,$dc,$dd,$dm,$ds,$header) = @_; my ($x,$y); my ($max_iter) = 50; my ($tol) = 5e-7; my ($arcsec_per_radian) = 206264.80625; my ($pi) = 3.14159265359; # Convert RA and Dec to radians. my ($ra_rad) = $rh+$rm/60+$rs/3600; $ra_rad *= $pi/12; if ($ra_rad > $pi) {$ra_rad -= 2*$pi;} my ($dec_rad) = $dd+$dm/60+$ds/3600; if ($dc eq "-") {$dec_rad *= -1;} $dec_rad *= $pi/180; my ($rac_rad) = $header->{'PLTRAH'}+ $header->{'PLTRAM'}/60+ $header->{'PLTRAS'}/3600; $rac_rad *= $pi/12; if ($rac_rad > $pi) {$rac_rad -= 2*$pi;} my ($decc_rad) = $header->{'PLTDECD'}+ $header->{'PLTDECM'}/60+ $header->{'PLTDECS'}/3600; if ($header->{'PLTDECSN'} eq "-") {$decc_rad *= -1}; $decc_rad *= $pi/180; # Initialize. my ($i) = 0; my ($delta_x) = 2*$tol; my ($delta_y) = 2*$tol; # Convert RA and Dec to standard coordinates, xi and eta, in arcsec. my ($div) = sin($dec_rad)*sin($decc_rad)+cos($dec_rad)*cos($decc_rad)* cos($ra_rad-$rac_rad); my ($xi) = cos($dec_rad)*sin($ra_rad-$rac_rad)*$arcsec_per_radian/$div; my ($eta) = (sin($dec_rad)*cos($decc_rad)-cos($dec_rad)*sin($decc_rad)* cos($ra_rad-$rac_rad))*$arcsec_per_radian/$div; # Set initail value for x,y. my ($obj_x) = $xi/$header->{'PLTSCALE'}; my ($obj_y) = $eta/$header->{'PLTSCALE'}; # Iterate by Newton's method. while (($i < $max_iter) and (abs($delta_x) >= $tol) and (abs($delta_y) >= $tol)) { $i += 1; my ($f,$fx,$fy,$g,$gx,$gy) = PltModel($obj_x,$obj_y,$header); $f -= $xi; $g -= $eta; $delta_x = (-$f*$gy+$g*$fy)/($fx*$gy-$fy*$gx); $delta_y = (-$g*$fx+$f*$gx)/($fx*$gy-$fy*$gx); $obj_x += $delta_x; $obj_y += $delta_y; } # Convert mm from plate center to pixels. $x = ($header->{'PPO3'}-$obj_x*1000)/$header->{'XPIXELSZ'}; $y = ($header->{'PPO6'}+$obj_y*1000)/$header->{'YPIXELSZ'}; # Convert to pixels on the FITS image. # NOTE: We need to subtract 0.5 pixel to allow for the DSS pixel # origin definition (DSS coordinates refer to the lower left # corner of the pixel; PGPLOT coordinates refer to the pixel # center). $x -= $header->{'CNPIX1'}+0.5; $y -= $header->{'CNPIX2'}+0.5; return ($x,$y); } # Routine to compute the plate model and its partial derivatives for use # in computing inverse astrometric solutions. Based on PLTMODEL in the # GetImage software (/pkg/merlin/dss/getimage1.2/src/astrmcal.c). sub PltModel { my ($x,$y,$header) = @_; my ($f,$fx,$fy,$g,$gx,$gy); # f is the xi standard coordinate. # fx is the derivative of xi with respect to x. # fy is the derivative of xi with respect to y. # g is the eta standard coordinate. # gx is the derivative of eta with respect to x. # gy is the derivative of eta with respect to y. my ($cjunk,$x4,$y4); # X plate model. $cjunk = ($x*$x+$y*$y)*($x*$x+$y*$y); $x4 = ($x*$x)*($x*$x); $y4 = ($y*$y)*($y*$y); $f = $header->{'AMDX1' }*$x + $header->{'AMDX2' }*$y + $header->{'AMDX3' } + $header->{'AMDX4' }*$x*$x + $header->{'AMDX5' }*$x*$y + $header->{'AMDX6' }*$y*$y + $header->{'AMDX7' }*($x*$x+$y*$y) + $header->{'AMDX8' }*$x*$x*$x + $header->{'AMDX9' }*$x*$x*$y + $header->{'AMDX10'}*$x*$y*$y + $header->{'AMDX11'}*$y*$y*$y + $header->{'AMDX12'}*$x*($x*$x+$y*$y) + $header->{'AMDX13'}*$x*$cjunk; # Derivative of X model with respect to X. $fx = $header->{'AMDX1' } + $header->{'AMDX4' }*2*$x + $header->{'AMDX5' }*$y + $header->{'AMDX7' }*2*$x + $header->{'AMDX8' }*3*$x*$x + $header->{'AMDX9' }*2*$x*$y + $header->{'AMDX10'}*$y*$y + $header->{'AMDX12'}*(3*$x*$x+$y*$y) + $header->{'AMDX13'}*(5*$x4+6*$x*$x*$y*$y+$y4); # Derivative of X model with respect to Y. $fy = $header->{'AMDX2' } + $header->{'AMDX5' }*$x + $header->{'AMDX6' }*2*$y + $header->{'AMDX7' }*2*$y + $header->{'AMDX9' }*$x*$x + $header->{'AMDX10'}*$x*2*$y + $header->{'AMDX11'}*3*$y*$y + $header->{'AMDX12'}*2*$x*$y + $header->{'AMDX13'}*4*$x*$y*($x*$x+$y*$y); # Y plate model. $g = $header->{'AMDY1' }*$y + $header->{'AMDY2' }*$x + $header->{'AMDY3' } + $header->{'AMDY4' }*$y*$y + $header->{'AMDY5' }*$y*$x + $header->{'AMDY6' }*$x*$x + $header->{'AMDY7' }*($x*$x+$y*$y) + $header->{'AMDY8' }*$y*$y*$y + $header->{'AMDY9' }*$y*$y*$x + $header->{'AMDY10'}*$y*$x*$x + $header->{'AMDY11'}*$x*$x*$x + $header->{'AMDY12'}*$y*($x*$x+$y*$y) + $header->{'AMDY13'}*$y*$cjunk; # Derivative of Y model with respect to X. $gx = $header->{'AMDY2' } + $header->{'AMDY5' }*$y + $header->{'AMDY6' }*2*$x + $header->{'AMDY7' }*2*$x + $header->{'AMDY9' }*$y*$y + $header->{'AMDY10'}*$y*2*$x + $header->{'AMDY11'}*3*$x*$x + $header->{'AMDY12'}*2*$x*$y + $header->{'AMDY13'}*4*$x*$y*($x*$x+$y*$y); # Derivative of Y model with respect to Y. $gy = $header->{'AMDY1' } + $header->{'AMDY4' }*2*$y + $header->{'AMDY5' }*$x + $header->{'AMDY7' }*2*$y + $header->{'AMDY8' }*3*$y*$y + $header->{'AMDY9' }*2*$y*$x + $header->{'AMDY10'}*$x*$x + $header->{'AMDY12'}*($x*$x+3*$y*$y) + $header->{'AMDY13'}*(5*$y4+6*$x*$x*$y*$y+$x4); return ($f,$fx,$fy,$g,$gx,$gy); } # Routine to convert RA and Dec in radians to HMS. sub Rad2HMS { my ($ra,$dec) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds); my ($pi) = 3.14159265359; # Convert RA to hours and Dec to degrees. $ra *= 12/$pi; $dec *= 180/$pi; if ($dec >= 0) { $dc = "+"; } else { $dc = "-"; } $dec = abs($dec); # Convert to HMS format. $rh = int($ra); $rm = int(($ra-$rh)*60); $rs = ($ra-$rh-$rm/60)*3600; $dd = int($dec); $dm = int(($dec-$dd)*60); $ds = ($dec-$dd-$dm/60)*3600; return ($rh,$rm,$rs,$dc,$dd,$dm,$ds); } # Routine to convert RA and Dec in degrees to HMS. sub Deg2HMS { my ($ra,$dec) = @_; my ($rh,$rm,$rs,$dc,$dd,$dm,$ds); # Convert RA to hours. $ra /= 15; if ($dec >= 0) { $dc = "+"; } else { $dc = "-"; } $dec = abs($dec); # Convert to HMS format. $rh = int($ra); $rm = int(($ra-$rh)*60); $rs = ($ra-$rh-$rm/60)*3600; $dd = int($dec); $dm = int(($dec-$dd)*60); $ds = ($dec-$dd-$dm/60)*3600; return ($rh,$rm,$rs,$dc,$dd,$dm,$ds); } # Routine to generate color table. sub Color_Table { my ($tab,$con,$bri) = @_; my ($gl) = [0,1]; my ($gr) = [0,1]; my ($gg) = [0,1]; my ($gb) = [0,1]; my ($rl) = [-0.50,0.00,0.17,0.33,0.50,0.67,0.83,1.00,1.70]; my ($rr) = [ 0.00,0.00,0.00,0.00,0.60,1.00,1.00,1.00,1.00]; my ($rg) = [ 0.00,0.00,0.00,1.00,1.00,1.00,0.60,0.00,1.00]; my ($rb) = [ 0.00,0.30,0.80,1.00,0.30,0.00,0.00,0.00,1.00]; my ($hl) = [ 0.00,0.20,0.40,0.60,1.00]; my ($hr) = [ 0.00,0.50,1.00,1.00,1.00]; my ($hg) = [ 0.00,0.00,0.50,1.00,1.00]; my ($hb) = [ 0.00,0.00,0.00,0.30,1.00]; my ($wl) = [ 0.00,0.50,0.50,0.70,0.70,0.85,0.85,0.95,0.95,1.00]; my ($wr) = [ 0.00,1.00,0.00,0.00,0.30,0.80,0.30,1.00,1.00,1.00]; my ($wg) = [ 0.00,0.50,0.40,1.00,0.00,0.00,0.20,0.70,1.00,1.00]; my ($wb) = [ 0.00,0.00,0.00,0.00,0.40,1.00,0.00,0.00,0.95,1.00]; my ($al) = [ 0.00,0.10,0.10,0.20,0.20,0.30,0.30,0.40,0.40,0.50, 0.50,0.60,0.60,0.70,0.70,0.80,0.80,0.90,0.90,1.00]; my ($ar) = [ 0.00,0.00,0.30,0.30,0.50,0.50,0.00,0.00,0.00,0.00, 0.00,0.00,0.00,0.00,1.00,1.00,1.00,1.00,1.00,1.00]; my ($ag) = [ 0.00,0.00,0.30,0.30,0.00,0.00,0.00,0.00,0.80,0.80, 0.60,0.60,1.00,1.00,1.00,1.00,0.80,0.80,0.00,0.00]; my ($ab) = [ 0.00,0.00,0.30,0.30,0.70,0.70,0.70,0.70,0.90,0.90, 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00]; $con *= 10; if ($tab == 1) { # Grayscale. pgctab($gl,$gr,$gg,$gb,2,$con,$bri); } elsif ($tab == 2) { # Rainbow. pgctab($rl,$rr,$rg,$rb,9,$con,$bri); } elsif ($tab == 3) { # Heat. pgctab($hl,$hr,$hg,$hb,5,$con,$bri); } elsif ($tab == 4) { # Weird IRAF. pgctab($wl,$wr,$wg,$wb,10,$con,$bri); } elsif ($tab == 5) { # AIPS. pgctab($al,$ar,$ag,$ab,20,$con,$bri); } return; } # Routine to draw the NIFS slitlet grid. sub NIFS_Grid { my ($x0,$y0,$xscale,$yscale) = @_; my ($i,$x); my ($ns) = 29; my ($y1) = $y0-1.5/$yscale; my ($y2) = $y0+1.5/$yscale; foreach $i (1..$ns-1) { $x = $x0+0.103*($i-$ns/2)/$xscale; pgmove($x,$y1); pgdraw($x,$y2); } return; } # Base 10 logarithmn. sub log10 { my $n = shift; return log($n)/log(10); }