IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 6, 2007, 3:44:38 PM (19 years ago)
Author:
eugene
Message:

rework for consistency with the changes to the database and PS-IPP-Config

File:
1 edited

Legend:

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

    r14009 r14048  
    1616use IPC::Cmd 0.36 qw( can_run run );
    1717use PS::IPP::Metadata::Config;
     18use PS::IPP::Metadata::Stats;
     19
    1820use PS::IPP::Metadata::List qw( parse_md_list );
    1921use File::Temp qw( tempfile );
     
    3335use Pod::Usage qw( pod2usage );
    3436
    35 my ($det_id, $iter, $det_type, $camera, $dbname, $workdir, $no_update, $no_op);
     37my ($det_id, $iter, $det_type, $camera, $dbname, $workdir, $reduction, $no_update, $no_op);
    3638GetOptions(
    37     'det_id|d=s'        => \$det_id,
    38     'iteration|i=s'     => \$iter,
    39     'camera|c=s'        => \$camera,
    40     'det_type|t=s'      => \$det_type,
    41     'dbname|d=s'        => \$dbname, # Database name
    42     'workdir|w=s'       => \$workdir,   # Working directory, for output files
    43     'no-update'         => \$no_update,
    44     'no-op'             => \$no_op,
    45 ) or pod2usage( 2 );
     39           'det_id|d=s'        => \$det_id,
     40           'iteration|i=s'     => \$iter,
     41           'camera|c=s'        => \$camera,
     42           'det_type|t=s'      => \$det_type,
     43           'dbname|d=s'        => \$dbname, # Database name
     44           'workdir|w=s'       => \$workdir,    # Working directory, for output files
     45           'reduction|=s'      => \$reduction,
     46           'no-update'         => \$no_update,
     47           'no-op'             => \$no_op,
     48           ) or pod2usage( 2 );
    4649
    4750pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     
    5861$reduction = 'DETREND' unless defined $reduction;
    5962
    60 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE' . uc($det_type); # Recipe to use
     63my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE_' . uc($det_type)); # Recipe to use
    6164&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe1;
    6265
    63 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE' . uc($det_type); # Recipe to use
     66my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE_' . uc($det_type)); # Recipe to use
    6467&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe2;
    6568
     
    6972# XXX  (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1
    7073my $STATS =
    71    [   
    72        #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
    73        { name => "bg",             type => "mean",  flag => "-bg" },
    74        { name => "bg",             type => "stdev", flag => "-bg_mean_stdev" },
    75        { name => "bg_stdev",       type => "rms",   flag => "-bg_stdev" },
    76        # { name => "bg_mean_stdev",  type => "rms",   flag => "-bg_mean_stdev" },
    77    ];
     74    [   
     75        #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
     76        { name => "bg",             type => "mean",  flag => "-bg" },
     77        { name => "bg",             type => "stdev", flag => "-bg_mean_stdev" },
     78        { name => "bg_stdev",       type => "rms",   flag => "-bg_stdev" },
     79        # { name => "bg_mean_stdev",  type => "rms",   flag => "-bg_mean_stdev" },
     80        ];
    7881
    7982# Look for programs we need
     
    8790
    8891# Get list of component files
    89 my $files;                      # Array of component files
     92my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
    9093{
    91     my $command = "$dettool -normalizedimfile -det_id $det_id -iteration $iter"; # Command to run
     94    $command = "$dettool -normalizedimfile -det_id $det_id -iteration $iter"; # Command to run
    9295    $command .= " -dbname $dbname" if defined $dbname;
    93     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     96    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    9497        run(command => $command, verbose => 1);
    9598    unless ($success) {
     
    131134unless ($no_op) {
    132135    # Make the jpeg for binning 1
    133     {
    134         my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
    135         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    136             run(command => $command, verbose => 1);
    137         &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
    138     }
     136    $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
     137    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     138        run(command => $command, verbose => 1);
     139    &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
    139140   
    140141    # Make the jpeg for binning 2
    141     {
    142         my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
    143         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    144             run(command => $command, verbose => 1);
    145         &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
    146     }
     142    $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
     143    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     144        run(command => $command, verbose => 1);
     145    &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
     146
    147147}
    148148
    149149# command to update the database
    150 my $command = "$dettool -addnormalizedexp";
     150$command = "$dettool -addnormalizedexp";
    151151$command .= " -det_id $det_id";
    152152$command .= " -iteration $iter";
     
    164164# Add the processed file to the database
    165165unless ($no_update) {
    166     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     166    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    167167        run(command => $command, verbose => 1);
    168168    unless ($success) {
Note: See TracChangeset for help on using the changeset viewer.