- Timestamp:
- Mar 14, 2012, 8:20:30 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/tools/dlapstacks (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/dlapstacks
r33438 r33521 20 20 use DBI; 21 21 use PS::IPP::Config 1.01 qw( :standard ); 22 use File::Temp qw( tempfile tempdir ); 23 use File::Basename; 24 use IPC::Cmd 0.36 qw( can_run run ); 25 22 26 23 27 my $ipprc = PS::IPP::Config->new(); … … 25 29 26 30 my ($requested_filter, $no_display, $skycell_id, $verbose, $ra, $dec, $convolved); 27 my ($singleframe); 31 my ($singleframe, $fitToFrame, $deasin, $save_temps); 32 33 my $temproot = '/local/ipp/tmp'; 34 my $outdir; 35 28 36 29 37 GetOptions( 30 38 '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, # 39 'skycell_id|s=s'=> \$skycell_id, # don't bother with 40 'convolved|c' => \$convolved, # display convolved stack images instead of unconvolved 41 'fit' => \$fitToFrame, 42 'deasin|d' => \$deasin, 43 'label|l=s' => \$label, # use a different label (careful!) 44 'tess_id|t=s' => \$tess_id, # 45 'outdir|o=s' => \$outdir, 35 46 'no-display|n' => \$no_display, # don't run ds9 just print the filenames 36 47 'single' => \$singleframe, 48 'save-temps' => \$save_temps, 37 49 'verbose|v' => \$verbose, 38 50 ) or pod2usage( 2 ); … … 46 58 pod2usage( -msg => 'if ra is suplied <dec> must be supplied as well', -exitval => 2) 47 59 if (defined $ra and ! defined $dec); 60 61 my $missing_tools; 62 my $ppstamp; 63 if ($deasin) { 64 $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp") and $missing_tools = 1; 65 } 66 if ($missing_tools) { 67 # warn("Can't find required tools."); 68 exit($PS_EXIT_CONFIG_ERROR); 69 } 48 70 49 71 my $extension; … … 154 176 $imagesize = 680; 155 177 } 178 if ($deasin) { 179 if ($outdir) { 180 print "Saving deasined files to $outdir\n"; 181 # user specified output directory save the files there 182 if (!-d $outdir) { 183 mkdir $outdir or die "failed to mkdir $outdir\n"; 184 } 185 } else { 186 # otherwise use a temporary directory 187 $outdir = tempdir ("$temproot/dlapstacks.temp.XXXX", CLEANUP => !$save_temps); 188 print "deasined files will be saved to $outdir\n" if $save_temps; 189 } 190 } 156 191 # Build the ds9 argument list 157 192 my @args; … … 159 194 foreach my $f (@files) { 160 195 next if ! $f; 161 my $filename = $f->{path_base} . ".$extension"; 162 my $resolved = $ipprc->file_resolve($filename); 163 next if !$resolved; 196 my $pathname = $f->{path_base} . ".$extension"; 197 my $filename = $ipprc->file_resolve($pathname); 198 next if !$filename; 199 # run ppstamp to undo the asin scaling. The output from ppstamp is linear F32 images 200 if ($deasin) { 201 my $base = basename($pathname); 202 my $destbase = $base; 203 204 # drop the .fits for the output path for ppstamp 205 $destbase =~ s/\.fits//g; 206 207 my $command = "$ppstamp -wholefile -file $filename $outdir/$destbase"; 208 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 209 run(command => $command, verbose => $verbose); 210 unless ($success) { 211 print STDERR join "", @$stderr_buf; 212 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 213 die("Unable to perform ppstamp: $error_code\n"); 214 } 215 216 # new filename for ds9 217 $filename = "$outdir/$base"; 218 } 164 219 165 220 if ($f->{X} > 0) { … … 184 239 # loaded. pan thatone and then matching the wcs for the frames. 185 240 # Also that allows V0 and V3 skycells to have east to the left orientation 186 # push @args, ($ resolved, $panargs);187 push @args, $ resolved;241 # push @args, ($filename, $panargs); 242 push @args, $filename; 188 243 } 189 244 my $ds9cmd = "ds9 -geom 1024x1024 @args $panargs"; 190 245 $ds9cmd .= " -single" if $singleframe; 246 $ds9cmd .= " -zoom to fit" if $fitToFrame; 191 247 $ds9cmd .= " -match frames wcs"; 248 $ds9cmd .= " -frame first" if $singleframe; 192 249 print "$ds9cmd\n" if $verbose; 193 250 system $ds9cmd;
Note:
See TracChangeset
for help on using the changeset viewer.
