- Timestamp:
- Jul 2, 2015, 9:42:32 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/skycalibration.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/skycalibration.pl
r38115 r38565 62 62 63 63 my ($skycal_id, $stack_id, $camera, $dbname, $threads, $outroot, $path_base, $filter, $singlefilter, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps); 64 my $run_state = 'new'; 64 65 GetOptions( 65 66 'skycal_id=s' => \$skycal_id, # sky calibration run id … … 69 70 'threads=s' => \$threads, # Number of threads to use 70 71 'outroot=s' => \$outroot, # Output root name 72 'run-state=s' => \$run_state, # 'new' or 'update' 71 73 'path_base=s' => \$path_base, # path_base of input 72 74 'filter=s' => \$filter, # filter for input stack … … 112 114 # generate the input 113 115 my $cmdflags = ""; 116 117 unless ($run_state eq 'new' or $run_state eq 'update') { 118 &my_die("$run_state is not a valid value for run-state\n", $skycal_id, $PS_EXIT_CONFIG_ERROR); 119 } 120 my $updateMode = $run_state eq 'update'; 114 121 115 122 my $recipe_psastro = $ipprc->reduction($reduction, 'STATICSKY_CALIBRATION'); # Recipe to use for psastro … … 223 230 # Perform psastro analysis 224 231 my $output_sources_filerule = 'PSASTRO.OUTPUT.CMF'; 232 my $quality = 0; 225 233 { 226 234 my $command = "$psastro $outroot"; … … 230 238 $command .= " -recipe PSPHOT $recipe_psphot"; 231 239 $command .= " -F PSASTRO.OUTPUT $output_sources_filerule"; 240 $command .= " -Db PSASTRO.SAVE.CFF F" if $updateMode; 232 241 $command .= " -stats $stats"; 233 242 # $command .= " -recipe PPSTATS CAMSTATS"; … … 262 271 $cmdflags .= $compatability_flags unless ($cmdflags =~ /-n_detections/); 263 272 264 my $quality;265 273 ($quality) = $cmdflags =~ /-quality (\d+)/; 266 274 if (!$quality) { … … 279 287 280 288 # Add the result to the database 281 {289 if (!$updateMode) { 282 290 my $command = "$staticskytool -skycal_id $skycal_id"; 283 291 $command .= " -addskycalresult -path_base $outroot"; … … 292 300 unless ($success) { 293 301 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 294 my $err_message = "Unable to perform staticskytool -addresult"; 302 my $err_message = "Unable to perform $command"; 303 warn($err_message); 304 exit $error_code; 305 } 306 } else { 307 print "skipping $command\n"; 308 } 309 } else { 310 if ($quality) { 311 # First update the result 312 my $command = "$staticskytool -updateresult $skycal_id -set_fault 0"; 313 $command .= " -set_quality $quality"; 314 $command .= " -dbname $dbname" if defined $dbname; 315 316 unless($no_update) { 317 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 318 run(command => $command, verbose => $verbose); 319 unless ($success) { 320 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 321 my $err_message = "Unable to perform $command"; 322 warn($err_message); 323 exit $error_code; 324 } 325 } else { 326 print "skipping $command\n"; 327 } 328 } 329 my $command = "$staticskytool -skycal_id $skycal_id"; 330 $command .= ' -updaterun -set_state full'; 331 $command .= " -dbname $dbname" if defined $dbname; 332 333 unless($no_update) { 334 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 335 run(command => $command, verbose => $verbose); 336 unless ($success) { 337 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 338 my $err_message = "Unable to perform $command"; 295 339 warn($err_message); 296 340 exit $error_code; … … 315 359 if (defined $skycal_id and not $no_update) { 316 360 my $command = "$staticskytool -skycal_id $skycal_id -fault $exit_code"; 317 $command .= " -addskycalresult"; 318 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 319 $command .= " -hostname $host" if defined $host; 320 $command .= " -path_base $outroot" if defined $outroot; 361 if ($updateMode) { 362 $command .= ' -updateskycalresult'; 363 } else { 364 $command .= " -addskycalresult"; 365 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 366 $command .= " -hostname $host" if defined $host; 367 $command .= " -path_base $outroot" if defined $outroot; 368 } 321 369 $command .= " -dbname $dbname" if defined $dbname; 322 370 run(command => $command, verbose => $verbose);
Note:
See TracChangeset
for help on using the changeset viewer.
