Changeset 27297
- Timestamp:
- Mar 16, 2010, 9:23:13 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/ipp_apply_burntool.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ipp_apply_burntool.pl
r26497 r27297 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) { … … 125 125 my $rawImfile = $file->{uri}; 126 126 my $rawImfileReal = $ipprc->file_resolve($rawImfile, 0); 127 127 128 128 my $outTable = $file->{uri}; 129 129 $outTable =~ s/fits$/burn.tbl/; 130 130 my $outTableReal = $ipprc->file_resolve($outTable, 1); 131 131 132 132 my $process = 0; 133 133 my $previousTableStyle = 0; 134 134 135 135 if ($state == 0) { 136 $process = 1;136 $process = 1; 137 137 } 138 138 elsif ($state == -1) { 139 $process = 1;139 $process = 1; 140 140 } 141 141 elsif ($state == -3) { 142 $process = 1;142 $process = 1; 143 143 } 144 144 elsif ($state == -2) { 145 &my_die("Aborting as $rawImfile has modified pixel data!");145 &my_die("Aborting as $rawImfile has modified pixel data!"); 146 146 } 147 147 elsif ($state == $burntoolStateGood) { 148 $process = 0;149 $previousTableStyle = 1;148 $process = 0; 149 $previousTableStyle = 1; 150 150 } 151 151 elsif ($state == -1 * $burntoolStateGood) { 152 $process = 0;153 # $previousTable = "in=$outTableReal";154 $previousTableStyle = -1;152 $process = 0; 153 # $previousTable = "in=$outTableReal"; 154 $previousTableStyle = -1; 155 155 } 156 156 else { 157 $process = 1;157 $process = 1; 158 158 } 159 159 if ($REALRUN == 0) { 160 print "##Pretending to process as instructed!\n";161 $process = 1;160 print "##Pretending to process as instructed!\n"; 161 $process = 1; 162 162 } 163 163 if (($process == 1)||($processNext == 1)) { 164 $processNext = 1; 165 # Set state to processing 166 my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN); 167 if ($status) { 168 &my_die("failed to update imfile"); 169 } 170 $file->{burntool_state} = -1; 171 172 my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX", 173 DIR => '/tmp/', 174 UNLINK => !$save_temps, 175 SUFFIX => '.fits'); 176 my $tempPixels = $tempfile->filename; 177 178 # Run burntool 179 $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN); 180 if ($status) { 181 &my_die("failed on funpack",$exp_id,$class_id); 182 } 183 if ($previousTable ne '') { 184 $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN); 185 } 186 else { 187 $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN); 188 } 189 if ($status) { 190 &my_die("failed on burntool",$exp_id,$class_id); 191 } 192 193 $status = vsystem ("$nebXattr --write $outTable user.copies:2", $REALRUN); 194 if ($status) { 195 &my_die("failed to neb-xattr imfile", $outTable); 196 } 197 $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN); 198 if ($status) { 199 &my_die("failed to update imfile"); 200 } 201 202 $previousTableStyle = -1; 203 204 print "\n"; 205 } 206 164 $processNext = 1; 165 # Set state to processing 166 my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN); 167 if ($status) { 168 &my_die("failed to update imfile"); 169 } 170 $file->{burntool_state} = -1; 171 172 my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX", 173 DIR => '/tmp/', 174 UNLINK => !$save_temps, 175 SUFFIX => '.fits'); 176 my $tempPixels = $tempfile->filename; 177 178 # Run burntool 179 $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN); 180 if ($status) { 181 &my_die("failed on funpack",$exp_id,$class_id); 182 } 183 if ($previousTable ne '') { 184 $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN); 185 } 186 else { 187 $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN); 188 } 189 if ($status) { 190 &my_die("failed on burntool",$exp_id,$class_id); 191 } 192 &my_die("Unable to find output file: $outTableReal", $exp_id, $class_id) unless $ipprc->file_exists($outTableReal); 193 194 $status = vsystem ("$nebXattr --write $outTable user.copies:2", $REALRUN); 195 if ($status) { 196 &my_die("failed to neb-xattr imfile", $outTable); 197 } 198 $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN); 199 if ($status) { 200 &my_die("failed to update imfile"); 201 } 202 203 $previousTableStyle = -1; 204 205 print "\n"; 206 } 207 207 208 if ($previousTableStyle == 1) { 208 $previousTable = "infits=$rawImfileReal";209 $previousTable = "infits=$rawImfileReal"; 209 210 } 210 211 elsif ($previousTableStyle == -1) { 211 $previousTable = "in=$outTableReal";212 $previousTable = "in=$outTableReal"; 212 213 } 213 214 else { 214 die "previousTableStyle undefined!\n";215 } 216 217 } 218 215 die "previousTableStyle undefined!\n"; 216 } 217 218 } 219 219 220 exit 0; 220 221 … … 224 225 225 226 print "$command\n"; 226 227 227 228 my $status = 0; 228 229 if ($realrun) { 229 $status = system ($command);230 $status = system ($command); 230 231 } 231 232 … … 236 237 my $message = shift; 237 238 if ($#_ != -1) { 238 my $exp_id = shift;239 my $class_id = shift;240 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);239 my $exp_id = shift; 240 my $class_id = shift; 241 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1); 241 242 } 242 243 printf STDERR "$message\n";
Note:
See TracChangeset
for help on using the changeset viewer.
