Changeset 25027 for branches/pap/ippScripts/scripts/chip_imfile.pl
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/chip_imfile.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippScripts/scripts/chip_imfile.pl
r23688 r25027 20 20 use PS::IPP::Metadata::Config; 21 21 use PS::IPP::Config 1.01 qw( :standard ); 22 use File::Temp qw( tempfile ); 22 23 23 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 39 40 # Parse the command-line arguments 40 41 my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose, 41 $no_update, $ no_op, $redirect, $magicked, $deburned );42 $no_update, $save_temps, $no_op, $redirect, $magicked, $deburned ); 42 43 GetOptions( 43 44 'exp_id=s' => \$exp_id, # Exposure identifier … … 52 53 'run-state=s' => \$run_state, # current state of the run (new, update) 53 54 'magicked' => \$magicked, # magicked state of input file 54 'deburned=s' => \$deburned, # does deburned image exist? 55 'deburned=s' => \$deburned, # does deburned image exist? 55 56 'threads=s' => \$threads, # Number of threads to use for ppImage 56 57 'verbose' => \$verbose, # Print to stdout … … 58 59 'no-op' => \$no_op, # Don't do any operations? 59 60 'redirect-output' => \$redirect, 61 'save-temps' => \$save_temps, # Save temporary files? 60 62 ) or pod2usage( 2 ); 61 63 62 64 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 63 pod2usage( -msg => "Required options: --exp_id --chip_id --c lass_id --uri --camera --outroot --run-state",65 pod2usage( -msg => "Required options: --exp_id --chip_id --chip_imfile_id --class_id --uri --camera --outroot --run-state", 64 66 -exitval => 3) unless 65 67 defined $exp_id and … … 142 144 my $useDeburnedImage = metadataLookupBool($recipeData, 'USE.DEBURNED.IMAGE'); 143 145 if ($useDeburnedImage && $deburned) { 144 $uri =~ s/fits$/burn.fits/; 145 &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri); 146 $uri =~ s/fits$/burn.fits/; 147 &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri); 148 } 149 150 # apply the 'tiltystreak' operation, if desired 151 my $tiltystreakApply = metadataLookupBool($recipeData, 'TILTYSTREAK.APPLY'); 152 if ($tiltystreakApply) { 153 154 my $tiltystreakByClass = metadataLookupMD($recipeData, 'TILTYSTREAK.BY.CLASS'); 155 my $tiltystreakClassApply = metadataLookupBool($tiltystreakByClass, "APPLY.$class_id"); 156 if ($tiltystreakClassApply) { 157 158 my $tiltystreakClassOptions = metadataLookupStr($tiltystreakByClass, "OPTIONS.$class_id"); 159 if ($tiltystreakClassOptions eq "none") { 160 $tiltystreakClassOptions = ""; 161 } 162 163 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 164 165 # XXX make these optional (must be built by psbuild as well...) 166 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 167 my $tiltystreak = can_run('tiltystreak') or &my_die ("Can't find tiltystreak", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 168 169 # create an temporary output file: 170 my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.tmp.XXXX", UNLINK => !$save_temps ); 171 172 print "uri: $uri\n"; 173 174 # get the UNIX version of the (possible) neb: or path: filename 175 my $uriReal = $ipprc->file_resolve( $uri ); 176 177 print "uriReal: $uriReal\n"; 178 179 # unpack the data (is a NOP if not compressed) 180 $command = "$funpack -S $uriReal > $tempName"; 181 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 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 funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 185 } 186 187 # run tiltystreak 188 $command = "$tiltystreak $tempName $tiltystreakClassOptions"; 189 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 190 unless ($success) { 191 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 192 &my_die("Unable to perform tiltystreak: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 193 } 194 195 # supply the output file as the new input file 196 $uri = $tempName; 197 } 146 198 } 147 199 … … 201 253 } 202 254 chomp $cmdflags; 203 ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag 255 if (($camera ne "GPC1") or ($class_id ne "XY27") or ($exp_id < 53171)) { 256 ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag 257 } else { 258 # hack to kick ota 27 out of subsequent analysis by setting quality flag to a non-zero value 259 my ($before, $after) = split " -quality ", $cmdflags; 260 261 # get the current value 262 ($quality) = $after =~ /^(\d+)/; 263 $after = substr($after, length($quality)); 264 265 # replace it if it is zero 266 $quality = 42 if !$quality; 267 268 # rebuild the cmdflags 269 $cmdflags = $before . " -quality $quality"; 270 $cmdflags .= " $after" if $after; 271 } 204 272 } 205 273 … … 265 333 $command = "$chiptool -addprocessedimfile"; 266 334 $command .= " -exp_id $exp_id"; 267 $command .= " -uri $outputImage" ;335 $command .= " -uri $outputImage" if defined $outputImage; 268 336 $command .= " -path_base $outroot"; 269 337 $command .= " -hostname $host" if defined $host;
Note:
See TracChangeset
for help on using the changeset viewer.
