IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20378


Ignore:
Timestamp:
Oct 24, 2008, 3:03:22 PM (18 years ago)
Author:
eugene
Message:

substantial work to make script consistent with pipelin

File:
1 edited

Legend:

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

    r20100 r20378  
    1010print "\n\n";
    1111print "Starting script $0 on $host\n\n";
     12print "command: @ARGV\n\n";
    1213
    1314use vars qw( $VERSION );
     
    2324use Pod::Usage qw( pod2usage );
    2425
    25 my ( $det_id, $exp_id, $class_id, $det_type, $exp_tag, $input_uri, $camera, $dbname, $workdir, $reduction,
    26      $verbose, $no_update, $no_op, $outroot, $redirect, $corr_id, $corr_type, $corr_uri );
     26my ( $det_id, $class_id, $det_type, $input_uri, $camera, $dbname,
     27     $verbose, $no_update, $no_op, $outroot, $redirect, $corr_uri );
    2728GetOptions(
    2829    'det_id|d=s'        => \$det_id,
    29     'exp_id|e=s'        => \$exp_id,
    3030    'class_id|i=s'      => \$class_id,
    3131    'det_type|t=s'      => \$det_type,
    32     'exp_tag|=s'        => \$exp_tag,
    3332    'input_uri|u=s'     => \$input_uri,
    34     'corr_id|u=s'       => \$corr_id,
    35     'corr_type|u=s'     => \$corr_type,
     33    'corr_uri|u=s'      => \$corr_uri,
     34    'outroot|o=s'       => \$outroot,
    3635    'camera|c=s'        => \$camera,
    3736    'dbname|d=s'        => \$dbname, # Database name
    38     'workdir|w=s'       => \$workdir, # Working directory, for output files
    3937    'verbose'           => \$verbose,   # Print to stdout
    4038    'no-update'         => \$no_update,
    4139    'no-op'             => \$no_op,
    42     'outroot'           => \$outroot,
    4340    'redirect-output'   => \$redirect,
    4441) or pod2usage( 2 );
    4542
    4643pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    47 pod2usage( -msg => "Required options: --det_id --exp_id --class_id --det_type --exp_tag --input_uri --camera",
     44pod2usage( -msg => "Required options: --det_id --class_id --det_type --input_uri --camera --outroot",
    4845           -exitval => 3)
    4946    unless defined $det_id
    50     and defined $exp_id
    5147    and defined $class_id
    5248    and defined $det_type
    53     and defined $exp_tag
    5449    and defined $input_uri
     50    and defined $outroot
    5551    and defined $camera;
    5652
     
    5955
    6056if ($redirect) {
    61     die "must suplly --outroot with --redirect-output" if !defined ($outroot);
    62     my $logDest     = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
    63        or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     57    my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
     58       or &my_die("Missing entry from camera config", $det_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    6459    $ipprc->redirect_output($logDest);
    6560}
    6661
    67 # Recipes to use as a function of detrend type
    68 $reduction = "DETREND" unless defined $reduction;
    69 my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_PROCESS'); # Recipe name to use
     62# Recipes to use as a function of detrend type
     63# XXX there are no recipe options for dvoApplyCorr...
     64# XXX in the future, we may define corrections other than the flat-field correction
     65# $reduction = "DETREND" unless defined $reduction;
     66# my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_CORRECT'); # Recipe name to use
     67
     68# XXX for now, check and warn, but don't exit on unexpected det_types
     69# det_type is type of the CORRECTED (output) file
     70if ($det_type ne "FLAT") { warn ("unexpected input detrend type: correcting data of type $det_type"); }
    7071
    7172# Look for programs we need
    7273my $missing_tools;
    7374my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    74 my $dvocorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1);
     75my $dvoApplyCorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1);
    7576if ($missing_tools) {
    7677    warn("Can't find required tools.");
     
    7879}
    7980
    80 &my_die("Couldn't find input file: $input_uri\n", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);
     81&my_die("Couldn't find input file: $input_uri\n", $det_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);
    8182
    82 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
    83 
    84 # detselect -select -det_id $corr_id -class_id $class_id;
    85 
    86 my $outputRoot  = $ipprc->file_prepare( "$exp_tag/$exp_tag.detproc.$det_id", $workdir, $input_uri );
    87 my $outputImage = $ipprc->filename("DVOCORR.OUTPUT", $outputRoot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
     83my $outputImage = $ipprc->filename("DVOFLAT.OUTPUT", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $class_id, $PS_EXIT_PROG_ERROR);
    8884
    8985# Run dvoApplyCorr
    9086unless ($no_op) {
    91     my $command = "$dvocorr -file $input_uri $outputRoot";
    92     $command .= " -corr $corr_uri";
     87    # unless explicitly supplied, the correction image is determined by dvoApplyCorr via look up to the detrend database
     88    my $command = "$dvoApplyCorr -file $input_uri $outroot";
     89    $command .= " -corr $corr_uri" if defined $corr_uri;
     90    $command .= " -dbname $dbname" if defined $dbname;
    9391
    9492    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    9694    unless ($success) {
    9795        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    98         &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $class_id, $error_code);
     96        &my_die("Unable to perform ppImage: $error_code", $det_id, $class_id, $error_code);
    9997    }
    10098
    101     &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
     99    &my_die("Couldn't find expected output file: $outputImage", $det_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
    102100}
    103101
    104102# command to update database
    105 my $command = "$dettool -addcorrectedimfile";
     103my $command = "$dettool -addcorrectimfile";
    106104$command .= " -det_id $det_id";
    107 $command .= " -exp_id $exp_id";
    108105$command .= " -class_id $class_id";
    109106$command .= " -uri $outputImage";
    110 $command .= " -path_base $outputRoot";
     107$command .= " -path_base $outroot";
    111108$command .= " -dbname $dbname" if defined $dbname;
    112109
     
    117114    unless ($success) {
    118115        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    119         warn("Unable to perform dettool -addcorrectedimfile: $error_code\n");
     116        warn("Unable to perform dettool -addcorrectimfile: $error_code\n");
    120117        exit($error_code);
    121118    }
     
    128125    my $msg = shift; # Warning message on die
    129126    my $det_id = shift;         # Detrend identifier
    130     my $exp_id = shift; # Exposure tag
    131127    my $class_id = shift; # Class identifier
    132128    my $exit_code = shift; # Exit code to add
    133129
    134130    carp($msg);
    135     if (defined $det_id and defined $exp_id and defined $class_id and not $no_update) {
    136         my $command = "$dettool -addcorrectedimfile";
     131    if (defined $det_id and defined $class_id and not $no_update) {
     132        my $command = "$dettool -addcorrectimfile";
    137133        $command .= " -det_id $det_id";
    138         $command .= " -exp_id $exp_id";
    139134        $command .= " -class_id $class_id";
    140         $command .= " -path_base $outputRoot";
     135        $command .= " -path_base $outroot";
    141136        $command .= " -code $exit_code";
    142137        $command .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.