Changeset 26242 for trunk/pstamp/scripts
- Timestamp:
- Nov 21, 2009, 10:24:29 AM (17 years ago)
- Location:
- trunk/pstamp/scripts
- Files:
-
- 2 edited
-
pstamp_job_run.pl (modified) (8 diffs)
-
pstampparse.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_job_run.pl
r26212 r26242 13 13 use Carp; 14 14 use File::Basename; 15 use File::Copy; 15 16 use Digest::MD5::File qw( file_md5_hex ); 16 17 use PS::IPP::PStamp::RequestFile qw( :standard ); … … 20 21 use PS::IPP::Metadata::Config; 21 22 #use PS::IPP::Metadata::Stats; 22 #use PS::IPP::Metadata::List qw( parse_md_list );23 use PS::IPP::Metadata::List qw( parse_md_list ); 23 24 24 25 use PS::IPP::Config qw( :standard ); 25 26 26 my ($job_id, $redirect_output, $outputBase, $rownum, $jobType );27 my ($job_id, $redirect_output, $outputBase, $rownum, $jobType, $options); 27 28 my ($verbose, $dbname, $dbserver, $no_update); 28 29 … … 32 33 'rownum=s' => \$rownum, 33 34 'output_base=s' => \$outputBase, 35 'options=s' => \$options, 34 36 'redirect-output' => \$redirect_output, 35 37 'dbname=s' => \$dbname, … … 51 53 my_die("rownum is required", $job_id, $PS_EXIT_PROG_ERROR) if !$rownum; 52 54 my_die("output_base is required", $job_id, $PS_EXIT_PROG_ERROR) if !$outputBase; 55 56 $options = 1 if !$options; 53 57 54 58 … … 107 111 my $reglist = "$dir/reglist$job_id"; 108 112 109 open F, ">$reglist" or my_die( "can't open $reglist for output", $job_id, $PS_EXIT_UNKNOWN_ERROR); 113 my $F; 114 open $F, ">$reglist" or my_die( "can't open $reglist for output", $job_id, $PS_EXIT_UNKNOWN_ERROR); 110 115 111 116 # Figure out what output images were produced … … 116 121 $PSTAMP_SELECT_WEIGHT => "wt.fits"); 117 122 118 # we always create a stamp of the image 119 my $output_mask = $PSTAMP_SELECT_IMAGE; 120 121 # we search the argString for -mask and -variance. 122 # searching the arg string allows us to avoid adding a column in pstampJob 123 $output_mask |= $PSTAMP_SELECT_MASK if ($argString =~ /-mask/); 124 $output_mask |= $PSTAMP_SELECT_WEIGHT if ($argString =~ /-variance/); 123 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_WEIGHT); 125 124 126 125 foreach my $key (keys (%extensions)) { … … 137 136 138 137 # XXX is pstamp always the right file type, if not where do we get the right one? 139 print F file_registration_line($filename, $path, "pstamp") . "\n"; 140 } 141 142 close F; 138 print $F file_registration_line($filename, $path, "pstamp") . "\n"; 139 } 140 141 get_other_outputs($F, $outputBase, $options); 142 143 close $F; 143 144 $jobStatus = $PS_EXIT_SUCCESS; 144 145 } elsif ($exitStatus == $PSTAMP_NO_OVERLAP) { 145 $jobStatus = $PSTAMP_NO_OVERLAP 146 $jobStatus = $PSTAMP_NO_OVERLAP; 146 147 } else { 147 148 my_die( "ppstamp failed with error code: $exitStatus", $job_id, $exitStatus); … … 206 207 } 207 208 } 209 210 sub get_other_outputs { 211 my $f = shift; 212 my $output_base = shift; 213 my $options = shift; 214 215 if ($options & ( $PSTAMP_SELECT_CMF | $PSTAMP_SELECT_PSF | $PSTAMP_SELECT_BACKMDL)) { 216 if (0) { 217 my $params_file = $output_base . ".mdc"; 218 open (IN, "<$params_file") 219 or my_die("failed to open params file: $params_file", $job_id, $PS_EXIT_UNKNOWN_ERROR); 220 221 my $data = $mdcParser->parse(join "", (<IN>)) 222 or my_die("failed to parse params file: $params_file", $job_id, $PS_EXIT_UNKNOWN_ERROR); 223 224 my $components = parse_md_list($data); 225 226 my $n = scalar @$components; 227 if ($n != 1) { 228 my_die("params file $params_file contains unexpected number of components: $n", 229 $job_id, $PS_EXIT_PROG_ERROR); 230 } 231 my $comp = $components->[0]; 232 } 233 my $comp = read_params_file($output_base); 234 235 my $stage = $comp->{stage}; 236 237 # raw files don't have any other data products 238 return 1 if $stage eq "raw"; 239 240 # add the other data products if they are selected and exist. 241 # silently skip them if they don't exist. Perhaps this should be 242 # detected in pstampparse so that the user can be notified with 243 # a message in parse_error.txt ("warp do not have a background model") 244 my $cmf_file = $comp->{cmf} if ($options & $PSTAMP_SELECT_CMF); 245 my $psf_file = $comp->{psf} if ($options & $PSTAMP_SELECT_PSF); 246 my $backmdl_file = $comp->{backmdl} if ($options & $PSTAMP_SELECT_BACKMDL); 247 248 my $outdir = dirname($output_base); 249 my $basename = basename($output_base); 250 my ($rownum, $jobnum, $therest) = split /_/, $basename; 251 &my_die("failed to split basename: $basename", $job_id, $PS_EXIT_CONFIG_ERROR) 252 if (!$therest or !$rownum or !$jobnum); 253 254 my $prefix = "${rownum}_${jobnum}_"; 255 256 if ($cmf_file) { 257 print "cmf file is $cmf_file\n"; 258 copy_and_register_file($f, $cmf_file, $outdir, $prefix); 259 } 260 if ($psf_file) { 261 print "psf_file is $psf_file\n"; 262 copy_and_register_file($f, $psf_file, $outdir, $prefix); 263 } 264 if ($backmdl_file) { 265 print "backmdl_file is $backmdl_file\n";; 266 copy_and_register_file($f, $backmdl_file, $outdir, $prefix); 267 } 268 } 269 } 270 sub read_params_file { 271 my $output_base = shift; 272 273 my $params_file = $output_base . ".mdc"; 274 open (IN, "<$params_file") 275 or my_die("failed to open params file: $params_file", $job_id, $PS_EXIT_UNKNOWN_ERROR); 276 277 my $data = $mdcParser->parse(join "", (<IN>)) 278 or my_die("failed to parse params file: $params_file", $job_id, $PS_EXIT_UNKNOWN_ERROR); 279 280 my $components = parse_md_list($data); 281 282 my $n = scalar @$components; 283 if ($n != 1) { 284 my_die("params file $params_file contains unexpected number of components: $n", 285 $job_id, $PS_EXIT_PROG_ERROR); 286 } 287 return $components->[0]; 288 } 289 290 # copy_and_register_file ($f, $src, $destdir, $prefix); 291 sub copy_and_register_file { 292 my $F = shift; 293 my $src = shift; 294 my $destdir = shift; 295 my $prefix = shift; 296 297 my $fn = $prefix . basename($src); 298 my $dst = "$destdir/$fn"; 299 300 my $resolved = $ipprc->file_resolve($src); 301 302 my_die("failed to resolve $src", $job_id, $PS_EXIT_UNKNOWN_ERROR) if !$resolved; 303 304 copy($resolved, $dst) or my_die("failed to copy $resolved to $dst", $job_id, $PS_EXIT_UNKNOWN_ERROR); 305 306 print $F file_registration_line($fn, $dst, "fits") . "\n"; 307 } 208 308 209 309 sub my_die -
trunk/pstamp/scripts/pstampparse.pl
r26209 r26242 371 371 $args .= " -astrom $image->{astrom}" if $image->{astrom}; 372 372 } 373 374 $image->{job_args} = $args; 375 376 # XXX: we can get rid of the following everything that we need is 377 # in the params file 373 378 374 379 $args .= " -file $imagefile";
Note:
See TracChangeset
for help on using the changeset viewer.
