IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 21, 2009, 4:29:35 PM (17 years ago)
Author:
Paul Price
Message:

Remove hack that removes XY27: no longer necessary because of PATTERN.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/chip_imfile.pl

    r25442 r25471  
    145145    my $useDeburnedImage = metadataLookupBool($recipeData, 'USE.DEBURNED.IMAGE');
    146146    if ($useDeburnedImage) {
    147         ## Check that we have required programs:
    148 #       print STDERR "Inside burntool loop!\n";
    149         my $regtool  = can_run('regtool') or &my_die ("Can't find regtool", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    150         my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    151         my $burntool = can_run('burntool') or &my_die ("Can't find burntool", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    152        
    153         ## Check the current burntool processing version:
    154         my $regtool_state_cmd = "$regtool -processedimfile -exp_id $exp_id -class_id $class_id -limit 1";
    155         if (defined($dbname)) {
    156             $regtool_state_cmd .= " -dbname $dbname";
    157         }
    158         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    159             run(command => $regtool_state_cmd, verbose => $verbose);
    160 
    161         unless ($success) {
    162             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    163             &my_die("Unable to perform regtool: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    164         }
    165 
    166         my $regData = $mdcParser->parse(join "", @$stdout_buf) or
    167             &my_die("Unable to parse regtool metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    168         my $regData2 = parse_md_list($regData);
    169 
    170         my $burntoolState = 999;
    171         foreach my $regEntry (@$regData2) {
    172 #           print "$regEntry->{exp_id} $regEntry->{burntool_state}\n";
    173 
    174             if ($regEntry->{exp_id} == $exp_id) {
    175                 $burntoolState = $regEntry->{burntool_state};
    176             }
    177         }
    178         if ($burntoolState == 999) {
    179             &my_die("Unable to find burntool_state in metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    180         }
    181 
    182         ## Read camera config to get the current good burntool state :
    183         ## XXX This is extremely slow. Any better way to do this?
    184         my $camera_config_cmd = "$ppConfigDump -camera $camera -dump-camera -";
    185         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    186             run(command => $camera_config_cmd, verbose => $verbose);
    187         unless ($success) {
    188             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    189             &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    190         }
    191 
    192         my $camData = $mdcParser->parse(join "", @$stdout_buf) or
    193             &my_die("Unable to parse ppConfigDump metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    194 
    195         my $burntoolStateGood;
    196         foreach my $camEntry (@$camData) {
    197             if ($camEntry->{name} eq "BURNTOOL.STATE.GOOD") {
    198                 $burntoolStateGood = $camEntry->{value};
    199             }
    200         }
    201 
    202         if (abs($burntoolState) != $burntoolStateGood) {
    203             &my_die("Image burntool version does not match current accepted version.", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    204         }
    205 
    206         ## We now know that we have an image that has been burntooled. 
    207         my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",
    208                                               UNLINK => !$save_temps, SUFFIX => '.fits' );
    209        
    210         # get the UNIX version of the (possible) neb: or path: filename
    211         my $uriReal = $ipprc->file_resolve( $uri );
    212 
    213         # funpack into the temp file.
    214         my $funpack_cmd = "$funpack -S $uriReal > $tempName";
    215         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
    216         unless ($success) {
    217             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    218             &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    219         }
    220        
    221         ## Construct commands to apply the pre-calculated burntool trailfits to the pixel data.
    222         my ($burntoolTable_uri, $burntoolTable_uriReal);
    223         my $burntool_cmd = "$burntool ";
    224 
    225         if ($burntoolState == -1 * $burntoolStateGood) {   # Burntool information stored in an external table.
    226             $burntoolTable_uri = $uri;
    227             $burntoolTable_uri =~ s/fits$/burn.tbl/;
    228             $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
    229             unless ($ipprc->file_exists($burntoolTable_uri)) {
    230                 &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR);
    231             }
    232 
    233             $burntool_cmd .= "$tempName in=${burntoolTable_uriReal} apply=t";
    234         }
    235         elsif ($burntoolState == $burntoolStateGood) { # Burntool information stored in a header table.
    236             $burntool_cmd .= "$tempName apply=t";
    237         }
    238         else {
    239             &my_die("Image data not properly burntooled, impossible state", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    240         }
    241 
    242         ## Run burntool to change the pixels of tempfile, and repoint $uri to that file.
    243         ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
    244             run(command => $burntool_cmd, verbose => $verbose);
    245         unless ($success) {
    246             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    247             &my_die("Unable to perform burntool: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    248         }
    249 
    250         $uri = $tempName;
    251         unless ($ipprc->file_exists($uri)) {
    252             &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    253         }       
    254 
    255 #       print STDERR "$uri $uriReal $tempName $burntoolTable_uri $burntoolTable_uriReal $burntool_cmd $save_temps\n";
    256 #       exit(100);     
     147        ## Check that we have required programs:
     148#       print STDERR "Inside burntool loop!\n";
     149        my $regtool  = can_run('regtool') or &my_die ("Can't find regtool", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     150        my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     151        my $burntool = can_run('burntool') or &my_die ("Can't find burntool", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     152
     153        ## Check the current burntool processing version:
     154        my $regtool_state_cmd = "$regtool -processedimfile -exp_id $exp_id -class_id $class_id -limit 1";
     155        if (defined($dbname)) {
     156            $regtool_state_cmd .= " -dbname $dbname";
     157        }
     158        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     159            run(command => $regtool_state_cmd, verbose => $verbose);
     160
     161        unless ($success) {
     162            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     163            &my_die("Unable to perform regtool: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     164        }
     165
     166        my $regData = $mdcParser->parse(join "", @$stdout_buf) or
     167            &my_die("Unable to parse regtool metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     168        my $regData2 = parse_md_list($regData);
     169
     170        my $burntoolState = 999;
     171        foreach my $regEntry (@$regData2) {
     172#           print "$regEntry->{exp_id} $regEntry->{burntool_state}\n";
     173
     174            if ($regEntry->{exp_id} == $exp_id) {
     175                $burntoolState = $regEntry->{burntool_state};
     176            }
     177        }
     178        if ($burntoolState == 999) {
     179            &my_die("Unable to find burntool_state in metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     180        }
     181
     182        ## Read camera config to get the current good burntool state :
     183        ## XXX This is extremely slow. Any better way to do this?
     184        my $camera_config_cmd = "$ppConfigDump -camera $camera -dump-camera -";
     185        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     186            run(command => $camera_config_cmd, verbose => $verbose);
     187        unless ($success) {
     188            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     189            &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     190        }
     191
     192        my $camData = $mdcParser->parse(join "", @$stdout_buf) or
     193            &my_die("Unable to parse ppConfigDump metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     194
     195        my $burntoolStateGood;
     196        foreach my $camEntry (@$camData) {
     197            if ($camEntry->{name} eq "BURNTOOL.STATE.GOOD") {
     198                $burntoolStateGood = $camEntry->{value};
     199            }
     200        }
     201
     202        if (abs($burntoolState) != $burntoolStateGood) {
     203            &my_die("Image burntool version does not match current accepted version.", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     204        }
     205
     206        ## We now know that we have an image that has been burntooled.
     207        my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",
     208                                              UNLINK => !$save_temps, SUFFIX => '.fits' );
     209
     210        # get the UNIX version of the (possible) neb: or path: filename
     211        my $uriReal = $ipprc->file_resolve( $uri );
     212
     213        # funpack into the temp file.
     214        my $funpack_cmd = "$funpack -S $uriReal > $tempName";
     215        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
     216        unless ($success) {
     217            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     218            &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     219        }
     220
     221        ## Construct commands to apply the pre-calculated burntool trailfits to the pixel data.
     222        my ($burntoolTable_uri, $burntoolTable_uriReal);
     223        my $burntool_cmd = "$burntool ";
     224
     225        if ($burntoolState == -1 * $burntoolStateGood) {   # Burntool information stored in an external table.
     226            $burntoolTable_uri = $uri;
     227            $burntoolTable_uri =~ s/fits$/burn.tbl/;
     228            $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     229            unless ($ipprc->file_exists($burntoolTable_uri)) {
     230                &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR);
     231            }
     232
     233            $burntool_cmd .= "$tempName in=${burntoolTable_uriReal} apply=t";
     234        }
     235        elsif ($burntoolState == $burntoolStateGood) { # Burntool information stored in a header table.
     236            $burntool_cmd .= "$tempName apply=t";
     237        }
     238        else {
     239            &my_die("Image data not properly burntooled, impossible state", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     240        }
     241
     242        ## Run burntool to change the pixels of tempfile, and repoint $uri to that file.
     243        ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
     244            run(command => $burntool_cmd, verbose => $verbose);
     245        unless ($success) {
     246            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     247            &my_die("Unable to perform burntool: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     248        }
     249
     250        $uri = $tempName;
     251        unless ($ipprc->file_exists($uri)) {
     252            &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     253        }
     254
     255#       print STDERR "$uri $uriReal $tempName $burntoolTable_uri $burntoolTable_uriReal $burntool_cmd $save_temps\n";
     256#       exit(100);
    257257    }
    258258
     
    261261    if ($tiltystreakApply) {
    262262
    263         my $tiltystreakByClass = metadataLookupMD($recipeData, 'TILTYSTREAK.BY.CLASS');
    264         my $tiltystreakClassApply = metadataLookupBool($tiltystreakByClass, "APPLY.$class_id");
    265         if ($tiltystreakClassApply) {
    266 
    267             my $tiltystreakClassOptions = metadataLookupStr($tiltystreakByClass, "OPTIONS.$class_id");
    268             if ($tiltystreakClassOptions eq "none") {
    269                 $tiltystreakClassOptions = "";
    270             }
    271 
    272             my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
    273 
    274             # XXX make these optional (must be built by psbuild as well...)
    275             my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    276             my $tiltystreak = can_run('tiltystreak') or &my_die ("Can't find tiltystreak", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    277 
    278             # create an temporary output file:
    279             my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.tmp.XXXX", UNLINK => !$save_temps );
    280 
    281             print "uri: $uri\n";
    282 
    283             # get the UNIX version of the (possible) neb: or path: filename
    284             my $uriReal = $ipprc->file_resolve( $uri );
    285 
    286             print "uriReal: $uriReal\n";
    287 
    288             # unpack the data (is a NOP if not compressed)
    289             $command = "$funpack -S $uriReal > $tempName";
    290             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    291             unless ($success) {
    292                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    293                 &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    294             }
    295 
    296             # run tiltystreak
    297             $command = "$tiltystreak $tempName $tiltystreakClassOptions";
    298             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    299             unless ($success) {
    300                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    301                 &my_die("Unable to perform tiltystreak: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    302             }
    303 
    304             # supply the output file as the new input file
    305             $uri = $tempName;
    306         }
     263        my $tiltystreakByClass = metadataLookupMD($recipeData, 'TILTYSTREAK.BY.CLASS');
     264        my $tiltystreakClassApply = metadataLookupBool($tiltystreakByClass, "APPLY.$class_id");
     265        if ($tiltystreakClassApply) {
     266
     267            my $tiltystreakClassOptions = metadataLookupStr($tiltystreakByClass, "OPTIONS.$class_id");
     268            if ($tiltystreakClassOptions eq "none") {
     269                $tiltystreakClassOptions = "";
     270            }
     271
     272            my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
     273
     274            # XXX make these optional (must be built by psbuild as well...)
     275            my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     276            my $tiltystreak = can_run('tiltystreak') or &my_die ("Can't find tiltystreak", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     277
     278            # create an temporary output file:
     279            my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.tmp.XXXX", UNLINK => !$save_temps );
     280
     281            print "uri: $uri\n";
     282
     283            # get the UNIX version of the (possible) neb: or path: filename
     284            my $uriReal = $ipprc->file_resolve( $uri );
     285
     286            print "uriReal: $uriReal\n";
     287
     288            # unpack the data (is a NOP if not compressed)
     289            $command = "$funpack -S $uriReal > $tempName";
     290            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     291            unless ($success) {
     292                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     293                &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     294            }
     295
     296            # run tiltystreak
     297            $command = "$tiltystreak $tempName $tiltystreakClassOptions";
     298            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     299            unless ($success) {
     300                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     301                &my_die("Unable to perform tiltystreak: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     302            }
     303
     304            # supply the output file as the new input file
     305            $uri = $tempName;
     306        }
    307307    }
    308308
     
    362362        }
    363363        chomp $cmdflags;
    364         if (($camera ne "GPC1") or ($class_id ne "XY27") or ($exp_id < 53171)) {
    365             ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag
    366         } else {
    367             # hack to kick ota 27 out of subsequent analysis by setting quality flag to a non-zero value
    368             my ($before, $after) = split " -quality ", $cmdflags;
    369 
    370             # get the current value
    371             ($quality) = $after =~ /^(\d+)/;
    372             $after = substr($after, length($quality));
    373 
    374             # replace it if it is zero
    375             $quality = 42 if !$quality;
    376 
    377             # rebuild the cmdflags
    378             $cmdflags = $before . " -quality $quality";
    379             $cmdflags .= " $after" if $after;
    380         }
     364        ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag
    381365    }
    382366
Note: See TracChangeset for help on using the changeset viewer.