Changeset 36018
- Timestamp:
- Aug 23, 2013, 1:31:54 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (6 diffs)
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm (modified) (2 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r36010 r36018 774 774 } 775 775 776 776 777 if ($skycells) { 778 # We have a list of skycells. Find matching projection cells. 779 780 #list of projection_cells that we've included 781 my %projection_cells_found; 777 782 foreach my $skycell (@$skycells) { 778 783 my $tess_id = $skycell->{tess_id}; … … 781 786 my $projection_cell = skycell_id_to_projection_cell($skycell_id); 782 787 783 print "$tess_id $skycell_id $projection_cell\n"; 784 my $command = "$stacktool -dbname $imagedb -summary -tess_id $tess_id -projection_cell $projection_cell"; 788 # only need to include a projection cell once 789 next if $projection_cells_found{$projection_cell}; 790 791 $projection_cells_found{$projection_cell} = 1; 792 793 # print "$tess_id $skycell_id $projection_cell\n"; 794 795 my $command = "$stacktool -dbname $imagedb -summary -tess_id $tess_id"; 796 $command .= " -projection_cell $projection_cell"; 785 797 786 798 $command .= " -filter $filter" if $filter; … … 791 803 } 792 804 } 793 # XXX: Lookup stackSummaries that match794 } 805 } 806 795 807 if ($results) { 796 808 foreach my $summary (@$results) { … … 799 811 800 812 # we need to flesh out the hashes returned with values that the parser expects 813 $summary->{stage} = 'stack_summary'; 801 814 $summary->{component} = $projection_cell; 802 815 $summary->{stage_id} = $summary->{sass_id}; 803 # $summary->{image} = "$path_base.$projection_cell.image.b1.fits"; 804 $summary->{image} = "$path_base.$projection_cell"; 816 $summary->{path_base} = "$path_base.$projection_cell"; 817 818 # The stack_summary stage doesn't follow the usual ipp conventions for file rules 819 # and path_base. We leave it up to the program that runs the job to handle this. 820 # However, the parser uses the image parameter to set the job's outputBase (by removing the .fits) 821 # so we need to set it. Just use the new path_base. 822 $summary->{image} = $summary->{path_base}; 805 823 $summary->{state} = 'full'; 806 824 $summary->{data_state} = 'full'; … … 809 827 $summary->{row_index} = []; 810 828 push @{$summary->{row_index}}, 0; 811 # XXX: is there anything else? 829 830 # XXX: Are there any other required parameters? 812 831 # TODO: create a function to validate the components returned 813 # and make sure that any required elements are there 832 # and make sure that any required elements are there. 814 833 } 815 834 } … … 1970 1989 } 1971 1990 1972 # not particularly elegant 1991 # Convert from skycell_id to projection_cell 1992 # This code is not particularly elegant but I think that it matches the SQL used 1993 # to create stackAssocations does. 1994 1973 1995 sub skycell_id_to_projection_cell { 1974 1996 my $skycell_id = shift; 1997 1998 # split skycell_id into '.' separated components 1975 1999 my @strs = split '\.', $skycell_id; 1976 2000 1977 2001 my $num = scalar @strs; 2002 2003 # projection_cell is 'skycell_id' plus all .num values except the last one 1978 2004 my $projection_cell = $strs[0]; 1979 2005 for (my $i=1; $i < $num - 1; $i++) { -
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm
r35466 r36018 29 29 $PSTAMP_SELECT_BACKMDL 30 30 $PSTAMP_SELECT_JPEG 31 $PSTAMP_SELECT_EXP 32 $PSTAMP_SELECT_NUM 31 33 $PSTAMP_SELECT_UNCOMPRESSED 32 34 $PSTAMP_SELECT_INVERSE … … 71 73 our $PSTAMP_SELECT_BACKMDL = 32; 72 74 our $PSTAMP_SELECT_JPEG = 64; 73 # unused 128 74 # unused 256 75 our $PSTAMP_SELECT_EXP = 128; 76 our $PSTAMP_SELECT_NUM = 256; 75 77 our $PSTAMP_SELECT_UNCOMPRESSED = 512; 76 78 our $PSTAMP_SELECT_INVERSE = 1024; -
trunk/pstamp/scripts/pstamp_job_run.pl
r35903 r36018 62 62 $options &= ~($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED); 63 63 64 64 65 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 65 66 if ($redirect_output) { … … 95 96 my $argString; 96 97 $argString = $params->{job_args}; 98 99 my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 100 97 101 my $stage = $params->{stage}; 98 99 # XXX: should we do any other sanity checking? 100 my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 102 my_die("stage is not defined", $job_id, $PS_EXIT_DATA_ERROR) if !$stage; 103 104 if ($stage eq 'stack_summary') { 105 106 # remove options not supported by stack summary 107 $options &= ~($PSTAMP_SELECT_SOURCES | $PSTAMP_SELECT_BACKMDL | $PSTAMP_SELECT_INVERSE 108 | $PSTAMP_RESTORE_BACKGROUND); 109 110 # stackSummary outputs do not follow the usual IPP conventions for file names. 111 # The parser (actually Job.pm) has deferred handling this until here 112 update_stack_summary_filenames($params); 113 114 } elsif ($stage ne 'stack') { 115 # ignore options only supported by stack and stack_summary 116 $options &= ~($PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM); 117 } 118 101 119 102 120 if ($stage eq "raw") { … … 181 199 } 182 200 183 # my ($tmpImage, $tmpMask, $tmpVariance, $tmproot); 184 185 my $command = "$ppstamp $outputBase $argString $fileArgs"; 186 $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG); 187 $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED); 188 $command .= " -stage $stage"; 189 $command .= " -forheader $calibfile" if $calibfile; 190 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 191 run(command => $command, verbose => $verbose); 201 # unless the stage is stack_summary we use ppstamp to make postage stamps (including -wholefile) 202 # otherwise we make copies of the input files to the outputs 203 my $use_ppstamp = ($stage ne 'stack_summary'); 192 204 193 205 my $exitStatus; 194 if (WIFEXITED($error_code)) { 195 $exitStatus = WEXITSTATUS($error_code); 196 } else { 197 print STDERR "ppstamp failed error_code: $error_code\n"; 198 $exitStatus = $PS_EXIT_SYS_ERROR; 206 if ($use_ppstamp) { 207 my $command = "$ppstamp $outputBase $argString $fileArgs"; 208 $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG); 209 $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED); 210 $command .= " -stage $stage"; 211 $command .= " -forheader $calibfile" if $calibfile; 212 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 213 run(command => $command, verbose => $verbose); 214 215 if (WIFEXITED($error_code)) { 216 $exitStatus = WEXITSTATUS($error_code); 217 } else { 218 print STDERR "ppstamp failed error_code: $error_code\n"; 219 $exitStatus = $PS_EXIT_SYS_ERROR; 220 } 221 # XXX: if stage is stack deal with EXP and NUM images if selected 222 } else { 223 $exitStatus = justCopyFiles($outputBase, \$options, $params); 199 224 } 200 225 … … 208 233 209 234 # Note: we are assuming the contents of the PSTAMP filerules here. 210 my %extensions = ( $PSTAMP_SELECT_IMAGE => "fits", 211 $PSTAMP_SELECT_MASK => "mk.fits", 212 $PSTAMP_SELECT_VARIANCE => "wt.fits", 213 $PSTAMP_SELECT_SOURCES => "cmf", 214 $PSTAMP_SELECT_JPEG => "jpg"); 215 216 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE | $PSTAMP_SELECT_JPEG | $PSTAMP_SELECT_SOURCES); 235 my %extensions = ( $PSTAMP_SELECT_IMAGE => 'fits', 236 $PSTAMP_SELECT_MASK => 'mk.fits', 237 $PSTAMP_SELECT_VARIANCE => 'wt.fits', 238 $PSTAMP_SELECT_SOURCES => 'cmf', 239 $PSTAMP_SELECT_JPEG => 'jpg', 240 $PSTAMP_SELECT_EXP => 'exp.fits', 241 $PSTAMP_SELECT_NUM => 'num.fits'); 242 243 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE 244 | $PSTAMP_SELECT_JPEG | $PSTAMP_SELECT_SOURCES | $PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM); 217 245 218 246 foreach my $key (keys (%extensions)) { … … 534 562 } 535 563 564 sub update_stack_summary_filenames { 565 my $params = shift; 566 567 my $path_base = $params->{path_base}; 568 569 $params->{image} = $path_base . ".image.b1.fits"; 570 $params->{mask} = $path_base . ".mask.b1.fits"; 571 $params->{weight} = $path_base . ".variance.b1.fits"; 572 $params->{exp} = $path_base . ".exp.b1.fits"; 573 $params->{num} = $path_base . ".num.b1.fits"; 574 575 } 576 577 sub myCopy { 578 my ($dest, $src, $type, $dieOnFail) = @_; 579 580 my $result; 581 my $resolved = $ipprc->file_resolve($src); 582 if ($ipprc->file_exists($resolved)) { 583 $result = copy($resolved, $dest); 584 } else { 585 my $msg = "Specified source $type image $src not found."; 586 if ($dieOnFail) { 587 $msg .= "\n"; 588 } else { 589 $msg .= " ignoring\n"; 590 } 591 carp $msg; 592 $result = 0; 593 } 594 595 if (!$result and $dieOnFail) { 596 &my_die("Unable to copy $type image", $job_id, $PS_EXIT_SYS_ERROR, 'run'); 597 } 598 return $result; 599 } 600 601 sub justCopyFiles { 602 my ($outputBase, $r_options, $params) = @_; 603 604 my $options = $$r_options; 605 if ($options & $PSTAMP_SELECT_IMAGE) { 606 myCopy("$outputBase.fits", $params->{image}, 'image', 1); 607 } 608 if ($options & $PSTAMP_SELECT_MASK) { 609 if (!myCopy("$outputBase.mk.fits", $params->{mask}, 'mask', 0)) { 610 $options &= ~$PSTAMP_SELECT_MASK; 611 } 612 } 613 if ($options & $PSTAMP_SELECT_VARIANCE) { 614 if (!myCopy("$outputBase.wt.fits", $params->{weight}, 'variance', 0)) { 615 $options = ~$PSTAMP_SELECT_VARIANCE; 616 } 617 } 618 if ($options & $PSTAMP_SELECT_EXP) { 619 if (!myCopy("$outputBase.exp.fits", $params->{exp}, 'exp', 0)) { 620 $options &= ~$PSTAMP_SELECT_EXP; 621 } 622 } 623 if ($options & $PSTAMP_SELECT_NUM) { 624 if (!myCopy("$outputBase.num.fits", $params->{num}, 'num', 0)) { 625 $options &= ~$PSTAMP_SELECT_NUM; 626 } 627 } 628 629 $$r_options = $options; 630 631 return 0; 632 } 633 536 634 sub my_die 537 635 {
Note:
See TracChangeset
for help on using the changeset viewer.
