IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35685 for trunk/ippScripts


Ignore:
Timestamp:
Jun 19, 2013, 10:21:44 AM (13 years ago)
Author:
bills
Message:

Add ppImage recipe value APPLY.BURNTOOL defaults to TRUE.
If USE.DEBURNED.IMAGE is set burntool will be applied in ppImage
if APPLY.BURNTOOL is true. If APPLY.BURNTOOL is false burntool will
be applied using the burntool program by chip_imfile.pl. If USE.DEBURNED.IMAGE
is false (default for other cameras) burntool will not be applied at all.
Also added recipe CHIP_PRESERVE_BG_AUXMASK which will be used for M31
processing. CHIP_PRESERVE_BG changed to set MASK.AUXMASK false
Added M31_BG_PRESERVE reduction

File:
1 edited

Legend:

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

    r35668 r35685  
    228228    ## XXX make the feature more general?
    229229    my $useDeburnedImage = metadataLookupBool($recipeData, 'USE.DEBURNED.IMAGE');
     230    my $ppImageApplyBurntool = metadataLookupBool($recipeData, 'APPLY.BURNTOOL');
     231    my $burntoolArgument;
    230232
    231233    if ($useDeburnedImage) {
     
    328330        }
    329331
    330         ## We now know that we have an image that has been burntooled.
    331         my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",
     332        # if recipe option to have ppImage apply burntool is set and the burntool information is store in
     333        # an external table, check the existence of that table file and set $burntoolArgument.
     334        # If burntool state does not match fall through to the code that uses the burntool program
     335        if ($ppImageApplyBurntool && ($burntoolState == -1 * $burntoolStateGood)) {
     336            my $burntoolTable_uri = $uri;
     337            $burntoolTable_uri =~ s/fits$/burn.tbl/;
     338            my $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     339            if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) {
     340                my $repair_cmd = "$nebrepair $burntoolTable_uri";
     341                my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     342                unless ($repair_success) {
     343                    &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     344                }
     345                $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     346            }
     347            unless ($ipprc->file_exists($burntoolTable_uri)) {
     348                # Catch errors here
     349                &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR);
     350            }
     351            $burntoolArgument = " -burntool $burntoolTable_uri";
     352        } else {
     353
     354            ## We now know that we have an image that has been burntooled.
     355            my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",
    332356                                              UNLINK => !$save_temps, SUFFIX => '.fits' );
    333357
    334         # get the UNIX version of the (possible) neb: or path: filename
    335         my $uriReal = $ipprc->file_resolve( $uri );
    336         # Catch errors here
    337         if (!$uriReal) {
    338             my $repair_cmd = "$nebrepair $uri";
    339             my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
    340             unless ($repair_success) {
    341                 &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    342             }
    343             $uriReal = $ipprc->file_resolve( $uri );
    344         }
    345            
    346         &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal;
    347 
    348         # funpack into the temp file.
    349         my $funpack_cmd = "$funpack -S $uriReal > $tempName";
    350         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
    351         unless ($success) {
    352             # Catch errors here
    353             my $repair_cmd = "$nebrepair $uri";
    354             my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
    355             unless ($repair_success) {
    356                 &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    357             }
    358             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
    359         }
    360         unless ($success) {
    361             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    362             &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    363         }
    364 
    365         ## Construct commands to apply the pre-calculated burntool trailfits to the pixel data.
    366         my ($burntoolTable_uri, $burntoolTable_uriReal);
    367         my $burntool_cmd = "$burntool ";
    368 
    369         if ($burntoolState == -1 * $burntoolStateGood) {   # Burntool information stored in an external table.
    370             $burntoolTable_uri = $uri;
    371             $burntoolTable_uri =~ s/fits$/burn.tbl/;
    372             $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
    373             if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) {
    374                 my $repair_cmd = "$nebrepair $burntoolTable_uri";
    375                 my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
    376                 unless ($repair_success) {
    377                     &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    378                 }
    379                 $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
    380             }
    381             unless ($ipprc->file_exists($burntoolTable_uri)) {
    382                 # Catch errors here
    383                 &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR);
    384             }
    385 
    386             $burntool_cmd .= "$tempName in=${burntoolTable_uriReal} persist=t apply=t";
    387         }
    388         elsif ($burntoolState == $burntoolStateGood) { # Burntool information stored in a header table.
    389             $burntool_cmd .= "$tempName persist=t apply=t";
    390         }
    391         else {
    392             &my_die("Image data not properly burntooled, impossible state", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    393         }
    394 
    395         ## Run burntool to change the pixels of tempfile, and repoint $uri to that file.
    396         ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
    397             run(command => $burntool_cmd, verbose => $verbose);
    398         unless ($success) {
    399             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    400             &my_die("Unable to perform burntool: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    401         }
    402 
    403         $uri = $tempName;
    404         unless ($ipprc->file_exists($uri)) {
    405             &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    406         }
    407 
    408 #       print STDERR "$uri $uriReal $tempName $burntoolTable_uri $burntoolTable_uriReal $burntool_cmd $save_temps\n";
    409 #       exit(100);
     358            # get the UNIX version of the (possible) neb: or path: filename
     359            my $uriReal = $ipprc->file_resolve( $uri );
     360                # Catch errors here
     361            if (!$uriReal) {
     362                my $repair_cmd = "$nebrepair $uri";
     363                my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     364                unless ($repair_success) {
     365                    &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     366                }
     367                $uriReal = $ipprc->file_resolve( $uri );
     368            }
     369               
     370            &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal;
     371
     372            # funpack into the temp file.
     373            my $funpack_cmd = "$funpack -S $uriReal > $tempName";
     374            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
     375            unless ($success) {
     376                # Catch errors here
     377                my $repair_cmd = "$nebrepair $uri";
     378                my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     379                unless ($repair_success) {
     380                    &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     381                }
     382                ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
     383            }
     384            unless ($success) {
     385                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     386                &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     387            }
     388
     389            ## Construct commands to apply the pre-calculated burntool trailfits to the pixel data.
     390            my ($burntoolTable_uri, $burntoolTable_uriReal);
     391            my $burntool_cmd = "$burntool ";
     392
     393            if ($burntoolState == -1 * $burntoolStateGood) {   # Burntool information stored in an external table.
     394                $burntoolTable_uri = $uri;
     395                $burntoolTable_uri =~ s/fits$/burn.tbl/;
     396                $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     397                if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) {
     398                    my $repair_cmd = "$nebrepair $burntoolTable_uri";
     399                    my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     400                    unless ($repair_success) {
     401                        &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     402                    }
     403                    $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     404                }
     405                unless ($ipprc->file_exists($burntoolTable_uri)) {
     406                    # Catch errors here
     407                    &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR);
     408                }
     409
     410                $burntool_cmd .= "$tempName in=${burntoolTable_uriReal} persist=t apply=t";
     411            }
     412            elsif ($burntoolState == $burntoolStateGood) { # Burntool information stored in a header table.
     413                $burntool_cmd .= "$tempName persist=t apply=t";
     414            }
     415            else {
     416                &my_die("Image data not properly burntooled, impossible state", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     417            }
     418
     419            ## Run burntool to change the pixels of tempfile, and repoint $uri to that file.
     420            ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
     421                run(command => $burntool_cmd, verbose => $verbose);
     422            unless ($success) {
     423                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     424                &my_die("Unable to perform burntool: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     425            }
     426
     427            $uri = $tempName;
     428            unless ($ipprc->file_exists($uri)) {
     429                &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     430            }
     431
     432    #       print STDERR "$uri $uriReal $tempName $burntoolTable_uri $burntoolTable_uriReal $burntool_cmd $save_temps\n";
     433    #       exit(100);
     434        }
    410435    }
    411436
     
    483508        $command .= " -R PPIMAGE.CHIP FITS.TYPE NONE";
    484509    }
     510    $command .= $burntoolArgument if $burntoolArgument;
    485511    $command .= " -threads $threads" if defined $threads;
    486512    $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
Note: See TracChangeset for help on using the changeset viewer.