Changeset 33030 for trunk/ippScripts/scripts/addstar_run.pl
- Timestamp:
- Dec 27, 2011, 3:09:17 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/addstar_run.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/haf_add201112 (added) merged: 32980-32981,32984-32987,32989,32992,33003,33005,33008-33009,33012,33017-33018,33021-33023,33027
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/addstar_run.pl
r32832 r33030 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 $stage_extra1; 41 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 42 $no_op, $redirect, $save_temps); 41 43 GetOptions( … … 43 45 'camera|c=s' => \$camera, # Camera 44 46 'stage|s=s' => \$stage, # Camera 47 'stage_id|w=s' => \$stage_id, 45 48 'multi_num|w=s' => \$multi_num, # the number for a staticskymulti (for finding cmf) 46 49 'dbname|d=s' => \$dbname, # Database name … … 71 74 defined $dvodb and 72 75 defined $camera; 76 if ($stage =~ /cam/ && !defined $stage_id) { 77 my_die("cam stage requires -stage_id", $add_id, 3); 78 79 } 73 80 if ($minidvodb && !defined($minidvodb_group)) { 74 81 my_die( "missing minidvodb_group", $add_id, 3 ); … … 108 115 109 116 # it was PSASTRO.OUTPUT 110 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 111 117 118 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 119 120 if ($stage =~ /cam/) { 121 # if it is cam stage we need to be careful when grabbing the filename. 122 # This breaks down into a few steps: 123 124 #get info about the cam_id 125 my $magicked; 126 { 127 my $mdcParser = PS::IPP::Metadata::Config->new; 128 my $command = "$camtool -processedexp -cam_id " . $stage_id; 129 $command .= " -dbname $dbname" if defined $dbname; 130 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 run(command => $command, verbose => $verbose); 132 &my_die( "Unable to get info on camRun", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 133 if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first 134 &my_die( "empty camRun", $add_id, $PS_EXIT_SYS_ERROR); 135 print "listing nothing\n"; 136 } else { 137 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 138 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 139 #this fails if there is nothing listed. I checked. 140 my $components = parse_md_list($metadata) or 141 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 142 my $comp = $$components[0]; 143 my $mparsed = $comp->{magicked}; 144 145 if (!defined($mparsed)) { 146 &my_die("Unable to parse magicked", $add_id, $PS_EXIT_PROG_ERROR); 147 } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk. 148 print "found a value for magicked:$mparsed\n"; 149 $magicked = $mparsed; 150 } 151 152 #is this cam_id magicked or not? 153 if ($magicked) { 154 $stage_extra1 = $magicked; 155 $fpaObjects = $ipprc->destreaked_filename("$fpaObjects") or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 156 print "cam_id is magicked, using $fpaObjects for the cam smf\n"; 157 } else { 158 print "cam_id is NOT magicked, using $fpaObjects for the cam smf\n"; 159 } 160 } 161 } 112 162 if (($stage =~/staticsky/) || ($stage =~/stack/)) { 113 163 $fpaObjects =~ s/smf$/cmf/; 114 115 } 116 164 } 117 165 if ($stage =~/staticsky_multi/) { 118 166 $fpaObjects =~ s/smf$/cmf/; #this should do nothing because it was already modded above … … 120 168 my $nice_num = sprintf ("%03d", $multi_num); 121 169 $fpaObjects =~ s/cmf$/$nice_num.cmf/; #this make it look for .001.cmf, etc 122 123 170 } 124 171 125 172 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 126 173 127 174 # convert supplied DVO database name to UNIX filename 128 175 my $dvodbReal; … … 131 178 $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ) or &my_die("can't get path for dvodb", $add_id, $PS_EXIT_CONFIG_ERROR); 132 179 } 133 134 135 136 137 180 my $dtime_addstar = 0; 138 139 181 if (defined $dvodbReal) { 140 if ($minidvodb) { 141 142 #if (!defined($minidvodb_name)) { 143 #take the active one, if it's not defined on the command line 144 #reverts would have this already set, for example. 145 my $command = "addtool -listminidvodbrun "; 146 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group; 147 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 148 $command .= " -state 'active' -limit 1"; 149 $command .= " -dbname $dbname" if defined $dbname; 150 print $command; 151 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 152 run(command => $command, verbose => $verbose); 153 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 154 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 155 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 156 157 my $components = parse_md_list($metadata) or 158 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 159 my $comp = $$components[0]; 160 $minidvodb_path = $comp->{minidvodb_path}; 161 $minidvodb_name = $comp->{minidvodb_name}; 162 163 if (!defined($minidvodb_path)) { 164 &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR); 165 } 166 if (!defined($minidvodb_name)) { 167 &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR); 168 } 169 #} 170 # tack on the minidvodb part to the db. 171 # $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/'; 172 #we don't need this now that I fixed the paths 173 174 } 175 else { 176 177 $minidvodb_path = $dvodbReal; 178 } 179 180 unless ($no_op) { 182 if ($minidvodb) { 183 my $command = "addtool -listminidvodbrun "; 184 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group; 185 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 186 $command .= " -state 'active' -limit 1"; 187 $command .= " -dbname $dbname" if defined $dbname; 188 print $command; 189 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 190 run(command => $command, verbose => $verbose); 191 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 192 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 193 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 194 195 my $components = parse_md_list($metadata) or 196 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 197 my $comp = $$components[0]; 198 $minidvodb_path = $comp->{minidvodb_path}; 199 $minidvodb_name = $comp->{minidvodb_name}; 200 201 if (!defined($minidvodb_path)) { 202 &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR); 203 } 204 if (!defined($minidvodb_name)) { 205 &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR); 206 } 207 } 208 else { 209 $minidvodb_path = $dvodbReal; 210 } 211 212 unless ($no_op) { 181 213 print $dvodbReal; 182 183 ## addstar can either save the full set of detections, or just184 ## the image metadata, in the dvodb. this is set in the185 ## database table addRun186 187 # addstar requires the user to have a valid .ptolemyrc which188 # in turn points at ippconfig/dvo.site189 190 # get the names for the camera and the real input file191 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar192 my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);193 194 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)195 my $command = "$addstar -update"; # XXX optionally set -update?196 $command .= " -D CAMERA $camdir";197 $command .= " -D CATDIR $minidvodb_path";198 $command .= " $realFile";199 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference214 215 ## addstar can either save the full set of detections, or just 216 ## the image metadata, in the dvodb. this is set in the 217 ## database table addRun 218 219 # addstar requires the user to have a valid .ptolemyrc which 220 # in turn points at ippconfig/dvo.site 221 222 # get the names for the camera and the real input file 223 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 224 my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR); 225 226 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 227 my $command = "$addstar -update"; # XXX optionally set -update? 228 $command .= " -D CAMERA $camdir"; 229 $command .= " -D CATDIR $minidvodb_path"; 230 $command .= " $realFile"; 231 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference 200 232 $command .= " -image" if $image_only; 201 233 if ($stage =~ /staticsky/) { 202 234 $command .= " -accept-astrom "; 203 235 } #careful here - this matches staticsky and staticsky_multi 204 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script205 206 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =207 run(command => $command, verbose => $verbose);208 unless ($success) {209 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);210 &my_die("Unable to perform addstar: $error_code", $add_id, $error_code);211 }212 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script236 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 237 238 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 239 run(command => $command, verbose => $verbose); 240 unless ($success) { 241 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 242 &my_die("Unable to perform addstar: $error_code", $add_id, $error_code); 243 } 244 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script 213 245 } 214 246 } … … 221 253 $fpaCommand .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path; 222 254 $fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 255 $fpaCommand .= " -stage_extra1" if defined $stage_extra1; 223 256 $fpaCommand .= " -dbname $dbname" if defined $dbname; 224 257 print $fpaCommand; … … 253 286 $command .= " -path_base $outroot" if defined $outroot; 254 287 $command .= (" -dtime_addstar " . ((DateTime->now->mjd - $mjd_start) * 86400)); 255 $fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 288 # $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; don't think we want it recorded (not sure) 289 $command .= " -stage_extra1 $stage_extra1" if defined $stage_extra1; 256 290 $command .= " -dbname $dbname" if defined $dbname; 291 print $command; 257 292 system ($command); 258 293 }
Note:
See TracChangeset
for help on using the changeset viewer.
