IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 10, 2008, 4:11:38 PM (18 years ago)
Author:
Paul Price
Message:

Plot flagged (CR and bad fit) sources in a different colour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/ds9_cmf_regions.pl

    r17520 r18077  
    77use Pod::Usage qw( pod2usage );
    88use Data::Dumper;
     9use Carp;
    910
    1011Astro::FITS::CFITSIO::PerlyUnpacking(1);
     
    1617
    1718
    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
     19my ( $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
    2326     $save_temps
    2427     );
    2528
    2629# Defaults
    27 $colour = "red";
     30$colour = "blue";
     31$flag_colour = "red";
    2832$radius = 5;
     33$flag = 0x3888;
    2934
    3035GetOptions(
    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?
    3744) or pod2usage( 2 );
    3845
     
    4350    and defined $extname;
    4451
    45 my $status;                     # Status of FITSIO calls
     52my $status;                     # Status of FITSIO calls
    4653my $fits = Astro::FITS::CFITSIO::open_file( $filename, READONLY, $status ); # FITS file handle
    4754check_fitsio($status);
    4855$fits->movnam_hdu(BINARY_TBL, $extname, 0, $status) and check_fitsio($status);
    49 my $numRows;                    # Number of rows in table
     56my $numRows;                    # Number of rows in table
    5057$fits->get_num_rows($numRows, $status) and check_fitsio($status);
    5158
    52 my ($xCol, $yCol);              # Column numbers for x and y
     59my ($xCol, $yCol, $flagCol);     # Column numbers for x,y, flag
    5360$fits->get_colnum(0, 'X_PSF', $xCol, $status) and check_fitsio($status);
    5461$fits->get_colnum(0, 'Y_PSF', $yCol, $status) and check_fitsio($status);
     62$fits->get_colnum(0, 'FLAGS', $flagCol, $status) and check_fitsio($status);
    5563
    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);
     64my ($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);
    6368$fits->close_file($status);
    6469
    6570my ($coordFile, $coordName) = tempfile( "/tmp/ds9_cmf_regions.XXXX", UNLINK => !$save_temps );
    6671for (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";
    6974}
    7075close $coordFile;
    7176
    7277my @settings = settings_save("regions format",
    73                              "regions system"); # Settings to save
     78                             "regions system"); # Settings to save
    7479
    7580xpaset("frame $frame") if defined $frame;
     
    9095sub check_fitsio
    9196{
    92     my $status = shift;         # Status of FITSIO calls
     97    my $status = shift;         # Status of FITSIO calls
    9398
    9499    if ($status != 0) {
    95         my $msg;                # Message to output
    96         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";
    98103    }
    99104}
     
    102107sub settings_save
    103108{
    104     my @settings;               # Values of settings
     109    my @settings;               # Values of settings
    105110    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;
    108113    }
    109114    return @settings;
Note: See TracChangeset for help on using the changeset viewer.