Changeset 27298 for trunk/ippScripts/scripts/ipp_apply_burntool.pl
- Timestamp:
- Mar 16, 2010, 9:26:43 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/ipp_apply_burntool.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_apply_burntool.pl
r27112 r27298 1 1 #!/usr/bin/env perl 2 2 # this program is used to run 'burntool' on images for a single chip 3 # for all exposures for a given time period. 4 # USAGE: ipp_apply_burntool.pl --dbname gpc1 --class_id XY00 --dateobs_begin YYYY/MM/DD --dateobs_end YYYY/MM/DD 3 # for all exposures for a given time period. 4 # USAGE: ipp_apply_burntool.pl --dbname gpc1 --class_id XY00 --dateobs_begin YYYY/MM/DD --dateobs_end YYYY/MM/DD 5 5 6 6 # XXX todo: 7 7 # - add filters to processedimfile 8 # 8 # 9 9 10 10 use warnings; … … 82 82 foreach my $cfg (@$recipeData) { 83 83 if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') { 84 $burntoolStateGood = $cfg->{value};84 $burntoolStateGood = $cfg->{value}; 85 85 } 86 86 } … … 100 100 $command .= " -dbname $dbname" if defined $dbname; 101 101 102 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 102 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 103 103 run ( command => $command, verbose => $verbose); 104 104 unless ($success) { … … 114 114 push @single, $value; 115 115 if ($value =~ /^\s*END\s*$/) { 116 push @single, "\n";117 118 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );119 &my_die("Unable to parse output from regtool", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_PROG_ERROR) unless120 defined $list;121 push @{ $files }, @$list;122 @single = ();116 push @single, "\n"; 117 118 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 119 &my_die("Unable to parse output from regtool", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_PROG_ERROR) unless 120 defined $list; 121 push @{ $files }, @$list; 122 @single = (); 123 123 } 124 124 } … … 142 142 my $rawImfile = $file->{uri}; 143 143 my $rawImfileReal = $ipprc->file_resolve($rawImfile, 0); 144 144 145 145 my $outTable = $file->{uri}; 146 146 $outTable =~ s/fits$/burn.tbl/; 147 147 my $outTableReal = $ipprc->file_resolve($outTable, 1); 148 148 149 149 my $process = 0; 150 150 my $previousTableStyle = 0; 151 151 152 152 if ($state == 0) { 153 $process = 1;153 $process = 1; 154 154 } 155 155 elsif ($state == -1) { 156 $process = 1;156 $process = 1; 157 157 } 158 158 elsif ($state == -3) { 159 $process = 1;159 $process = 1; 160 160 } 161 161 elsif ($state == -2) { 162 &my_die("Aborting as $rawImfile has modified pixel data!");162 &my_die("Aborting as $rawImfile has modified pixel data!"); 163 163 } 164 164 elsif ($state == $burntoolStateGood) { 165 $process = 0;166 $previousTableStyle = 1;165 $process = 0; 166 $previousTableStyle = 1; 167 167 } 168 168 elsif ($state == -1 * $burntoolStateGood) { 169 $process = 0;170 # $previousTable = "in=$outTableReal";171 $previousTableStyle = -1;169 $process = 0; 170 # $previousTable = "in=$outTableReal"; 171 $previousTableStyle = -1; 172 172 } 173 173 else { 174 $process = 1;174 $process = 1; 175 175 } 176 176 if ($REALRUN == 0) { 177 print "##Pretending to process as instructed!\n";178 $process = 1;177 print "##Pretending to process as instructed!\n"; 178 $process = 1; 179 179 } 180 180 if (($process == 1)||($processNext == 1)) { 181 $processNext = 1; 182 # Set state to processing 183 my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN); 184 if ($status) { 185 &my_die("failed to update imfile"); 186 } 187 $file->{burntool_state} = -1; 188 189 my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX", 190 DIR => '/tmp/', 191 UNLINK => !$save_temps, 192 SUFFIX => '.fits'); 193 my $tempPixels = $tempfile->filename; 194 195 # Run burntool 196 $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN); 197 if ($status) { 198 &my_die("failed on funpack",$exp_id,$class_id); 199 } 200 if ($previousTable ne '') { 201 $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN); 202 } 203 else { 204 $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN); 205 } 206 if ($status) { 207 &my_die("failed on burntool",$exp_id,$class_id); 208 } 209 210 $status = vsystem ("$nebXattr --write $outTable user.copies:2",$REALRUN); 211 $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN); 212 if ($status) { 213 &my_die("failed to update imfile"); 214 } 215 216 $previousTableStyle = -1; 217 218 print "\n"; 219 } 220 181 $processNext = 1; 182 # Set state to processing 183 my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN); 184 if ($status) { 185 &my_die("failed to update imfile"); 186 } 187 $file->{burntool_state} = -1; 188 189 my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX", 190 DIR => '/tmp/', 191 UNLINK => !$save_temps, 192 SUFFIX => '.fits'); 193 my $tempPixels = $tempfile->filename; 194 195 # Run burntool 196 $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN); 197 if ($status) { 198 &my_die("failed on funpack",$exp_id,$class_id); 199 } 200 if ($previousTable ne '') { 201 $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN); 202 } 203 else { 204 $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN); 205 } 206 if ($status) { 207 &my_die("failed on burntool",$exp_id,$class_id); 208 } 209 &my_die("Unable to find output file: $outTableReal", $exp_id, $class_id) unless $ipprc->file_exists($outTableReal); 210 211 $status = vsystem ("$nebXattr --write $outTable user.copies:2",$REALRUN); 212 $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN); 213 if ($status) { 214 &my_die("failed to update imfile"); 215 } 216 217 $previousTableStyle = -1; 218 219 print "\n"; 220 } 221 221 222 if ($previousTableStyle == 1) { 222 $previousTable = "infits=$rawImfileReal";223 $previousTable = "infits=$rawImfileReal"; 223 224 } 224 225 elsif ($previousTableStyle == -1) { 225 $previousTable = "in=$outTableReal";226 $previousTable = "in=$outTableReal"; 226 227 } 227 228 else { 228 die "previousTableStyle undefined!\n";229 } 230 231 } 232 229 die "previousTableStyle undefined!\n"; 230 } 231 232 } 233 233 234 exit 0; 234 235 … … 238 239 239 240 print "$command\n"; 240 241 241 242 my $status = 0; 242 243 if ($realrun) { 243 $status = system ($command);244 $status = system ($command); 244 245 } 245 246 … … 250 251 my $message = shift; 251 252 if ($#_ != -1) { 252 my $exp_id = shift;253 my $class_id = shift;254 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);253 my $exp_id = shift; 254 my $class_id = shift; 255 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1); 255 256 } 256 257 printf STDERR "$message\n";
Note:
See TracChangeset
for help on using the changeset viewer.
