Changeset 17787 for trunk/ippScripts/scripts/warp_skycell.pl
- Timestamp:
- May 23, 2008, 3:06:45 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_skycell.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_skycell.pl
r17760 r17787 34 34 'outroot=s' => \$outroot, # Output root name 35 35 'verbose' => \$verbose, # Print to stdout 36 'no-update' => \$no_update, # Don't update the database?36 'no-update' => \$no_update, # Don't update the database? 37 37 'no-op' => \$no_op, # Don't do any operations? 38 38 'save-temps' => \$save_temps, # Save temporary files? … … 51 51 $ipprc->define_camera($camera); 52 52 53 my $STATS = 54 [ 53 my $STATS = 54 [ 55 55 # PPSTATS KEYWORD STATISTIC WARPTOOL FLAG 56 56 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, 57 57 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" }, 58 #{ name => "DT_WARP", type => "sum", flag => "-dtime_warp", dtype => "float" },58 { name => "DT_WARP", type => "sum", flag => "-dtime_warp", dtype => "float" }, 59 59 { name => "GOOD_PIXEL_FRAC", type => "mean", flag => "-good_frac", dtype => "float" }, 60 { name => "RANGE.XMIN", type => "mean", flag => "-xmin", dtype => "int" }, 61 { name => "RANGE.XMAX", type => "mean", flag => "-xmax", dtype => "int" }, 62 { name => "RANGE.YMIN", type => "mean", flag => "-ymin", dtype => "int" }, 63 { name => "RANGE.YMAX", type => "mean", flag => "-ymax", dtype => "int" }, 60 64 ]; 61 65 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser … … 66 70 my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1); 67 71 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 68 if ($missing_tools) { 72 if ($missing_tools) { 69 73 warn("Can't find required tools."); 70 exit($PS_EXIT_CONFIG_ERROR); 74 exit($PS_EXIT_CONFIG_ERROR); 71 75 } 72 76 73 77 # Get list of component imfiles for exposure 74 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files78 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 75 79 my $imfiles; 76 80 { … … 78 82 $command .= " -dbname $dbname" if defined $dbname; 79 83 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 run(command => $command, verbose => $verbose);81 unless ($success) { 82 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);83 &my_die("Unable to perform warptool -scmap: $error_code", $warp_id, $skycell_id, $tess_id, $error_code);84 run(command => $command, verbose => $verbose); 85 unless ($success) { 86 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 87 &my_die("Unable to perform warptool -scmap: $error_code", $warp_id, $skycell_id, $tess_id, $error_code); 84 88 } 85 89 86 90 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 87 &my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);88 $imfiles = parse_md_list($metadata) or 89 &my_die("Unable to parse metadata list", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);91 &my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR); 92 $imfiles = parse_md_list($metadata) or 93 &my_die("Unable to parse metadata list", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR); 90 94 } 91 95 92 96 # Where do we get the astrometry source from? 93 my $astromSource; # The astrometry source97 my $astromSource; # The astrometry source 94 98 { 95 99 my $command = "$ppConfigDump -camera $camera -dump-recipe PSWARP -"; 96 100 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 97 run(command => $command, verbose => $verbose);98 unless ($success) { 99 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);100 &my_die("Unable to perform ppConfigDump: $error_code", $warp_id, $error_code);101 run(command => $command, verbose => $verbose); 102 unless ($success) { 103 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 104 &my_die("Unable to perform ppConfigDump: $error_code", $warp_id, $error_code); 101 105 } 102 106 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 103 &my_die("Unable to parse metadata config doc", $warp_id, $PS_EXIT_PROG_ERROR);107 &my_die("Unable to parse metadata config doc", $warp_id, $PS_EXIT_PROG_ERROR); 104 108 $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE'); 105 109 } … … 128 132 my $wrote_astrom = 0; 129 133 foreach my $imfile (@$imfiles) { 130 my $image = $imfile->{uri}; # Image name134 my $image = $imfile->{uri}; # Image name 131 135 my $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $imfile->{chip_path_base}, $imfile->{class_id}); # Mask name 132 136 my $weight = $ipprc->filename("PPIMAGE.CHIP.WEIGHT", $imfile->{chip_path_base}, $imfile->{class_id}); # Mask name … … 135 139 &my_die("Couldn't find input file: $mask", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($mask); 136 140 137 my $astrom; # Astrometry file141 my $astrom; # Astrometry file 138 142 if ($astromSource eq 'PSASTRO.OUTPUT.MEF') { 139 $astrom = $ipprc->filename($astromSource, $imfile->{cam_path_base});143 $astrom = $ipprc->filename($astromSource, $imfile->{cam_path_base}); 140 144 } elsif ($astromSource eq 'PSASTRO.OUTPUT') { 141 my $chipRoot = $imfile->{chip_path_base};142 my $classID = $imfile->{class_id};143 $astrom = $ipprc->filename($astromSource, $chipRoot, $classID); # Astrometry file145 my $chipRoot = $imfile->{chip_path_base}; 146 my $classID = $imfile->{class_id}; 147 $astrom = $ipprc->filename($astromSource, $chipRoot, $classID); # Astrometry file 144 148 } 145 149 146 150 &my_die("Couldn't find input file: $astrom", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless defined $astrom and $ipprc->file_exists($astrom); 147 151 148 152 print $imageFile "$image\n"; 149 153 print $maskFile "$mask\n"; 150 154 print $weightFile "$weight\n"; 151 155 152 156 if (!$wrote_astrom) { 153 print $astromFile "$astrom\n";154 # XXX simplify this? only ever have one file for astrometry (must be MEF)155 if ($astromSource eq 'PSASTRO.OUTPUT.MEF') { 156 $wrote_astrom = 1;157 }157 print $astromFile "$astrom\n"; 158 # XXX simplify this? only ever have one file for astrometry (must be MEF) 159 if ($astromSource eq 'PSASTRO.OUTPUT.MEF') { 160 $wrote_astrom = 1; 161 } 158 162 } 159 163 } … … 165 169 166 170 # Run pswarp 167 my $accept = 1; # Accept the skycell?171 my $accept = 1; # Accept the skycell? 168 172 unless ($no_op) { 169 173 my $command = "$pswarp"; … … 175 179 $command .= " -stats $outputStats"; 176 180 $command .= " -recipe PPSTATS WARPSTATS"; 177 $command .= " -psf"; # Turn on PSF determination181 $command .= " -psf"; # Turn on PSF determination 178 182 $command .= " -tracedest $traceDest -log $logDest"; 179 183 180 184 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 181 run(command => $command, verbose => $verbose);182 unless ($success) { 183 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);184 &my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $tess_id, $error_code);185 run(command => $command, verbose => $verbose); 186 unless ($success) { 187 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 188 &my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $tess_id, $error_code); 185 189 } 186 190 … … 188 192 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 189 193 # Get the statistics on the warped image 190 my $statsFile; # File handle194 my $statsFile; # File handle 191 195 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 192 196 my @contents = <$statsFile>; # Contents of file … … 195 199 196 200 my $metadata = $mdcParser->parse($contents) 197 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);201 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR); 198 202 $accept = metadataLookupBool($metadata, "ACCEPT"); 199 203 if ($accept) { 200 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);201 202 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);203 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);204 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);205 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);206 &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);204 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR); 205 206 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 207 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 208 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 209 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 210 &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF); 207 211 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1); 208 212 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2); … … 218 222 219 223 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 220 run(command => $command, verbose => $verbose);221 unless ($success) { 222 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);223 warn("Unable to perform warptool -addwarped: $error_code\n");224 exit($error_code);224 run(command => $command, verbose => $verbose); 225 unless ($success) { 226 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 227 warn("Unable to perform warptool -addwarped: $error_code\n"); 228 exit($error_code); 225 229 } 226 230 } … … 228 232 sub my_die 229 233 { 230 my $msg = shift; # Warning message on die231 my $warp_id = shift; # Warp identifier232 my $skycell_id = shift; # Skycell identifier233 my $tess_id = shift; # Tesselation identifier234 my $exit_code = shift; # Exit code to add234 my $msg = shift; # Warning message on die 235 my $warp_id = shift; # Warp identifier 236 my $skycell_id = shift; # Skycell identifier 237 my $tess_id = shift; # Tesselation identifier 238 my $exit_code = shift; # Exit code to add 235 239 236 240 warn($msg); 237 241 if (defined $warp_id and defined $skycell_id and defined $tess_id and not $no_update) { 238 my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id -code $exit_code";239 $command .= " -dbname $dbname" if defined $dbname;242 my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id -code $exit_code"; 243 $command .= " -dbname $dbname" if defined $dbname; 240 244 run(command => $command, verbose => $verbose); 241 245 }
Note:
See TracChangeset
for help on using the changeset viewer.
