Changeset 8763 for trunk/ippScripts/scripts/detrend_create_resid.pl
- Timestamp:
- Sep 6, 2006, 4:32:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_create_resid.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_create_resid.pl
r8715 r8763 3 3 use warnings; 4 4 use strict; 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 5 8 6 9 use IPC::Cmd qw( can_run run ); … … 9 12 use Data::Dumper; 10 13 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 my ($det_id, $iter, $exp_id, $class_id, $det_type, $detrend, 18 $input_uri, $output_uri); 19 GetOptions( 20 'det_id|d=s' => \$det_id, 21 'iteration=s' => \$iter, 22 'exp_id|e=s' => \$exp_id, 23 'class_id|i=s' => \$class_id, 24 'det_type|t=s' => \$det_type, 25 'detrend=s' => \$detrend, 26 'input_uri|u=s' => \$input_uri, 27 'output_uri|o=s' => \$output_uri, 28 ) or pod2usage( 2 ); 29 30 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 31 pod2usage( 32 -msg => "Required options: --det_id --iteration --exp_id --class_id --det_type --detrend --input_uri --output_uri", 33 -exitval => 3, 34 ) unless defined $det_id 35 and defined $iter 36 and defined $exp_id 37 and defined $class_id 38 and defined $det_type 39 and defined $detrend 40 and defined $input_uri 41 and defined $output_uri; 11 42 12 43 # Recipes to use, as a function of the detrend type … … 34 65 use constant DELETE_STATS => 0; # Delete the statistics file when done? 35 66 36 # Parse the command-line arguments37 if (scalar @ARGV != 8) {38 die "Apply a stacked detrend image to an individual detrend.\n\n" .39 "Usage: $0 DET_ID ITERATION EXP_ID CLASS_ID DETREND_TYPE DETREND.fits INPUT.fits OUTPUT_ROOT\n\n";40 }41 my $detId = shift @ARGV; # Detrend ID42 my $iter = shift @ARGV; # Iteration43 my $expId = shift @ARGV; # Exposure ID44 my $classId = shift @ARGV; # Class ID45 my $detType = shift @ARGV; # Detrend type46 my $detrend = shift @ARGV; # The detrend frame to apply47 my $input = shift @ARGV; # Input FITS file48 my $output = shift @ARGV; # Output root name49 50 67 # Look for programs we need 51 68 my $missing_tools; … … 55 72 56 73 # Recipe to use in processing 57 my $recipe = RECIPES->{$det Type};58 die "Unrecognised detrend type: $det Type\n" if not defined $recipe;74 my $recipe = RECIPES->{$det_type}; 75 die "Unrecognised detrend type: $det_type\n" if not defined $recipe; 59 76 # Detrend to use in processing 60 my $detFlag = DETRENDS->{$det Type};61 die "Unrecognised detrend type: $det Type\n" if not defined $detFlag;77 my $detFlag = DETRENDS->{$det_type}; 78 die "Unrecognised detrend type: $det_type\n" if not defined $detFlag; 62 79 # Prefix to use for filename 63 my $prefix = PREFIX->{$det Type};64 die "Unrecognised detrend type: $det Type\n" if not defined $prefix;80 my $prefix = PREFIX->{$det_type}; 81 die "Unrecognised detrend type: $det_type\n" if not defined $prefix; 65 82 66 83 ### Output file names --- must match camera configuration! 67 my $outputRoot = $prefix . '_' . $output ;68 my $outputName = $outputRoot . '.' . $class Id . '.fit';69 my $outputStats = $outputRoot . '.' . $class Id . '.stats';70 my $bin1Name = $outputRoot . '.' . $class Id . '.b1.fit';71 my $bin2Name = $outputRoot . '.' . $class Id . '.b2.fit';84 my $outputRoot = $prefix . '_' . $output_uri; 85 my $outputName = $outputRoot . '.' . $class_id . '.fit'; 86 my $outputStats = $outputRoot . '.' . $class_id . '.stats'; 87 my $bin1Name = $outputRoot . '.' . $class_id . '.b1.fit'; 88 my $bin2Name = $outputRoot . '.' . $class_id . '.b2.fit'; 72 89 73 90 # Run ppImage 74 91 { 75 my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .92 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . 76 93 " -stat $outputStats $detFlag $detrend"; # Command to run ppImage 77 94 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 78 95 run(command => $command, verbose => 1); 79 die "Unable to perform ppImage on $input : $error_code\n" if not $success;96 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 80 97 die "Couldn't find expected output file: $outputName\n" if not -f $outputName; 81 98 die "Couldn't find expected output file: $bin1Name\n" if not -f $bin1Name; … … 99 116 # Add the processed file to the database 100 117 { 101 my $command = "$dettool -addresidimfile -det_id $det Id -iteration $iter -exp_id $expId " .102 "-class_id $class Id -recip $recipe -uri $outputName -b1_uri $bin1Name " .118 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_id $exp_id " . 119 "-class_id $class_id -recip $recipe -uri $outputName -b1_uri $bin1Name " . 103 120 "-b2_uri $bin2Name"; # Command to run dettool 104 121 $command .= " -bg " . $stats->bg_mean(); … … 108 125 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 109 126 run(command => $command, verbose => 1); 110 die "Unable to perform dettool -addprocessed for $det Id/$expId/$classId: $error_code\n"127 die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n" 111 128 if not $success; 112 129 } 113 130 114 unlink "$output .stats" if DELETE_STATS;131 unlink "$output_uri.stats" if DELETE_STATS; 115 132 116 133 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
