Changeset 35118 for trunk/ippScripts/scripts/background_warp.pl
- Timestamp:
- Feb 7, 2013, 1:40:20 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/background_warp.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/background_warp.pl
r34592 r35118 29 29 my $missing_tools; 30 30 my $bgtool = can_run('bgtool') or (warn "Can't find bgtool" and $missing_tools = 1); 31 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); 31 32 my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1); 32 33 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); … … 38 39 39 40 my ($warp_bg_id, $skycell_id, $tess_dir, $reduction, $camera, $dbname, $outroot, $threads, $verbose, $no_update, $no_op, $redirect, $save_temps); 40 my ($astrometry, $imageName, $maskName, $ magicked);41 my ($astrometry, $imageName, $maskName, $weightName, $magicked); 41 42 GetOptions( 42 43 'warp_bg_id|i=s' => \$warp_bg_id, # Warp identifier … … 117 118 # Get list of filenames 118 119 my $tempOutRoot = "/tmp/background.warp.$warp_bg_id.$skycell_id"; 120 121 # XXX: get this from recipe 122 my $alternate_astrometry_label = 'M31.test.20130206.bgsub'; 123 # XXX: get exp_id from command line 124 my $exp_id = 196758; 125 119 126 if (!defined $imageName) { 120 127 # go find our inputs 121 my ($imageFile, $maskFile); 128 my $astrom_path_base; 129 if (defined $alternate_astrometry_label) { 130 my $command = "$camtool -processedexp -exp_id $exp_id -label $alternate_astrometry_label"; 131 $command .= " -dbname $dbname" if $dbname; 132 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 133 run(command => $command, verbose => $verbose); 134 unless ($success) { 135 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to perform camtool -processedexp: $error_code", $warp_bg_id, $error_code); 137 } 138 my $entries = $mdcParser->parse_list(join "", @$stdout_buf) or 139 &my_die("Unable to parse metadata config doc", $warp_bg_id, $PS_EXIT_PROG_ERROR); 140 my $entry = $entries->[0]; 141 $astrom_path_base = $entry->{path_base}; 142 } 143 144 my ($imageFile, $maskFile, $weightFile); 122 145 ($imageFile, $imageName) = tempfile( "$tempOutRoot.image.list.XXXX", UNLINK => !$save_temps); 123 146 ($maskFile, $maskName) = tempfile( "$tempOutRoot.mask.list.XXXX", UNLINK => !$save_temps); 147 ($weightFile, $weightName) = tempfile( "$tempOutRoot.wt.list.XXXX", UNLINK => !$save_temps); 124 148 my $command = "$bgtool -warpinputs"; 125 149 $command .= " -warp_bg_id $warp_bg_id"; … … 139 163 my $image = $ipprc->filename("PPBACKGROUND.OUTPUT", $chip_path, $class_id); 140 164 my $mask = $ipprc->filename("PPBACKGROUND.OUTPUT.MASK", $chip_path, $class_id ); 165 my $wt = $ipprc->filename("PPBACKGROUND.OUTPUT.VARIANCE", $chip_path, $class_id ); 141 166 print $imageFile "$image\n"; 142 167 print $maskFile "$mask\n"; 168 print $weightFile "$wt\n"; 143 169 &my_die("Can't find input image: $image", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($image); 144 170 &my_die("Can't find input mask: $mask", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($mask); 171 &my_die("Can't find input mask: $wt", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($wt); 145 172 146 173 &my_die("Magic status don't match: $magicked vs $file->{magicked}", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) if defined $magicked and $magicked != $file->{magicked}; 147 174 $magicked = $file->{magicked}; 148 175 149 my $cam_path = $file->{cam_path_base}; 150 my $astrom = $ipprc->filename($astromSource, $cam_path); 151 &my_die("Astrometry files don't match: $astrom vs $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) if defined $astrometry and $astrom ne $astrometry; 152 $astrometry = $astrom; 176 if (!$astrom_path_base) { 177 my $cam_path = $file->{cam_path_base}; 178 my $astrom = $ipprc->filename($astromSource, $cam_path); 179 &my_die("Astrometry files don't match: $astrom vs $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) if defined $astrometry and $astrom ne $astrometry; 180 $astrometry = $astrom; 181 } elsif (!$astrometry) { 182 # using alternate astrometry 183 $astrometry = $ipprc->filename($astromSource, $astrom_path_base); 184 } 153 185 } 154 186 close $imageFile; 155 187 close $maskFile; 188 close $weightFile; 156 189 } 157 190 … … 166 199 my $out_image = prepare_output("PSWARP.OUTPUT", $outroot, $skycell_id, 1); 167 200 my $out_mask = prepare_output("PSWARP.OUTPUT.MASK", $outroot, $skycell_id, 1); 201 my $out_wt = prepare_output("PSWARP.OUTPUT.VARIANCE", $outroot, $skycell_id, 1); 168 202 my $out_stats = prepare_output("SKYCELL.STATS", $outroot, $skycell_id, 1); 169 203 my $out_config = prepare_output("PSWARP.CONFIG", $outroot, $skycell_id, 1); … … 179 213 $command .= " -list $imageName"; 180 214 $command .= " -masklist $maskName"; 215 $command .= " -variancelist $weightName"; 181 216 $command .= " -astrom $astrometry"; 182 217 $command .= " $outroot $skyFile"; … … 220 255 &my_die("Couldn't find expected output file: $out_image", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_image); 221 256 &my_die("Couldn't find expected output file: $out_mask", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_mask); 257 &my_die("Couldn't find expected output file: $out_wt", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_wt); 222 258 &my_die("Couldn't find expected output file: $out_config", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_config); 223 259 }
Note:
See TracChangeset
for help on using the changeset viewer.
