Changeset 38516 for trunk/ippScripts/scripts/staticsky.pl
- Timestamp:
- Jun 22, 2015, 3:24:54 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/staticsky.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/staticsky.pl
r37915 r38516 43 43 print "USAGE: staticsky.pl --sky_id (sky_id) --outroot (root) --camera (camera) [options]\n"; 44 44 print " --sky_id (sky_id) : run identifier\n"; 45 print " --run-state (state) : run state (new or update)\n"; 45 46 print " --camera (camera) : Camera name\n"; 46 47 print " --dbname (dbname) : Database name\n"; … … 62 63 63 64 my ($sky_id, $camera, $dbname, $threads, $outroot, $reduction, $require_sources, $verbose, $no_update, $no_op, $redirect, $save_temps); 65 my $run_state ='new'; 66 64 67 GetOptions( 65 68 'sky_id=s' => \$sky_id, # Diff identifier 69 'run-state=s' => \$run_state, 66 70 'camera|c=s' => \$camera, # Camera name 67 71 'dbname|d=s' => \$dbname, # Database name … … 88 92 defined $camera; 89 93 94 95 &my_die("unexpected run state: $run_state", $sky_id, $PS_EXIT_PROG_ERROR) unless ($run_state eq 'new') or ($run_state eq 'update'); 96 my $updatemode = $run_state eq 'update'; 97 90 98 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $sky_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 91 99 … … 126 134 my $nInputs = @$files; 127 135 128 if (1){136 { 129 137 my $recipe_psphot = $ipprc->reduction($reduction, 'STACKPHOT_PSPHOT'); # Recipe to use for psphot 130 138 my $recipe_ppsub = $ipprc->reduction($reduction, 'STACKPHOT_PPSUB'); # Recipe to use for ppsub … … 163 171 my $expnumRaw = $ipprc->filename("PPSTACK.UNCONV.EXPNUM", $path_base ); # Expnum name 164 172 165 my $sources = $ipprc->filename("PSPHOT.OUT.CMF.MEF", $path_base ); # Sources name 173 my $sources; 174 my ($psfRaw, $backmdlRaw); 175 if (!$updatemode) { 176 # sources from stack run. 177 # XXX: We don't need this file anymore. 178 $sources = $ipprc->filename("PSPHOT.OUT.CMF.MEF", $path_base ); # Sources name 179 } else { 180 # name of output sources from this run when in new state 181 $require_sources = 1 unless $no_op; 182 $sources = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot, $stack_id); 183 # During update we rename the sources file to this 184 my $originalSources = "$sources.original"; 185 if (!$ipprc->file_exists($originalSources)) { 186 if ($ipprc->file_exists($sources)) { 187 unless ($no_op) { 188 if (!$ipprc->file_rename($sources, $originalSources)) { 189 &my_die("failed to rename $sources $originalSources", $sky_id, $PS_EXIT_PROG_ERROR); 190 } 191 } 192 } else { 193 # maybe this should be a fault 2 194 &my_die("failed to to find either sources file to update as either $sources or $originalSources", $sky_id, $PS_EXIT_PROG_ERROR); 195 } 196 } 197 $sources = $originalSources; 198 $psfRaw = $ipprc->filename("PSPHOT.STACK.PSF.SAVE", $outroot, $stack_id); 199 $backmdlRaw = $ipprc->filename("PSPHOT.STACK.BACKMDL", $outroot, $stack_id); 200 } 201 166 202 167 203 # XXX is this the correct PSF file? … … 194 230 print $listFile " SOURCES STR " . $sources . "\n"; 195 231 } 232 if ($updatemode) { 233 &my_die("Couldn't find input: $psfRaw", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$psfRaw"); 234 &my_die("Couldn't find input: $backmdlRaw", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$backmdlRaw"); 235 print $listFile " RAW:PSF STR " . $psfRaw . "\n"; 236 print $listFile " RAW:BACKMDL STR " . $backmdlRaw . "\n"; 237 } 196 238 if ($needConvolvedImages) { 197 239 print $listFile " CNV:IMAGE STR " . $imageCnv . "\n"; … … 205 247 } 206 248 207 # my $cmdflags;249 close $listFile; 208 250 209 251 # Perform stack photometry analysis 210 252 { 211 253 my $command = "$psphotStack $outroot"; 254 $command .= " -updatemode" if $updatemode; 212 255 $command .= " -input $listName"; 213 256 $command .= " -threads $threads" if defined $threads; … … 275 318 # &my_die("Couldn't find expected output file: $chisqMask", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqMask); 276 319 # &my_die("Couldn't find expected output file: $chisqVariance", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqVariance); 320 321 if (!$updatemode) { 322 # XXX: should be checking for existence of psf and backmdl output files 323 } 277 324 } 278 325 } else { … … 280 327 } 281 328 } 282 } else {283 # XXX This mode is no longer used. We run psphotStack even if there is only one filter284 # single input. Run psphot285 # find the recipe286 my $recipe_psphot = $ipprc->reduction($reduction, 'STACKPHOT_SINGLE_PSPHOT'); # Recipe to use for psphot287 unless ($recipe_psphot) {288 &my_die("Couldn't find selected reduction for STACKPHOT: $reduction\n", $sky_id, $PS_EXIT_CONFIG_ERROR);289 }290 291 print "reduction: $reduction\n";292 print "recipe_psphot: $recipe_psphot\n";293 294 my $configuration = $ipprc->filename("PSPHOT.SKY.CONFIG", $outroot);295 296 my $file = $files->[0];297 298 # XXX if we take the input from 'warp', we will need to make different selections here299 my $path_base = $file->{path_base};300 print "input: $path_base\n";301 302 # examine the recipe to determine whether to analyze the "raw" or convolved images303 my $command = "$ppConfigDump -camera $camera -dump-recipe PSPHOT -recipe PSPHOT $recipe_psphot -";304 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =305 run(command => $command, verbose => 0);306 unless ($success) {307 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);308 &my_die("Unable to perform ppConfigDump: $error_code", $sky_id, $PS_EXIT_SYS_ERROR);309 }310 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or311 &my_die("Unable to parse metadata config doc", $sky_id, $PS_EXIT_SYS_ERROR);312 313 my $use_raw = metadataLookupBool($recipeData, 'PSPHOT.STACK.USE.RAW');314 315 my ($image, $mask, $variance, $expnum);316 if ($use_raw) {317 $image = $ipprc->filename("PPSTACK.UNCONV", $path_base ); # Image name318 $mask = $ipprc->filename("PPSTACK.UNCONV.MASK", $path_base ); # Mask name319 $variance = $ipprc->filename("PPSTACK.UNCONV.VARIANCE", $path_base ); # Weight name320 $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Expnum name321 } else {322 $image = $ipprc->filename("PPSTACK.OUTPUT", $path_base ); # Image name323 $mask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $path_base ); # Mask name324 $variance = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $path_base ); # Weight name325 $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Expnum name326 }327 328 my $output_sources_filerule = "PSPHOT.OUT.CMF.MEF";329 my $output_psf_filerule = "PSPHOT.PSF.SKY.SAVE";330 331 # XXX we could make some different choices if some inputs do not exist...332 &my_die("Couldn't find input: $image", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$image");333 &my_die("Couldn't find input: $mask", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$mask");334 &my_die("Couldn't find input: $variance", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$variance");335 &my_die("Couldn't find input: $expnum", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$expnum");336 337 # Perform stack photometry analysis338 {339 my $command = "$psphot $outroot";340 $command .= " -file $image";341 $command .= " -mask $mask";342 $command .= " -variance $variance";343 $command .= " -expnum $expnum";344 $command .= " -threads $threads" if defined $threads;345 $command .= " -recipe PSPHOT $recipe_psphot";346 $command .= " -dumpconfig $configuration" if $configuration;347 $command .= " -tracedest $traceDest -log $logDest";348 $command .= " -F PSPHOT.OUTPUT $output_sources_filerule";349 $command .= " -F PSPHOT.PSF.SAVE $output_psf_filerule";350 351 unless ($no_op) {352 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);353 unless ($success) {354 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);355 &my_die("Unable to perform psphot: $error_code", $sky_id, $error_code);356 }357 358 my $quality = 0;359 if (!$quality) {360 my $outputSources = $ipprc->filename($output_sources_filerule, $outroot);361 &my_die("Couldn't find expected output file: $outputSources", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);362 my $outputPSF = $ipprc->filename($output_psf_filerule, $outroot);363 &my_die("Couldn't find expected output file: $outputPSF", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);364 }365 366 &my_die("Couldn't find expected output file: $configuration", $sky_id, $PS_EXIT_SYS_ERROR)367 unless $ipprc->file_exists($configuration);368 } else {369 print "Not executing: $command\n";370 }371 }372 329 } 373 330 … … 377 334 { 378 335 my $command = "$staticskytool -sky_id $sky_id"; 379 $command .= " -addresult -path_base $outroot"; 380 $command .= " -num_inputs $nInputs"; 381 # $command .= " $cmdflags"; 382 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 383 $command .= " -hostname $host" if defined $host; 384 $command .= " -dbname $dbname" if defined $dbname; 336 if ($updatemode) { 337 $command .= " -updaterun -set_state full"; 338 } else { 339 $command .= " -addresult -path_base $outroot"; 340 $command .= " -num_inputs $nInputs"; 341 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 342 $command .= " -hostname $host" if defined $host; 343 $command .= " -dbname $dbname" if defined $dbname; 344 } 385 345 386 346 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 388 348 unless ($success) { 389 349 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 390 my $err_message = "Unable to perform staticskytool -addresult";350 my $err_message = "Unable to perform: $command\n"; 391 351 warn($err_message); 392 352 exit $error_code; … … 406 366 warn($msg); 407 367 if (defined $sky_id and not $no_update) { 368 408 369 my $command = "$staticskytool -sky_id $sky_id -fault $exit_code"; 409 $command .= " -addresult"; 410 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 411 $command .= " -hostname $host" if defined $host; 412 $command .= " -path_base $outroot" if defined $outroot; 413 $command .= " -dbname $dbname" if defined $dbname; 370 if ($updatemode) { 371 $command .= " -updateresult"; 372 } else { 373 $command .= " -addresult"; 374 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 375 $command .= " -hostname $host" if defined $host; 376 $command .= " -path_base $outroot" if defined $outroot; 377 $command .= " -dbname $dbname" if defined $dbname; 378 } 414 379 run(command => $command, verbose => $verbose); 415 380 }
Note:
See TracChangeset
for help on using the changeset viewer.
