Changeset 25143
- Timestamp:
- Aug 20, 2009, 11:12:36 AM (17 years ago)
- Location:
- branches/czw_branch/cleanup/pstamp
- Files:
-
- 5 edited
-
scripts/pstamp_finish.pl (modified) (12 diffs)
-
scripts/pstamp_job_run.pl (modified) (1 diff)
-
scripts/pstamp_listjobs.pl (modified) (1 diff)
-
scripts/pstampparse.pl (modified) (23 diffs)
-
src/ppstampMakeStamp.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup/pstamp/scripts/pstamp_finish.pl
r25051 r25143 8 8 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 9 9 use Pod::Usage qw( pod2usage ); 10 use Carp; 10 11 11 12 use Time::Local; … … 47 48 48 49 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 49 50 50 if ($redirect_output) { 51 51 my $logDest = "$out_dir/psfinish.$req_id.log"; … … 94 94 if (!mkdir $out_dir) { 95 95 print STDERR "cannot create output directory $out_dir"; 96 stop_request ($req_id, $PS_EXIT_UNKNOWN_ERROR);96 stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR); 97 97 } 98 98 … … 102 102 # request 103 103 print STDERR "output directory $out_dir exists but is not a directory"; 104 stop_request ($req_id, $PS_EXIT_UNKNOWN_ERROR);104 stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR); 105 105 } 106 106 107 107 if (! -e $req_file ) { 108 108 print STDERR "request file $req_file is missing\n"; 109 stop_request ($req_id, $PS_EXIT_CONFIG_ERROR);109 stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR); 110 110 } 111 111 … … 117 117 # point 118 118 print STDERR "failed to read request_file $req_file" ; 119 stop_request ($req_id, $PS_EXIT_CONFIG_ERROR);119 stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR); 120 120 } 121 121 … … 154 154 print STDERR "Request $req_id produced no jobs.\n" 155 155 } 156 # No Jobs. 157 # XXXX Ouch. We need results for each rownum (each request specification) in the request file 158 # including those that produced no jobs. 159 # for now add an entry for rownum 1 and a phony error code. 160 # we've included parse_error.txt to the fileset if it exists 161 # 162 my $rownum = 0; 163 my $fault = 42; # get a real error code 164 print $tdf "$rownum|$fault|0|0|"; 165 print $tdf "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|\n"; 156 # This should not happen. A fake job should be queued 157 stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR); 166 158 } else { 167 159 my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc"); … … 182 174 my $exp_id = $job->{exp_id}; 183 175 176 if ($fault eq $PSTAMP_DUP_REQUEST) { 177 # this request had a duplicate request name. We can't put the results 178 # on the data store since the product name is already used 179 # maybe we could be more clever about this and choose a fileset name 180 stop_request_and_exit($req_id, $fault); 181 } 182 184 183 my ($row, $req_info, $project) = get_request_info($rows, $rownum); 185 184 … … 188 187 if (!$image_db) { 189 188 carp("failed to find imagedb for project: $project"); 190 stop_request($req_id, $PS_EXIT_CONFIG_ERROR); 189 if (!$fault) { 190 stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR); 191 } 191 192 } 192 193 … … 227 228 print $tdf "$exp_info|"; 228 229 print $tdf "$req_info|"; 230 print $tdf "\n"; 229 231 } 230 232 } else { … … 277 279 } 278 280 279 sub stop_request {281 sub stop_request_and_exit { 280 282 my $req_id = shift; 281 283 my $fault = shift; … … 299 301 my $row = $rows->{$rownum}; 300 302 303 # these may be set to null during processing 304 my $component = $row->{COMPONENT}; 305 $component = "null" if !$component; 306 my $tess_id = $row->{TESS_ID}; 307 $tess_id = "null" if !$tess_id; 308 301 309 # This is ugly, error prone and hard to change. 302 310 # Create a results file module and provide a list of the names (we have the data in the columns) 303 311 my $rowinfo = "$row->{PROJECT}|$row->{JOB_TYPE}|$row->{REQ_TYPE}|$row->{IMG_TYPE}|"; 304 $rowinfo .= "$row->{ID}|$ row->{TESS_ID}|$row->{COMPONENT}|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";312 $rowinfo .= "$row->{ID}|$tess_id|$component|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|"; 305 313 $rowinfo .= "$row->{REQFILT}|$row->{COORD_MASK}|$row->{CENTER_X}|$row->{CENTER_Y}|"; 306 314 $rowinfo .= "$row->{WIDTH}|$row->{HEIGHT}"; … … 313 321 my $exp_id = shift; 314 322 315 if (!$exp_id ) {323 if (!$exp_id or !$image_db) { 316 324 # no exposure id just return zeros 317 325 # XXX: we could put a value in for filter, but we don't have a good place to find it -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_job_run.pl
r25051 r25143 208 208 $command .= " -job_id $job_id"; 209 209 $command .= " -fault $exit_code"; 210 # XXX: fix pstamptool to not require -state when -fault with nonzero value is provided 211 $command .= " -state run"; 210 212 $command .= " -dbname $dbname" if defined $dbname; 211 213 $command .= " -dbserver $dbserver" if defined $dbserver; -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_listjobs.pl
r24951 r25143 12 12 my $verbose; 13 13 my $dbname; 14 my $d server;14 my $dbserver; 15 15 16 16 GetOptions( -
branches/czw_branch/cleanup/pstamp/scripts/pstampparse.pl
r25051 r25143 14 14 use PS::IPP::PStamp::Job qw( :standard ); 15 15 use File::Temp qw(tempfile); 16 use Carp; 16 17 17 18 my $verbose; … … 91 92 # make sure the file contains what we are expecting 92 93 93 die "$request_file_name is not a PS1_PS_REQEST" if $extname ne "PS1_PS_REQUEST"; 94 die "REQ_NAME not found in $request_file_name" if (!$req_name); 95 die "wrong EXTVER $extver found in $request_file_name" if ($extver ne "1"); 94 # we shouldn't get here if this is the case so just die. No need to notify the client 95 my_die("$request_file_name is not a PS1_PS_REQEST", $PS_EXIT_PROG_ERROR) if $extname ne "PS1_PS_REQUEST"; 96 my_die("REQ_NAME not found in $request_file_name", $PS_EXIT_PROG_ERROR) if (!$req_name); 97 my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1"); 98 99 # check for duplicate request name 100 if (!$no_update) { 101 my $command = "$pstamptool -listreq -name $req_name"; 102 $command .= " -dbname $dbname" if $dbname; 103 $command .= " -dbserver $dbserver" if $dbserver; 104 # no verbose so that error message about request not found doesn't appear in parse_error.txt 105 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 106 run(command => $command, verbose => 0); 107 my $exitStatus = $error_code >> 8; 108 if ($success) { 109 # -listreq succeeded duplicate request name 110 insertFakeJobForRow(undef, 0, $PSTAMP_DUP_REQUEST); 111 exit 0; 112 } elsif ($exitStatus ne $PS_EXIT_DATA_ERROR) { 113 # wrong error code something else is wrong 114 my_die("$command failed", $exitStatus); 115 } 116 } 96 117 97 118 if ($req_id and !$no_update) { 119 # update the database with the request name. This will be used as the 120 # the output data store's product name 98 121 my $command = "$pstamptool -updatereq -req_id $req_id -name $req_name"; 99 122 $command .= " -outProduct $product"; … … 103 126 run(command => $command, verbose => $verbose); 104 127 unless ($success) { 105 die "$command failed";128 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 106 129 } 107 130 } … … 120 143 } 121 144 my $table = $mdcParser->parse(join "", @$stdout_buf) or 122 die("Unable to parse metdata config doc");145 my_die("Unable to parse metdata config doc", $PS_EXIT_UNKNOWN_ERROR); 123 146 124 147 $rows = parse_md_list($table); … … 143 166 # parameters that select the images of interest 144 167 my $project = $row->{PROJECT}; 168 169 # note: resolve_project avoids running pstamptool every time by remembering the 170 # last project resolved 171 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 172 if (!$proj_hash) { 173 print STDERR "project $project not found\n" if $verbose; 174 insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PRODUCT); 175 $num_jobs++; 176 next; 177 } 145 178 my $req_type = $row->{REQ_TYPE}; 146 179 $stage = $row->{IMG_TYPE}; … … 153 186 154 187 my $option_mask= $row->{OPTION_MASK}; 155 156 die "valid region of interest is required to make postage stamps" 157 if (($job_type eq "stamp") and ! validROI($row)); 188 my $inverse = ($option_mask & $PSTAMP_SELECT_INVERSE) ? 1 : 0; 189 $row->{inverse} = $inverse; 158 190 159 191 my $skycenter = $row->{skycenter} = ! ($row->{COORD_MASK} & $PSTAMP_CENTER_IN_PIXELS); 160 $component = "" if (defined($component) and ($component eq "null" or $component eq "all")); 192 193 my $search_component = (!defined($component) or ($component eq "null")) ? "" : $component; 161 194 162 die "job_type is list_uri but mode is $mode" if ($job_type eq "list_uri") and ($mode ne "list_uri"); 163 164 165 # note: resolve_project avoids running pstamptool every time by remembering the 166 # last project resolved 167 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 168 die "project $project not found\n" unless $proj_hash; 195 if (!$skycenter and !$search_component) { 196 print STDERR "COMPONENT must be specified for pixel coordinate ROI\n" if $verbose; 197 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 198 $num_jobs++; 199 next; 200 } 201 202 $search_component = "" if $search_component eq "all"; 203 204 if (($job_type eq "stamp") and ! validROI($row)) { 205 print STDERR "invalid ROI for row $rownum\n" if $verbose; 206 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 207 $num_jobs++; 208 next; 209 } 210 211 212 # $mode list_uri is a debugging mode (it may used by the http interface) 213 # if this happens just croak 214 my_die("job_type is list_uri but mode is $mode", $PS_EXIT_PROG_ERROR) if ($job_type eq "list_uri") and ($mode ne "list_uri"); 215 169 216 170 217 my $image_db = $proj_hash->{dbname}; … … 173 220 174 221 # collect rows with the same images of interest in a list so that they 175 # can be processed optimially222 # can be looked up together 176 223 if (@rowList) { 177 224 my $firstRow = $rowList[0]; 178 # XXX: the collecting might work with !$skycenter but I need to think about it 179 if ($skycenter and same_images_of_interest($row, $firstRow)) { 225 # note order of these parameters matters 226 if (same_images_of_interest($firstRow, $row)) { 227 228 # add this row to the list and move on 180 229 push @rowList, $row; 181 # On to the next row 230 182 231 next; 232 183 233 } else { 184 # queue the jobs for this set of rows 234 # this row has different selectors 235 # queue the jobs for the ones we've collected 185 236 $num_jobs += queueJobs($mode, \@rowList, $imageList); 186 237 @rowList = (); … … 188 239 } 189 240 241 # look up images for the current row 190 242 if ($req_type eq "bycoord") { 191 die "center must be specified in sky coordintes for bycoord" if ( ! $skycenter); 192 die "lookup bycoord is not yet implemented"; 243 if (!$skycenter) { 244 print STDERR "center must be specified in sky coordintes for bycoord" if $verbose; 245 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 246 $num_jobs++; 247 next; 248 } 249 print STDERR "lookup bycoord is not yet implemented" if $verbose; 250 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED); 251 $num_jobs++; 252 next; 193 253 } else { 194 195 # Call PS::IPP::PStamp::Job's locate_images routine to get the parameters for this 196 # request specification. An array reference is returned 254 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this 255 # request specification. An array reference is returned. 197 256 my ($x, $y); 198 $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $component, $skycenter, 199 $x, $y, $mjd_min, $mjd_max, $filter, $verbose); 200 } 201 202 if (!$imageList or !@$imageList) { 203 print STDERR "no matching images found for row $rownum\n"; 204 next; 205 } 206 $row->{need_magic} = $need_magic; 207 push @rowList, $row; 257 258 $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $search_component, 259 $inverse, $skycenter, $x, $y, $mjd_min, $mjd_max, $filter, $verbose); 260 261 if (!$imageList or !@$imageList) { 262 print STDERR "no matching images found for row $rownum\n" if $verbose; 263 # note in this case queueJobs inserts the fake job for these rows 264 } 265 $row->{need_magic} = $need_magic; 266 push @rowList, $row; 267 } 208 268 } 209 269 … … 212 272 } 213 273 214 if ($mode eq "queue_jobs") { 215 if ($num_jobs) { 216 exit 0; 217 } else { 218 # no jobs queued return error to get the request stopped 219 # TODO: need to define meaningful error codes 220 exit $PS_EXIT_UNKNOWN_ERROR; 221 } 222 } else { 223 exit 0; 224 } 274 if (($mode eq "queue_jobs") and ($num_jobs eq 0)) { 275 print STDERR "no jobs created for $req_name\n" if $verbose; 276 insertFakeJobForRow(undef, 0, $PSTAMP_UNKNOWN_ERROR); 277 } 278 279 # PAU 280 281 exit 0; 225 282 226 283 … … 232 289 my $have_skycells = shift; 233 290 my $need_magic = shift; 291 my $num_jobs = 0; 292 293 my $rownum = $row->{ROWNUM}; 294 295 my $components = $row->{components}; 296 297 my $roi_string; 298 299 # note values were insured to be numbers in validROI() 300 my $x = $row->{CENTER_X}; 301 my $y = $row->{CENTER_Y}; 302 my $w = $row->{WIDTH}; 303 my $h = $row->{HEIGHT}; 304 my $coord_mask = $row->{COORD_MASK}; 305 if ($x && ($x ne "null") && $y && ($y ne "null") && $w && ($w ne "null") && $h && ($h ne "null")) { 306 if ($coord_mask & $PSTAMP_CENTER_IN_PIXELS) { 307 $roi_string = "-pixcenter $x $y"; 308 } else { 309 $roi_string = "-skycenter $x $y"; 310 } 311 if ($coord_mask & $PSTAMP_RANGE_IN_PIXELS) { 312 $roi_string .= " -pixrange $w $h"; 313 } else { 314 $roi_string .= " -arcrange $w $h"; 315 } 316 } 234 317 235 318 # loop over images … … 244 327 245 328 # skip this component if it is not in the list for this row 246 next if !$row->{components}->{$component}; 247 248 my $rownum = $row->{ROWNUM}; 249 250 my $roi_string; 251 252 # note values were insured to be numbers in validROI() 253 my $x = $row->{CENTER_X}; 254 my $y = $row->{CENTER_Y}; 255 my $w = $row->{WIDTH}; 256 my $h = $row->{HEIGHT}; 257 my $coord_mask = $row->{COORD_MASK}; 258 if ($x && ($x ne "null") && $y && ($y ne "null") && $w && ($w ne "null") && $h && ($h ne "null")) { 259 if ($coord_mask & $PSTAMP_CENTER_IN_PIXELS) { 260 $roi_string = "-pixcenter $x $y"; 261 } else { 262 $roi_string = "-skycenter $x $y"; 263 } 264 if ($coord_mask & $PSTAMP_RANGE_IN_PIXELS) { 265 $roi_string .= " -pixrange $w $h"; 266 } else { 267 $roi_string .= " -arcrange $w $h"; 268 } 269 } 329 next if ! $components->{$component}; 330 331 $job_num++; 270 332 271 333 my $imagefile = $image->{image}; 272 334 if (($stage ne "stack") and ($need_magic and !$image->{magicked})) { 273 # XXX: should we add a faulted job so the client can know what happened ?335 # XXX: should we add a faulted job so the client can know what happened if no images come back? 274 336 print STDERR "skippping non-magicked image $imagefile\n" if $verbose; 337 338 # for now assume yes. 339 340 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 341 275 342 next; 276 343 } … … 282 349 } 283 350 284 $job_num++;285 286 351 # add astrometry file for raw and chip images if one is available 287 352 if (($stage eq "chip") || ($stage eq "raw")) { … … 302 367 303 368 # copy the argument list to a file 304 open ARGSLIST, ">$argslist" or die "failed to open $argslist";369 open ARGSLIST, ">$argslist" or my_die("failed to open $argslist", $PS_EXIT_UNKNOWN_ERROR); 305 370 print ARGSLIST "$args\n"; 306 close ARGSLIST or die "failed to close $argslist"; 307 308 # XXX: TODO: here is where we need to check whether or not the source inputs still exist 309 # and if not, queue an update job and set the job state appropriately. 371 close ARGSLIST or my_die("failed to close $argslist", $PS_EXIT_UNKNOWN_ERROR); 310 372 311 373 my $newState = "run"; 374 my $fault = 0; 375 376 if (($stage ne 'stack') and ($stage ne 'raw')) { 377 if (($image->{state} eq 'goto_purged') or ($image->{data_state} eq 'purged')) { 378 $newState = 'stop'; 379 $fault = $PSTAMP_GONE; 380 } elsif (($image->{data_state} ne 'full') or ($image->{state} ne 'full' )) { 381 # XXX here is where we need to queue an update job 382 # for now just say that the image is not available 383 $newState = 'stop'; 384 $fault = $PSTAMP_NOT_AVAILABLE; 385 } 386 } 312 387 313 388 $num_jobs++; 314 389 my $command = "$pstamptool -addjob -req_id $req_id -job_type $row->{JOB_TYPE}" 315 390 . " -outputBase $output_base -rownum $rownum -state $newState"; 391 $command .= " -fault $fault" if $fault; 316 392 $command .= " -exp_id $exp_id" if $exp_id; 317 393 $command .= " -dbname $dbname" if $dbname; … … 331 407 # should we keep going for other uris? If so how do we report that some 332 408 # of the work that the request wanted isn't going to get done 333 die "failed to queue job for request $req_id";409 my_die("failed to queue job for request $req_id", $PS_EXIT_UNKNOWN_ERROR); 334 410 } 335 411 } else { … … 337 413 } 338 414 } 415 if ( $num_jobs == 0 ) { 416 print STDERR "no jobs for row $rownum\n" if $verbose; 417 insertFakeJobForRow($row, 1, $PSTAMP_NO_OVERLAP); 418 $num_jobs = 1; 419 } 339 420 return $num_jobs; 340 421 } 341 422 423 # queue jobs for a collection of request specifications that have the same Images of Interest 342 424 sub queueJobs 343 425 { … … 358 440 } 359 441 } elsif ($job_type eq "get_image") { 360 die "get_image jobs not implemented yet"; 442 print STDERR "get_image jobs not implemented yet" if $verbose; 443 foreach my $row (@$rowList) { 444 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED); 445 $num_jobs++; 446 } 361 447 } else { 362 my $thisRun; 363 364 my ($pointsList, $pointsListName) = tempfile ("/tmp/pointsList.XXXX", UNLINK => !$save_temps); 365 foreach my $row (@$rowList) { 366 print $pointsList "$row->{ROWNUM} $row->{CENTER_X} $row->{CENTER_Y}\n"; 367 $row->{components} = {}; 368 } 369 close $pointsList; 448 if (!$imageList or (scalar @$imageList eq 0)) { 449 # we didn't find any images for this set of rows. Insert a fake job to carry 450 # the status back to the requestor 451 foreach my $row (@$rowList) { 452 insertFakeJobForRow($row, 1, $PSTAMP_NO_IMAGE_MATCH); 453 $num_jobs++; 454 } 455 return $num_jobs; 456 } 370 457 371 458 my $have_skycells; … … 376 463 } 377 464 465 my $thisRun; 466 467 my ($pointsList, $pointsListName) = tempfile ("/tmp/pointsList.XXXX", UNLINK => !$save_temps); 468 my $npoints = 0; 469 foreach my $row (@$rowList) { 470 $row->{components} = {}; 471 if ($row->{skycenter}) { 472 print $pointsList "$row->{ROWNUM} $row->{CENTER_X} $row->{CENTER_Y}\n"; 473 $npoints++; 474 } else { 475 # this row's center is in pixel coordinates add all images to the component list for this row 476 foreach my $i (@$imageList) { 477 my $component = $have_skycells ? $i->{skycell_id} : $i->{class_id}; 478 my_die( "image found with no value for component", $PS_EXIT_UNKNOWN_ERROR) if !$component; 479 $row->{components}->{$component} = 1; 480 } 481 } 482 } 483 close $pointsList; 484 378 485 my $tess_dir_abs; 379 486 my $last_tess_id = ""; 380 487 while ($thisRun = getOneRun($stage, $imageList)) { 381 { 488 if ($npoints) { 489 # we collected a set of sky coordintates above filter the images so that only 490 # those tat contain the centers are processed 382 491 my $command = "$dvoImagesAtCoords $pointsListName"; 383 492 if ($have_skycells) { … … 391 500 } else { 392 501 my $astrom = $thisRun->[0]->{astrom}; 393 die "no astrometry file found"if !$astrom;502 my_die( "no astrometry file found", $PS_EXIT_UNKNOWN_ERROR) if !$astrom; 394 503 my $astrom_resolved = $ipprc->file_resolve($astrom); 395 504 $command .= " -astrom $astrom_resolved"; … … 400 509 print STDERR @$stderr_buf; 401 510 my $rc = $error_code >> 8; 402 die "dvoImagesAtCoords failed: $rc";511 my_die( "dvoImagesAtCoords failed: $rc", $PS_EXIT_UNKNOWN_ERROR); 403 512 } 404 513 # now we have a list of row numbers and components … … 422 531 } 423 532 return $num_jobs; 533 } 534 sub insertFakeJobForRow 535 { 536 my $row = shift; 537 my $job_num = shift; 538 my $fault = shift; 539 540 my ($job_type, $rownum); 541 if ($row) { 542 $job_type = $row->{JOB_TYPE}; 543 $rownum = $row->{ROWNUM}; 544 } else { 545 $job_type = "none"; 546 $rownum = 0; 547 } 548 549 my $command = "$pstamptool -addjob -req_id $req_id -job_type $job_type" 550 . " -rownum $rownum -state stop -fault $fault"; 551 $command .= " -dbname $dbname" if $dbname; 552 $command .= " -dbserver $dbserver" if $dbserver; 553 554 if ($mode eq "list_job") { 555 # this is a debugging mode, just print the pstamptool that would have run 556 # this is sort of like the mode -noupdate that some other tools support 557 print "$command\n"; 558 } elsif (!$no_update) { 559 # mode eq "queue_job" 560 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 561 run(command => $command, verbose => $verbose); 562 unless ($success) { 563 print STDERR @$stderr_buf; 564 # XXX TODO: now what? Should we mark the error state for the request? 565 # should we keep going for other uris? If so how do we report that some 566 # of the work that the request wanted isn't going to get done 567 my_die("failed to queue job for request $req_id", $PS_EXIT_UNKNOWN_ERROR); 568 } 569 } else { 570 print "skipping command: $command\n"; 571 } 424 572 } 425 573 … … 440 588 return $image->{diff_id}; 441 589 } else { 442 die "unenexpected stage: $stage found";590 my_die("unenexpected stage: $stage found", $PS_EXIT_PROG_ERROR); 443 591 } 444 592 } … … 476 624 return 0 if ($r1->{IMG_TYPE} ne $r2->{IMG_TYPE}); 477 625 return 0 if ($r1->{ID} ne $r2->{ID}); 626 return 0 if ($r1->{inverse} ne $r2->{inverse}); 478 627 479 628 if (defined($r1->{COMPONENT})) { 480 629 return 0 if !defined $r2->{COMPONENT} or ($r1->{COMPONENT} ne $r2->{COMPONENT}); 481 630 } elsif (defined($r2->{COMPONENT})) { 631 # if first row has no component all of the images will be retrieved, so 632 # the fact that this row has a component is ok. Fall through to return 1 633 # XXX Nope that doesn't work (yet) 482 634 return 0; 483 635 } … … 514 666 return undef; 515 667 } 668 669 sub my_die 670 { 671 my $msg = shift; 672 my $fault = shift; 673 674 carp $msg; 675 676 # we don't fault the request here pstamp_parser_run.pl handles that if necessary 677 678 return $fault; 679 } -
branches/czw_branch/cleanup/pstamp/src/ppstampMakeStamp.c
r21403 r25143 17 17 18 18 static void skyToChip(pmAstromObj *pt, pmFPA *fpa, pmChip *chip); 19 static bool setMaskedToNAN(pmConfig *config, psImage *image, psImage *mask, psImage *variance); 19 20 20 21 // convert the input chip's transforms to the output … … 325 326 break; 326 327 } 328 if (readout->variance) { 329 outReadout->variance = extractStamp(readout->variance, extractRegion, 0); 330 if (!outReadout->variance) { 331 psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp weight image\n"); 332 status = false; 333 break; 334 } 335 } 327 336 if (readout->mask) { 328 337 outReadout->mask = extractStamp(readout->mask, extractRegion, 0); … … 332 341 break; 333 342 } 334 } 335 if (readout->variance) { 336 outReadout->variance = extractStamp(readout->variance, extractRegion, 0); 337 if (!outReadout->variance) { 338 psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp weight image\n"); 339 status = false; 340 break; 343 344 if (!setMaskedToNAN(config, outReadout->image, outReadout->mask, outReadout->variance)) { 345 psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp mask image\n"); 346 status = false; 347 break; 341 348 } 342 349 } … … 668 675 669 676 677 static bool setMaskedToNAN(pmConfig *config, psImage *image, psImage *mask, psImage *variance) 678 { 679 bool status; 680 psMetadata *masks = psMetadataLookupMetadata(&status, config->recipes, "MASKS"); 681 if (!status) { 682 psError(PM_ERR_CONFIG, false, "failed to lookup MASKS in recipes\n"); 683 return false; 684 } 685 // we set anything masked to NAN except if CONV.POOR is the only bit set 686 // First check the old value 687 psU32 convPoor = psMetadataLookupU32(&status, masks, "POOR.WARP"); 688 if (!status) { 689 convPoor = psMetadataLookupU32(&status, masks, "CONV.POOR"); 690 if (!status) { 691 psError(PM_ERR_CONFIG, false, "failed to lookup mask value for CONV.POOR in recipes\n"); 692 return false; 693 } 694 } 695 psU32 maskMask = ~convPoor; 696 697 double exciseValue; 698 if (image->type.type == PS_TYPE_U16) { 699 exciseValue = 0xffff; 700 } else if (image->type.type == PS_TYPE_F32) { 701 exciseValue = NAN; 702 } else { 703 psError(PS_ERR_PROGRAMMING, true, "unexpected image type: %d\n", image->type.type); 704 return false; 705 } 706 long numExcised = 0; 707 for (int y=0; y<image->numRows; y++) { 708 for (int x=0; x<image->numCols; x++) { 709 psU16 maskVal = psImageGet(mask, x, y); 710 if (maskVal & maskMask) { 711 numExcised++; 712 psImageSet(image, x, y, exciseValue); 713 if (variance) { 714 psImageSet(variance, x, y, exciseValue); 715 } 716 } 717 } 718 } 719 fprintf(stderr, "excised %ld masked pixels\n", numExcised); 720 721 return true; 722 }
Note:
See TracChangeset
for help on using the changeset viewer.
