IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27169


Ignore:
Timestamp:
Mar 3, 2010, 4:17:02 PM (16 years ago)
Author:
watersc1
Message:

the disk files need to be funpacked before being fpacked with the lossy compression. I feel like I should have known that.

File:
1 edited

Legend:

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

    r27164 r27169  
    2121use PS::IPP::Config 1.01 qw( :standard );
    2222use PS::IPP::Metadata::Config;
     23use File::Temp qw( tempfile );
    2324use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2425use Pod::Usage qw( pod2usage );
     
    2829my $regtool = can_run( 'regtool' ) or (warn "Can't find regtool" and $missing_tools = 1);
    2930my $fpack   = can_run( 'fpack' ) or (warn "Can't find fpack" and $missing_tools = 1);
    30 my ($exp_id, $class_id, $exp_name, $uri, $bytes, $md5sum, $dbname, $state, $verbose, $no_update, $no_op, $logfile);
     31my $funpack   = can_run( 'funpack' ) or (warn "Can't find funpack" and $missing_tools = 1);
     32my ($exp_id, $class_id, $exp_name, $uri, $bytes, $md5sum, $dbname, $state);
     33my ($verbose, $no_update, $no_op, $logfile, $save_temps);
    3134my ($camera);
    3235GetOptions(
     
    4447    'no-op'               => \$no_op,
    4548    'logfile=s'           => \$logfile,
     49    'save-temps'          => \$save_temps,
    4650    ) or pod2usage ( 2 );
    4751
     
    9195        if ($ipprc->file_exists($compUri));
    9296    my $compReal= $ipprc->file_resolve( $compUri, 'create');
    93     my $compress_command = "$fpack -h -s 8 -S $uriReal >  $compReal";
     97    # Apparently we need to funpack before fpacking.  Probably should have realized that beforehand.
     98    my $tempfile = new File::Temp ( TEMPLATE => "${exp_name}.XXXX",
     99                                    DIR => '/tmp/',
     100                                    UNLINK => !$save_temps,
     101                                    SUFFIX => '.fits');
     102    my $tempReal = $tempfile->filename;
     103
     104    my $uncompress_command = "$funpack -S $uriReal > $tempReal";
     105    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
     106        run(command => $uncompress_command, verbose => $verbose);
     107    unless ($success) {
     108        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     109        &my_die("Unable to uncompress file: $uri -> $compUri: $error_code",
     110                $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     111    }
     112    my $compress_command = "$fpack -h -s 8 -S $tempReal >  $compReal";
    94113    print STDERR "$compReal $uriReal $compress_command\n";
    95     my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
     114    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
    96115        run(command => $compress_command, verbose => $verbose);
    97116    unless ($success) {
    98117        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    99         &my_die("Unable to compress file: $uri -> $compUri: $error_code", $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     118        &my_die("Unable to compress file: $uri -> $compUri: $error_code",
     119                $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
    100120    }
    101121    my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed";
     
    135155
    136156        # If that die is removed, this will compress things as well.
    137         &my_die("Output compressed file already exists: $compUri\n",
    138                 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
    139             if ($ipprc->file_exists($compUri));
    140         my $compReal= $ipprc->file_resolve( $compUri, 'create');
    141         my $compress_command = "$fpack -h -s 8 -S $uriReal >  $compReal";
    142         print STDERR "$compReal $uriReal $compress_command\n";
    143         my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
    144             run(command => $compress_command, verbose => $verbose);
    145         unless ($success) {
    146             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    147             &my_die("Unable to compress file: $uri -> $compUri: $error_code",
    148                     $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
    149         }
     157        #
     158#       &my_die("Output compressed file already exists: $compUri\n",
     159#               $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
     160#           if ($ipprc->file_exists($compUri));
     161#       my $compReal= $ipprc->file_resolve( $compUri, 'create');
     162       
     163#       my $compress_command = "$fpack -h -s 8 -S $uriReal >  $compReal";
     164#       print STDERR "$compReal $uriReal $compress_command\n";
     165#       my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
     166#           run(command => $compress_command, verbose => $verbose);
     167#       unless ($success) {
     168#           $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     169#           &my_die("Unable to compress file: $uri -> $compUri: $error_code",
     170#                   $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     171#       }
    150172    }
    151173
Note: See TracChangeset for help on using the changeset viewer.