IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2006, 4:32:51 PM (20 years ago)
Author:
jhoblitt
Message:

change from positional to named CLI options

File:
1 edited

Legend:

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

    r8734 r8763  
    44use strict;
    55
     6use vars qw( $VERSION );
     7$VERSION = '0.01';
     8
    69use IPC::Cmd qw( can_run run );
    710use PS::IPP::Metadata::Config;
    811use PS::IPP::Metadata::List qw( parse_md_list );
    912use PS::IPP::Metadata::Stats;
    10 use Data::Dumper;
     13
     14use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     15use Pod::Usage qw( pod2usage );
     16
     17my ($det_id, $iter, $class_id, $det_type);
     18GetOptions(
     19    'det_id|d=s'        => \$det_id,
     20    'iteration=s'       => \$iter,
     21    'class_id|i=s'      => \$class_id,
     22    'det_type|t=s'      => \$det_type,
     23) or pod2usage( 2 );
     24
     25pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     26pod2usage(
     27    -msg => "Required options: --det_id --iteration --class_id --det_type",
     28    -exitval => 3,
     29) unless defined $det_id
     30    and defined $iter
     31    and defined $class_id
     32    and defined $det_type;
    1133
    1234# Recipes to use as a function of detrend type
     
    2446    };   
    2547
    26 # Parse command-line arguments
    27 die "Stack detrends.\n\n" .
    28     "Usage: $0 DET_ID ITER CLASS_ID DETREND_TYPE\n\n"
    29     if scalar @ARGV != 4;
    30 my $detId = shift @ARGV;        # Detrend ID
    31 my $iter = shift @ARGV;         # Iteration number
    32 my $classId = shift @ARGV;      # Class ID
    33 my $detType = shift @ARGV;      # Detrend type
    34 
    35 die "Unrecognised detrend type: $detType\n" if not defined RECIPES->{$detType};
    36 my $recipe = RECIPES->{$detType}; # Recipe to use in stacking
     48die "Unrecognised detrend type: $det_type\n" if not defined RECIPES()->{$det_type};
     49my $recipe = RECIPES()->{$det_type}; # Recipe to use in stacking
    3750
    3851# Look for programs we need
     
    4760my $files;                      # Array of files to be stacked
    4861{
    49     my $command = "$dettool -processed -det_id $detId -iteration $iter -class_id $classId"; # Command to run
     62    my $command = "$dettool -processed -det_id $det_id -iteration $iter -class_id $class_id"; # Command to run
    5063    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    5164        run(command => $command, verbose => 1);
     
    5770
    5871# Stack the files
    59 my $output = $detType . '_' . $classId . '_' . $detId . '_' . $iter . '.fit'; # Output name
    60 my $outputStats = $detType . '_' . $classId . '_' . $detId . '_' . $iter . '.stats'; # Statistics name
     72my $output = $det_type . '_' . $class_id . '_' . $det_id . '_' . $iter . '.fit'; # Output name
     73my $outputStats = $det_type . '_' . $class_id . '_' . $det_id . '_' . $iter . '.stats'; # Statistics name
    6174{
    6275    my $command = "$ppMerge $output"; # Command to run
     
    6679    }
    6780    $command .= " -recipe PPMERGE $recipe";
    68     $command .= ' -type ' . uc($detType); # Type of stacking to perform
     81    $command .= ' -type ' . uc($det_type); # Type of stacking to perform
    6982    $command .= " -stats $outputStats"; # Statistics output filename
    7083
     
    95108# Add the resultant into the database
    96109{
    97     my $command = "$dettool -addstacked -det_id $detId -iteration $iter -class_id $classId" .
     110    my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id" .
    98111        " -uri $output -recip $recipe"; # Command to run
    99112    $command .= ' -bg ' . $stats->bg_mean();
    100113    $command .= ' -bg_stdev ' . $stats->bg_stdev();
    101114    $command .= ' -bg_mean_stdev ' . $stats->bg_mean_stdev();
    102     $command .= ' -pleasenormalize' if NORMALISE()->{$detType};
     115    $command .= ' -pleasenormalize' if NORMALISE()->{$det_type};
    103116    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    104117        run(command => $command, verbose => 1);
Note: See TracChangeset for help on using the changeset viewer.