Changeset 33438 for trunk/tools/dlapstacks
- Timestamp:
- Mar 7, 2012, 2:43:28 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/tools/dlapstacks (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/dlapstacks
r33379 r33438 4 4 use warnings; 5 5 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 15 my $label = 'LAP.ThreePi.20110809'; 10 16 my $tess_id = 'RINGS.V3'; 11 my $label = 'LAP.ThreePi.20110809';12 17 13 18 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 16 21 use PS::IPP::Config 1.01 qw( :standard ); 17 22 18 my $ipprc = PS::IPP::Config->new();23 my $ipprc = PS::IPP::Config->new(); 19 24 my $dbh = getDBHandle(); 20 25 21 22 26 my ($requested_filter, $no_display, $skycell_id, $verbose, $ra, $dec, $convolved); 23 27 my ($singleframe); 24 28 25 29 GetOptions( 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, 30 37 'verbose|v' => \$verbose, 31 38 ) or pod2usage( 2 ); … … 36 43 $ra = shift; 37 44 $dec = shift; 45 46 pod2usage( -msg => 'if ra is suplied <dec> must be supplied as well', -exitval => 2) 47 if (defined $ra and ! defined $dec); 38 48 39 49 my $extension; … … 44 54 } 45 55 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 58 if (($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 62 my $whichimage_output; 63 if (!$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 78 my $query = "SELECT skycell_id, filter, stack_id, quality, state, path_base 56 79 FROM stackRun join stackSumSkyfile USING(stack_id) 57 80 WHERE stackRun.state ='full' AND label = '$label' AND skycell_id = ?"; … … 69 92 70 93 # @files will contain the list of skycells found in order of skycell_id, filter. 71 # The sewill be displayed in this order so that the image frames are in order of increasing bandpass94 # The images will be displayed in this order so that the image frames are in order of increasing bandpass 72 95 my @files = (); 73 96 … … 81 104 foreach (split "\n", $whichimage_output) { 82 105 chomp; 106 83 107 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 85 111 $stmt->execute($skycell) or die $stmt->errstr; 86 112 my $files_found = 0; 87 113 while (my $f = $stmt->fetchrow_hashref()) { 88 114 next if $f->{quality}; 115 next if $f->{state} ne 'full'; 116 89 117 my $filter = $f->{filter}; 90 118 my $stack_id = $f->{stack_id}; 91 119 my $path_base = $f->{path_base}; 120 92 121 # save the skycell coordinates so we can pan efficiently below 93 122 $f->{X} = $x; 94 123 $f->{Y} = $y; 95 124 96 # Find where this filter goes in the array 125 # Find where this filter goes in the array of files 97 126 my $i = $index{$filter}; 98 127 if (!defined $i) { … … 100 129 next; 101 130 } 102 # if multiple skycells match the coordinates bump the index 131 # if multiple skycells match the coordinates bump the index by $num_filters 103 132 $i += $skycells * $num_filters; 104 133 $files[$i] = $f; … … 112 141 113 142 if (!$total_files) { 114 print "no files found\n";143 print "no matching stacks found\n"; 115 144 exit 1; 116 145 } … … 118 147 119 148 if (!$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 123 157 my @args; 158 my $panargs = ""; 124 159 foreach my $f (@files) { 125 160 next if ! $f; … … 127 162 my $resolved = $ipprc->file_resolve($filename); 128 163 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. 131 172 my $xlabel = $f->{X} + $imagesize / 2; 132 173 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 134 175 # I couldn't make this work. The circle would appear but without the text 135 176 # my $label = " -regions command 'circle($xlabel,$ylabel,1)' # text={ $f->{filter} }"; … … 140 181 # $panargs .= $label; 141 182 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"; 145 192 print "$ds9cmd\n" if $verbose; 146 193 system $ds9cmd; 147 194 } 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"; 148 199 foreach my $f (@files) { 149 200 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"; 151 202 } 152 203 }
Note:
See TracChangeset
for help on using the changeset viewer.
