Changeset 37403 for branches/eam_branches/ps2-tc3-20130727/pstamp/scripts
- Timestamp:
- Sep 19, 2014, 4:05:27 PM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 10 edited
-
. (modified) (1 prop)
-
pstamp/scripts/psmkreq (modified) (3 diffs)
-
pstamp/scripts/pstamp_checkdependent.pl (modified) (5 diffs, 1 prop)
-
pstamp/scripts/pstamp_finish.pl (modified) (1 diff, 1 prop)
-
pstamp/scripts/pstamp_insert_request.pl (modified) (1 diff)
-
pstamp/scripts/pstamp_job_run.pl (modified) (6 diffs, 1 prop)
-
pstamp/scripts/pstamp_save_server_status.pl (modified) (1 prop)
-
pstamp/scripts/pstamp_webrequest.pl (modified) (1 diff)
-
pstamp/scripts/pstampparse.pl (modified) (1 diff, 1 prop)
-
pstamp/scripts/request_finish.pl (modified) (3 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/psmkreq
r36680 r37403 29 29 my ($ra, $dec, $x, $y, $list, $output, $req_name, $req_name_base); 30 30 31 my ($image, $mask, $variance, $jpeg, $cmf, $psf, $backmdl, $inverse );31 my ($image, $mask, $variance, $jpeg, $cmf, $psf, $backmdl, $inverse, $restorebackground); 32 32 my ($convolved, $unconvolved, $uncompressed, $use_imfile_id, $no_wait); 33 33 … … 120 120 'convolved' => \$convolved, 121 121 'uncompressed' => \$uncompressed, 122 'restorebackground' => \$restorebackground, 122 123 'use_imfile_id' => \$use_imfile_id, 123 124 'do_not_wait' => \$no_wait, … … 224 225 $option_mask |= $PSTAMP_USE_IMFILE_ID if $use_imfile_id; 225 226 $option_mask |= $PSTAMP_SELECT_INVERSE if $inverse; 227 $option_mask |= $PSTAMP_RESTORE_BACKGROUND if $restorebackground; 226 228 } 227 229 $option_mask |= $PSTAMP_NO_WAIT_FOR_UPDATE if $no_wait; -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_checkdependent.pl
- Property svn:mergeinfo set to
r36680 r37403 20 20 use PS::IPP::PStamp::RequestFile qw( :standard ); 21 21 use Carp; 22 23 my $disable_3PI_updates = 0; 24 my $ra_max_3PI_hours = 22.5; # disable updates for skycells with ra greater than this (hours) 25 my $ra_max_3PI = $ra_max_3PI_hours * 15 * 3.14149 / 180.; # rawExp.ra is in radians 22 26 23 27 # XXX: put this in a module somewhere … … 257 261 push @chips, $chip->{class_id}; 258 262 263 if ($disable_3PI_updates && ($chip->{data_group} =~ /ThreePi/)) { 264 # we are getting close to the end of PV2. Do not update PV1 chips if RA is above the limit. 265 my $ra = $chip->{ra}; 266 if (!defined($ra) or ($ra > $ra_max_3PI)) { 267 print "3PI updates are currently disabled for RA $ra > $ra_max_3PI (radians)\n"; 268 return $PSTAMP_NOT_AVAILABLE; 269 } else { 270 print "allowing 3PI updates RA $ra\n"; 271 } 272 } 273 259 274 my $state = $chip->{state}; 260 275 my $data_state = $chip->{data_state}; … … 303 318 $command .= " -set_label $rlabel" if $rlabel; 304 319 305 # if this is one of the chipRuns from the PV1 LAP regenerate without using the ppImage configdump file 306 if ($chip->{data_group} =~ /^LAP.ThreePi.20130706/) { 307 $command .= ' -set_update_mode 1'; 320 my $update_mode; 321 if ($chip->{data_group} =~ /^LAP.ThreePi.20120706/) { 322 # if this is one of the chipRuns from the PV1 LAP regenerate without using the ppImage configdump file. 323 # XXX: PV2 processing is complete. Don't do this anymore 324 # $update_mode = 1; 325 } elsif ($chip->{data_group} =~ /^M31.rp.2013/) { 326 # Version of M31 processed with recipes and auxiliary masks incompatible with the 327 # current code. Run from scratch which will use compatible versions of the same masks.. 328 $update_mode = 1; 308 329 } 330 $command .= " -set_update_mode $update_mode" if $update_mode; 309 331 310 332 if (!$no_update) { … … 371 393 my $data_state = $metadata->{data_state}; 372 394 395 # we are getting close to the end of PV2. optionally do not update 3Pi data. 396 if ($disable_3PI_updates && ($metadata->{data_group} =~ /ThreePi/)) { 397 my $ra = $metadata->{ra}; 398 if (!defined $ra or ($ra > $ra_max_3PI)) { 399 print "3PI updates are currently disabled for RA $ra > $ra_max_3PI (radians)\n"; 400 return $PSTAMP_NOT_AVAILABLE; 401 } else { 402 print "allowing 3PI updates RA $ra\n"; 403 } 404 } 405 373 406 # The update system currently requires that data that has been magicked be destreaked 374 407 # at chip stage so it needs magic even if the customer doesn't. … … 451 484 } 452 485 $chip_id = $chip->{chip_id}; 486 # XXX: -scmap doesn't have ra and dec. Copy it from the warp 487 $chip->{ra} = $metadata->{ra}; 488 $chip->{decl} = $metadata->{decl}; 453 489 454 490 # if chip has been magicked before require it to be magicked again -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_finish.pl
- Property svn:mergeinfo set to
r35409 r37403 211 211 chomp $line; 212 212 my ($img_name, $reported_size, $reported_sum, $filetype) = split '\|', $line; 213 # ... instead let dsreg compute the paramters by leaving them blank 214 print $rlf "$img_name|||$filetype|\n"; 213 my $use_supplied_size = 1; 214 if ($use_supplied_size) { 215 print $rlf "$img_name|$reported_size|$reported_sum|$filetype|\n"; 216 } else { 217 # ... instead let dsreg compute the paramters by leaving them blank 218 print $rlf "$img_name|||$filetype|\n"; 219 } 215 220 216 221 # add line to the table definition file -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_insert_request.pl
r36680 r37403 119 119 } 120 120 121 my $datestr = strftime "%Y%m%d", gmtime; 121 # put file in directory for the current date 122 my $datestr = strftime "%Y/%m/%d", gmtime; 122 123 my $datedir = "$workdir/webreq/$datestr"; 123 124 if (! -e $datedir ) { 124 if (! mkdir $datedir ) { 125 print STDERR "failed to create working directory $datedir"; 125 my $rc = system "mkdir -p $datedir"; 126 if ($rc) { 127 my $status = $rc >> 8; 128 print STDERR "failed to create working directory $datedir: $rc $status"; 126 129 exit $PS_EXIT_CONFIG_ERROR; 127 130 } 128 131 } 132 129 133 130 134 my $webreq_num = get_webreq_num(); -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_job_run.pl
- Property svn:mergeinfo set to
r36680 r37403 29 29 my ($job_id, $redirect_output, $outputBase, $rownum, $jobType, $options); 30 30 my ($verbose, $dbname, $dbserver, $no_update, $save_temps); 31 my $very_verbose = 0; # for debugging 31 32 32 33 GetOptions( … … 67 68 } 68 69 70 if ($verbose && $save_temps) { 71 # we're probably debugging turn up the verbosity 72 $very_verbose = 1; 73 } 74 69 75 if (!$dbserver) { 70 76 $dbserver = metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER'); 71 77 } 72 78 79 my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR"); 80 $temproot = "/tmp" if !defined $temproot; 81 73 82 my $missing_tools; 74 83 75 84 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);85 my $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1); 86 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); 87 my $psgetcalibinfo = can_run('psgetcalibinfo') or (warn "Can't find psgetcalibinfo" and $missing_tools = 1); 79 88 my $dquery_job_run = can_run('dquery_job_run.pl') or (warn "Can't find dquery_job_run.pl" and $missing_tools = 1); 80 89 my $whichnode = can_run('whichnode') or (warn "can't find whichnode" and $missing_tools = 1); 90 my $ppBackground = can_run('ppBackground') or (warn "Can't find ppBackground" and $missing_tools = 1); 91 my $ppBackgroundStack = can_run('ppBackgroundStack') or (warn "Can't find ppBackgroundStack" and $missing_tools = 1); 92 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); 93 my $fpack = can_run('fpack') or (warn "Can't find fpack" and $missing_tools = 1); 94 81 95 82 96 if ($missing_tools) { … … 120 134 } 121 135 136 if ($options & $PSTAMP_RESTORE_BACKGROUND) { 137 # this subroutine creates a background restored version of the image or fails. 138 # upon success params->{image} is replaced with the new (temporary) version 139 my $error_code = create_background_restored_images($params); 140 if ($error_code) { 141 # if error code is one of the permanant ones set state of job to stop 142 my_die("failed to create background restored images", $job_id, $error_code, 143 $error_code >= $PSTAMP_FIRST_ERROR_CODE ? 'stop' : undef); 144 } 145 } 146 122 147 my $image = $params->{image}; 123 148 my $mask; 124 149 my $variance; 150 125 151 my $fileArgs = " -file $params->{image}"; 126 152 my @file_list = ($params->{image}); … … 197 223 198 224 # unless the stage is stack_summary we use ppstamp to make postage stamps (including -wholefile) 199 # otherwisewe make copies of the input files to the outputs225 # if stage is stack_summary we make copies of the input files to the outputs 200 226 my $use_ppstamp = ($stage ne 'stack_summary'); 201 227 … … 216 242 $exitStatus = $PS_EXIT_SYS_ERROR; 217 243 } 218 # XXX: if stage is stack deal with EXP and NUM images if selected 244 245 # if stage is stack deal with EXP and NUM images if selected by running ppstamp again 246 if (!$exitStatus and $stage eq 'stack' and ($options & ($PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM))) { 247 # XXX Here I am assuming that nothing relevant gets added to $argString 248 # Need to check 249 my $roiArgs = $params->{job_args}; 250 251 # XXX: define expnum and exptime input images in the params file so that we don't have to 252 # make assumptions about the file rules here 253 my $pathBase = $params->{stack_path_base}; 254 $pathBase = $params->{path_base} unless defined $pathBase; 255 unless (defined $pathBase) { 256 my_die("stack path base undefined found when creating exp or expnum image", $job_id, $PS_EXIT_PROG_ERROR); 257 } 258 $pathBase .= ".unconv"; 259 my $tmpBase = "$outputBase.TMP"; 260 # nocompress because exp image gets corrupted if we do 261 my $command = "$ppstamp $tmpBase $roiArgs -nocompress -stage stack"; 262 # XXX: use file rules 263 # Image is the EXP (exptime) image 264 $command .= " -file $pathBase.exp.fits"; 265 # treat number image as mask 266 $command .= " -mask $pathBase.num.fits" if ($options & $PSTAMP_SELECT_NUM); 267 268 $command .= " -forheader $calibfile" if $calibfile; 269 270 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 271 run(command => $command, verbose => $verbose); 272 273 if (WIFEXITED($error_code)) { 274 $exitStatus = WEXITSTATUS($error_code); 275 } else { 276 print STDERR "ppstamp failed error_code: $error_code\n"; 277 $exitStatus = $PS_EXIT_SYS_ERROR; 278 } 279 280 # command to compress fits files to stdout using gzip 281 my $fpack_gzip = "$fpack -g -S"; 282 $fpack_gzip .= " -D" unless $save_temps; 283 284 if (!$exitStatus and ($options & $PSTAMP_SELECT_NUM)) { 285 # rename the num image if selected since it is not a mask 286 # Change .exp.mk to .num 287 my $tmpName = "$tmpBase.mk.fits"; 288 my $numName = "$outputBase.num.fits"; 289 # optionally fpack it while we're here unless user wants uncompressed images 290 unless ($options & $PSTAMP_SELECT_UNCOMPRESSED) { 291 my $command = "$fpack_gzip $tmpName > $numName"; 292 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 293 run(command => $command, verbose => $verbose); 294 295 if (WIFEXITED($error_code)) { 296 $exitStatus = WEXITSTATUS($error_code); 297 } else { 298 print STDERR "ppstamp failed error_code: $error_code\n"; 299 print STDERR "@$stderr_buf\n"; 300 $exitStatus = $PS_EXIT_SYS_ERROR; 301 } 302 } elsif (!$exitStatus) { 303 rename $tmpName, $numName 304 or my_die ("failed to rename $tmpName to $numName", $job_id, $PS_EXIT_UNKNOWN_ERROR); 305 } 306 307 } 308 # fpack the exp image if not -nocompress 309 unless ($exitStatus or ($options & $PSTAMP_SELECT_UNCOMPRESSED)) { 310 my $command = "$fpack_gzip $tmpBase.fits > $outputBase.exp.fits"; 311 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 312 run(command => $command, verbose => $verbose); 313 314 if (WIFEXITED($error_code)) { 315 $exitStatus = WEXITSTATUS($error_code); 316 } else { 317 print STDERR "ppstamp failed error_code: $error_code\n"; 318 print STDERR "@$stderr_buf\n"; 319 $exitStatus = $PS_EXIT_SYS_ERROR; 320 } 321 } elsif (!$exitStatus) { 322 rename "$tmpBase.fits", "$outputBase.exp.fits" 323 or my_die ("failed to rename $tmpBase.fits to $outputBase.exp.fits", $job_id, $PS_EXIT_UNKNOWN_ERROR); 324 } 325 } 219 326 } else { 220 327 $exitStatus = justCopyFiles($outputBase, \$options, $params); … … 665 772 } 666 773 774 # use ppBackground or ppBackgroundStack to produce background restored images 775 sub create_background_restored_images { 776 my $params = shift; 777 my $stage = $params->{stage}; 778 779 if ($stage ne 'stack' and $stage ne 'chip') { 780 # this function is only supported for chip and stack stage 781 # perhaps the parser should catch this ... 782 print STDERR "background restoration not currently supported for stage $params->{stage}\n"; 783 return $PSTAMP_BG_RESTORE_NOT_AVAILABLE; 784 } 785 786 my $tempdir = tempdir("$temproot/pstamp.$job_id.XXXX", CLEANUP => !$save_temps); 787 my $imagedb = $params->{imagedb}; 788 my $camera = $params->{camera}; 789 790 # reinstantiate IPP Configuration using the now known camera so that we get the applicable file rules 791 $ipprc = PS::IPP::Config->new($camera); 792 793 my $input_image = $params->{image}; 794 my $input_mask = $params->{mask}; 795 my $input_variance = $params->{weight}; 796 797 if ($stage eq 'stack') { 798 my $stack_id = $params->{stack_id}; 799 my $mdcfile = "$tempdir/stk.$stack_id.bkg_input.mdc"; 800 { 801 my $command = "$stack_bkg_mk_mdc --stack_id $stack_id --camera $camera --dbname $imagedb > $mdcfile"; 802 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 803 run(command => $command, verbose => $verbose); 804 unless ($success) { 805 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 806 &my_die("Unable to perform stack_bg_mk_mdc.pl: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 807 } 808 } 809 810 my $outroot = "$tempdir/stk.$stack_id"; 811 812 # XXX: get otapath from a config file or detrend system 813 my $otapath = "neb:///detrends/background_OTA_models.20140527/test_solutions"; 814 { 815 my $command = "$ppBackgroundStack $outroot -input $mdcfile -image $input_image" 816 . " -OTApath $otapath" ; 817 $command .= " -mask $input_mask" if $input_mask; 818 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 819 run(command => $command, verbose => $very_verbose); 820 unless ($success) { 821 # we turned off verbosity because ppBackgroundStack emits too much output 822 # XXX: perhaps use a log file and save it with the job data 823 print STDERR join "", @$stderr_buf; 824 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 825 &my_die("Unable to perform ppBackgroundStack: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 826 } 827 } 828 # it's all good change the image to be passed to ppstamp 829 $params->{image} = $ipprc->filename('PPBACKGROUND.STACK.OUTPUT', $outroot) or 830 &my_die("Unable to resolve ppBackgroundStack output file name", $job_id, $PS_EXIT_UNKNOWN_ERROR, 'run'); 831 832 } elsif ($stage eq 'chip') { 833 my $input_mdl = $params->{backmdl}; 834 my $chip_id = $params->{chip_id}; 835 my $class_id = $params->{class_id}; 836 my $outroot = "$tempdir/bgrestored.ch.$chip_id"; 837 { 838 my $command = "$ppBackground $outroot -background $input_mdl -image $input_image"; 839 # XXX: I think ppBackground might always require mask and variance images 840 $command .= " -mask $input_mask"; 841 $command .= " -variance $input_variance"; 842 843 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 844 run(command => $command, verbose => $verbose); 845 unless ($success) { 846 print STDERR join "", @$stderr_buf; 847 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 848 &my_die("Unable to perform ppBackground: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 849 } 850 } 851 $params->{image} = $ipprc->filename('PPBACKGROUND.OUTPUT', $outroot, $class_id) or 852 &my_die("Unable to resolve ppBackgroundStack output image name", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 853 $params->{mask} = $ipprc->filename('PPBACKGROUND.OUTPUT.MASK', $outroot, $class_id) or 854 &my_die("Unable to resolve ppBackgroundStack output mask name", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 855 $params->{weight} = $ipprc->filename('PPBACKGROUND.OUTPUT.VARIANCE', $outroot, $class_id) or 856 &my_die("Unable to resolve ppBackgroundStack output variance name", $job_id, $PS_EXIT_CONFIG_ERROR, 'run'); 857 858 } else { 859 # can't get here 860 &my_die( "background restoration not currently supported for stage $params->{stage}\n", 861 $job_id, $PS_EXIT_PROG_ERROR, 'stop'); ; 862 } 863 864 return 0; 865 } 866 667 867 sub my_die 668 868 { -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_save_server_status.pl
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_webrequest.pl
r35439 r37403 93 93 my $command = "$psmkreq --req_name $request_name --output $request_file @ARGV"; 94 94 95 if (0) { 96 open DEBUG, ">>/tmp/pstamp.debug.log"; 97 print DEBUG "\ncommand is: $command\n"; 98 close DEBUG; 99 } 100 95 101 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 96 102 run(command => $command, verbose => $verbose); 97 103 unless ($success) { 98 104 print STDERR @$stderr_buf; 105 print STDERR "\ncommand was: $command\n"; 99 106 die("Unable to perform psmkreq: $error_code"); 100 107 } -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstampparse.pl
- Property svn:mergeinfo set to
r36680 r37403 179 179 $label = "PY"; 180 180 $label_changed = 1; 181 } elsif ($lcname =~ /ncu/) { 182 $label = 'NCU'; 183 $label_changed = 1; 184 } elsif (($lcname =~ /mpe_/) or ($lcname =~ /sd_/) or ($lcname =~ /^jk/)) { 185 $label = 'MPE'; 186 $label_changed = 1; 181 187 } 182 188 print "Setting label for $req_name to $label\n" if $label_changed; -
branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/request_finish.pl
- Property svn:mergeinfo set to
r27874 r37403 20 20 21 21 use PS::IPP::Config qw( :standard ); 22 use PS::IPP::PStamp::RequestFile qw( :standard ); 22 23 23 24 my ( $req_id, $req_name, $req_file, $req_type, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output ); 25 26 my $ipprc = PS::IPP::Config->new(); 24 27 25 28 GetOptions( … … 57 60 if ($redirect_output) { 58 61 my $logDest = "$outdir/reqfinish.$req_id.log"; 59 my $ipprc = PS::IPP::Config->new();60 62 $ipprc->redirect_output($logDest); 63 } 64 65 if (!$dbserver) { 66 $dbserver = metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER'); 61 67 } 62 68 … … 90 96 } 91 97 } else { 92 # Unknown request type. 93 # Since we don't have a req_name there's not much we can do so just the request's state to stop. 98 # Unknown request type. Stop job with fault invalid request. 94 99 print STDERR "request $req_id has unknown reqType $req_type\n" if $verbose; 95 my $command = "$pstamptool -updatereq -req_id $req_id -state stop -fault $PS_EXIT_DATA_ERROR"; 100 101 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $PSTAMP_INVALID_REQUEST"; 96 102 $command .= " -dbname $dbname" if $dbname; 97 103 $command .= " -dbserver $dbserver" if $dbserver;
Note:
See TracChangeset
for help on using the changeset viewer.
