IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33438 for trunk


Ignore:
Timestamp:
Mar 7, 2012, 2:43:28 PM (14 years ago)
Author:
bills
Message:

various improvements including allowing user to specifiy label and tess_id
but forbid MD labels unless the label contains 'REF' or 'ref' to avoid
finding the nightly stacks and ceating chaos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/dlapstacks

    r33379 r33438  
    44use warnings;
    55
    6 # given an RA and DEC lookup find the LAP stack images
    7 
    8 # XXX: consider making these options these could be made options I guess
    9 
     6# given an RA and DEC or a skycell_id find the LAP stack images containing them
     7# and display using ds9
     8
     9# XXX: consider accepting a string of parameters to be passed to ds9
     10# add --fit set ds9 to fit to frame
     11# XXX if label is supplied by the user and it is like MD%
     12# guess at the tess_id
     13# allow mask and variance images to be displayed as well
     14
     15my $label   = 'LAP.ThreePi.20110809';
    1016my $tess_id = 'RINGS.V3';
    11 my $label = 'LAP.ThreePi.20110809';
    1217
    1318use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    1621use PS::IPP::Config 1.01 qw( :standard );
    1722
    18 my $ipprc =  PS::IPP::Config->new();
     23my $ipprc = PS::IPP::Config->new();
    1924my $dbh = getDBHandle();
    2025
    21 
    2226my ($requested_filter, $no_display, $skycell_id, $verbose, $ra, $dec, $convolved);
    23 
     27my ($singleframe);
    2428
    2529GetOptions(
    26     'filter|f=s'    => \$requested_filter,
    27     'convolved'     => \$convolved,
    28     'no-display|n'  => \$no_display,
    29     'skycell_id=s'  => \$skycell_id,
     30    'filter|f=s'    => \$requested_filter,  # restrict to a single filter
     31    'skycell_id=s'  => \$skycell_id,        # don't bother with
     32    'convolved'     => \$convolved,         # display convolved stack images instead of unconvolved
     33    'label=s'       => \$label,             # use a different label (careful!)
     34    'tess_id=s'     => \$tess_id,           #
     35    'no-display|n'  => \$no_display,        # don't run ds9 just print the filenames
     36    'single'        => \$singleframe,
    3037    'verbose|v'     => \$verbose,
    3138) or pod2usage( 2 );
     
    3643$ra = shift;
    3744$dec = shift;
     45
     46pod2usage( -msg => 'if ra is suplied <dec> must be supplied as well', -exitval => 2)
     47    if (defined $ra and ! defined $dec);
    3848
    3949my $extension;
     
    4454}
    4555
    46 # run whichimage to find a list of skycells containing the given coordinates
    47 my $whichimage_output = `whichimage --listchipcoords --tess_id $tess_id $ra $dec`;
    48 
    49 print $whichimage_output if $verbose;
    50 
    51 my @results = split "\n", $whichimage_output;
    52 
    53 die "whichimage returned no output\n" if scalar @results == 0;
    54 
    55 my $query = "SELECT skycell_id, filter, stack_id, quality, path_base
     56# don't allow MD label unless it's a refstack.
     57# Nightly stacks have too many images
     58if (($label =~ /MD/) and !(uc($label) =~ /REF/)) {
     59    die "cannot use this program for label $label because we will probably too many matches. Talk to Bill\n";
     60}
     61
     62my $whichimage_output;
     63if (!$skycell_id or (defined $ra and defined $dec)) {
     64    # run whichimage to find a list of skycells containing the given coordinates and the
     65    # image coordinates of the requested sky coordinates
     66    $whichimage_output = `whichimage --listchipcoords --tess_id $tess_id $ra $dec`;
     67
     68    print "Output from whichimage:\n$whichimage_output\n" if $verbose;
     69
     70    my @results = split "\n", $whichimage_output;
     71
     72    die "whichimage returned no output\n" if scalar @results == 0;
     73} else {
     74    # we were supplied a skycell create a fake whichimage_output that can be parsed below
     75    $whichimage_output = "0 0 dummy $skycell_id -1 -1\n";
     76}
     77
     78my $query = "SELECT skycell_id, filter, stack_id, quality, state, path_base
    5679    FROM stackRun join stackSumSkyfile USING(stack_id)
    5780    WHERE stackRun.state ='full' AND label = '$label' AND skycell_id = ?";
     
    6992
    7093# @files will contain the list of skycells found in order of skycell_id, filter.
    71 # These will be displayed in this order so that the image frames are in order of increasing bandpass
     94# The images will be displayed in this order so that the image frames are in order of increasing bandpass
    7295my @files = ();
    7396
     
    81104foreach (split "\n", $whichimage_output) {
    82105    chomp;
     106
    83107    my ($radeg, $decdeg, undef, $skycell, $x, $y) = split " ";
    84     print "$skycell $radeg $decdeg\n" if $verbose;
     108
     109    print "skycell: $skycell RA (deg): $radeg DEC (deg): $decdeg (X,Y): ($x, $y)\n" if $verbose;
     110
    85111    $stmt->execute($skycell) or die $stmt->errstr;
    86112    my $files_found = 0;
    87113    while (my $f = $stmt->fetchrow_hashref()) {
    88114        next if $f->{quality};
     115        next if $f->{state} ne 'full';
     116
    89117        my $filter = $f->{filter};
    90118        my $stack_id = $f->{stack_id};
    91119        my $path_base = $f->{path_base};
     120
    92121        # save the skycell coordinates so we can pan efficiently below
    93122        $f->{X} = $x;
    94123        $f->{Y} = $y;
    95124
    96         # Find where this filter goes in the array
     125        # Find where this filter goes in the array of files
    97126        my $i = $index{$filter};
    98127        if (!defined $i) {
     
    100129            next;
    101130        }
    102         # if multiple skycells match the coordinates bump the index
     131        # if multiple skycells match the coordinates bump the index by $num_filters
    103132        $i += $skycells * $num_filters;
    104133        $files[$i] = $f;
     
    112141
    113142if (!$total_files) {
    114     print "no files found\n";
     143    print "no matching stacks found\n";
    115144    exit 1;
    116145}
     
    118147
    119148if (!$no_display) {
    120     # estimate of image size for the case where we have 5 frames
    121     my $imagesize = 680;
    122     # my $panargs = "-pan to $ra $dec wcs fk5";
     149    my $imagesize;
     150    if ($singleframe) {
     151        $imagesize = 1024;
     152    } else {
     153        # estimate of image size for the case where we have 5 frames
     154        $imagesize = 680;
     155    }
     156    # Build the ds9 argument list
    123157    my @args;
     158    my $panargs = "";
    124159    foreach my $f (@files) {
    125160        next if ! $f;
     
    127162        my $resolved = $ipprc->file_resolve($filename);
    128163        next if !$resolved;
    129         my $panargs = "-pan to $f->{X} $f->{Y}";
    130 
     164
     165        if ($f->{X} > 0) {
     166            $panargs = "-pan to $f->{X} $f->{Y}";
     167        } else {
     168            $panargs = "";
     169        }
     170
     171        # The following is an attempt put the filter name in the image using a region with text a label.
    131172        my $xlabel = $f->{X} + $imagesize / 2;
    132173        my $ylabel = $f->{Y} + $imagesize / 2;
    133         # The following is an attempt put the filter name in the image using a region with text a label.
     174
    134175        # I couldn't make this work. The circle would appear but without the text
    135176        # my $label = " -regions command  'circle($xlabel,$ylabel,1)' # text={ $f->{filter} }";
     
    140181        # $panargs .= $label;
    141182
    142         push @args, ($resolved, $panargs);
    143     }
    144     my $ds9cmd = "ds9 -geom 1024x1024 @args";
     183        # I used to pan each frame but it turns out to be quicker to wait until the last image is
     184        # loaded. pan thatone and then matching the wcs for the frames.
     185        # Also that allows V0 and V3 skycells to have east to the left orientation
     186        # push @args, ($resolved, $panargs);
     187        push @args, $resolved;
     188    }
     189    my $ds9cmd = "ds9 -geom 1024x1024 @args $panargs";
     190    $ds9cmd .= " -single" if $singleframe;
     191    $ds9cmd .= " -match frames wcs";
    145192    print "$ds9cmd\n" if $verbose;
    146193    system $ds9cmd;
    147194} else {
     195    # no-display option Just print out some information
     196    print "\n" if $verbose;
     197    print "Skycell ID        stack_id filter   path_base\n";
     198    print "------------------------------------------------------------------------------------------\n";
    148199    foreach my $f (@files) {
    149200        next if !$f;
    150         print "$f->{skycell_id} $f->{stack_id} $f->{filter} $f->{path_base}\n";
     201        print "$f->{skycell_id}  $f->{stack_id}   $f->{filter} $f->{path_base}\n";
    151202    }
    152203}
Note: See TracChangeset for help on using the changeset viewer.