Changeset 35118
- Timestamp:
- Feb 7, 2013, 1:40:20 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
ippScripts/scripts/background_chip.pl (modified) (5 diffs)
-
ippScripts/scripts/background_warp.pl (modified) (7 diffs)
-
ppBackground/src/ppBackground.h (modified) (2 diffs)
-
ppBackground/src/ppBackgroundArguments.c (modified) (3 diffs)
-
ppBackground/src/ppBackgroundCamera.c (modified) (2 diffs)
-
ppBackground/src/ppBackgroundData.c (modified) (2 diffs)
-
ppBackground/src/ppBackgroundLoop.c (modified) (1 diff)
-
ppBackground/src/ppBackgroundRestore.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/background_chip.pl
r34422 r35118 14 14 use DateTime; 15 15 my $mjd_start = DateTime->now->mjd; # MJD of starting script 16 use File::Basename; 16 17 17 18 use vars qw( $VERSION ); … … 123 124 my $in_image = $ipprc->filename("PPIMAGE.CHIP", $in_path, $class_id); 124 125 my $in_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $in_path, $class_id); 126 my $in_wt = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $in_path, $class_id); 125 127 my $in_bg = $ipprc->filename("PSPHOT.BACKMDL", $in_path, $class_id); 126 128 my $in_pattern = $ipprc->filename("PPIMAGE.PATTERN", $in_path, $class_id); … … 148 150 } 149 151 152 # XXX: M31 TEST turn off restoring pattern correction 153 $apply_pattern = 0; 154 150 155 # Set up files 151 156 &my_die("Couldn't find input file: $in_image\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_image); 152 157 &my_die("Couldn't find input file: $in_mask\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_mask); 158 &my_die("Couldn't find input file: $in_wt\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_wt); 153 159 &my_die("Couldn't find input file: $in_bg\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_bg) or !$apply_bg; 154 160 &my_die("Couldn't find input file: $in_pattern\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_pattern) or !$apply_pattern; … … 163 169 my $out_image = prepare_output("PPBACKGROUND.OUTPUT", $outroot, $class_id, 1); 164 170 my $out_mask = prepare_output("PPBACKGROUND.OUTPUT.MASK", $outroot, $class_id, 1); 171 my $out_wt = prepare_output("PPBACKGROUND.OUTPUT.VARIANCE", $outroot, $class_id, 1); 165 172 my $out_stats = prepare_output("PPBACKGROUND.STATS", $outroot, $class_id, 1); 166 173 my $out_config = prepare_output("PPBACKGROUND.CONFIG", $outroot, $class_id, 1); 167 174 my $traceDest = prepare_output("TRACE.IMFILE", $outroot, $class_id, 1); 175 176 my $auxmask; 177 178 my $apply_auxiliary_mask = 1; 179 if ($apply_auxiliary_mask) { 180 my @auxmask_start_date = qw( 181 0000 182 5178 183 5218 184 5403 185 5424 186 5455 187 5485 188 5512 189 5545 190 5770 191 5797 192 5825 193 5854 194 5881 195 6138 196 6153 197 6197 198 6214 199 ); 200 my @auxmask_end_date = qw( 201 5177 202 5217 203 5402 204 5423 205 5454 206 5484 207 5511 208 5544 209 5769 210 5796 211 5824 212 5853 213 5880 214 6137 215 6152 216 6196 217 6213 218 9999 219 ); 220 221 my $outroot_base = basename($outroot); 222 223 # Assume that outroot base begins with exp_name: fix by passing in exp_name 224 my $mjd = substr($outroot_base, 1, 4); 225 if ($mjd =~ /\D/) { 226 my $error_code = 1; 227 &my_die("unexpected outroot base: $outroot_base: $error_code", $chip_bg_id, $class_id, $error_code); 228 } 229 230 my $i = 0; 231 while ($auxmask_end_date[$i] < $mjd) { 232 $i++; 233 } 234 235 my $auxmask_base = "/data/ipp064.0/bills/m31-masks/www.usm.uni-muenchen.de/people/arri/PAndromeda/masks_fits/mask"; 236 237 $auxmask = sprintf "%s_%04d-%04d_%s.fits", $auxmask_base, $auxmask_start_date[$i], $auxmask_end_date[$i], $class_id; 238 print "Auxililary mask file is $auxmask\n"; 239 } 240 241 242 168 243 169 244 # Run ppImage … … 172 247 $command .= " -image $in_image"; 173 248 $command .= " -mask $in_mask"; 249 $command .= " -variance $in_wt"; 250 $command .= " -auxmask $auxmask" if $auxmask; 174 251 $command .= " -stats $out_stats" if $do_stats; 175 252 $command .= " -background $in_bg" if $apply_bg; -
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 } -
trunk/ppBackground/src/ppBackground.h
r34800 r35118 13 13 psString patternName; // Filename of pattern 14 14 psString backgroundName; // Filename of background 15 psString imageName, maskName; // Filenames of input image/mask 15 psString imageName; // Filenames of input image 16 psString maskName; // Filenames of input mask 17 psString varianceName; // Filenames of input variance 18 psString auxMaskName; // Filename of auxillary mask 16 19 psString outRoot; // Output root name 17 20 psMetadata *stats; // Statistics for output … … 52 55 const pmChip *pattern, // Chip with pattern 53 56 const pmFPAview *view, // View to data 54 pmConfig *config // Configuration 57 pmConfig *config, // Configuration 58 psImageMaskType maskBad // value to use for bad pixels 55 59 ); 56 60 -
trunk/ppBackground/src/ppBackgroundArguments.c
r28543 r35118 49 49 psMetadataAddStr(arguments, PS_LIST_TAIL, "-image", 0, "Filename of image (required)", NULL); 50 50 psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask", 0, "Filename of mask", NULL); 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-variance", 0, "Filename of variance image", NULL); 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-auxmask", 0, "Filename of auxiliary mask", NULL); 51 53 psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Output statistics file", NULL); 52 54 psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "Output configuration file", NULL); … … 59 61 data->imageName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-image")); 60 62 data->maskName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-mask")); 63 data->varianceName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-variance")); 64 data->auxMaskName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-auxmask")); 61 65 data->outRoot = psStringCopy(argv[1]); 62 66 psMetadataAddStr(arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot); … … 64 68 psTrace("ppBackground", 1, "Done reading command-line arguments\n"); 65 69 66 if (!data->patternName && !data->backgroundName ) {67 psError(PPBACKGROUND_ERR_CONFIG, true, "Must specify at least one of -pattern and -background ");70 if (!data->patternName && !data->backgroundName && !data->auxMaskName) { 71 psError(PPBACKGROUND_ERR_CONFIG, true, "Must specify at least one of -pattern and -background -auxmask"); 68 72 return false; 69 73 } -
trunk/ppBackground/src/ppBackgroundCamera.c
r28289 r35118 65 65 } 66 66 67 fileArguments("VARIANCE", data->varianceName, "Input uncorrected variance", data->config); 68 pmFPAfileBindFromArgs(&status, image, data->config, "PPBACKGROUND.VARIANCE", "VARIANCE"); // File 69 if (!status) { 70 psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.VARIANCE"); 71 return false; 72 } 73 74 if (data->auxMaskName) { 75 fileArguments("AUXMASK", data->auxMaskName, "Auxiliary mask", data->config); 76 pmFPAfileBindFromArgs(&status, image, data->config, "PPBACKGROUND.AUXMASK", "AUXMASK"); // File 77 if (!status) { 78 psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.MASK"); 79 return false; 80 } 81 } 82 67 83 pmFPAfile *output = pmFPAfileDefineOutput(data->config, image->fpa, "PPBACKGROUND.OUTPUT"); 68 84 if (!output) { … … 79 95 outMask->save = true; 80 96 97 pmFPAfile *outVariance = pmFPAfileDefineOutput(data->config, output->fpa, "PPBACKGROUND.OUTPUT.VARIANCE"); 98 if (!outVariance) { 99 psError(psErrorCodeLast(), false, "Unable to define output."); 100 return false; 101 } 102 outVariance->save = true; 103 81 104 #if 0 82 105 // Now the camera has been determined, we can read the recipe -
trunk/ppBackground/src/ppBackgroundData.c
r28276 r35118 17 17 psFree(data->imageName); 18 18 psFree(data->maskName); 19 psFree(data->varianceName); 20 psFree(data->auxMaskName); 19 21 psFree(data->outRoot); 20 22 psFree(data->stats); … … 33 35 data->imageName = NULL; 34 36 data->maskName = NULL; 37 data->varianceName = NULL; 38 data->auxMaskName = NULL; 35 39 data->outRoot = NULL; 36 40 data->stats = NULL; -
trunk/ppBackground/src/ppBackgroundLoop.c
r28300 r35118 135 135 pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern 136 136 pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model 137 if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config )) {137 if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config, maskBad)) { 138 138 psError(psErrorCodeLast(), false, "Unable to replace background"); 139 139 return false; -
trunk/ppBackground/src/ppBackgroundRestore.c
r34813 r35118 35 35 36 36 bool ppBackgroundRestore(pmChip *chip, const pmChip *background, const pmChip *pattern, 37 const pmFPAview *oldView, pmConfig *config )37 const pmFPAview *oldView, pmConfig *config, psImageMaskType maskBad) 38 38 { 39 39 PS_ASSERT_PTR_NON_NULL(chip, false); … … 120 120 } 121 121 122 psImage *auxMask = psMetadataLookupPtr(NULL, ro->analysis, "EXPNUM"); 123 if (auxMask) { 124 if (auxMask->numCols != mask->numCols || auxMask->numRows != mask->numRows) { 125 psError(PPBACKGROUND_ERR_DATA, true, "auxiliary mask size (%d x %d) does not match input size (%d x %d)", 126 auxMask->numCols, auxMask->numRows, numCols, numRows); 127 return false; 128 } 129 // Arno's masks are floating point, fix later and zero means bad 130 #define AUXMASK_DATA F32 131 for (int y = 0; y < numRows; y++) { 132 for (int x = 0; x < numCols; x++) { 133 if (auxMask->data.AUXMASK_DATA[y][x] == 0) { 134 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskBad; 135 } 136 } 137 } 138 } 139 140 122 141 ro->data_exists = true; 123 142 ro->parent->data_exists = true;
Note:
See TracChangeset
for help on using the changeset viewer.
