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/phase0imfile.pl

    r8715 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::Stats;
     12use PS::IPP::Metadata::StatsFilter;
    913use Data::Dumper;
     14
     15use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     16use Pod::Usage qw( pod2usage );
     17
     18my ($exp_id, $class, $class_id, $uri);
     19
     20GetOptions(
     21    'exp_id|e=s'    => \$exp_id,
     22    'class|c=s'     => \$class,
     23    'class_id|i=s'  => \$class_id,
     24    'uri|u=s'       => \$uri,
     25) or pod2usage( 2 );
     26
     27pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     28pod2usage(
     29    -msg => "Required options: --exp_id --class --class_id --uri",
     30    -exitval => 3,
     31) unless defined $exp_id
     32    and defined $class
     33    and defined $class_id
     34    and defined $uri;
     35
     36# XXX the uri should be processed either here or by ppImage
     37my $file = $uri;
    1038
    1139use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats
     
    4068use constant P0TOOL_BG_MEAN_STDEV => '-bg_mean_stdev'; # Switch to add the bg mean stdev
    4169
    42 # Parse command-line arguments
    43 if (scalar @ARGV == 0 || scalar @ARGV > 3) {
    44     die "Perform phase 0 processing at the imfile level.\n\n" .
    45         "Usage: $0 EXP_ID CLASS_ID FILE.fits\n\n";
    46 }
    47 
    48 my $expid = shift @ARGV;        # Exposure identifier
    49 my $classid = shift @ARGV;        # Class identifier
    50 my $file = shift @ARGV;                # Input filename
    51 
    52 
    5370# Look for programs we need
    5471my $missing_tools;
     
    6380    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    6481        run(command => $command, verbose => 1);
    65     die "Unable to perform ppStats on exposure id $expid: $error_code\n" if not $success;
     82    die "Unable to perform ppStats on exposure id $exp_id: $error_code\n" if not $success;
    6683   
    6784    # Parse the output
     
    6986    my $metadata = $mdcParser->parse(join "", @$stdout_buf)
    7087            or die "unable to parse metadata config doc";
     88    my $statsfilter = PS::IPP::Metadata::StatsFilter->new;
     89    $metadata = $statsfilter->filter($metadata)
     90        or die "failed to filter stats document";
    7191    my @constants = keys %{CONSTANTS()}; # List of constants to parse out
    7292    my @variables = keys %{VARIABLES()}; # List of variables to parse out
     
    7797# Push the results into the database
    7898{
    79     my $command = $p0tool . " " . P0TOOL_MODE() . " " . P0TOOL_EXPID() . " " . $expid . " " .
    80         P0TOOL_CLASSID() . " " . $classid; # Command to run p0tool
     99    my $command = $p0tool . " " . P0TOOL_MODE() . " " . P0TOOL_EXPID() . " " . $exp_id . " " .
     100        P0TOOL_CLASSID() . " " . $class_id; # Command to run p0tool
    81101   
    82102    foreach my $constant (keys %{CONSTANTS()}) {
Note: See TracChangeset for help on using the changeset viewer.