IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 14, 2009, 10:22:38 AM (17 years ago)
Author:
eugene
Message:

adding option to pre-process image with tiltystreak program

File:
1 edited

Legend:

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

    r24352 r24396  
    2020use PS::IPP::Metadata::Config;
    2121use PS::IPP::Config 1.01 qw( :standard );
     22use File::Temp qw( tempfile );
    2223
    2324use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    3940# Parse the command-line arguments
    4041my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose,
    41      $no_update, $no_op, $redirect, $magicked, $deburned );
     42     $no_update, $save_temps, $no_op, $redirect, $magicked, $deburned );
    4243GetOptions(
    4344    'exp_id=s'          => \$exp_id,    # Exposure identifier
     
    5859    'no-op'             => \$no_op,     # Don't do any operations?
    5960    'redirect-output'   => \$redirect,
     61    'save-temps'        => \$save_temps, # Save temporary files?
    6062    ) or pod2usage( 2 );
    6163
     
    144146        $uri =~ s/fits$/burn.fits/;
    145147        &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);
     148    }
     149
     150    # apply the 'tiltystreak' operation, if desired
     151    my $applyTiltyStreak = metadataLookupBool($recipeData, 'APPLY.TILTYSTREAK');
     152    if ($applyTiltyStreak) {
     153
     154        my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
     155
     156        # XXX make these optional (must be built by psbuild as well...)
     157        my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     158        my $tiltystreak = can_run('tiltystreak') or &my_die ("Can't find tiltystreak", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     159
     160        # create an temporary output file:
     161        my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.tmp.XXXX", UNLINK => !$save_temps );
     162
     163        print "uri: $uri\n";
     164
     165        # get the UNIX version of the (possible) neb: or path: filename
     166        my $uriReal = $ipprc->file_resolve( $uri );
     167
     168        print "uriReal: $uriReal\n";
     169
     170        # unpack the data (is a NOP if not compressed)
     171        $command = "$funpack -S $uriReal > $tempName";
     172        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     173        unless ($success) {
     174            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     175            &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     176        }
     177
     178        # run tiltystreak
     179        $command = "$tiltystreak $tempName";
     180        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     181        unless ($success) {
     182            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     183            &my_die("Unable to perform tiltystreak: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     184        }
     185
     186        # supply the output file as the new input file
     187        $uri = $tempName;
    146188    }
    147189
Note: See TracChangeset for help on using the changeset viewer.