IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25442


Ignore:
Timestamp:
Sep 18, 2009, 10:29:30 AM (17 years ago)
Author:
watersc1
Message:

Modified chip_imfile.pl to accept burntool tables and apply corrections on-the-fly. Fixed bugs in ipp_cleanup.pl. Incremented BURNTOOL.STATE.GOOD to match updated upstream code.

Location:
trunk
Files:
3 edited

Legend:

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

    r24549 r25442  
    1919use IPC::Cmd 0.36 qw( can_run run );
    2020use PS::IPP::Metadata::Config;
     21use PS::IPP::Metadata::List qw( parse_md_list );
    2122use PS::IPP::Config 1.01 qw( :standard );
    2223use File::Temp qw( tempfile );
     
    143144    ## XXX make the feature more general?
    144145    my $useDeburnedImage = metadataLookupBool($recipeData, 'USE.DEBURNED.IMAGE');
    145     if ($useDeburnedImage && $deburned) {
    146         $uri =~ s/fits$/burn.fits/;
    147         &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri);
     146    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);     
    148257    }
    149258
  • trunk/ippScripts/scripts/ipp_cleanup.pl

    r25324 r25442  
    123123            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    124124
    125             if (!$config_file or ! -e $config_file) {
     125#            if (!$config_file or ! -e $config_file) {
     126            unless ($ipprc->file_exists($config_file)) {
    126127                print STDERR "skipping cleanup for chipRun $stage_id $class_id "
    127                     . " because config file is missing\n";
     128                    . " because config file ($config_file) is missing\n";
    128129                $status = 0;
    129130            }
     
    132133            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    133134
    134             if ($config_file and -e $config_file) {
     135            if ($ipprc->file_exists($config_file)) {
    135136                print STDERR "skipping scrubbed for chipRun $stage_id $class_id "
    136                     . " because config file is present\n";
     137                    . " because config file ($config_file) is present\n";
    137138                $status = 0;
    138139            }
     
    144145
    145146            # delete the temporary image datafiles
    146             addFilename (\@files, "PPIMAGE.OUTPUT", $path_base, $class_id);
    147             addFilename (\@files, "PPIMAGE.OUTPUT.MASK", $path_base, $class_id);
    148             addFilename (\@files, "PPIMAGE.OUTPUT.VARIANCE", $path_base, $class_id);
     147#            addFilename (\@files, "PPIMAGE.OUTPUT", $path_base, $class_id);
     148#            addFilename (\@files, "PPIMAGE.OUTPUT.MASK", $path_base, $class_id);
     149#            addFilename (\@files, "PPIMAGE.OUTPUT.VARIANCE", $path_base, $class_id);
    149150            addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id);
    150151            addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id);
     
    236237    if ($mode eq "goto_cleaned") {
    237238        my $config_file = $ipprc->filename("PSASTRO.CONFIG", $path_base);
    238 
    239         if (!$config_file or ! -e $config_file) {
     239       
     240        unless ($ipprc->file_exists($config_file)) {
    240241            print STDERR "skipping cleanup for camRun $stage_id because config file is missing\n";
    241242            $status = 0;
     
    245246        my $config_file = $ipprc->filename("PSASTRO.CONFIG", $path_base);
    246247
    247         if ($config_file and -e $config_file) {
     248        if ($ipprc->file_exists($config_file)) {
    248249            print STDERR "skipping cleanup for camRun $stage_id because config file ($config_file) is present\n";
    249250            $status = 0;
     
    329330            my $config_file = $ipprc->filename("PSWARP.CONFIG", $path_base, $skycell_id);
    330331
    331             if (!$config_file or ! -e $config_file) {
     332            unless ($ipprc->file_exists($config_file)) {
    332333                print STDERR "skipping cleanup for warpRun $stage_id $skycell_id" .
    333334                    " because config file is missing\n";
     
    338339            my $config_file = $ipprc->filename("PSWARP.CONFIG", $path_base, $skycell_id);
    339340
    340             if ($config_file and -e $config_file) {
     341            if ($ipprc->file_exists($config_file)) {
    341342                print STDERR "skipping scrubbed for warpRun $stage_id $skycell_id" .
    342343                    " because config file is present\n";
     
    345346        }
    346347        if ($status) {
     348            my @files = ();
    347349            # delete the temporary image datafiles
    348350            addFilename(\@files, "PSWARP.OUTPUT", $path_base, $skycell_id );
     
    433435            my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id);
    434436
    435             $config_file =~ s%^file://%%;
    436             if (!$config_file or ! -e $config_file) {
     437            unless ($ipprc->file_exists($config_file)) {
    437438                print STDERR "skipping cleanup for stackRun $stage_id $skycell_id" .
    438439                    " because config file is missing\n";
    439440                $status = 0;
    440441            }
    441             $config_file = 'file://' . $config_file;
    442442        }
    443443        elsif ($mode eq "goto_scrubbed") {
    444444            my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id);
    445             $config_file =~ s%^file://%%;
    446             if ($config_file and -e $config_file) {
     445
     446            if ($ipprc->file_exists($config_file)) {
    447447                print STDERR "skipping scrubbed for stackRun $stage_id $skycell_id" .
    448448                    " because config file is present\n";
     
    451451        }
    452452        if ($status) {
     453            my @files = ();
    453454            # delete the temporary image datafiles
    454455            addFilename(\@files, "PPSTACK.OUTPUT", $path_base, $skycell_id);
     
    535536            my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id);
    536537
    537             $config_file =~ s%^file://%%;
    538             if (!$config_file or ! -e $config_file) {
     538            unless ($ipprc->file_exists($config_file)) {
    539539                print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" .
    540540                    " because config file ($config_file) is missing\n";
    541541                $status = 0;
    542542            }
    543             $config_file = 'file://' . $config_file;
    544543        }
    545544        elsif ($mode eq "goto_scrubbed") {
    546545            my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id);
    547             $config_file =~ s%^file://%%;
    548             if ($config_file and -e $config_file) {
     546
     547            if ($ipprc->file_exists($config_file)) {
    549548                print STDERR "skipping scrubbed for diffRun $stage_id $skycell_id" .
    550549                    " because config file ($config_file) is present\n";
     
    553552        }
    554553        if ($status) {
     554            my @files = ();
    555555            # delete the temporary image datafiles
    556556            addFilename(\@files, "PPSUB.OUTPUT", $path_base, $skycell_id);
     
    581581               
    582582            }
    583             print STDERR "MY FILES: @files\n";
     583#           print STDERR "MY FILES: @files\n";
    584584            $status = &delete_files(\@files);
    585585        }
    586         print STDERR "MY STATUS: $status\n";
     586#       print STDERR "MY STATUS: $status\n";
    587587        if ($status) {
    588588            my $command = "$difftool -diff_id $stage_id";
     
    675675            my $config_file = $ipprc->filename("PPSIM.CONFIG", $path_base, $class_id);
    676676
    677             if (!$config_file or ! -e $config_file) {
     677            unless ($ipprc->file_exists($config_file)) {
    678678                print STDERR "skipping cleanup for fakeRun $stage_id $class_id "
    679679                    . " because config file is missing\n";
     
    684684            my $config_file = $ipprc->filename("PPSIM.CONFIG", $path_base, $class_id);
    685685
    686             if ($config_file and -e $config_file) {
     686            if ($ipprc->file_exists($config_file)) {
    687687                print STDERR "skipping scrubbed for fakeRun $stage_id $class_id "
    688688                    . " because config file is present\n";
     
    795795            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    796796
    797             if (!$config_file or ! -e $config_file) {
     797            unless ($ipprc->file_exists($config_file)) {
    798798                print STDERR "skipping cleanup for detrend.process.imfile $stage_id $class_id "
    799799                    . " because config file is missing\n";
     
    804804            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    805805
    806             if ($config_file and -e $config_file) {
     806            if ($ipprc->file_exists($config_file)) {
    807807                print STDERR "skipping scrubbed for detrend.process.imfile $stage_id $class_id "
    808808                    . " because config file is present\n";
     
    942942            my $config_file = $ipprc->filename("PSIMAGE.CONFIG", $path_base);
    943943           
    944             if (!$config_file or ! -e $config_file) {
     944            unless ($ipprc->file_exists($config_file)) {
    945945                print STDERR "skipping cleanup for $stage $stage_id because config file is missing\n";
    946946                $status = 0;
     
    950950            my $config_file = $ipprc->filename("PSIMAGE.CONFIG", $path_base);
    951951           
    952             if ($config_file and -e $config_file) {
     952            if ($ipprc->file_exists($config_file)) {
    953953                print STDERR "skipping cleanup for $stage $stage_id because config file ($config_file) is present\n";
    954954                $status = 0;
     
    10941094
    10951095        if ($status) {
     1096            my @files = ();
    10961097            # delete the temporary image datafiles
    10971098            # There's no convenient way to get the detrend type, so I'm queueing all of them for deletion.
     
    12271228                run(command => $command, verbose => $verbose);
    12281229            unless ($success) {
    1229                 print STDERR "WTF: $success TTT $error_code QQQ\n";
    12301230                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    12311231                &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code);
     
    13161316            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base);
    13171317           
    1318             if (!$config_file or ! -e $config_file) {
     1318            unless ($ipprc->file_exists($config_file)) {
    13191319                print STDERR "skipping cleanup for $stage $stage_id because config file is missing\n";
    13201320                $status = 0;
     
    13241324            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base);
    13251325           
    1326             if ($config_file and -e $config_file) {
     1326            if ($ipprc->file_exists($config_file)) {
    13271327                print STDERR "skipping cleanup for $stage $stage_id because config file ($config_file) is present\n";
    13281328                $status = 0;
     
    14501450            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base);
    14511451           
    1452             if (!$config_file or ! -e $config_file) {
     1452            unless ($ipprc->file_exists($config_file)) {
    14531453                print STDERR "skipping cleanup for $stage $stage_id because config file is missing\n";
    14541454                $status = 0;
     
    14581458            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base);
    14591459           
    1460             if ($config_file and -e $config_file) {
     1460            if ($ipprc->file_exists($config_file)) {
    14611461                print STDERR "skipping cleanup for $stage $stage_id because config file ($config_file) is present\n";
    14621462                $status = 0;
     
    15911591            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    15921592
    1593             if (!$config_file or ! -e $config_file) {
     1593            unless ($ipprc->file_exists($config_file)) {
    15941594                print STDERR "skipping cleanup for $stage $stage_id $class_id "
    15951595                    . " because config file is missing\n";
     
    16001600            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    16011601
    1602             if ($config_file and -e $config_file) {
     1602            if ($ipprc->file_exists($config_file)) {
    16031603                print STDERR "skipping scrubbed for $stage $stage_id $class_id "
    16041604                    . " because config file is present\n";
     
    17311731            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base);
    17321732           
    1733             if (!$config_file or ! -e $config_file) {
     1733            unless ($ipprc->file_exists($config_file)) {
    17341734                print STDERR "skipping cleanup for $stage $stage_id because config file is missing\n";
    17351735                $status = 0;
     
    17391739            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base);
    17401740           
    1741             if ($config_file and -e $config_file) {
     1741            if ($ipprc->file_exists($config_file)) {
    17421742                print STDERR "skipping cleanup for $stage $stage_id because config file ($config_file) is present\n";
    17431743                $status = 0;
     
    18331833{
    18341834    my $files = shift; # reference to a list of files to unlink
    1835 
    1836 #     open(TMPLOG,">>/tmp/czw.cleanup.log");
    1837 #     flock(TMPLOG,2);
     1835#     my $test_verbose = 1;
     1836   
     1837#     if ($test_verbose == 1) {
     1838#       open(TMPLOG,">>/tmp/czw.cleanup.log");
     1839#       flock(TMPLOG,2);
     1840#     }
    18381841
    18391842    # this script is, of course, very dangerous.
    18401843    foreach my $file (@$files) {
    1841         print STDERR "unlinking $file\n";
    1842 #       print TMPLOG "$stage $stage_id $file";
    1843 #       my $ff = $file;
    1844 #       $ff =~ s%^file://%%;
    1845 #       unless (-e $ff) {
    1846 #           print TMPLOG "\t File not found\n";
     1844        print STDERR "unlinking $stage $stage_id $file";
     1845        unless ($ipprc->file_exists($file)) {
     1846            print STDERR "\t File not found\n";
     1847        }
     1848        else {
     1849            print STDERR "\n";
     1850        }
     1851
     1852#       if ($test_verbose == 1) {
     1853#           print TMPLOG "$stage $stage_id $file";
     1854           
     1855#           else {
     1856#               print TMPLOG "\n";
     1857#           }
    18471858#       }
    1848 #       else {
    1849 #           print TMPLOG "\n";
    1850 #       }
    18511859
    18521860        $ipprc->file_delete($file);
    18531861    }
    18541862
    1855 #     flock(TMPLOG,8);
    1856 #     close(TMPLOG);
     1863#     if ($test_verbose == 1) {
     1864#       flock(TMPLOG,8);
     1865#       close(TMPLOG);
     1866#     }
    18571867
    18581868    return 1;
  • trunk/ippconfig/gpc1/camera.config

    r25425 r25442  
    148148PHOTCODE.RULE           STR     {DETECTOR}.{FILTER.ID}.{CHIP.NAME}      # Rule for generating photcode
    149149
    150 BURNTOOL.STATE.GOOD     S16     12  # Value for burntool_state with the most recent bt version.
     150BURNTOOL.STATE.GOOD     S16     13  # Value for burntool_state with the most recent bt version.
Note: See TracChangeset for help on using the changeset viewer.