- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/camera_exp.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ippScripts/scripts/camera_exp.pl
r24465 r27840 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; … … 39 40 } 40 41 41 my ( $exp_tag, $cam_id, $camera, $outroot, $ recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,42 my ( $exp_tag, $cam_id, $camera, $outroot, $dbname, $reduction, $dvodb, $verbose, $no_update, 42 43 $no_op, $redirect, $save_temps, $run_state); 43 44 GetOptions( 44 45 'exp_tag=s' => \$exp_tag, # Exposure identifier 45 46 'cam_id=s' => \$cam_id, # Camtool identifier 46 'recipe=s' => \$recipe, # Recipe to use47 47 'camera|c=s' => \$camera, # Camera 48 48 'dbname|d=s' => \$dbname, # Database name … … 93 93 &my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe2; 94 94 95 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use96 &my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;95 #my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use 96 #&my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar; 97 97 98 98 my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use … … 145 145 } 146 146 147 148 my $produceMasks; # Produce masks? 149 { 150 # Get the PSASTRO recipe 151 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 152 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 153 run(command => $command, verbose => $verbose); 154 unless ($success) { 155 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 156 &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_CONFIG_ERROR); 157 } 158 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 159 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_CONFIG_ERROR); 160 161 $produceMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK'); 162 } 163 164 147 165 ### not needed to have such an extensive temp file name. 148 166 my ($list1File, $list1Name) = tempfile( "/tmp/$exp_tag.cm.$cam_id.b1.list.XXXX", UNLINK => !$save_temps ); # For binning 1 … … 154 172 155 173 # XXX we perform astrometry iff photometry output exists 156 my $chipObjectsExist = 0;174 my @outMasks; # Names of output masks 157 175 foreach my $file (@$files) { 176 next if $file->{quality} != 0; 158 177 # use the path_base as OUTPUT root and convert the filenames with ipprc->filename: 159 178 my $class_id = $file->{class_id}; … … 164 183 my $chipMask = $ipprc->filename("PPIMAGE.CHIP.MASK", $file->{path_base}, $class_id); 165 184 166 # if any of the output chip photometry files exist, we can run psastro / addstar below167 if ($ipprc->file_exists($chipObjects)) {168 $chipObjectsExist = 1;169 } else {170 if ($verbose) { print "skipping $chipObjects (not found)\n"; }171 next;172 }173 174 185 print $list1File ($ipprc->filename("PPIMAGE.BIN1", $file->{path_base}, $class_id) . "\n"); 175 186 print $list2File ($ipprc->filename("PPIMAGE.BIN2", $file->{path_base}, $class_id) . "\n"); 176 187 print $list3File ($chipObjects . "\n"); 177 188 print $list4File ($chipMask . "\n"); 189 190 push @outMasks, $ipprc->filename("PSASTRO.OUTPUT.MASK", $outroot, $class_id) if $produceMasks; 178 191 } 179 192 close $list1File; … … 205 218 } 206 219 207 my $dtime_addstar = 0;220 #my $dtime_addstar = 0; 208 221 209 222 unless ($no_op) { … … 223 236 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 224 237 } 225 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_ PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1);238 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1); 226 239 } 227 240 … … 238 251 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 239 252 } 240 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2); 241 } 242 243 # only run psastro / addstar if any of the output chip astrometry files exist (should we test for successful astrometry?) 244 if ($chipObjectsExist) { 253 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2); 254 } 255 256 { 245 257 # run psastro on the chipObjects, producing fpaObjects 246 258 my $command; 247 259 $command = "$psastro"; 248 $command .= " -list $list3Name";249 $command .= " -masklist $list4Name";250 $command .= " $outroot";260 $command .= " -list $list3Name"; 261 $command .= " -masklist $list4Name"; 262 $command .= " $outroot"; 251 263 $command .= " -recipe PSASTRO $recipe_psastro"; 252 264 $command .= " -tracedest $traceDest -log $logDest"; … … 274 286 if ($do_stats) { 275 287 my $fpaStatsReal = $ipprc->file_resolve($fpaStats); 276 &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless -f $fpaStatsReal;288 &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $fpaStatsReal ); 277 289 278 290 # parse stats from metadata … … 293 305 294 306 if (!$quality) { 295 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 307 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($fpaObjects); 308 309 foreach my $outMask (@outMasks) { 310 &my_die("Unable to find expected output file: $outMask", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outMask); 311 } 312 313 if ($run_state eq 'new') { 314 &my_die("Couldn't find expected output file: $configuration", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration); 315 } 296 316 } 297 317 298 318 # run addstar on the output fpaObjects (if a DVO database is defined) 299 if (defined $dvodbReal and ($run_state eq 'new')) {300 301 ## XXX the camera analysis can either save the full set of302 ## detections, or just the image metadata, in the dvodb303 304 ## get the addstar recipe for this camera and CAMERA reduction305 $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -";306 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =307 run(command => $command, verbose => $verbose);308 unless ($success) {309 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);310 &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_SYS_ERROR);311 }312 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or313 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_SYS_ERROR);314 315 ## allow the dvodb to save only images, or the full detection set316 my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY');317 318 # XXX this construct requires the user to have a valid .ptolemyrc319 # XXX which in turn points at ippconfig/dvo.site320 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)321 # XXX this needs to be converted to addstar_client...322 323 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar324 my $command;325 $command = "$addstar -D CAMERA $camdir -update";326 $command .= " -image" if $imagesOnly;327 $command .= " -D CATDIR $dvodbReal";328 329 my $realFile = $ipprc->file_resolve($fpaObjects);330 $command .= " $realFile";331 332 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script333 334 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =335 run(command => $command, verbose => $verbose);336 unless ($success) {337 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);338 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);339 }340 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script341 }319 # if (defined $dvodbReal and ($run_state eq 'new')) { 320 321 # ## XXX the camera analysis can either save the full set of 322 # ## detections, or just the image metadata, in the dvodb 323 324 # ## get the addstar recipe for this camera and CAMERA reduction 325 # $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -"; 326 # ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 327 # run(command => $command, verbose => $verbose); 328 # unless ($success) { 329 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 330 # &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_SYS_ERROR); 331 # } 332 # my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 333 # &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_SYS_ERROR); 334 335 # ## allow the dvodb to save only images, or the full detection set 336 # my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY'); 337 338 # # XXX this construct requires the user to have a valid .ptolemyrc 339 # # XXX which in turn points at ippconfig/dvo.site 340 # # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 341 # # XXX this needs to be converted to addstar_client... 342 343 # my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 344 # my $command; 345 # $command = "$addstar -D CAMERA $camdir -update"; 346 # $command .= " -image" if $imagesOnly; 347 # $command .= " -D CATDIR $dvodbReal"; 348 349 # my $realFile = $ipprc->file_resolve($fpaObjects); 350 # $command .= " $realFile"; 351 352 # my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 353 354 # my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 355 # run(command => $command, verbose => $verbose); 356 # unless ($success) { 357 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 358 # &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code); 359 # } 360 # $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script 361 # } 342 362 } 343 363 } … … 353 373 $fpaCommand .= " -hostname $host" if defined $host; 354 374 $fpaCommand .= " -dtime_script $dtime_script"; 355 $fpaCommand .= " -dtime_addstar $dtime_addstar";375 # $fpaCommand .= " -dtime_addstar $dtime_addstar"; 356 376 } else { 357 $fpaCommand .= " -updaterun -s tate full";377 $fpaCommand .= " -updaterun -set_state full"; 358 378 } 359 379 $fpaCommand .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
