- Timestamp:
- Oct 18, 2009, 10:23:28 AM (17 years ago)
- Location:
- branches/eam_branches/20090820
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/addstar_run.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820
-
branches/eam_branches/20090820/ippScripts/scripts/addstar_run.pl
r25766 r25870 28 28 # Look for programs we need 29 29 my $missing_tools; 30 #my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);31 30 my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1); 32 #my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);33 31 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 34 #my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);35 #my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);36 32 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 37 33 if ($missing_tools) { … … 40 36 } 41 37 42 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $ recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,43 $no_op, $redirect, $save_temps , $run_state);38 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $image_only, $verbose, $no_update, 39 $no_op, $redirect, $save_temps); 44 40 GetOptions( 45 41 'exp_tag=s' => \$exp_tag, # Exposure identifier 46 42 'add_id=s' => \$add_id, # Camtool identifier 47 'recipe=s' => \$recipe, # Recipe to use48 43 'camera|c=s' => \$camera, # Camera 49 44 'dbname|d=s' => \$dbname, # Database name … … 52 47 'reduction=s' => \$reduction, # Reduction class 53 48 'dvodb|w=s' => \$dvodb, # output DVO database 54 ' run-state=s' => \$run_state, # 'new' or 'update'49 'image-only' => \$image_only, # Print to stdout 55 50 'verbose' => \$verbose, # Print to stdout 56 51 'no-update' => \$no_update, # Update the database? … … 74 69 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 75 70 76 if (not defined $run_state) { $run_state = 'new'; }77 if ($run_state eq 'update') {78 $logDest .= '.update';79 }80 81 71 if ($redirect) { 82 72 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $add_id, $PS_EXIT_SYS_ERROR ); … … 89 79 $reduction = 'DEFAULT' unless defined $reduction; 90 80 81 # XXX This is now not used: do we still need it? 91 82 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use 92 83 &my_die("Unrecognised ADDSTAR recipe", $add_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar; 93 84 94 #my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use95 #&my_die("Unrecognised PSASTRO recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;96 97 85 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 98 99 my $cmdflags;100 101 # Get list of component files102 my $files; # Array of component files103 {104 my $command = "$addtool -pendingexp -add_id $add_id"; # Command to run105 $command .= " -dbname $dbname" if defined $dbname;106 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =107 run(command => $command, verbose => $verbose);108 unless ($success) {109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);110 &my_die("Unable to perform addtool: $error_code", $add_id, $error_code);111 }112 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or113 &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_PROG_ERROR);114 115 # extract the metadata for the files into a hash list116 $files = parse_md_list($metadata) or117 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);118 }119 120 my $chipObjectsExist = 0;121 86 122 87 # Output products … … 126 91 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $camroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 127 92 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 128 129 if ($run_state eq 'update') {130 $traceDest .= '.update';131 }132 93 133 94 # convert supplied DVO database name to UNIX filename … … 141 102 142 103 unless ($no_op) { 143 if (defined $dvodbReal and ($run_state eq 'new')) { 144 ## XXX the camera analysis can either save the full set of 145 ## detections, or just the image metadata, in the dvodb 104 if (defined $dvodbReal) { 105 106 ## addstar can either save the full set of detections, or just 107 ## the image metadata, in the dvodb. this is set in the 108 ## database table addRun 146 109 147 ## get the addstar recipe for this camera and CAMERA reduction 148 my $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -"; 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 run(command => $command, verbose => $verbose); 151 unless ($success) { 152 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die("Unable to perform ppConfigDump: $error_code", $add_id, $PS_EXIT_SYS_ERROR); 154 } 155 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 156 &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_SYS_ERROR); 157 158 ## allow the dvodb to save only images, or the full detection set 159 my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY'); 160 161 # XXX this construct requires the user to have a valid .ptolemyrc 162 # XXX which in turn points at ippconfig/dvo.site 110 # addstar requires the user to have a valid .ptolemyrc which 111 # in turn points at ippconfig/dvo.site 112 113 # get the names for the camera and the real input file 114 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 115 my $realFile = $ipprc->file_resolve($fpaObjects); 116 163 117 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 164 # XXX this needs to be converted to addstar_client... 165 166 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 167 $command = "$addstar -D CAMERA $camdir -update"; 168 $command .= " -image" if $imagesOnly; 118 my $command = "$addstar -update"; # XXX optionally set -update? 119 $command .= " -D CAMERA $camdir"; 169 120 $command .= " -D CATDIR $dvodbReal"; 170 171 my $realFile = $ipprc->file_resolve($fpaObjects);172 121 $command .= " $realFile"; 122 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference 123 $command .= " -image" if $image_only; 173 124 174 125 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 175 126 176 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =127 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 177 128 run(command => $command, verbose => $verbose); 178 129 unless ($success) { … … 184 135 } 185 136 186 187 137 # This needs to be updated when addtool is written. BROKEN 188 138 my $fpaCommand = "$addtool -add_id $add_id"; 189 if ($run_state eq 'new') { 190 $fpaCommand .= " -addprocessedexp"; 191 $fpaCommand .= " -path_base $outroot"; 192 $fpaCommand .= " $cmdflags"; 193 $fpaCommand .= " -dtime_addstar $dtime_addstar"; 194 } else { 195 $fpaCommand .= " -updaterun -state full"; 196 } 139 $fpaCommand .= " -addprocessedexp"; 140 $fpaCommand .= " -path_base $outroot"; 141 $fpaCommand .= " -dtime_addstar $dtime_addstar"; 197 142 $fpaCommand .= " -dbname $dbname" if defined $dbname; 198 143 … … 223 168 # This needs to be updated when addtool is written. BROKEN 224 169 my $command = "$addtool -add_id $add_id"; 225 if ($run_state eq 'new') { 226 $command .= " -addprocessedexp"; 227 $command .= " -uri UNKNOWN"; 228 $command .= " -fault $exit_code"; 229 $command .= " -path_base $outroot"; 230 $command .= " -path_base $outroot" if defined $outroot; 231 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 232 } else { 233 $command .= " -updateprocessedexp"; 234 $command .= " -fault $exit_code"; 235 } 170 $command .= " -addprocessedexp"; 171 $command .= " -fault $exit_code"; 172 $command .= " -path_base $outroot" if defined $outroot; 173 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 236 174 $command .= " -dbname $dbname" if defined $dbname; 237 175 system ($command); … … 239 177 exit $exit_code; 240 178 } 241 242 179 243 180 END {
Note:
See TracChangeset
for help on using the changeset viewer.
