Changeset 9364
- Timestamp:
- Oct 6, 2006, 2:11:25 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/phase2.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/phase2.pl
r9097 r9364 8 8 use PS::IPP::Metadata::Stats; 9 9 use Data::Dumper; 10 use PS::IPP::Config; 11 my $ipprc = PS::IPP::Config->new(); # IPP configuration 12 use File::Spec; 10 13 11 use constant RECIPE => 'PPIMAGE_OBDF.config'; # Recipe to use 12 use constant PREFIX => 'obdf'; # Prefix to attach to filenames 13 use constant DELETE_STATS => 0; # Delete the statistics file when done? 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 use constant RECIPE => 'PPIMAGE_OBDSF.config'; # Recipe to use 14 18 15 19 # Parse the command-line arguments 16 if (scalar @ARGV != 4) { 17 die "Perform phase 2 processing.\n\n" . 18 "Usage: $0 EXP_ID CLASS_ID INPUT.fits OUTPUT_ROOT\n\n"; 19 } 20 my $expTag = shift @ARGV; # Exposure ID 21 my $classId = shift @ARGV; # Class ID 22 my $input = shift @ARGV; # Input FITS file 23 my $output = shift @ARGV; # Output root name 20 my ($expTag, # Exposure tag 21 $classId, # Class Id 22 $input, # Input FITS file 23 $no_update # Don't update the database? 24 ); 25 GetOptions( 26 'exp_tag|e=s' => \$expTag, 27 'class_id|i=s' => \$classId, 28 'uri|u=s' => \$input, 29 'no-update' => \$no_update 30 ) or pod2usage( 2 ); 31 32 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 33 pod2usage( 34 -msg => "Required options: --exp_tag --class_id --uri", 35 -exitval => 3, 36 ) unless defined $expTag 37 and defined $classId 38 and defined $input; 24 39 25 40 # Look for programs we need … … 30 45 31 46 ### Output file name --- must match camera configuration! 32 my $outputRoot = PREFIX . '_' . $output; 33 my $outputName = $outputRoot . '.' . $classId ; 34 my $outputImage = $outputName . '.fit'; 35 my $outputStats = $outputName . '.stats'; 36 my $outputBin1Name = $outputName . 'b1.fit'; 37 my $outputBin2Name = $outputName . 'b2.fit'; 47 my ($vol, $dir, $file) = File::Spec->splitpath( $input ); 48 my $outputRoot = $expTag . '.p2.'; 49 $outputRoot = File::Spec->rel2abs( File::Spec->catpath( $vol, $dir, $outputRoot ), $ipprc->workdir() ); 50 my $outputImage = $outputRoot . '.' . $classId . '.fits'; 51 my $outputStats = $outputRoot . '.' . $classId . '.stats'; 52 my $outputBin1Name = $outputRoot . '.' . $classId . 'b1.fits'; 53 my $outputBin2Name = $outputRoot . '.' . $classId . 'b2.fits'; 38 54 39 55 # Run ppImage … … 45 61 die "Unable to perform ppImage on $input: $error_code\n" if not $success; 46 62 die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage; 63 die "Couldn't find expected output file: $outputBin1Name\n" if not -f $outputBin1Name; 64 die "Couldn't find expected output file: $outputBin2Name\n" if not -f $outputBin2Name; 65 die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats; 47 66 } 48 67 … … 51 70 { 52 71 my $statsFile; # File handle 53 open $statsFile, "$outputStats"or die "Can't open statistics file $outputStats: $!\n";72 open $statsFile, $outputStats or die "Can't open statistics file $outputStats: $!\n"; 54 73 my @contents = <$statsFile>; # Contents of file 55 74 close $statsFile; … … 62 81 63 82 # Add the processed file to the database 64 { 83 $outputImage = File::Spec->abs2rel( $outputImage, $ipprc->workdir() ); 84 $outputBin1Name = File::Spec->abs2rel( $outputBin1Name, $ipprc->workdir() ); 85 $outputBin2Name = File::Spec->abs2rel( $outputBin2Name, $ipprc->workdir() ); 86 unless ($no_update) { 65 87 # Command to run dettool 66 88 my $command = "$p2tool -processed"; … … 79 101 die "Unable to perform p2tool -processed for $expTag/$classId: $error_code\n" 80 102 if not $success; 103 104 unlink $outputStats; 81 105 } 82 106 83 unlink "$outputStats" if DELETE_STATS;84 85 107 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
