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_process_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, $det_type, $exp_tag, $camera, $dbname, $workdir, $no_update, $no_op);
     37my ($det_id, $exp_id, $det_type, $exp_tag, $camera, $dbname, $workdir, $reduction, $no_update, $no_op);
    3638GetOptions(
    3739    'det_id|d=s'        => \$det_id,
    3840    'det_type|t=s'      => \$det_type,
    39     'exp_tag|e=s'       => \$exp_tag,
     41    'exp_id|d=s'        => \$exp_id,
     42    'exp_tag|=s'        => \$exp_tag,
    4043    'camera|c=s'        => \$camera,
    4144    'dbname|d=s'        => \$dbname, # Database name
    4245    'workdir|w=s'       => \$workdir,   # Working directory, for output files
     46    'reduction|=s'      => \$reduction,
    4347    'no-update'         => \$no_update,
    4448    'no-op'             => \$no_op,
     
    4650
    4751pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    48 pod2usage( -msg => "Required options: --det_id --det_type --exp_tag --camera",
     52pod2usage( -msg => "Required options: --det_id --det_type --exp_id --exp_tag --camera",
    4953           -exitval => 3)
    5054    unless defined $det_id
    5155    and defined $det_type
     56    and defined $exp_id
    5257    and defined $exp_tag
    5358    and defined $camera;
     
    5863$reduction = 'DETREND' unless defined $reduction;
    5964
    60 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE' . uc($det_type); # Recipe to use
    61 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe1;
    62 
    63 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE' . uc($det_type); # Recipe to use
    64 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe2;
     65my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE_' . uc($det_type)); # Recipe to use
     66&my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe1;
     67
     68my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE_' . uc($det_type)); # Recipe to use
     69&my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe2;
    6570
    6671# values to extract from output metadata and the stats to calculate
     
    8792
    8893# Get list of component files
    89 my $files;                      # Array of component files
     94my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
    9095{
    91     my $command = "$dettool -processedimfile -det_id $det_id -exp_tag $exp_tag"; # Command to run
     96    $command = "$dettool -processedimfile -det_id $det_id -exp_id $exp_id"; # Command to run
    9297    $command .= " -dbname $dbname" if defined $dbname;
    93     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    94         run(command => $command, verbose => 1);
    95     unless ($success) {
    96         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    97         &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_tag, $error_code);
     98    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     99        run(command => $command, verbose => 1);
     100    unless ($success) {
     101        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     102        &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_id, $error_code);
    98103    }
    99104
     
    101106    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    102107    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    103         &my_die("Unable to parse metadata config doc", $det_id, $exp_tag, $PS_EXIT_PROG_ERROR);
     108        &my_die("Unable to parse metadata config doc", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);
    104109
    105110    # parse the file info in the metadata
    106111    $files = parse_md_list($metadata) or
    107         &my_die("Unable to parse metadata list", $det_id, $exp_tag, $PS_EXIT_PROG_ERROR);
     112        &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);
    108113
    109114    # parse the stats in the metadata
    110115    my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    111116    unless ($stats->parse($metadata)) {
    112         &my_die("Unable to find all values in statistics output.\n", $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     117        &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);
    113118    }
    114119}
     
    132137unless ($no_op) {
    133138    # Make the jpeg for binning 1
    134     {
    135         my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
    136         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    137             run(command => $command, verbose => 1);
    138         unless ($success) {
    139             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    140             &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code);
    141         }
    142         &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1);
    143     }
     139    $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
     140    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     141        run(command => $command, verbose => 1);
     142    unless ($success) {
     143        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     144        &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code);
     145    }
     146    &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1);
    144147   
    145148    # Make the jpeg for binning 2
    146     {
    147         my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
    148         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    149             run(command => $command, verbose => 1);
    150         unless ($success) {
    151             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    152             &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code);
    153         }
    154         &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2);
    155     }
     149    $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
     150    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     151        run(command => $command, verbose => 1);
     152    unless ($success) {
     153        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     154        &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code);
     155    }
     156    &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2);
    156157}
    157158
    158159# Command to update the database
    159 my $command = "$dettool -addprocessedexp";
     160$command = "$dettool -addprocessedexp";
    160161$command .= " -det_id $det_id";
    161 $command .= " -exp_tag $exp_tag";
     162$command .= " -exp_id $exp_id";
    162163$command .= " -recip $recipe1,$recipe2 -path_base $outputRoot";
    163164$command .= " -dbname $dbname" if defined $dbname;
     
    172173# Add the processed file to the database
    173174unless ($no_update) {
    174     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     175    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    175176        run(command => $command, verbose => 1);
    176177    unless ($success) {
     
    187188    my $msg = shift; # Warning message on die
    188189    my $det_id = shift;         # Detrend identifier
    189     my $exp_tag = shift; # Exposure tag
     190    my $exp_id = shift; # Exposure tag
    190191    my $exit_code = shift; # Exit code to add
    191192
    192193    carp($msg);
    193     if ($det_id and $exp_tag and not $no_update) {
     194    if ($det_id and $exp_id and not $no_update) {
    194195        my $command = "$dettool -addprocessedexp";
    195196        $command .= " -det_id $det_id";
    196         $command .= " -exp_tag $exp_tag";
     197        $command .= " -exp_id $exp_id";
    197198        $command .= " -code $exit_code";
    198199        $command .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.