Changeset 36811 for trunk/pstamp/scripts/pstamp_job_run.pl
- Timestamp:
- Jun 3, 2014, 4:05:28 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_job_run.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_job_run.pl
r36142 r36811 71 71 } 72 72 73 my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR"); 74 $temproot = "/tmp" if !defined $temproot; 75 76 73 77 my $missing_tools; 74 78 75 79 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 76 my $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1);77 my $pstamp_get_image_job = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1);78 my $psgetcalibinfo = can_run('psgetcalibinfo') or (warn "Can't find psgetcalibinfo" and $missing_tools = 1);80 my $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1); 81 my $pstamp_get_image_job = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1); 82 my $psgetcalibinfo = can_run('psgetcalibinfo') or (warn "Can't find psgetcalibinfo" and $missing_tools = 1); 79 83 my $dquery_job_run = can_run('dquery_job_run.pl') or (warn "Can't find dquery_job_run.pl" and $missing_tools = 1); 80 84 my $whichnode = can_run('whichnode') or (warn "can't find whichnode" and $missing_tools = 1); 85 my $ppBackgroundStack = can_run('ppBackgroundStack') or (warn "Can't find ppBackgroundStack" and $missing_tools = 1); 86 my $stack_bkg_mk_mdc = can_run('stack_bkg_mk_mdc.pl') or (warn "Can't find stack_bkg_mk_mdc.pl" and $missing_tools = 1); 81 87 82 88 if ($missing_tools) { … … 120 126 } 121 127 128 if ($options & $PSTAMP_RESTORE_BACKGROUND) { 129 # this subroutine creates a background restored version of the image or fails. 130 # upon success params->{image} is replaced with the new (temporary) version 131 my $error_code = create_background_restored_images($params); 132 if ($error_code) { 133 # if error code is one of the permanant ones set state of job to stop 134 my_die("failed to create background restored images", $job_id, $error_code, 135 $error_code >= $PSTAMP_FIRST_ERROR_CODE ? 'stop' : undef); 136 } 137 } 138 122 139 my $image = $params->{image}; 123 140 my $mask; 124 141 my $variance; 142 143 # We need to background restore HERE 144 # and change the image file supplied to ppstamp 145 125 146 my $fileArgs = " -file $params->{image}"; 126 147 my @file_list = ($params->{image}); … … 665 686 } 666 687 688 sub create_background_restored_images { 689 my $params = shift; 690 my $stage = $params->{stage}; 691 if ($stage eq 'stack') { 692 my $tempdir = tempdir("$temproot/pstamp.$job_id.XXXX", CLEANUP => !$save_temps); 693 my $camera = $params->{camera}; 694 my $imagedb = $params->{imagedb}; 695 my $stack_id = $params->{stack_id}; 696 my $mdcfile = "$tempdir/stk.$stack_id.bkg_input.mdc"; 697 { 698 my $command = "$stack_bkg_mk_mdc --stack_id $stack_id --camera $camera --dbname $imagedb > $mdcfile"; 699 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 700 run(command => $command, verbose => $verbose); 701 unless ($success) { 702 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 703 &my_die("Unable to perform stack_bg_mk_mdc.pl: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 704 } 705 } 706 my $input_image = $params->{image}; 707 my $input_mask = $params->{mask}; 708 # XXX: perhaps we should save the background restored file in the working directory instead of a tempdir 709 my $outroot = "$tempdir/stk.$stack_id"; 710 # XXX: get otapath from a config file or detrend system 711 my $otapath = "neb:///detrends/background_OTA_models.20140527/test_solutions"; 712 { 713 my $command = "$ppBackgroundStack $outroot -input $mdcfile -image $input_image" 714 . " -OTApath $otapath" 715 ; 716 $command .= " -mask $input_mask" if $input_mask; 717 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 718 run(command => $command, verbose => 0); 719 unless ($success) { 720 # we turned off verbosity because ppBackgroundStack emits too much output 721 # XXX: perhaps use a log file and save it with the job data 722 print STDERR join "", @$stderr_buf; 723 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 724 &my_die("Unable to perform ppBackgroundStack: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 725 } 726 } 727 # it's all good change the image to be passed to ppstamp 728 # XXX use filerule 729 $params->{image} = "$outroot.bkgrest.fits"; 730 } else { 731 print STDERR "background restoration not currently supported for stage $params->{stage}\n"; 732 return $PSTAMP_BG_RESTORE_NOT_AVAILABLE; 733 } 734 735 return 0; 736 } 737 667 738 sub my_die 668 739 {
Note:
See TracChangeset
for help on using the changeset viewer.
