Changeset 33022
- Timestamp:
- Dec 24, 2011, 9:44:18 AM (15 years ago)
- Location:
- branches/haf_add201112
- Files:
-
- 2 edited
-
ippScripts/scripts/addstar_run.pl (modified) (8 diffs)
-
ippTasks/addstar.pro (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/haf_add201112/ippScripts/scripts/addstar_run.pl
r33021 r33022 30 30 my $missing_tools; 31 31 my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1); 32 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); 32 33 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 33 34 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); … … 37 38 } 38 39 my $minidvodb_path; 39 my ( $add_id, $camera, $stage, $ multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,40 my ( $add_id, $camera, $stage, $stage_id, $multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update, 40 41 $no_op, $redirect, $save_temps); 41 42 GetOptions( … … 43 44 'camera|c=s' => \$camera, # Camera 44 45 'stage|s=s' => \$stage, # Camera 46 'stage_id|w=s' => \$stage_id, 45 47 'multi_num|w=s' => \$multi_num, # the number for a staticskymulti (for finding cmf) 46 48 'dbname|d=s' => \$dbname, # Database name … … 71 73 defined $dvodb and 72 74 defined $camera; 75 if ($stage =~ /cam/ && !defined $stage_id) { 76 my_die("cam stage requires -stage_id", $add_id, 3); 77 78 } 73 79 if ($minidvodb && !defined($minidvodb_group)) { 74 80 my_die( "missing minidvodb_group", $add_id, 3 ); … … 109 115 # it was PSASTRO.OUTPUT 110 116 111 117 my $fpaObjects; 112 118 if ($stage =~ /cam/) { 113 119 # if it is cam stage we need to be careful when grabbing the filename. 114 120 # This breaks down into a few steps: 115 121 116 122 #get info about the cam_id 117 123 my $magicked; 118 124 { 119 120 my $mdcParser = PS::IPP::Metadata::Config->new; 125 my $mdcParser = PS::IPP::Metadata::Config->new; 121 126 my $command = "$camtool -processedexp -cam_id " . $stage_id; 122 127 $command .= " -dbname $dbname" if defined $dbname; … … 125 130 &my_die( "Unable to get info on camRun", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 126 131 if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first 127 &my_die( "empty camRun", $add_id, $PS_EXIT_SYS_ERROR 128 print "listing nothing\n"; 129 } else { 130 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 131 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 132 #this fails if there is nothing listed. I checked. 133 my $components = parse_md_list($metadata) or 134 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 135 my $comp = $$components[0]; 136 my $mparsed = $comp->{magicked}; 137 138 if (!defined($mparsed)) { 139 &my_die("Unable to parse magicked", $add_id, $PS_EXIT_PROG_ERROR); 140 } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk. 141 print "found a value for magicked:$mparsed\n"; 142 $magicked = $mparsed; 143 } 144 145 146 147 #is this cam_id magicked or not? 148 if ($magicked) { 149 my $fpaObjects = $ipprc->destreak_filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 150 } else { 151 152 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 153 } 154 155 132 &my_die( "empty camRun", $add_id, $PS_EXIT_SYS_ERROR); 133 print "listing nothing\n"; 134 } else { 135 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 136 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 137 #this fails if there is nothing listed. I checked. 138 my $components = parse_md_list($metadata) or 139 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 140 my $comp = $$components[0]; 141 my $mparsed = $comp->{magicked}; 142 143 if (!defined($mparsed)) { 144 &my_die("Unable to parse magicked", $add_id, $PS_EXIT_PROG_ERROR); 145 } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk. 146 print "found a value for magicked:$mparsed\n"; 147 $magicked = $mparsed; 148 } 149 150 #is this cam_id magicked or not? 151 if ($magicked) { 152 $fpaObjects = $ipprc->destreak_filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 153 print "cam_id is magicked, using $fpaObjects for the cam smf\n"; 154 } else { 155 156 $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 157 print "cam_id is NOT magicked, using $fpaObjects for the cam smf\n"; 158 } 159 } 156 160 } else { 157 158 my$fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);161 # for non cam stages, grabe the file name like this: 162 $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 159 163 } 160 164 if (($stage =~/staticsky/) || ($stage =~/stack/)) { 161 165 $fpaObjects =~ s/smf$/cmf/; 162 163 } 164 166 } 165 167 if ($stage =~/staticsky_multi/) { 166 168 $fpaObjects =~ s/smf$/cmf/; #this should do nothing because it was already modded above … … 168 170 my $nice_num = sprintf ("%03d", $multi_num); 169 171 $fpaObjects =~ s/cmf$/$nice_num.cmf/; #this make it look for .001.cmf, etc 170 171 172 } 172 173 173 174 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 174 175 175 176 # convert supplied DVO database name to UNIX filename 176 177 my $dvodbReal; … … 179 180 $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ) or &my_die("can't get path for dvodb", $add_id, $PS_EXIT_CONFIG_ERROR); 180 181 } 181 182 183 184 185 182 my $dtime_addstar = 0; 186 187 183 if (defined $dvodbReal) { 188 if ($minidvodb) { 189 190 #if (!defined($minidvodb_name)) { 191 #take the active one, if it's not defined on the command line 192 #reverts would have this already set, for example. 193 my $command = "addtool -listminidvodbrun "; 194 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group; 195 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 196 $command .= " -state 'active' -limit 1"; 197 $command .= " -dbname $dbname" if defined $dbname; 198 print $command; 199 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 200 run(command => $command, verbose => $verbose); 201 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 202 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 203 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 204 205 my $components = parse_md_list($metadata) or 206 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 207 my $comp = $$components[0]; 208 $minidvodb_path = $comp->{minidvodb_path}; 209 $minidvodb_name = $comp->{minidvodb_name}; 210 211 if (!defined($minidvodb_path)) { 212 &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR); 213 } 214 if (!defined($minidvodb_name)) { 215 &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR); 216 } 217 #} 218 # tack on the minidvodb part to the db. 219 # $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/'; 220 #we don't need this now that I fixed the paths 221 222 } 223 else { 224 225 $minidvodb_path = $dvodbReal; 226 } 227 228 unless ($no_op) { 184 if ($minidvodb) { 185 my $command = "addtool -listminidvodbrun "; 186 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group; 187 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 188 $command .= " -state 'active' -limit 1"; 189 $command .= " -dbname $dbname" if defined $dbname; 190 print $command; 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 192 run(command => $command, verbose => $verbose); 193 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 194 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 195 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 196 197 my $components = parse_md_list($metadata) or 198 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 199 my $comp = $$components[0]; 200 $minidvodb_path = $comp->{minidvodb_path}; 201 $minidvodb_name = $comp->{minidvodb_name}; 202 203 if (!defined($minidvodb_path)) { 204 &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR); 205 } 206 if (!defined($minidvodb_name)) { 207 &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR); 208 } 209 } 210 else { 211 $minidvodb_path = $dvodbReal; 212 } 213 214 unless ($no_op) { 229 215 print $dvodbReal; 230 231 ## addstar can either save the full set of detections, or just232 ## the image metadata, in the dvodb. this is set in the233 ## database table addRun234 235 # addstar requires the user to have a valid .ptolemyrc which236 # in turn points at ippconfig/dvo.site237 238 # get the names for the camera and the real input file239 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar240 my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);241 242 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)243 my $command = "$addstar -update"; # XXX optionally set -update?244 $command .= " -D CAMERA $camdir";245 $command .= " -D CATDIR $minidvodb_path";246 $command .= " $realFile";247 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference216 217 ## addstar can either save the full set of detections, or just 218 ## the image metadata, in the dvodb. this is set in the 219 ## database table addRun 220 221 # addstar requires the user to have a valid .ptolemyrc which 222 # in turn points at ippconfig/dvo.site 223 224 # get the names for the camera and the real input file 225 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 226 my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR); 227 228 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 229 my $command = "$addstar -update"; # XXX optionally set -update? 230 $command .= " -D CAMERA $camdir"; 231 $command .= " -D CATDIR $minidvodb_path"; 232 $command .= " $realFile"; 233 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference 248 234 $command .= " -image" if $image_only; 249 235 if ($stage =~ /staticsky/) { 250 236 $command .= " -accept-astrom "; 251 237 } #careful here - this matches staticsky and staticsky_multi 252 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script253 254 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =255 run(command => $command, verbose => $verbose);256 unless ($success) {257 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);258 &my_die("Unable to perform addstar: $error_code", $add_id, $error_code);259 }260 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script238 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 239 240 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 241 run(command => $command, verbose => $verbose); 242 unless ($success) { 243 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 244 &my_die("Unable to perform addstar: $error_code", $add_id, $error_code); 245 } 246 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script 261 247 } 262 248 } -
branches/haf_add201112/ippTasks/addstar.pro
r32832 r33022 318 318 book getword addPendingExp $pageName stage_extra1 -var STAGE_EXTRA1 319 319 book getword addPendingExp $pageName stageroot -var STAGEROOT 320 book getword addPendingExp $pageName stage -var STAGE 320 book getword addPendingExp $pageName stage -var STAGE 321 book getword addPendingExp $pageName stage_id -var STAGE_ID 321 322 book getword addPendingExp $pageName workdir -var WORKDIR_TEMPLATE 322 323 book getword addPendingExp $pageName reduction -var REDUCTION … … 367 368 if ("$STAGE" == "staticsky_multi") 368 369 $run = $run --multi_num $STAGE_EXTRA1 370 end 371 if ("$STAGE" == "cam") 372 $run = $run --stage_id $STAGE_ID 369 373 end 370 374 if ("$IMAGE_ONLY" == "T")
Note:
See TracChangeset
for help on using the changeset viewer.
