Changeset 34772 for branches/czw_branch/20120906/pstamp
- Timestamp:
- Dec 6, 2012, 6:32:19 PM (14 years ago)
- Location:
- branches/czw_branch/20120906/pstamp
- Files:
-
- 12 edited
- 1 copied
-
scripts (modified) (1 prop)
-
scripts/dquery_finish.pl (modified) (2 diffs)
-
scripts/pstamp_checkdependent.pl (modified) (5 diffs)
-
scripts/pstamp_finish.pl (modified) (2 diffs)
-
scripts/pstamp_request_file (modified) (8 diffs)
-
scripts/pstamp_targetlist_file.pl (copied) (copied from trunk/pstamp/scripts/pstamp_targetlist_file.pl )
-
scripts/pstampparse.pl (modified) (6 diffs)
-
src/ppstampArguments.c (modified) (4 diffs)
-
src/ppstampMakeStamp.c (modified) (15 diffs)
-
src/ppstampOptions.c (modified) (1 diff)
-
src/ppstampOptions.h (modified) (1 diff)
-
src/ppstampParseCamera.c (modified) (1 diff)
-
src/pstamp.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/pstamp/scripts
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20120905/pstamp/scripts (added) merged: 34428,34466,34567,34575,34735,34747
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/pstamp/scripts/dquery_finish.pl
r33324 r34772 128 128 my $job_id = $job->{job_id}; 129 129 130 if ($job->{fault}) { 131 # how do we get this information back to the user? 132 print STDERR "job: $job_id faulted with $job->{fault}\n"; 133 next; 134 } 130 135 my $outputBase = $job->{outputBase}; 131 136 my $results = "${outputBase}results.txt"; … … 166 171 my $results = shift; 167 172 168 open IN, "<$results_file" or my_die("failed to open $results_file ", $PS_EXIT_UNKNOWN_ERROR);173 open IN, "<$results_file" or my_die("failed to open $results_file\n", $PS_EXIT_UNKNOWN_ERROR); 169 174 170 175 foreach my $line (<IN>) { -
branches/czw_branch/20120906/pstamp/scripts/pstamp_checkdependent.pl
r34238 r34772 137 137 print "skipping $command\n"; 138 138 } 139 } elsif (($it->{state} eq 'cleaned') or ($it->{state} eq ' update')) {139 } elsif (($it->{state} eq 'cleaned') or ($it->{state} eq 'goto_cleaned') or ($it->{state} eq 'update')) { 140 140 # For warp and diff stages we need to call the 'queue_update' subroutines even if the 141 141 # data_state is update in order to check the state of inputs in earlier stages in the pipeline … … 260 260 # caller will fault the jobs 261 261 return $error_code; 262 } elsif ($chip->{state} eq 'goto_cleaned') { 263 264 # we don't need to check for full data_state 265 # if ($chip->{data_state} eq 'full') { 266 { 267 # cleanup must not be running. Set state to update. If this chip is not 'full' it will be 268 # set to be updated the next time this script is invoked 269 # XXX: In the very rare case that this chip run is actually in the running cleanup pantasks 270 # queue things may get confused but we can live with that 271 my $command = "$chiptool -updaterun -set_state update -chip_id $chip_id"; 272 $command .= " -set_label $rlabel" if $rlabel; 273 274 if (!$no_update) { 275 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 276 run(command => $command, verbose => $verbose); 277 unless ($success) { 278 my_die("failed to change ${stage}Run $stage_id $component from goto_cleaned to update", $PS_EXIT_UNKNOWN_ERROR); 279 } 280 } else { 281 print "skipping $command\n"; 282 } 283 $queued_update = 1; 284 } 262 285 } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) { 263 286 … … 320 343 } 321 344 } 345 346 my $tess_id = $metadata->{tess_id}; 347 if ($tess_id eq 'RINGS.V0') { 348 # we have stopped updating data from RINGS.V0 349 return $PSTAMP_GONE 350 } 322 351 if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or 323 352 ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/) or ($data_state eq 'drop')) { … … 343 372 344 373 my $skycell = $metadata; 374 375 # if ($skycell->{state} eq 'goto_cleaned' and $skycell->{data_state} eq 'full') { 376 if ($skycell->{state} eq 'goto_cleaned') { 377 # cleanup has been queued, but hasn't finished, probably due to an error or cleanup is not running. 378 # It's "safe" to set the state to update. If the skycell is not full it will be set to update 379 # the next time this task runs 380 my $command = "$warptool -updaterun -set_state update -warp_id $warp_id"; 381 $command .= " -set_label $rlabel" if $rlabel; 382 383 if (!$no_update) { 384 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 385 run(command => $command, verbose => $verbose); 386 unless ($success) { 387 my_die("failed to change state of ${stage}Run $stage_id from goto_cleaned to update", $PS_EXIT_UNKNOWN_ERROR); 388 } 389 } else { 390 print "skipping $command\n"; 391 } 392 return 0; 393 } 345 394 346 395 # get the list of input chips for this skycell … … 428 477 my $skycell = $metadata; 429 478 my $skycell_id = $skycell->{skycell_id}; 479 480 # if ($metadata->{state} eq 'goto_cleaned' and $metadata->{data_state} eq 'full') { 481 if ($metadata->{state} eq 'goto_cleaned') { 482 # cleanup must not be running. Set state to update. If the skycell is not 'full' it will be 483 # set to be updated the next time this script is invoked 484 print "changing state of diffRun $diff_id from goto_cleaned to update. skycell $skycell_id is full\n"; 485 my $command = "$difftool -updaterun -set_state update -diff_id $diff_id"; 486 $command .= " -set_label $rlabel" if $rlabel; 487 488 if (!$no_update) { 489 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 490 run(command => $command, verbose => $verbose); 491 unless ($success) { 492 my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR); 493 } 494 } else { 495 print "skipping $command\n"; 496 } 497 return 0; 498 } 430 499 431 500 if ($diff_mode == $IPP_DIFF_MODE_WARP_STACK ) { -
branches/czw_branch/20120906/pstamp/scripts/pstamp_finish.pl
r33670 r34772 107 107 my ($header, $rows) = read_request_file($req_file); 108 108 109 if (!$header or !$rows) { 110 # Since a request got queued, the request file must have been readable at some 111 # point 109 my $action = $header->{ACTION}; 110 111 if (!$header or (($action eq 'PROCESS') and !$rows)) { 112 # Since a request got queued, the request file must have been readable at some point 112 113 my_die("failed to read request file $req_file", $req_id, $PS_EXIT_CONFIG_ERROR); 113 114 } … … 126 127 } 127 128 128 # The results table definition file 129 my ($tdf, $table_def_name) = tempfile ("$outdir/tabledef.XXXX", UNLINK => !$save_temps); 130 131 # data for the header 132 print $tdf "$req_name|$req_id|\n"; 133 134 # get the list of jobs generated for this request 135 my @jobs; 136 { 137 my $command = "$pstamptool -listjob -req_id $req_id"; 138 $command .= " -dbname $dbname" if $dbname; 139 $command .= " -dbserver $dbserver" if $dbserver; 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 run(command => $command, verbose => $verbose); 142 unless ($success) { 143 die("Unable to perform $command error code: $error_code"); 144 } 145 my $output = join "", @$stdout_buf; 146 if (!$output) { 147 # This should not happen. A fake job should have been entered 148 my_die("Request $req_id produced no jobs", $req_id, $PS_EXIT_PROG_ERROR); 149 } else { 150 my $jobs = parse_md_fast($mdcParser, $output); 151 152 @jobs = @$jobs; 153 } 154 } 155 156 my $exp_info; 157 foreach my $job (@jobs) { 158 my $job_id = $job->{job_id}; 159 my $job_type = $job->{jobType}; 160 my $rownum = $job->{rownum}; 161 my $fault = $job->{fault}; 162 my $exp_id = $job->{exp_id}; 163 164 my $error_string = get_error_string($fault); 165 166 if (($fault eq $PSTAMP_DUP_REQUEST) and ($req_name eq "NULL")) { 167 # this request had a duplicate request name yet the parser didn't give 168 # it an "ERROR style name. 169 my_die("duplicate request not given a request name", $req_id, $PS_EXIT_PROG_ERROR); 170 } 171 my ($row, $req_info, $project) = get_request_info($rows, $rownum); 172 173 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 174 my $image_db = $proj_hash->{dbname}; 175 if (!$image_db and !$fault) { 176 # if project isn't resolvable, the paser should have faulted this job 177 my_die("failed to find imagedb for project $project", $req_id, $PS_EXIT_CONFIG_ERROR); 178 } 179 180 my $job_params = get_job_parameters($job); 181 my $stage = ""; 182 if ($job_params) { 183 $stage = $job_params->{stage}; 184 } 185 186 if ($stage ne 'stack') { 187 # get the metadata for the exposure (if any i.e. stack) 188 # returns an appropriate string if !$exp_id 189 $exp_info = get_exposure_info($job_params, $image_db, $exp_id); 190 } else { 191 my $filter = $job_params->{filter}; 192 $filter = "0" if !$filter; 193 my $mjd_obs = $job_params->{mjd_obs}; 194 $mjd_obs = "0" if !$mjd_obs; 195 $exp_info = "$mjd_obs|0|0|$filter|0|0"; 196 } 197 198 if (($job_type eq "stamp") || ($job_type eq "get_image") || ($job_type eq "none")) { 199 my $jreglist = "$outdir/reglist$job_id"; 200 if (open JRL, "<$jreglist") {; 201 # process the reglist file to get the list of files produced by this job 202 foreach my $line (<JRL>) { 203 204 # XXX: we are getting many cases where the size and/or md5sum calculated by 205 # the job has changed by the time the request_finish has run 206 # Don't 207 # add line to the requests's reglist 208 # .... 209 # print $rlf $line; 210 211 212 chomp $line; 213 my ($img_name, $reported_size, $reported_sum, $filetype) = split '\|', $line; 214 # ... instead let dsreg compute the paramters by leaving them blank 215 print $rlf "$img_name|||$filetype|\n"; 216 217 # add line to the table definition file 218 print $tdf "$rownum|$fault|$error_string|$img_name|$job_id|"; 219 220 # ra_deg and dec_deg are the coordinates of center of the stamp 221 # first assume that the image is compressed and check the first extension. 222 # If not found check the PHU. If that doesn't work just set them to zero. 223 # XXX do this more cleanly 224 my (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields -x 0 RA_DEG DEC_DEG`; 225 if (!defined $ra_deg) { 226 (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields RA_DEG DEC_DEG`; 129 my $request_fault = 0; 130 if ($action eq 'PROCESS') { 131 # The results table definition file 132 my ($tdf, $table_def_name) = tempfile ("$outdir/tabledef.XXXX", UNLINK => !$save_temps); 133 # data for the header 134 print $tdf "$req_name|$req_id|\n"; 135 # get the list of jobs generated for this request 136 my @jobs; 137 { 138 my $command = "$pstamptool -listjob -req_id $req_id"; 139 $command .= " -dbname $dbname" if $dbname; 140 $command .= " -dbserver $dbserver" if $dbserver; 141 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 142 run(command => $command, verbose => $verbose); 143 unless ($success) { 144 die("Unable to perform $command error code: $error_code"); 145 } 146 my $output = join "", @$stdout_buf; 147 if (!$output) { 148 # This should not happen. A fake job should have been entered 149 my_die("Request $req_id produced no jobs", $req_id, $PS_EXIT_PROG_ERROR); 150 } else { 151 my $jobs = parse_md_fast($mdcParser, $output); 152 153 @jobs = @$jobs; 154 } 155 } 156 157 my $exp_info; 158 foreach my $job (@jobs) { 159 my $job_id = $job->{job_id}; 160 my $job_type = $job->{jobType}; 161 my $rownum = $job->{rownum}; 162 my $fault = $job->{fault}; 163 my $exp_id = $job->{exp_id}; 164 165 my $error_string = get_error_string($fault); 166 167 if (($fault eq $PSTAMP_DUP_REQUEST) and ($req_name eq "NULL")) { 168 # this request had a duplicate request name yet the parser didn't give 169 # it an "ERROR style name. 170 my_die("duplicate request not given a request name", $req_id, $PS_EXIT_PROG_ERROR); 171 } 172 my ($row, $req_info, $project) = get_request_info($rows, $rownum); 173 174 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 175 my $image_db = $proj_hash->{dbname}; 176 if (!$image_db and !$fault) { 177 # if project isn't resolvable, the paser should have faulted this job 178 my_die("failed to find imagedb for project $project", $req_id, $PS_EXIT_CONFIG_ERROR); 179 } 180 181 my $job_params = get_job_parameters($job); 182 my $stage = ""; 183 if ($job_params) { 184 $stage = $job_params->{stage}; 185 } 186 187 if ($stage ne 'stack') { 188 # get the metadata for the exposure (if any i.e. stack) 189 # returns an appropriate string if !$exp_id 190 $exp_info = get_exposure_info($job_params, $image_db, $exp_id); 191 } else { 192 my $filter = $job_params->{filter}; 193 $filter = "0" if !$filter; 194 my $mjd_obs = $job_params->{mjd_obs}; 195 $mjd_obs = "0" if !$mjd_obs; 196 $exp_info = "$mjd_obs|0|0|$filter|0|0"; 197 } 198 199 if (($job_type eq "stamp") || ($job_type eq "get_image") || ($job_type eq "none")) { 200 my $jreglist = "$outdir/reglist$job_id"; 201 if (open JRL, "<$jreglist") {; 202 # process the reglist file to get the list of files produced by this job 203 foreach my $line (<JRL>) { 204 205 # XXX: we are getting many cases where the size and/or md5sum calculated by 206 # the job has changed by the time the request_finish has run 207 # Don't 208 # add line to the requests's reglist 209 # .... 210 # print $rlf $line; 211 212 213 chomp $line; 214 my ($img_name, $reported_size, $reported_sum, $filetype) = split '\|', $line; 215 # ... instead let dsreg compute the paramters by leaving them blank 216 print $rlf "$img_name|||$filetype|\n"; 217 218 # add line to the table definition file 219 print $tdf "$rownum|$fault|$error_string|$img_name|$job_id|"; 220 221 # ra_deg and dec_deg are the coordinates of center of the stamp 222 # first assume that the image is compressed and check the first extension. 223 # If not found check the PHU. If that doesn't work just set them to zero. 224 # XXX do this more cleanly 225 my (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields -x 0 RA_DEG DEC_DEG`; 226 if (!defined $ra_deg) { 227 (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields RA_DEG DEC_DEG`; 228 } 229 $ra_deg = 0.0 if (!$ra_deg); 230 $dec_deg = 0.0 if (!$dec_deg); 231 print $tdf "$ra_deg|$dec_deg|"; 232 233 print $tdf "$exp_info|"; 234 print $tdf "$req_info|"; 235 print $tdf "\n"; 227 236 } 228 $ra_deg = 0.0 if (!$ra_deg); 229 $dec_deg = 0.0 if (!$dec_deg); 230 print $tdf "$ra_deg|$dec_deg|"; 231 237 close JRL; 238 } else { 239 my_die("No reglist for successful job: $job_id", $req_id, $PS_EXIT_PROG_ERROR) 240 if $fault eq $PSTAMP_SUCCESS; 241 print STDERR "no reglist file for job $job_id\n" if $verbose; 242 print $tdf "$rownum|$fault|$error_string|0|$job_id|"; 243 print $tdf "0|0|"; # center of (non-existent) stamp 232 244 print $tdf "$exp_info|"; 233 245 print $tdf "$req_info|"; 234 246 print $tdf "\n"; 235 247 } 236 close JRL;237 248 } else { 238 my_die("No reglist for successful job: $job_id", $req_id, $PS_EXIT_PROG_ERROR) 239 if $fault eq $PSTAMP_SUCCESS; 240 print STDERR "no reglist file for job $job_id\n" if $verbose; 241 print $tdf "$rownum|$fault|$error_string|0|$job_id|"; 242 print $tdf "0|0|"; # center of (non-existent) stamp 243 print $tdf "$exp_info|"; 244 print $tdf "$req_info|"; 245 print $tdf "\n"; 246 } 247 } else { 248 # XXX do list jobs 249 # we can probably arange things to use the code as above and skip the fileset registration 250 print STDERR "Unknown jobType: $job_type"; 251 next; 252 } 253 } 254 close $rlf; 255 close $tdf; 256 my $request_fault = 0; 257 # make the results file 258 { 259 my $command = "$pstamp_results --input $table_def_name --output $outdir/results.fits"; 260 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 261 run(command => $command, verbose => $verbose); 262 unless ($success) { 263 print STDERR "Unable to perform $command error code: $error_code\n"; 264 $request_fault = $error_code >> 8; 265 } else { 266 # dump a textual representation 267 my $command = "$pstampdump $outdir/results.fits > $outdir/results.mdc"; 249 # XXX do list jobs 250 # we can probably arange things to use the code as above and skip the fileset registration 251 print STDERR "Unknown jobType: $job_type"; 252 next; 253 } 254 } 255 close $tdf; 256 # make the results file 257 { 258 my $command = "$pstamp_results --input $table_def_name --output $outdir/results.fits"; 268 259 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 269 260 run(command => $command, verbose => $verbose); 270 261 unless ($success) { 262 print STDERR "Unable to perform $command error code: $error_code\n"; 271 263 $request_fault = $error_code >> 8; 272 my_die("Unable to perform $command error code: $error_code", $req_id, $request_fault); 273 } 274 } 275 } 264 } else { 265 # dump a textual representation 266 my $command = "$pstampdump $outdir/results.fits > $outdir/results.mdc"; 267 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 268 run(command => $command, verbose => $verbose); 269 unless ($success) { 270 $request_fault = $error_code >> 8; 271 my_die("Unable to perform $command error code: $error_code", $req_id, $request_fault); 272 } 273 } 274 } 275 } elsif ($action ne 'LIST') { 276 my_die("Unexpected action $action found", $req_id, $PS_EXIT_PROG_ERROR); 277 } else { 278 # pstampparse did all of the work 279 } 280 281 close $rlf; 282 276 283 if (!$request_fault) { 277 284 # register the fileset -
branches/czw_branch/20120906/pstamp/scripts/pstamp_request_file
r29673 r34772 49 49 value => undef 50 50 }, 51 { name => 'ACTION', 52 writetype => TSTRING, 53 comment => 'Action to perform: LIST or PROCESS', 54 value => undef 55 }, 56 { name => 'USERNAME', 57 writetype => TSTRING, 58 comment => 'username for request (optional)', 59 value => undef 60 }, 61 { name => 'EMAIL', 62 writetype => TSTRING, 63 comment => 'email for submittor (optional)', 64 value => undef 65 }, 51 66 ]; 52 67 53 68 # Specification of columns to write 54 69 my $columns = [ 70 { name => 'ROWNUM', type => 'J', writetype => TULONG }, 71 72 { name => 'CENTER_X', type => 'D', writetype => TDOUBLE }, 73 { name => 'CENTER_Y', type => 'D', writetype => TDOUBLE }, 74 { name => 'WIDTH', type => 'D', writetype => TDOUBLE }, 75 { name => 'HEIGHT', type => 'D', writetype => TDOUBLE }, 76 # 2 bits in COORD_MASK indicate what units of roi coords are 77 { name => 'COORD_MASK', type => 'J', writetype => TULONG }, 78 79 { name => 'JOB_TYPE', type => '16A', writetype => TSTRING }, 80 { name => 'OPTION_MASK',type => 'J', writetype => TULONG }, 81 82 # image selection parameters 83 { name => 'PROJECT', type => '16A', writetype => TSTRING }, 84 # new in version 2 85 { name => 'SURVEY_NAME',type => '16A', writetype => TSTRING }, 86 { name => 'IPP_RELEASE', type => '16A', writetype => TSTRING }, 87 # end of new in version 2 88 { name => 'REQ_TYPE', type => '16A', writetype => TSTRING }, 89 { name => 'IMG_TYPE', type => '16A', writetype => TSTRING }, 90 { name => 'ID', type => '16A', writetype => TSTRING }, 91 { name => 'TESS_ID', type => '64A', writetype => TSTRING }, 92 { name => 'COMPONENT', type => '64A', writetype => TSTRING }, 93 94 { name => 'DATA_GROUP ',type => '64A', writetype => TSTRING }, 95 96 { name => 'REQFILT', type => '16A', writetype => TSTRING }, 97 { name => 'MJD_MIN', type => 'D', writetype => TDOUBLE }, 98 { name => 'MJD_MAX', type => 'D', writetype => TDOUBLE }, 99 { name => 'RUN_TYPE', type => '16A', writetype => TSTRING }, 100 101 { name => 'COMMENT ', type => '64A', writetype => TSTRING }, 102 ]; 103 my $columns_v1 = [ 55 104 { name => 'ROWNUM', type => 'J', writetype => TULONG }, 56 105 … … 89 138 } 90 139 140 # build array of arrays for the column data. Note if the input file is version 1 then 141 # some of thes will get dropped 91 142 my @colData; 92 143 foreach (@$columns) { … … 96 147 97 148 my $minimum_cols = 6; 98 my $numRows = read_data_for_table($in,'\s+', \@colData, $header, $minimum_cols); 149 my $extver = 2; 150 my $numRows = read_data_for_table($in,'\s+', \@colData, $header, $minimum_cols, \$extver); 99 151 if (!$numRows) { 100 152 print STDERR "no data in $input\n"; … … 115 167 $output = $req_name . ".fits" if !$output; 116 168 117 my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $ columns, $header);169 my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $extver > 1 ? $columns : $columns_v1, $header); 118 170 119 171 exit $status; … … 230 282 my $header = shift; # rerence to array of header keyword descriptions 231 283 my $minimum_required_vals = shift; 284 my $r_extver = shift; # reference to extension version 232 285 233 286 my $line_num = 0; … … 243 296 my @vals = split /$sep/, $line; 244 297 my $nvals = @vals; 245 die "number of header columns in input $nvals does not equal expected number of header words $nhead" 298 die "two few columns $nvals in header definition. Require at least 2" if @vals < 2; 299 300 $$r_extver = $vals[1]; 301 if ($extver > 1) { 302 die "number of header columns in input $nvals does not equal expected number of header words $nhead" 246 303 if (@vals != @$header); 247 248 for (my $i=0; $i < @$header; $i++) { 249 $header->[$i]->{value} = $vals[$i]; 250 } 251 252 last; # only one header line 253 } 304 } else { 305 # drop header keywords not used in version 1 306 for (my $i = @$header - 1; $i >= $nvals; $i--) { 307 pop @$header; 308 } 309 } 310 311 for (my $i=0; $i < $nvals; $i++) { 312 my $val = $vals[$i]; 313 if (defined $val) { 314 $header->[$i]->{value} = $val; 315 } else { 316 $header->[$i]->{value} = 'null'; 317 } 318 } 319 320 last; # one line defines the header 321 } 322 } 323 if ($$r_extver == 1) { 324 # pop off the colData arrays to account for the unused columns 325 pop @colData; 326 pop @colData; 327 pop @colData; 254 328 } 255 329 … … 271 345 exit 1; 272 346 } 347 # trim leading whitespace from comment 348 $comment =~ s/^\s+//; 273 349 if ($comment) { 274 350 if ($comment =~ /#/) { … … 381 457 print "If --output is omitted the output file name is set to REQ_NAME.fits\n\n"; 382 458 print "Header 1 Line. Format:\n\n"; 383 print " REQ_NAME EXTVER\n\n";459 print "REQ_NAME EXTVER ACTION USERNAME EMAIL\n\n"; 384 460 print "REQUEST specification (1 or more lines). Format:\n\n"; 385 print " ROWNUM CENTER_X CENTER_Y WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE ID TESS_ID COMPONENT DATA_GROUP REQFILT MJD_MIN MJD_MAX| COMMENT\n\n";461 print "ROWNUM CENTER_X CENTER_Y WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT SURVEY_NAME IPP_RELEASE REQ_TYPE IMG_TYPE ID TESS_ID COMPONENT DATA_GROUP REQFILT MJD_MIN MJD_MAX RUN_TYPE | COMMENT\n\n"; 386 462 387 463 exit 0; -
branches/czw_branch/20120906/pstamp/scripts/pstampparse.pl
r33670 r34772 93 93 my $fields_output; 94 94 { 95 my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ";95 my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ACTION USER EMAIL"; 96 96 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 97 97 run(command => $command, verbose => $verbose); … … 102 102 $fields_output = join "", @$stdout_buf; 103 103 } 104 my (undef, $extname, $extver, $req_name ) = split " ", $fields_output;104 my (undef, $extname, $extver, $req_name, $action, $username, $email) = split " ", $fields_output; 105 105 106 106 # make sure the file contains what we are expecting … … 109 109 my_die("$request_file_name is not a PS1_PS_REQEST", $PS_EXIT_PROG_ERROR) if $extname ne "PS1_PS_REQUEST"; 110 110 my_die("REQ_NAME not found in $request_file_name", $PS_EXIT_PROG_ERROR) if (!$req_name); 111 my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1" );111 my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1" and $extver ne "2"); 112 112 113 113 … … 230 230 # the images of interest for this new row doesn't match the list. 231 231 # process the list ... 232 $num_jobs += processRows( \@rowList);232 $num_jobs += processRows($action, \@rowList); 233 233 234 234 # and reset the list to contain just the new row … … 238 238 # out of rows process the list 239 239 if (scalar @rowList > 0) { 240 $num_jobs += processRows( \@rowList);241 } 242 243 if (($ mode eq "queue_job") and ($num_jobs eq 0)) {240 $num_jobs += processRows($action, \@rowList); 241 } 242 243 if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) { 244 244 print STDERR "no jobs created for $req_name\n" if $verbose; 245 245 insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST); … … 387 387 } 388 388 389 sub processRows {389 sub list_targets { 390 390 my $rowList = shift; 391 391 my $num_jobs = 0; 392 393 $num_jobs = 1; 394 return $num_jobs; 395 } 396 397 sub processRows { 398 my $action = shift; 399 my $rowList = shift; 400 my $num_jobs = 0; 401 402 if ($action eq 'LIST') { 403 return list_targets($rowList); 404 } 392 405 393 406 # all rows in the list are compatible -
branches/czw_branch/20120906/pstamp/src/ppstampArguments.c
r33504 r34772 25 25 fprintf(stderr, " [-mask mk_image] : mask image\n"); 26 26 fprintf(stderr, " [-variance var_image] : variance image\n"); 27 fprintf(stderr, " [-sources sources] : sources cmf (ignored for chip stage)\n"); 27 28 fprintf(stderr, " [-stage stage] : stage of input image (raw, chip, warp, stack, diff)\n"); 28 29 fprintf(stderr, " [-write_jpeg] : write a JPEG format of the image stamp\n"); 30 fprintf(stderr, " [-write_cmf] : create an output cmf with the sources overlapping the stamp\n"); 31 fprintf(stderr, " [-wholefile] : ignore the region of interest and process the entire input image\n"); 29 32 // fprintf(stderr, " [-no_censor_masked] : do not set masked pixels to NAN\n"); 30 33 fprintf(stderr, "\n"); … … 92 95 options->stage = psStringCopy(argv[argnum]); 93 96 psArgumentRemove(argnum, &argc, argv); 97 } else { 98 // Should we require this? 99 options->stage = psStringCopy("unknown"); 94 100 } 95 101 if ((argnum = psArgumentGet(argc, argv, "-write_jpeg"))) { 96 102 psArgumentRemove(argnum, &argc, argv); 97 103 options->writeJPEG = true; 98 } else { 99 options->writeJPEG = false; 104 } 105 if ((argnum = psArgumentGet(argc, argv, "-write_cmf"))) { 106 psArgumentRemove(argnum, &argc, argv); 107 options->writeCMF = true; 100 108 } 101 109 102 pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist"); 110 // XXX: Note: the various list options have never been tested with ppstamp to my knowledge 111 bool gotAstrom = false; 112 if ((argnum = psArgumentGet(argc, argv, "-astrom"))) { 113 gotAstrom = true; 114 pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist"); 115 } 103 116 pmConfigFileSetsMD(config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 104 117 pmConfigFileSetsMD(config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist"); 105 118 106 // the input file is a required argument; if not found, we will exit 119 if ((argnum = psArgumentGet(argc, argv, "-sources"))) { 120 pmConfigFileSetsMD(config->arguments, &argc, argv, "SOURCES", "-sources", "-sourceslist"); 121 // supplying a sources file implies that we want to save the output 122 options->writeCMF = true; 123 } else if (options->writeCMF && !gotAstrom) { 124 // if we didn't get a sources file but the user wanted us to write the sources we must 125 // have an astrometry file supplied 126 // XXX: Is this too restrictive? Could the sources be contained in say the input file? 127 psError(PSTAMP_ERR_ARGUMENTS, true, "cannot write cmf file unless input sources are supplied\n"); 128 usage(); 129 } 130 131 // the input image file is a required argument; if not found, we will exit 107 132 bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 108 133 if (!status) { … … 126 151 } 127 152 128 // finally the o utput file153 // finally the only argument left must be output outroot 129 154 if (argc < 2) { 130 155 psError(PSTAMP_ERR_ARGUMENTS, true, "must specify OUTPUT\n"); … … 135 160 } 136 161 137 // Add the output image (which remains on the command-line) to the arguments list138 162 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]); 139 140 // psMetadataPrint(stdout, config->arguments,0);141 163 142 164 return config; -
branches/czw_branch/20120906/pstamp/src/ppstampMakeStamp.c
r33504 r34772 19 19 static void chipToSky(pmAstromObj *pt, pmFPA *fpa, pmChip *chip); 20 20 static bool setMaskedToNAN(pmConfig *config, psImage *image, psImage *mask, psImage *variance); 21 static bool copySources(pmReadout *outputReadout, pmReadout *inputReadout, pmReadout *astromReadout, psRegion extractRegion); 21 22 22 23 // convert the input chip's transforms to the output … … 80 81 } 81 82 82 static bool copyMetadata(pmFPAfile *output, pmFPAfile *input, pmChip *inChip, ppstampOptions *options, pmAstromObj *center )83 static bool copyMetadata(pmFPAfile *output, pmFPAfile *input, pmChip *inChip, ppstampOptions *options, pmAstromObj *center, pmFPAfile *astrom, pmFPAview *inView) 83 84 { 84 85 pmChip *outChip; 85 pmFPAview * view = pmFPAviewAlloc(0);86 pmFPAview *outView = pmFPAviewAlloc(0); 86 87 87 88 // our output file has a single chip 88 view->chip = 0; 89 outChip = pmFPAviewThisChip(view, output->fpa); 90 psFree(view); 91 92 // copy data from the input chip header to the output. 89 outView->chip = 0; 90 outChip = pmFPAviewThisChip(outView, output->fpa); 91 psFree(outView); 92 pmHDU *outHDU = pmHDUGetHighest(output->fpa, outChip, NULL); 93 94 // copy data from the input's chip header to the output. 93 95 // since some of the keywords might be duplicated we may not want to copy both 94 96 95 pmHDU *inHDU = pmHDUFromChip(inChip); 96 pmHDU *outHDU = pmHDUGetHighest(output->fpa, outChip, NULL); 97 pmHDU *inHDU = NULL; 98 if (strcmp(options->stage, "raw") && input != astrom) { 99 // Copy the header from the astrometry file since it contains the psphot and psastro results 100 pmChip *astromChip = pmFPAviewThisChip(inView, astrom->fpa); 101 inHDU = pmHDUFromChip(astromChip); 102 } else { 103 inHDU = pmHDUFromChip(inChip); 104 } 97 105 98 106 if (inHDU->header) { … … 102 110 } 103 111 104 // copy the fpa concepts112 // copy the fpa and chip concepts 105 113 pmConceptsCopyFPA(output->fpa, input->fpa, false, false); 114 // Needed to preserve FPA.ZP 106 115 pmConceptsCopyChip(outChip, inChip, false); 116 117 // copy the cell concepts (needed to get CELL.EXPOSURE which gets used to set EXPTIME) 107 118 pmCell *outCell = outChip->cells->data[0]; // The only output cell 108 119 … … 122 133 } 123 134 124 // If input had WCS convert it for stamp135 // If input had WCS convert it for the new image coordinate system of our stamp 125 136 if (input->fpa->toSky) { 126 137 // copy the input fpa's transforms … … 135 146 } 136 147 } else { 137 psWarning("No WCS present in input\n"); 138 } 139 148 psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "No WCS present in input."); 149 } 150 151 // Save our specific metadata 140 152 psMetadataAddF64(outHDU->header, PS_LIST_TAIL, "RA_DEG", PS_META_REPLACE, "Right Ascension of stamp center", RAD_TO_DEG(center->sky->r)); 141 153 psMetadataAddF64(outHDU->header, PS_LIST_TAIL, "DEC_DEG", PS_META_REPLACE, "Declination of stamp center", RAD_TO_DEG(center->sky->d)); 154 155 // XXX: TODO: save the region of interest boundary and the offset to be applied. 156 // XXX: Gene thinks that there may be a way to handle this in the WCS 157 158 // Now a few sanity checks 159 // Make sure zero point in the fpa concepts matches the observed value in the input header 160 bool status; 161 float zpt_obs = psMetadataLookupF32(&status, outHDU->header, "ZPT_OBS"); 162 if (status) { 163 psMetadataAddF32(output->fpa->concepts, PS_LIST_TAIL, "FPA.ZP", PS_META_REPLACE, "Magnitude zero point", zpt_obs); 164 } 142 165 143 166 ppstampVersionMetadata(outHDU->header, options); … … 324 347 325 348 if (options->censorMasked && !setMaskedToNAN(config, outReadout->image, outReadout->mask, outReadout->variance)) { 326 psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp mask image\n");327 status = false;328 break;349 psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp mask image\n"); 350 status = false; 351 break; 329 352 } 330 353 } … … 335 358 status = true; 336 359 360 if (options->writeCMF) { 361 pmReadout *astromReadout = NULL; 362 if (astrom->fpa != input->fpa) { 363 astromReadout = pmFPAviewThisReadout(srcView, astrom->fpa); 364 } 365 if (!copySources(outReadout, astromReadout, astromReadout, extractRegion)) { 366 psError(PS_ERR_UNKNOWN, false, "failed to extract sources from region of interest.\n"); 367 status = false; 368 break; 369 } 370 } 371 337 372 psFree(outReadout); // drop reference 338 373 } … … 341 376 342 377 if (status) { 343 status = copyMetadata(output, input, inChip, options, center); 378 // For raw stage we need to do more work to build a proper header 379 status = copyMetadata(output, input, inChip, options, center, astrom, view); 344 380 } 345 381 return status ? PS_EXIT_SUCCESS : PS_EXIT_UNKNOWN_ERROR; … … 428 464 double dy = 0.5 * options->roip.dDEC / fpa->toSky->Ys; 429 465 430 if (dx > 5000) { 431 fprintf(stderr, "requested width %f too large reducing to 5000\n", dx); 432 dx = 5000; 433 } 434 if (dy > 5000) { 435 fprintf(stderr, "requested height %f too large reducing to 5000\n", dy); 436 dy = 5000; 466 // XXX: why do we limit this? 467 if (dx > 8000) { 468 psWarning( "requested width %f too large reducing to 8000\n", dx); 469 dx = 8000; 470 } 471 if (dy > 8000) { 472 psWarning( "requested height %f too large reducing to 8000\n", dy); 473 dy = 8000; 437 474 } 438 475 … … 480 517 ppstampOverlap returnval = PPSTAMP_OFF; 481 518 482 // fprintf(stderr, "ppstampChipBounds: %s\n", psRegionToString(*chipBounds));483 484 519 // set up the astrometry 485 520 pmHDU *hdu = pmFPAviewThisHDU(view, astrom->fpa); … … 498 533 } 499 534 } else { 500 // we use a default FPA pixel scale of 1.0501 535 if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0) && mustHaveAstrometry) { 502 536 psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA."); … … 537 571 center->chip->yErr = 0; 538 572 onChip = true; 539 chipToSky(center, input->fpa, chip); 573 if (input->fpa->toSky) { 574 chipToSky(center, input->fpa, chip); 575 } 540 576 } 541 577 } … … 550 586 int width = options->roip.dX; 551 587 int height = options->roip.dY; 552 if (width > 7000) {553 fprintf(stderr, "requested width %d too large reducing to 7000\n", width);554 width = 7000;588 if (width > 8000) { 589 psWarning( "requested width %d too large reducing to 8000\n", width); 590 width = 8000; 555 591 } 556 if (height > 7000) {557 fprintf(stderr, "requested height %d too large reducing to 7000\n", height);558 height = 7000;592 if (height > 8000) { 593 psWarning( "requested height %d too large reducing to 8000\n", height); 594 height = 8000; 559 595 } 560 596 … … 675 711 676 712 if (!foundOverlap && (returnval == PS_EXIT_SUCCESS)) { 677 fprintf(stderr,"ROI not found in input\n");713 psWarning( "ROI not found in input\n"); 678 714 returnval = PSTAMP_NO_OVERLAP; 679 715 } … … 739 775 } 740 776 741 // XXX: this shouldn't be a fprintf 742 fprintf(stderr, "Censored %ld masked pixels\n", numCensored); 777 psLogMsg("ppstamp", PS_LOG_DETAIL, "Censored %ld masked pixels\n", numCensored); 743 778 744 779 return true; 745 780 } 781 782 static bool copySources(pmReadout *outReadout, pmReadout *inReadout, pmReadout *astromReadout, psRegion extractRegion) { 783 bool status; 784 785 // first look for detections in the input readout. Those would have come from the -sources file 786 pmDetections *inDetections = psMetadataLookupPtr (&status, inReadout->analysis, "PSPHOT.DETECTIONS"); 787 if (!inDetections) { 788 // No detections on the input readout. Try the astrometry readout if supplied. 789 if (astromReadout) { 790 inDetections = psMetadataLookupPtr (&status, astromReadout->analysis, "PSPHOT.DETECTIONS"); 791 if (!inDetections) { 792 psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "no detections found on input or astrometry readout\n"); 793 return false; 794 } else { 795 psLogMsg("ppstampMakeStamp", PS_LOG_INFO, "using detections from astrom file\n"); 796 } 797 } else { 798 psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "no detections found on input readout\n"); 799 return false; 800 } 801 } 802 if (!inDetections->allSources) { 803 psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "no sources array found on detections structure\n"); 804 return false; 805 } 806 807 // Ok we have sources, allocate a detections structure and copy them to the output readout 808 psArray *inSources = inDetections->allSources; 809 810 pmDetections *outDetections = pmDetectionsAlloc(); 811 psMetadataAddPtr (outReadout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, 812 "psphot detections", outDetections); 813 814 psArray *outSources = outDetections->allSources = psArrayAllocEmpty( 100 ); 815 816 // include sources that are off the stamp by just a little bit 817 #define EXPAND_SIZE 16 818 psRegion sourceRegion = extractRegion; 819 sourceRegion.x0 -= EXPAND_SIZE; 820 sourceRegion.y0 -= EXPAND_SIZE; 821 sourceRegion.x1 += EXPAND_SIZE; 822 sourceRegion.y1 += EXPAND_SIZE; 823 824 for (int i = 0; i < inSources->n; i++ ) { 825 pmSource *src = inSources->data[i]; 826 827 float x = src->peak->xf; 828 float y = src->peak->yf; 829 if (x < sourceRegion.x0 || x > sourceRegion.x1 || 830 y < sourceRegion.y0 || y > sourceRegion.y1) { 831 continue; 832 } 833 psArrayAdd(outSources, 100, src); 834 } 835 836 return true; 837 } -
branches/czw_branch/20120906/pstamp/src/ppstampOptions.c
r33504 r34772 32 32 options->censorMasked = false; 33 33 options->writeJPEG = false; 34 options->writeCMF = false; 34 35 options->nocompress = false; 35 36 options->wholeFile = false; -
branches/czw_branch/20120906/pstamp/src/ppstampOptions.h
r33504 r34772 14 14 bool censorMasked; 15 15 bool writeJPEG; 16 bool writeCMF; 16 17 bool nocompress; 17 18 // -
branches/czw_branch/20120906/pstamp/src/ppstampParseCamera.c
r33504 r34772 120 120 } 121 121 122 // Set up the input and output sources files if needed 123 if (options->writeCMF) { 124 bool status; 125 126 // see if -sources file was supplied. 127 // If so define the file. 128 psPtr sourcesFile = psMetadataLookupStr(&status, config->arguments, "SOURCES"); 129 if (sourcesFile) { 130 pmFPAfile *sources = pmFPAfileBindFromArgs(&status, input, config, "PPSTAMP.INPUT.SOURCES", "SOURCES"); 131 if (!status) { 132 psError(psErrorCodeLast(), false, "Failed to load file definition for PPSTAMP.INPUT.SOURCES"); 133 return false; 134 } 135 if (!sources && !astrom) { 136 psError(psErrorCodeLast(), false, "Failed to define input sources file"); 137 return false; 138 } 139 } else { 140 psLogMsg ("ppstamp", PS_LOG_INFO, "output sources file requested but no input supplied. Will try the supplied astrometry file.\n"); 141 } 142 143 pmFPAfile *outputSources = NULL; 144 outputSources = pmFPAfileDefineSkycell(config, output->fpa, "PPSTAMP.OUTPUT.SOURCES"); 145 if (!outputSources) { 146 psError(psErrorCodeLast(), false, "Failed to define output sources file"); 147 return false; 148 } 149 outputSources->save = true; 150 } 151 122 152 pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSTAMP.CHIP"); 123 153 if (!chipImage) { -
branches/czw_branch/20120906/pstamp/src/pstamp.h
r28291 r34772 26 26 27 27 // values for options mask. 28 #define PSTAMP_SELECT_IMAGE 1 29 #define PSTAMP_SELECT_MASK 2 30 #define PSTAMP_SELECT_WEIGHT 4 31 #define PSTAMP_SELECT_CMF 8 32 #define PSTAMP_SELECT_PSF 16 33 #define PSTAMP_SELECT_BACKMDL 32 34 #define PSTAMP_SELECT_INVERSE 1024 35 #define PSTAMP_SELECT_UNCONV 2048 36 #define PSTAMP_USE_IMFILE_ID 16384 28 #define PSTAMP_SELECT_IMAGE 1 29 #define PSTAMP_SELECT_MASK 2 30 #define PSTAMP_SELECT_WEIGHT 4 31 #define PSTAMP_SELECT_SOURCES 8 32 #define PSTAMP_SELECT_CMF 8 33 #define PSTAMP_SELECT_PSF 16 34 #define PSTAMP_SELECT_BACKMDL 32 35 #define PSTAMP_SELECT_JPEG 64 36 // unused 128 37 // unused 256 38 #define PSTAMP_SELECT_UNCOMPRESSED 512 39 #define PSTAMP_SELECT_INVERSE 1024 40 #define PSTAMP_SELECT_UNCONV 2048 41 #define PSTAMP_RESTORE_BACKGROUND 4096 42 // unused 8192 43 #define PSTAMP_USE_IMFILE_ID 16384 37 44 38 #define PSTAMP_NO_WAIT_FOR_UPDATE 32768 45 #define PSTAMP_NO_WAIT_FOR_UPDATE 32768 46 #define PSTAMP_REQUEST_UNCENSORED 0x10000 47 #define PSTAMP_REQUIRE_UNCENSORED 0x20000 39 48 40 49 #define PSTAMP_CENTER_IN_PIXELS 1
Note:
See TracChangeset
for help on using the changeset viewer.
