Changeset 18077 for trunk/ippScripts/scripts/ds9_cmf_regions.pl
- Timestamp:
- Jun 10, 2008, 4:11:38 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/ds9_cmf_regions.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ds9_cmf_regions.pl
r17520 r18077 7 7 use Pod::Usage qw( pod2usage ); 8 8 use Data::Dumper; 9 use Carp; 9 10 10 11 Astro::FITS::CFITSIO::PerlyUnpacking(1); … … 16 17 17 18 18 my ( $filename, # Filename containing photometry 19 $extname, # Extension name containing photometry 20 $frame, # Frame number in ds9 21 $colour, # Region colour 22 $radius, # Radius for circle 19 my ( $filename, # Filename containing photometry 20 $extname, # Extension name containing photometry 21 $frame, # Frame number in ds9 22 $colour, # Region colour 23 $flag_colour, # Flagged source region colour 24 $flag, # Flags 25 $radius, # Radius for circle 23 26 $save_temps 24 27 ); 25 28 26 29 # Defaults 27 $colour = "red"; 30 $colour = "blue"; 31 $flag_colour = "red"; 28 32 $radius = 5; 33 $flag = 0x3888; 29 34 30 35 GetOptions( 31 'file=s' => \$filename, 32 'ext=s' => \$extname, 33 'frame=s' => \$frame, 34 'colour=s' => \$colour, 35 'radius=f' => \$radius, 36 'save-temps' => \$save_temps, # Save temporary files? 36 'file=s' => \$filename, 37 'ext=s' => \$extname, 38 'frame=s' => \$frame, 39 'colour=s' => \$colour, 40 'flag-colour=s' => \$flag_colour, 41 'flag=o' => \$flag, 42 'radius=f' => \$radius, 43 'save-temps' => \$save_temps, # Save temporary files? 37 44 ) or pod2usage( 2 ); 38 45 … … 43 50 and defined $extname; 44 51 45 my $status; # Status of FITSIO calls52 my $status; # Status of FITSIO calls 46 53 my $fits = Astro::FITS::CFITSIO::open_file( $filename, READONLY, $status ); # FITS file handle 47 54 check_fitsio($status); 48 55 $fits->movnam_hdu(BINARY_TBL, $extname, 0, $status) and check_fitsio($status); 49 my $numRows; # Number of rows in table56 my $numRows; # Number of rows in table 50 57 $fits->get_num_rows($numRows, $status) and check_fitsio($status); 51 58 52 my ($xCol, $yCol ); # Column numbers for x and y59 my ($xCol, $yCol, $flagCol); # Column numbers for x,y, flag 53 60 $fits->get_colnum(0, 'X_PSF', $xCol, $status) and check_fitsio($status); 54 61 $fits->get_colnum(0, 'Y_PSF', $yCol, $status) and check_fitsio($status); 62 $fits->get_colnum(0, 'FLAGS', $flagCol, $status) and check_fitsio($status); 55 63 56 my ($xType, $yType); # Types for x and y 57 $fits->get_coltype($xCol, $xType, undef, undef, $status) and check_fitsio($status); 58 $fits->get_coltype($yCol, $yType, undef, undef, $status) and check_fitsio($status); 59 60 my ($x, $y); # Coordinates read from table 61 $fits->read_col($xType, $xCol, 1, 1, $numRows, 0, $x, undef, $status) and check_fitsio($status); 62 $fits->read_col($yType, $yCol, 1, 1, $numRows, 0, $y, undef, $status) and check_fitsio($status); 64 my ($x, $y, $flags); # Coordinates and flags read from table 65 $fits->read_col(TFLOAT, $xCol, 1, 1, $numRows, 0, $x, undef, $status) and check_fitsio($status); 66 $fits->read_col(TFLOAT, $yCol, 1, 1, $numRows, 0, $y, undef, $status) and check_fitsio($status); 67 $fits->read_col(TINT, $flagCol, 1, 1, $numRows, 0, $flags, undef, $status) and check_fitsio($status); 63 68 $fits->close_file($status); 64 69 65 70 my ($coordFile, $coordName) = tempfile( "/tmp/ds9_cmf_regions.XXXX", UNLINK => !$save_temps ); 66 71 for (my $i = 0; $i < $numRows; $i++) { 67 print $coordFile "image; circle(" . ($$x[$i] + 1) . ',' . ($$y[$i] + 1) . 68 ",$radius \# color = $colour\n";72 print $coordFile "image; circle(" . ($$x[$i] + 1) . ',' . ($$y[$i] + 1) . ",$radius \# color = " . 73 (($$flags[$i] & $flag) ? $flag_colour : $colour) . "\n"; 69 74 } 70 75 close $coordFile; 71 76 72 77 my @settings = settings_save("regions format", 73 "regions system"); # Settings to save78 "regions system"); # Settings to save 74 79 75 80 xpaset("frame $frame") if defined $frame; … … 90 95 sub check_fitsio 91 96 { 92 my $status = shift; # Status of FITSIO calls97 my $status = shift; # Status of FITSIO calls 93 98 94 99 if ($status != 0) { 95 my $msg;# Message to output96 Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg );97 die"CFITSIO error: $msg\n";100 my $msg; # Message to output 101 Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg ); 102 croak "CFITSIO error: $msg\n"; 98 103 } 99 104 } … … 102 107 sub settings_save 103 108 { 104 my @settings; # Values of settings109 my @settings; # Values of settings 105 110 foreach my $setting (@_) { 106 my @values = xpaget($setting);107 push @settings, $setting . ' ' . shift @values;111 my @values = xpaget($setting); 112 push @settings, $setting . ' ' . shift @values; 108 113 } 109 114 return @settings;
Note:
See TracChangeset
for help on using the changeset viewer.
