Changeset 17803 for trunk/ippScripts/scripts/chip_imfile.pl
- Timestamp:
- May 23, 2008, 5:10:21 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/chip_imfile.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/chip_imfile.pl
r17671 r17803 28 28 $no_update, $no_op ); 29 29 GetOptions( 30 'exp_id=s' => \$exp_id, # Exposure identifier31 'exp_tag=s' => \$exp_tag, # Exposure identifier32 'chip_id=s' => \$chip_id, # Chiptool identifier33 'class_id=s' => \$class_id, # Class identifier34 'uri|u=s' => \$uri, # Input FITS file35 'camera|c=s' => \$camera,# Camera36 'outroot|w=s' => \$outroot, # output file base name37 'dbname|d=s' => \$dbname, # Database name38 'reduction=s' => \$reduction, # Reduction class39 'verbose' => \$verbose, # Print to stdout40 'no-update' => \$no_update, # Don't update the database?41 'no-op' => \$no_op,# Don't do any operations?42 ) or pod2usage( 2 );30 'exp_id=s' => \$exp_id, # Exposure identifier 31 'exp_tag=s' => \$exp_tag, # Exposure identifier 32 'chip_id=s' => \$chip_id, # Chiptool identifier 33 'class_id=s' => \$class_id, # Class identifier 34 'uri|u=s' => \$uri, # Input FITS file 35 'camera|c=s' => \$camera, # Camera 36 'outroot|w=s' => \$outroot, # output file base name 37 'dbname|d=s' => \$dbname, # Database name 38 'reduction=s' => \$reduction, # Reduction class 39 'verbose' => \$verbose, # Print to stdout 40 'no-update' => \$no_update, # Don't update the database? 41 'no-op' => \$no_op, # Don't do any operations? 42 ) or pod2usage( 2 ); 43 43 44 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 45 45 pod2usage( -msg => "Required options: --exp_id --exp_tag --chip_id --class_id --uri --camera --outroot", 46 -exitval => 3) unless46 -exitval => 3) unless 47 47 defined $exp_id and 48 48 defined $exp_tag and … … 74 74 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 75 75 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" }, 76 { name => "OVER_VAL", type => "mean", flag => "-bias", dtype => "float" },76 { name => "OVER_VAL", type => "mean", flag => "-bias", dtype => "float" }, 77 77 { name => "OVER_VAL", type => "stdev", flag => "-bias_stdev", dtype => "float" }, 78 78 { name => "FRINGE_0", type => "rms", flag => "-fringe_0", dtype => "float" }, … … 107 107 } 108 108 109 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files109 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 110 110 111 111 &my_die("Couldn't find input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri); … … 124 124 my $outputWeight = $ipprc->filename("PPIMAGE.CHIP.WEIGHT", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); 125 125 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); 126 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);127 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);128 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);129 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);126 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); 127 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); 128 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); 129 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); 130 130 131 131 # Run ppImage … … 141 141 142 142 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 143 run(command => $command, verbose => $verbose);143 run(command => $command, verbose => $verbose); 144 144 unless ($success) { 145 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);146 &my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code);145 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 146 &my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code); 147 147 } 148 148 … … 150 150 $command = "$ppConfigDump -camera $camera -dump-recipe PPIMAGE -recipe PPIMAGE $recipe -"; 151 151 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 152 run(command => $command, verbose => $verbose);152 run(command => $command, verbose => $verbose); 153 153 unless ($success) { 154 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);155 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);154 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 155 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 156 156 } 157 157 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 158 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);158 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 159 159 160 160 ## allow the output images to be optional, depending on the recipe / reduction class 161 161 my $outputImageExpect = metadataLookupBool($recipeData, 'CHIP.FITS'); 162 162 if ($outputImageExpect) { 163 &my_die("Couldn't find expected output file: $outputImage\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);163 &my_die("Couldn't find expected output file: $outputImage\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 164 164 } 165 165 166 166 my $outputMaskExpect = metadataLookupBool($recipeData, 'CHIP.MASK.FITS'); 167 167 if ($outputMaskExpect) { 168 &my_die("Couldn't find expected output file: $outputMask\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);168 &my_die("Couldn't find expected output file: $outputMask\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 169 169 } 170 170 171 171 my $outputWeightExpect = metadataLookupBool($recipeData, 'CHIP.WEIGHT.FITS'); 172 172 if ($outputWeightExpect) { 173 &my_die("Couldn't find expected output file: $outputWeight\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);173 &my_die("Couldn't find expected output file: $outputWeight\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 174 174 } 175 175 … … 179 179 180 180 # Get the statistics on the processed image 181 my $statsFile; # File handle181 my $statsFile; # File handle 182 182 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 183 183 my @contents = <$statsFile>; # Contents of file … … 185 185 186 186 # parse the statistics MDC file 187 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files187 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 188 188 my $metadata = $mdcParser->parse(join "", @contents); 189 189 unless ($metadata) { 190 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);190 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR); 191 191 } 192 192 193 193 # extract the stats from the metadata 194 194 unless ($stats->parse($metadata)) { 195 &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);195 &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR); 196 196 } 197 197 } … … 204 204 $command .= " -uri $outputImage"; 205 205 $command .= " -path_base $outroot"; 206 $command .= " -hostname $host" if defined $host; 206 207 $command .= " -dbname $dbname" if defined $dbname; 207 208 $command .= $stats->cmdflags(); … … 210 211 unless ($no_update) { 211 212 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 212 run(command => $command, verbose => $verbose);213 run(command => $command, verbose => $verbose); 213 214 unless ($success) { 214 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);215 warn("Unable to perform chiptool -addprocessedimfile: $error_code\n");216 exit($error_code);215 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 216 warn("Unable to perform chiptool -addprocessedimfile: $error_code\n"); 217 exit($error_code); 217 218 } 218 219 } else { … … 230 231 carp($msg); 231 232 if (defined $chip_id and defined $class_id and not $no_update) { 232 my $command = "$chiptool -addprocessedimfile"; 233 $command .= " -exp_id $exp_id"; 234 $command .= " -chip_id $chip_id"; 235 $command .= " -class_id $class_id"; 236 $command .= " -code $exit_code"; 237 $command .= " -uri $outputImage"; 238 $command .= " -dbname $dbname" if defined $dbname; 233 my $command = "$chiptool -addprocessedimfile"; 234 $command .= " -exp_id $exp_id"; 235 $command .= " -chip_id $chip_id"; 236 $command .= " -class_id $class_id"; 237 $command .= " -code $exit_code"; 238 $command .= " -uri $outputImage"; 239 $command .= " -hostname $host" if defined $host; 240 $command .= " -dbname $dbname" if defined $dbname; 239 241 system ($command); 240 242 }
Note:
See TracChangeset
for help on using the changeset viewer.
