IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8763


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

change from positional to named CLI options

Location:
trunk/ippScripts/scripts
Files:
6 edited

Legend:

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

    r8715 r8763  
    33use warnings;
    44use strict;
     5
     6use vars qw( $VERSION );
     7$VERSION = '0.01';
    58
    69use IPC::Cmd qw( can_run run );
     
    912use Data::Dumper;
    1013
     14use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     15use Pod::Usage qw( pod2usage );
     16
     17my ($det_id, $iter, $exp_id, $class_id, $det_type, $detrend,
     18        $input_uri, $output_uri);
     19GetOptions(
     20    'det_id|d=s'        => \$det_id,
     21    'iteration=s'       => \$iter,
     22    'exp_id|e=s'        => \$exp_id,
     23    'class_id|i=s'      => \$class_id,
     24    'det_type|t=s'      => \$det_type,
     25    'detrend=s'         => \$detrend,
     26    'input_uri|u=s'     => \$input_uri,
     27    'output_uri|o=s'    => \$output_uri,
     28) or pod2usage( 2 );
     29
     30pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     31pod2usage(
     32    -msg => "Required options: --det_id --iteration --exp_id --class_id --det_type --detrend --input_uri --output_uri",
     33    -exitval => 3,
     34) unless defined $det_id
     35    and defined $iter
     36    and defined $exp_id
     37    and defined $class_id
     38    and defined $det_type
     39    and defined $detrend
     40    and defined $input_uri
     41    and defined $output_uri;
    1142
    1243# Recipes to use, as a function of the detrend type
     
    3465use constant DELETE_STATS => 0; # Delete the statistics file when done?
    3566
    36 # Parse the command-line arguments
    37 if (scalar @ARGV != 8) {
    38     die "Apply a stacked detrend image to an individual detrend.\n\n" .
    39         "Usage: $0 DET_ID ITERATION EXP_ID CLASS_ID DETREND_TYPE DETREND.fits INPUT.fits OUTPUT_ROOT\n\n";
    40 }
    41 my $detId = shift @ARGV;        # Detrend ID
    42 my $iter = shift @ARGV;         # Iteration
    43 my $expId = shift @ARGV;        # Exposure ID
    44 my $classId = shift @ARGV;      # Class ID
    45 my $detType = shift @ARGV;      # Detrend type
    46 my $detrend = shift @ARGV;      # The detrend frame to apply
    47 my $input = shift @ARGV;        # Input FITS file
    48 my $output = shift @ARGV;       # Output root name
    49 
    5067# Look for programs we need
    5168my $missing_tools;
     
    5572
    5673# Recipe to use in processing
    57 my $recipe = RECIPES->{$detType};
    58 die "Unrecognised detrend type: $detType\n" if not defined $recipe;
     74my $recipe = RECIPES->{$det_type};
     75die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
    5976# Detrend to use in processing
    60 my $detFlag = DETRENDS->{$detType};
    61 die "Unrecognised detrend type: $detType\n" if not defined $detFlag;
     77my $detFlag = DETRENDS->{$det_type};
     78die "Unrecognised detrend type: $det_type\n" if not defined $detFlag;
    6279# Prefix to use for filename
    63 my $prefix = PREFIX->{$detType};
    64 die  "Unrecognised detrend type: $detType\n" if not defined $prefix;
     80my $prefix = PREFIX->{$det_type};
     81die  "Unrecognised detrend type: $det_type\n" if not defined $prefix;
    6582
    6683### Output file names --- must match camera configuration!
    67 my $outputRoot = $prefix . '_' . $output;
    68 my $outputName = $outputRoot . '.' . $classId . '.fit';
    69 my $outputStats = $outputRoot . '.' . $classId . '.stats';
    70 my $bin1Name = $outputRoot . '.' . $classId . '.b1.fit';
    71 my $bin2Name =  $outputRoot . '.' . $classId . '.b2.fit';
     84my $outputRoot = $prefix . '_' . $output_uri;
     85my $outputName = $outputRoot . '.' . $class_id . '.fit';
     86my $outputStats = $outputRoot . '.' . $class_id . '.stats';
     87my $bin1Name = $outputRoot . '.' . $class_id . '.b1.fit';
     88my $bin2Name =  $outputRoot . '.' . $class_id . '.b2.fit';
    7289
    7390# Run ppImage
    7491{
    75     my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .
     92    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
    7693        " -stat $outputStats $detFlag $detrend"; # Command to run ppImage
    7794    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    7895        run(command => $command, verbose => 1);
    79     die "Unable to perform ppImage on $input: $error_code\n" if not $success;
     96    die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success;
    8097    die "Couldn't find expected output file: $outputName\n" if not -f $outputName;
    8198    die "Couldn't find expected output file: $bin1Name\n" if not -f $bin1Name;
     
    99116# Add the processed file to the database
    100117{
    101     my $command = "$dettool -addresidimfile -det_id $detId -iteration $iter -exp_id $expId " .
    102         "-class_id $classId -recip $recipe -uri $outputName -b1_uri $bin1Name " .
     118    my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_id $exp_id " .
     119        "-class_id $class_id -recip $recipe -uri $outputName -b1_uri $bin1Name " .
    103120        "-b2_uri $bin2Name"; # Command to run dettool
    104121    $command .= " -bg " . $stats->bg_mean();
     
    108125    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    109126        run(command => $command, verbose => 1);
    110     die "Unable to perform dettool -addprocessed for $detId/$expId/$classId: $error_code\n"
     127    die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n"
    111128        if not $success;
    112129}
    113130
    114 unlink "$output.stats" if DELETE_STATS;
     131unlink "$output_uri.stats" if DELETE_STATS;
    115132
    116133__END__
  • trunk/ippScripts/scripts/detrend_process.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;
    9 use Data::Dumper;
    1012
     13use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     14use Pod::Usage qw( pod2usage );
     15
     16my ($det_id, $exp_id, $class, $class_id, $det_type, $input_uri, $output_uri);
     17GetOptions(
     18    'det_id|d=s'        => \$det_id,
     19    'exp_id|e=s'        => \$exp_id,
     20    'class=s'           => \$class,     # unused
     21    'class_id|i=s'      => \$class_id,
     22    'det_type|t=s'      => \$det_type,
     23    'input_uri|u=s'     => \$input_uri,
     24    'output_uri|o=s'    => \$output_uri,
     25) or pod2usage( 2 );
     26
     27pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     28pod2usage(
     29    -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri",
     30    -exitval => 3,
     31) unless defined $det_id
     32    and defined $exp_id
     33    and defined $class_id
     34    and defined $det_type
     35    and defined $input_uri
     36    and defined $output_uri;
    1137
    1238# Recipes to use, as a function of the detrend type
     
    2652use constant DELETE_STATS => 0; # Delete the statistics file when done?
    2753
    28 # Parse the command-line arguments
    29 if (scalar @ARGV != 6) {
    30     die "Perform detrend processing at the imfile level.\n\n" .
    31         "Usage: $0 DET_ID EXP_ID CLASS_ID DETREND_TYPE INPUT.fits OUTPUT_ROOT\n\n";
    32 }
    33 my $detId = shift @ARGV;        # Detrend ID
    34 my $expId = shift @ARGV;        # Exposure ID
    35 my $classId = shift @ARGV;      # Class ID
    36 my $detType = shift @ARGV;      # Detrend type
    37 my $input = shift @ARGV;        # Input FITS file
    38 my $output = shift @ARGV;       # Output root name
    39 
    4054# Look for programs we need
    4155my $missing_tools;
     
    4559
    4660# Recipe to use in processing
    47 my $recipe = RECIPES->{$detType};
    48 die "Unrecognised detrend type: $detType\n" if not defined $recipe;
    49 die "Unrecognised detrend type: $detType\n" if not defined PREFIX->{$detType};
     61my $recipe = RECIPES->{$det_type};
     62die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
     63die "Unrecognised detrend type: $det_type\n" if not defined PREFIX->{$det_type};
    5064
    5165### Output file name --- must match camera configuration!
    52 my $outputRoot =  PREFIX->{$detType} . '_' . $output;
    53 my $outputName = $outputRoot . '.' . $classId ;
     66my $outputRoot =  PREFIX->{$det_type} . '_' . $output_uri;
     67my $outputName = $outputRoot . '.' . $class_id ;
    5468my $outputImage = $outputName . '.fit';
    5569my $outputStats = $outputName . '.stats';
     
    5771# Run ppImage
    5872{
    59     my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .
     73    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
    6074        " -stat $outputStats"; # Command to run ppImage
    6175    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    6276        run(command => $command, verbose => 1);
    63     die "Unable to perform ppImage on $input: $error_code\n" if not $success;
     77    die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success;
    6478    die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage;
    6579}
     
    8195# Add the processed file to the database
    8296{
    83     my $command = "$dettool -addprocessed -det_id $detId -exp_id $expId " .
    84         "-class_id $classId -recip $recipe -uri $outputImage"; # Command to run dettool
     97    my $command = "$dettool -addprocessed -det_id $det_id -exp_id $exp_id " .
     98        "-class_id $class_id -recip $recipe -uri $outputImage"; # Command to run dettool
    8599    $command .= " -bg " . $stats->bg_mean();
    86100    $command .= " -bg_stdev " . $stats->bg_stdev();
     
    89103    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    90104        run(command => $command, verbose => 1);
    91     die "Unable to perform dettool -addprocessed for $detId/$expId/$classId: $error_code\n"
     105    die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n"
    92106        if not $success;
    93107}
  • trunk/ippScripts/scripts/detrend_reject_exp.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::List qw( parse_md_list );
    912use Statistics::Descriptive;
    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, $det_type);
     18GetOptions(
     19    'det_id|d=s'        => \$det_id,
     20    'iteration=s'       => \$iter,
     21    'det_type|t=s'      => \$det_type,
     22) or pod2usage( 2 );
     23
     24pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     25pod2usage(
     26    -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri",
     27    -exitval => 3,
     28) unless defined $det_id
     29    and defined $iter
     30    and defined $det_type;
     31
     32my $detType = shift @ARGV;      # Detrend type
    1133
    1234# Rejection threshold for the mean, in terms of the standard deviation
     
    3456    };
    3557
    36 # Parse command-line arguments
    37 die "Reject exposures based on the sample of exposures.\n\n" .
    38     "Usage: $0 DET_ID ITER DETREND_TYPE\n\n"
    39     if scalar @ARGV != 3;
    40 my $detId = shift @ARGV;        # Detrend ID
    41 my $iter = shift @ARGV;         # Iteration number
    42 my $detType = shift @ARGV;      # Detrend type
    43 
    4458# Look for programs we need
    4559my $missing_tools;
     
    5165my $exposures;                  # Array of exposures
    5266{
    53     my $command = "$dettool -residexp -det_id $detId -iteration $iter"; # Command to run
     67    my $command = "$dettool -residexp -det_id $det_id -iteration $iter"; # Command to run
    5468    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    5569        run(command => $command, verbose => 1);
     
    8296
    8397# Check the existence of the required rejection levels as a function of detrend type
    84 die "Unknown mean rejection level for detrend type $detType\n"
    85     if not exists REJECT_MEAN->{$detType};
    86 die "Unknown stdev rejection level for detrend type $detType\n"
    87     if not exists REJECT_STDEV->{$detType};
    88 die "Unknown mean stdev rejection level for detrend type $detType\n"
    89     if not exists REJECT_MEAN_STDEV->{$detType};
     98die "Unknown mean rejection level for detrend type $det_type\n"
     99    if not exists REJECT_MEAN->{$det_type};
     100die "Unknown stdev rejection level for detrend type $det_type\n"
     101    if not exists REJECT_STDEV->{$det_type};
     102die "Unknown mean stdev rejection level for detrend type $det_type\n"
     103    if not exists REJECT_MEAN_STDEV->{$det_type};
    90104
    91105# Go through again to do rejection, and update the database for each exposure
     
    93107for (my $i = 0; $i < scalar @means; $i++) {
    94108    my $expId = $expIds[$i];    # Exposure ID
    95     my $command = "$dettool -updateresidexp -det_id $detId -iteration $iter -exp_id $expId"; # Command to run
     109    my $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_id $expId"; # Command to run
    96110    my $reject = 0;             # Reject this exposure?
    97     if (defined REJECT_MEAN->{$detType} and
     111    if (defined REJECT_MEAN->{$det_type} and
    98112        defined $meanStats->standard_deviation() and
    99113        $meanStats->standard_deviation() > 0 and
    100         ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$detType}) {
     114        ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$det_type}) {
    101115        print "Rejecting $expId based on bad mean: " .
    102116            (($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation()) .
    103             " vs " . REJECT_MEAN->{$detType} . "\n";
     117            " vs " . REJECT_MEAN->{$det_type} . "\n";
    104118        $reject = 1;
    105     } elsif (defined REJECT_STDEV->{$detType} and
     119    } elsif (defined REJECT_STDEV->{$det_type} and
    106120             defined $stdevStats->standard_deviation() and
    107121             $stdevStats->standard_deviation() > 0 and
    108122             ($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation() >
    109              REJECT_STDEV->{$detType}) {
     123             REJECT_STDEV->{$det_type}) {
    110124        print "Rejecting $expId based on bad stdev: " .
    111125            (($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation()) .
    112             " vs " . REJECT_STDEV->{$detType} . "\n";
     126            " vs " . REJECT_STDEV->{$det_type} . "\n";
    113127        $reject = 1;
    114     } elsif (defined REJECT_MEAN_STDEV->{$detType} and
     128    } elsif (defined REJECT_MEAN_STDEV->{$det_type} and
    115129             defined $meanStdevStats->standard_deviation() and
    116130             $meanStdevStats->standard_deviation() > 0 and
    117131             ($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation() >
    118              REJECT_MEAN_STDEV->{$detType}) {
     132             REJECT_MEAN_STDEV->{$det_type}) {
    119133        print "Rejecting $expId based on bad stdev: " .
    120134            (($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation()) .
    121             " vs " . REJECT_MEAN_STDEV->{$detType} . "\n";
     135            " vs " . REJECT_MEAN_STDEV->{$det_type} . "\n";
    122136        $reject = 1;
    123137    }
     
    147161# Put the result into the database
    148162{
    149     my $command = "$dettool -adddetrunsummary -det_id $detId -iteration $iter " .
     163    my $command = "$dettool -adddetrunsummary -det_id $det_id -iteration $iter " .
    150164        "-bg " . $meanStats->mean() . " -bg_stdev " . $stdevStats->mean() .
    151165        " -bg_mean_stdev " . $meanStdevStats->mean();
     
    159173# Re-run processing if required
    160174{
    161     my $command = "$dettool -updatedetrun -det_id $detId";
     175    my $command = "$dettool -updatedetrun -det_id $det_id";
    162176    if ($stop) {
    163177        $command .= ' -stop';
  • trunk/ippScripts/scripts/detrend_reject_imfile.pl

    r8715 r8763  
    33use warnings;
    44use strict;
     5
     6use vars qw( $VERSION );
     7$VERSION = '0.01';
    58
    69use IPC::Cmd qw( can_run run );
     
    811use PS::IPP::Metadata::List qw( parse_md_list );
    912use Statistics::Descriptive;
    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, $exp_id, $det_type);
     18GetOptions(
     19    'det_id|d=s'        => \$det_id,
     20    'iteration=s'       => \$iter,
     21    'exp_id|e=s'        => \$exp_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 --exp_id --det_type",
     28    -exitval => 3,
     29) unless defined $det_id
     30    and defined $iter
     31    and defined $exp_id
     32    and defined $det_type;
    1133
    1234use constant RECIPE => 'PPIMAGE_J'; # Recipe to use for ppImage to make JPEGs
     
    5274
    5375
    54 # Parse command-line arguments
    55 die "Reject exposures based on the imfile.\n\n" .
    56     "Usage: $0 DET_ID ITER EXP_ID DETREND_TYPE\n\n"
    57     if scalar @ARGV != 4;
    58 my $detId = shift @ARGV;        # Detrend ID
    59 my $iter = shift @ARGV;         # Iteration number
    60 my $expId = shift @ARGV;        # Exposure ID
    61 my $detType = shift @ARGV;      # Detrend type
    62 
    6376# Look for programs we need
    6477my $missing_tools;
     
    7285my $files;                      # Array of component files
    7386{
    74     my $command = "$dettool -residimfile -det_id $detId -iteration $iter -exp_id $expId"; # Command to run
     87    my $command = "$dettool -residimfile -det_id $det_id -iteration $iter -exp_id $exp_id"; # Command to run
    7588    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    7689        run(command => $command, verbose => 1);
     
    8295
    8396# Generate the file list, and get the statistics
    84 my $outputName = $detType . '_' . $detId . '_' . $iter; # Root output name
     97my $outputName = $det_type . '_' . $det_id . '_' . $iter; # Root output name
    8598my $list1Name = $outputName . '_jpeg1.list'; # Name for the input file list for binning 1
    8699my $list2Name = $outputName . '_jpeg2.list'; # Name for the input file list for binning 2
     
    119132
    120133# Check the existence of the required rejection levels as a function of detrend type
    121 die "Unknown expected mean for detrend type $detType\n"
    122     if not exists EXPECTED_MEAN->{$detType};
    123 die "Unknown individual mean rejection level for detrend type $detType\n"
    124     if not exists REJECT_INDIVIDUAL_MEAN->{$detType};
    125 die "Unknown individual stdev rejection level for detrend type $detType\n"
    126     if not exists REJECT_INDIVIDUAL_STDEV->{$detType};
    127 die "Unknown sample mean rejection level for detrend type $detType\n"
    128     if not exists REJECT_SAMPLE_MEAN->{$detType};
    129 die "Unknown sample stdev rejection level for detrend type $detType\n"
    130     if not exists REJECT_SAMPLE_STDEV->{$detType};
     134die "Unknown expected mean for detrend type $det_type\n"
     135    if not exists EXPECTED_MEAN->{$det_type};
     136die "Unknown individual mean rejection level for detrend type $det_type\n"
     137    if not exists REJECT_INDIVIDUAL_MEAN->{$det_type};
     138die "Unknown individual stdev rejection level for detrend type $det_type\n"
     139    if not exists REJECT_INDIVIDUAL_STDEV->{$det_type};
     140die "Unknown sample mean rejection level for detrend type $det_type\n"
     141    if not exists REJECT_SAMPLE_MEAN->{$det_type};
     142die "Unknown sample stdev rejection level for detrend type $det_type\n"
     143    if not exists REJECT_SAMPLE_STDEV->{$det_type};
    131144
    132145# Reject based on the individual stats
     
    135148for (my $i = 0; $i < scalar @means; $i++) {
    136149    my $mean = $means[$i];      # Mean for this component
    137     $mean -= EXPECTED_MEAN->{$detType} if defined EXPECTED_MEAN->{$detType};
     150    $mean -= EXPECTED_MEAN->{$det_type} if defined EXPECTED_MEAN->{$det_type};
    138151    my $stdev = $stdevs[$i];    # Stdev for this component
    139152
    140     if (defined REJECT_INDIVIDUAL_MEAN->{$detType}
     153    if (defined REJECT_INDIVIDUAL_MEAN->{$det_type}
    141154        and $stdev > 0 and
    142         $mean / $stdev > REJECT_INDIVIDUAL_MEAN->{$detType}) {
     155        $mean / $stdev > REJECT_INDIVIDUAL_MEAN->{$det_type}) {
    143156        print "Rejecting exposure based on bad individual mean for component $i: " .
    144             ($mean / $stdev) . " vs " . REJECT_INDIVIDUAL_MEAN->{$detType} . "\n";
     157            ($mean / $stdev) . " vs " . REJECT_INDIVIDUAL_MEAN->{$det_type} . "\n";
    145158        $reject = 1;
    146159        last;
    147     } elsif (defined REJECT_INDIVIDUAL_STDEV->{$detType} and
    148              $stdev > REJECT_INDIVIDUAL_STDEV->{$detType}) {
     160    } elsif (defined REJECT_INDIVIDUAL_STDEV->{$det_type} and
     161             $stdev > REJECT_INDIVIDUAL_STDEV->{$det_type}) {
    149162        print "Rejecting exposure based on bad individual stdev for component $i: " .
    150             $stdev . " vs " . REJECT_INDIVIDUAL_STDEV->{$detType} . "\n";
     163            $stdev . " vs " . REJECT_INDIVIDUAL_STDEV->{$det_type} . "\n";
    151164        $reject = 1;
    152165        last;
     
    165178}
    166179my $meanStdev = $stdevStats->mean(); # Mean of the sample of stdevs
    167 if (defined REJECT_SAMPLE_MEAN->{$detType} and
     180if (defined REJECT_SAMPLE_MEAN->{$det_type} and
    168181    $stdev != 0 and
    169     $mean / $stdev > REJECT_SAMPLE_MEAN->{$detType}) {
     182    $mean / $stdev > REJECT_SAMPLE_MEAN->{$det_type}) {
    170183    print "Rejecting exposure based on bad mean: " . ($mean / $stdev) . " vs " .
    171         REJECT_SAMPLE_MEAN->{$detType} . "\n";
     184        REJECT_SAMPLE_MEAN->{$det_type} . "\n";
    172185    $reject = 1;
    173 } elsif (defined REJECT_SAMPLE_STDEV->{$detType} and
    174          $meanStdev > REJECT_SAMPLE_STDEV->{$detType}) {
     186} elsif (defined REJECT_SAMPLE_STDEV->{$det_type} and
     187         $meanStdev > REJECT_SAMPLE_STDEV->{$det_type}) {
    175188    print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " .
    176         REJECT_SAMPLE_STDEV->{$detType} . "\n";
     189        REJECT_SAMPLE_STDEV->{$det_type} . "\n";
    177190    $reject = 1;
    178191}
     
    180193# Add the result into the database
    181194{
    182     my $command = "$dettool -addresidexp -det_id $detId -iteration $iter -exp_id $expId " .
     195    my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_id $exp_id " .
    183196        "-recip " . RECIPE() . " -b1_uri $jpeg1Name -b2_uri $jpeg2Name -bg $mean -bg_stdev $stdev " .
    184197        "-bg_mean_stdev $meanStdev";    # Command to run
  • 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);
  • 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.