Changeset 27718 for trunk/ippScripts/scripts/ipp_detrend_combine.pl
- Timestamp:
- Apr 21, 2010, 11:35:15 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/ipp_detrend_combine.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_detrend_combine.pl
r17671 r27718 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 my $date = `date`; 9 10 print "\n\n"; 10 print "Starting script $0 on $host \n\n";11 print "Starting script $0 on $host at $date\n\n"; 11 12 12 13 use vars qw( $VERSION ); … … 32 33 $workdir, $dbname, $no_update); 33 34 GetOptions( 34 'det_type=s' => \$det_type, # Detrend type for new detrend35 'filelevel=s' => \$filelevel, # File level for new detrend36 'inst=s' => \$inst, # Instrument for new detrend37 'telescope=s' => \$telescope, # Telescope for new detrend38 'filter=s' => \$filter,# Filter name for new detrend39 'det_id1=s'=> \$det_id1, # Detrend id for detrend 140 'iteration1=s' => \$iter1, # Iteration for detrend 141 'det_id2=s'=> \$det_id2, # Detrend id for detrend 242 'iteration2=s' => \$iter2, # Iteration for detrend 243 'operation=s' => \$operation, # Operation to perform on files44 'mask' => \$mask, # Operation is on a mask45 'workdir=s' => \$workdir, # Working directory for output files46 'dbname=s' => \$dbname,# Database name47 'no-update' => \$no_update, # Don't update the database48 ) or pod2usage( 2 );35 'det_type=s' => \$det_type, # Detrend type for new detrend 36 'filelevel=s' => \$filelevel, # File level for new detrend 37 'inst=s' => \$inst, # Instrument for new detrend 38 'telescope=s' => \$telescope, # Telescope for new detrend 39 'filter=s' => \$filter, # Filter name for new detrend 40 'det_id1=s' => \$det_id1, # Detrend id for detrend 1 41 'iteration1=s' => \$iter1, # Iteration for detrend 1 42 'det_id2=s' => \$det_id2, # Detrend id for detrend 2 43 'iteration2=s' => \$iter2, # Iteration for detrend 2 44 'operation=s' => \$operation, # Operation to perform on files 45 'mask' => \$mask, # Operation is on a mask 46 'workdir=s' => \$workdir, # Working directory for output files 47 'dbname=s' => \$dbname, # Database name 48 'no-update' => \$no_update, # Don't update the database 49 ) or pod2usage( 2 ); 49 50 50 51 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 51 52 pod2usage( -msg => "Required options --det_type --filelevel --inst --telescope --det_id1 --iteration1 --det_id2 --iteration2 --workdir", 52 -exitval => 3,53 )53 -exitval => 3, 54 ) 54 55 unless defined $det_type 55 56 and defined $filelevel … … 65 66 $ipprc->define_camera($inst); 66 67 67 my $STATS = 68 [ 68 my $STATS = 69 [ 69 70 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 70 71 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, … … 90 91 die("File lists for detrends have differing lengths") unless scalar keys %$files1 == scalar keys %$files2; 91 92 92 my ($det_id, $iter); # Detrend identifier for the new detrend93 my ($det_id, $iter); # Detrend identifier for the new detrend 93 94 unless ($no_update) { 94 95 my $command = "$dettool -register_detrend -det_type $det_type -filelevel $filelevel -workdir $workdir " . 95 "-inst $inst -telescope $telescope"; # Command to run96 "-inst $inst -telescope $telescope"; # Command to run 96 97 $command .= " -filter $filter" if defined $filter; 97 98 $command .= " -dbname $dbname" if defined $dbname; 98 99 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 99 run(command => $command, verbose => 1);100 run(command => $command, verbose => 1); 100 101 unless ($success) { 101 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);102 die("Unable to run dettool -register_detrend: $error_code");102 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 103 die("Unable to run dettool -register_detrend: $error_code"); 103 104 } 104 105 … … 137 138 $command .= " -dbname $dbname" if defined $dbname; 138 139 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 139 run(command => $command, verbose => 1);140 run(command => $command, verbose => 1); 140 141 unless ($success) { 141 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);142 die("Unable to run ppArith: $error_code");142 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 143 die("Unable to run ppArith: $error_code"); 143 144 } 144 145 … … 149 150 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 150 151 { 151 my $statsFile;# File handle152 open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!");153 my @contents = <$statsFile>; # Contents of file154 close $statsFile;155 156 my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc");157 158 unless ($stats->parse($metadata)) {159 &my_die("Failure extracting metadata from the statistics output file.\n");160 }152 my $statsFile; # File handle 153 open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!"); 154 my @contents = <$statsFile>; # Contents of file 155 close $statsFile; 156 157 my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc"); 158 159 unless ($stats->parse($metadata)) { 160 &my_die("Failure extracting metadata from the statistics output file.\n"); 161 } 161 162 } 162 163 163 164 # Register the imfile 164 165 unless ($no_update) { 165 my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run166 $command .= " -class_id $class_id -uri $outName -path_base $outRoot";167 $command .= $stats->cmdflags();168 $command .= " -dbname $dbname" if defined $dbname;169 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =170 run(command => $command, verbose => 1);171 unless ($success) {172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);173 die("Unable to run dettool -register_detrend_imfile: $error_code");174 }166 my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run 167 $command .= " -class_id $class_id -uri $outName -path_base $outRoot"; 168 $command .= $stats->cmdflags(); 169 $command .= " -dbname $dbname" if defined $dbname; 170 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 171 run(command => $command, verbose => 1); 172 unless ($success) { 173 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 174 die("Unable to run dettool -register_detrend_imfile: $error_code"); 175 } 175 176 } 176 177 } … … 183 184 sub filelist 184 185 { 185 my $det_id = shift; # Detrend identifier186 my $iter = shift; # Iteration186 my $det_id = shift; # Detrend identifier 187 my $iter = shift; # Iteration 187 188 188 189 my $command = "$detselect -select -det_id $det_id -iteration $iter"; # Command to run 189 190 $command .= " -dbname $dbname" if defined $dbname; 190 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 191 run(command => $command, verbose => 1);192 run(command => $command, verbose => 1); 192 193 unless ($success) { 193 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);194 die("Unable to run detselect: $error_code");194 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 195 die("Unable to run detselect: $error_code"); 195 196 } 196 197 … … 202 203 203 204 foreach my $item ( @$list ) { 204 my $class_id = $item->{class_id};205 die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if206 defined $files{$class_id};207 $files{$class_id} = parse_md_list($md);205 my $class_id = $item->{class_id}; 206 die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if 207 defined $files{$class_id}; 208 $files{$class_id} = parse_md_list($md); 208 209 } 209 210
Note:
See TracChangeset
for help on using the changeset viewer.
