Changeset 27838 for branches/tap_branches/pstamp/scripts/pstamp_finish.pl
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstamp/scripts/pstamp_finish.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/pstamp/scripts/pstamp_finish.pl
r25739 r27838 63 63 my $pstamp_results = can_run('pstamp_results_file.pl') 64 64 or (warn "Can't find pstamp_results_file.pl" and $missing_tools = 1); 65 my $pstampdump = can_run('pstampdump') or (warn "Can't find pstampdump" and $missing_tools = 1); 65 66 if ($missing_tools) { 66 67 warn("Can't find required tools."); … … 123 124 my ($rlf, $reglist_name) = tempfile ("$out_dir/reglist.XXXX", UNLINK => !$save_temps); 124 125 print $rlf "results.fits|||table|\n"; 126 print $rlf "results.mdc|||text|\n"; 125 127 126 128 my $err_file = "parse_error.txt"; … … 169 171 my $exp_id = $job->{exp_id}; 170 172 173 171 174 if (($fault eq $PSTAMP_DUP_REQUEST) and ($req_name eq "NULL")) { 172 175 # this request had a duplicate request name. We can't put the results … … 186 189 } 187 190 188 if ($exp_id ne $last_exp_id) { 191 my $job_params = get_job_parameters($job); 192 my $stage = ""; 193 if ($job_params) { 194 $stage = $job_params->{stage}; 195 } 196 197 if ($stage ne 'stack') { 189 198 # get the metadata for the exposure (if any i.e. stack) 190 199 # returns an appropriate string if !$exp_id 191 200 $exp_info = get_exposure_info($image_db, $exp_id); 192 201 $last_exp_id = $exp_id; 202 } else { 203 my $filter = $job_params->{filter}; 204 $filter = "0" if !$filter; 205 $exp_info = "0|0|0|$filter|0|0"; 206 $last_exp_id = -1; 193 207 } 194 208 … … 208 222 209 223 # ra_deg and dec_deg are the coordinates of center of the stamp 224 # first assume that the image is compressed and check the first extension. 225 # If not found check the PHU. If that doesn't work just set them to zero. 210 226 # XXX do this more cleanly 211 my (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields -x -1 RA_DEG DEC_DEG`; 227 my (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields -x 0 RA_DEG DEC_DEG`; 228 if (!defined $ra_deg) { 229 (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields RA_DEG DEC_DEG`; 230 } 212 231 $ra_deg = 0.0 if (!$ra_deg); 213 232 $dec_deg = 0.0 if (!$dec_deg); … … 245 264 print STDERR "Unable to perform $command error code: $error_code\n"; 246 265 $request_fault = $error_code >> 8; 266 } else { 267 # dump a textual representation 268 my $command = "$pstampdump $out_dir/results.fits > $out_dir/results.mdc"; 269 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 270 run(command => $command, verbose => $verbose); 271 unless ($success) { 272 print STDERR "Unable to perform $command error code: $error_code\n"; 273 $request_fault = $error_code >> 8; 274 } 247 275 } 248 276 } … … 310 338 my $comment = $row->{COMMENT}; 311 339 $comment = "null" if !$comment; 312 my $label = $row->{LABEL}; 313 $label = "null" if !$label; 340 my $data_group = $row->{DATA_GROUP}; 341 if (!defined $data_group) { 342 # XXX: backwards compatibility hook. Remove "soon". 343 $data_group = $row->{LABEL}; 344 } 345 $data_group = "null" if !$data_group; 314 346 315 347 # This is ugly, error prone and hard to change. 316 348 # Create a results file module and provide a list of the names (we have the data in the columns) 317 349 my $rowinfo = "$row->{PROJECT}|$row->{JOB_TYPE}|$row->{REQ_TYPE}|$row->{IMG_TYPE}|"; 318 $rowinfo .= "$row->{ID}|$tess_id|$component|$ label|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";350 $rowinfo .= "$row->{ID}|$tess_id|$component|$data_group|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|"; 319 351 $rowinfo .= "$row->{REQFILT}|$row->{COORD_MASK}|$row->{CENTER_X}|$row->{CENTER_Y}|"; 320 352 $rowinfo .= "$row->{WIDTH}|$row->{HEIGHT}|"; … … 322 354 323 355 return ($row, $rowinfo, $row->{PROJECT}); 356 } 357 358 sub get_job_parameters { 359 my $job = shift; 360 if (!$job->{outputBase}) { 361 print "get_job_parameters: $job->{job_id} has no outputBase\n"; 362 return undef; 363 } 364 my $params_file = $job->{outputBase} . '.mdc'; 365 if (! -e $params_file ) { 366 print "get_job_parameters: $job->{job_id} has no parameters file\n"; 367 return undef; 368 } 369 open IN, "<$params_file" or die "unable to open $params_file"; 370 my $data = join "", (<IN>); 371 close IN; 372 if (! $data ) { 373 print "get_job_parameters: parameters file is empty\n"; 374 return undef; 375 } 376 my $metadata = $mdcParser->parse($data) or die("Unable to parse metdata config doc"); 377 378 my $results = parse_md_list($metadata); 379 if (scalar @$results != 1) { 380 print STDERR "get_job_params: failed to parse_md_list\n"; 381 return undef; 382 } 383 return $results->[0]; 324 384 } 325 385 … … 372 432 my $ra_deg = $exp->{ra} * RADIANS_TO_DEGREES; 373 433 my $decl_deg = $exp->{decl} * RADIANS_TO_DEGREES; 374 my $mjd_obs = dateobs_to_mjd($exp->{dateobs} , $exp->{exp_time});434 my $mjd_obs = dateobs_to_mjd($exp->{dateobs}); 375 435 376 436 my $info = "$mjd_obs|$ra_deg|$decl_deg|$exp->{filter}|$exp->{exp_time}|$exp->{exp_name}"; … … 381 441 sub dateobs_to_mjd { 382 442 my $dateobs = shift; 383 my $exp_time = shift;384 443 385 444 # dateobs is in format: 1970-01-01T00:00:00 … … 391 450 my $ticks = timegm($sec, $min, $hr, $day, $mon-1, $year-1900); 392 451 393 $ticks += $exp_time / 2.0;394 395 452 return 40587.0 + ($ticks/86400.); 396 453 }
Note:
See TracChangeset
for help on using the changeset viewer.
