Changeset 8763 for trunk/ippScripts/scripts/detrend_process.pl
- Timestamp:
- Sep 6, 2006, 4:32:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_process.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process.pl
r8715 r8763 4 4 use strict; 5 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 8 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::Stats; 9 use Data::Dumper;10 12 13 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 14 use Pod::Usage qw( pod2usage ); 15 16 my ($det_id, $exp_id, $class, $class_id, $det_type, $input_uri, $output_uri); 17 GetOptions( 18 'det_id|d=s' => \$det_id, 19 'exp_id|e=s' => \$exp_id, 20 'class=s' => \$class, # unused 21 'class_id|i=s' => \$class_id, 22 'det_type|t=s' => \$det_type, 23 'input_uri|u=s' => \$input_uri, 24 'output_uri|o=s' => \$output_uri, 25 ) or pod2usage( 2 ); 26 27 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 28 pod2usage( 29 -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri", 30 -exitval => 3, 31 ) unless defined $det_id 32 and defined $exp_id 33 and defined $class_id 34 and defined $det_type 35 and defined $input_uri 36 and defined $output_uri; 11 37 12 38 # Recipes to use, as a function of the detrend type … … 26 52 use constant DELETE_STATS => 0; # Delete the statistics file when done? 27 53 28 # Parse the command-line arguments29 if (scalar @ARGV != 6) {30 die "Perform detrend processing at the imfile level.\n\n" .31 "Usage: $0 DET_ID EXP_ID CLASS_ID DETREND_TYPE INPUT.fits OUTPUT_ROOT\n\n";32 }33 my $detId = shift @ARGV; # Detrend ID34 my $expId = shift @ARGV; # Exposure ID35 my $classId = shift @ARGV; # Class ID36 my $detType = shift @ARGV; # Detrend type37 my $input = shift @ARGV; # Input FITS file38 my $output = shift @ARGV; # Output root name39 40 54 # Look for programs we need 41 55 my $missing_tools; … … 45 59 46 60 # Recipe to use in processing 47 my $recipe = RECIPES->{$det Type};48 die "Unrecognised detrend type: $det Type\n" if not defined $recipe;49 die "Unrecognised detrend type: $det Type\n" if not defined PREFIX->{$detType};61 my $recipe = RECIPES->{$det_type}; 62 die "Unrecognised detrend type: $det_type\n" if not defined $recipe; 63 die "Unrecognised detrend type: $det_type\n" if not defined PREFIX->{$det_type}; 50 64 51 65 ### Output file name --- must match camera configuration! 52 my $outputRoot = PREFIX->{$det Type} . '_' . $output;53 my $outputName = $outputRoot . '.' . $class Id ;66 my $outputRoot = PREFIX->{$det_type} . '_' . $output_uri; 67 my $outputName = $outputRoot . '.' . $class_id ; 54 68 my $outputImage = $outputName . '.fit'; 55 69 my $outputStats = $outputName . '.stats'; … … 57 71 # Run ppImage 58 72 { 59 my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .73 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . 60 74 " -stat $outputStats"; # Command to run ppImage 61 75 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 62 76 run(command => $command, verbose => 1); 63 die "Unable to perform ppImage on $input : $error_code\n" if not $success;77 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 64 78 die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage; 65 79 } … … 81 95 # Add the processed file to the database 82 96 { 83 my $command = "$dettool -addprocessed -det_id $det Id -exp_id $expId " .84 "-class_id $class Id -recip $recipe -uri $outputImage"; # Command to run dettool97 my $command = "$dettool -addprocessed -det_id $det_id -exp_id $exp_id " . 98 "-class_id $class_id -recip $recipe -uri $outputImage"; # Command to run dettool 85 99 $command .= " -bg " . $stats->bg_mean(); 86 100 $command .= " -bg_stdev " . $stats->bg_stdev(); … … 89 103 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 90 104 run(command => $command, verbose => 1); 91 die "Unable to perform dettool -addprocessed for $det Id/$expId/$classId: $error_code\n"105 die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n" 92 106 if not $success; 93 107 }
Note:
See TracChangeset
for help on using the changeset viewer.
