- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/stack_skycell.pl (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ippScripts/scripts/stack_skycell.pl
r23745 r27840 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; … … 65 66 66 67 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 68 $| = 1; 69 print "I've set up: $stack_id\n"; 67 70 68 71 # XXX camera is not known here; cannot use filerules... … … 105 108 } 106 109 107 &my_die("Stack list contains less than two elements", $stack_id, $PS_EXIT_ SYS_ERROR) unless110 &my_die("Stack list contains less than two elements", $stack_id, $PS_EXIT_DATA_ERROR) unless 108 111 scalar @$files >= 2; 112 113 print "I've loaded my inputs: $stack_id\n"; 109 114 110 115 # Parse the list of input files to get the tesselation, skycell identifiers and camera … … 116 121 if ($file->{ignored}) { next; } 117 122 if (defined $tess_id) { 118 &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_ SYS_ERROR) unless123 &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_DATA_ERROR) unless 119 124 $file->{tess_id} eq $tess_id; 120 125 } else { … … 122 127 } 123 128 if (defined $skycell_id) { 124 &my_die("Skycell identifiers don't match", $stack_id, $PS_EXIT_ SYS_ERROR) unless129 &my_die("Skycell identifiers don't match", $stack_id, $PS_EXIT_DATA_ERROR) unless 125 130 $file->{skycell_id} eq $skycell_id; 126 131 } else { … … 128 133 } 129 134 if (defined $camera) { 130 &my_die("Cameras don't match", $stack_id, $PS_EXIT_ SYS_ERROR) unless $file->{camera} eq $camera;135 &my_die("Cameras don't match", $stack_id, $PS_EXIT_DATA_ERROR) unless $file->{camera} eq $camera; 131 136 } else { 132 137 $camera = $file->{camera}; … … 136 141 &my_die("Can't find camera", $stack_id, $PS_EXIT_SYS_ERROR) unless defined $camera; 137 142 $ipprc->define_camera($camera); 143 144 print "I've configured everything: $stack_id\n"; 138 145 139 146 # Recipes to use based on reduction class … … 146 153 } 147 154 155 my $recipe; 156 { 157 my $command = "$ppConfigDump -camera $camera -recipe PPSTACK $recipe_ppStack -dump-recipe PPSTACK -"; 158 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 159 run(command => $command, verbose => $verbose); 160 unless ($success) { 161 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 162 &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code); 163 } 164 $recipe = $mdcParser->parse(join "", @$stdout_buf) or 165 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR); 166 } 167 my $convolve = metadataLookupBool($recipe, 'CONVOLVE'); # Convolve inputs? 168 my $photometry = metadataLookupBool($recipe, 'PHOTOMETRY'); # perform photometry? 169 170 148 171 # Generate MDC file with the inputs 149 172 my $tess_base = basename($tess_id); … … 160 183 my $mask = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name 161 184 my $weight = $ipprc->filename( "PSWARP.OUTPUT.VARIANCE", $file->{path_base} ); # Weight name 162 my $psf = $ ipprc->filename( "PSPHOT.PSF.SKY.SAVE", $file->{path_base} ); # PSF name185 my $psf = $convolve ? $ipprc->filename( "PSPHOT.PSF.SKY.SAVE", $file->{path_base} ) : undef; # PSF name 163 186 my $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base}); # Sources name 164 187 … … 166 189 &my_die("Mask $mask does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $mask ); 167 190 &my_die("Weight $weight does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $weight ); 168 &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $psf);191 &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) if ($convolve and not $ipprc->file_exists( $psf )); 169 192 &my_die("Sources $sources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $sources ); 170 193 … … 172 195 print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 173 196 print $listFile "\tVARIANCE\tSTR\t" . $weight . "\n"; 174 print $listFile "\tPSF\tSTR\t" . $psf . "\n" ;197 print $listFile "\tPSF\tSTR\t" . $psf . "\n" if $convolve; 175 198 print $listFile "\tSOURCES\tSTR\t" . $sources . "\n"; 176 199 177 ### XXX NEED TO UPDATE THESE appropriately178 print $listFile "\tWEIGHTING\tF32\t" . 1.0 . "\n";179 180 200 print $listFile "END\n\n"; 181 201 } 202 203 print "I've checked everything: $stack_id\n"; 182 204 183 205 # Get the output filenames … … 185 207 my $outputMask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $outroot); 186 208 my $outputWeight = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $outroot); 187 my $outputSources = $ipprc->filename("PSPHOT.OUT.CMF.MEF", $outroot); ## this must be consistent with the value in diff_skycell.pl:101 209 my $outputSources = $photometry ? $ipprc->filename("PSPHOT.OUT.CMF.MEF", $outroot) : undef; ## this must be consistent with the value in diff_skycell.pl:101 210 188 211 ## use an explicit stack name for psphot output objects 189 212 #my $bin1Name = $ipprc->filename("PPSTACK.BIN1", $outroot); … … 200 223 201 224 my $cmdflags; 225 202 226 203 227 # Perform stacking … … 215 239 $command .= " -F SOURCE.PLOT.PSFMODEL SOURCE.PLOT.SKY.PSFMODEL"; 216 240 $command .= " -F SOURCE.PLOT.APRESID SOURCE.PLOT.SKY.APRESID"; 217 $command .= " -photometry";218 241 $command .= " -threads $threads" if defined $threads; 219 242 $command .= " -debug-stack" if defined $debug; … … 239 262 if ($do_stats) { 240 263 my $outputStatsReal = $ipprc->file_resolve($outputStats); 241 &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;264 &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal); 242 265 243 266 # measure stats … … 261 284 &my_die("Couldn't find expected output file: $outputMask", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 262 285 &my_die("Couldn't find expected output file: $outputWeight", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 263 &my_die("Couldn't find expected output file: $outputSources", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 286 if ($photometry) { 287 &my_die("Couldn't find expected output file: $outputSources", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 288 } 289 if ($run_state eq 'new') { 290 &my_die("Couldn't find expected output file: $configuration", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration); 291 } 264 292 # &my_die("Couldn't find expected output file: $bin1Name", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name); 265 293 # &my_die("Couldn't find expected output file: $bin2Name", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name); 266 294 } 267 295 296 print "I've stacked $listName: $stack_id\n"; 268 297 } 269 298 … … 282 311 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 283 312 } else { 284 $mode = "-updaterun -s tate full";313 $mode = "-updaterun -set_state full"; 285 314 } 286 315 $command .= " $mode -stack_id $stack_id"; … … 297 326 298 327 } 328 329 print "I've updated teh database: $stack_id\n"; 299 330 300 331 … … 340 371 341 372 print "Ensuring temporary images are deleted.\n"; 342 my $command = "$ppConfigDump -camera $camera -recipe PPSTACK $recipe_ppStack -dump-recipe PPSTACK -"; 343 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 344 run(command => $command, verbose => $verbose); 345 unless ($success) { 346 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 347 &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code); 348 } 349 my $md = $mdcParser->parse(join "", @$stdout_buf) or 350 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR); 351 352 my $temp_delete = metadataLookupBool($md, 'TEMP.DELETE'); # Delete temporary files? 373 374 my $temp_delete = defined($recipe) and metadataLookupBool($recipe, 'TEMP.DELETE'); # Delete temp files? 353 375 if ($temp_delete) { 354 my $temp_dir = metadataLookupStr($ md, 'TEMP.DIR'); # Directory with temporary files355 my $temp_image = metadataLookupStr($ md, 'TEMP.IMAGE'); # Suffix for image356 my $temp_mask = metadataLookupStr($ md, 'TEMP.MASK'); # Suffix for mask357 my $temp_weight = metadataLookupStr($ md, 'TEMP.VARIANCE'); # Suffix for weight376 my $temp_dir = metadataLookupStr($ipprc->{_siteConfig}, 'TEMP.DIR') or &my_die("Unable to find temporary directory in site configuration", $stack_id, $PS_EXIT_CONFIG_ERROR); # Directory with temporary files 377 my $temp_image = metadataLookupStr($recipe, 'TEMP.IMAGE'); # Suffix for image 378 my $temp_mask = metadataLookupStr($recipe, 'TEMP.MASK'); # Suffix for mask 379 my $temp_weight = metadataLookupStr($recipe, 'TEMP.VARIANCE'); # Suffix for weight 358 380 my $temp_root = basename($outroot); # Root name for temporary files 359 381 … … 372 394 } 373 395 396 print "I've reached the end of processing with a code of $?: $stack_id\n"; 374 397 375 398 END {
Note:
See TracChangeset
for help on using the changeset viewer.
