IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ippScripts/scripts/flatcorr_proc.pl

    r25916 r28003  
    1111# dvoMakeCorr -file outgrid.fits -ref ref.fits outcorr
    1212
    13 # dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc 
    14 
    15 # foreach $imfile () 
     13# dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc
     14
     15# foreach $imfile ()
    1616#   dettool -register_imfile -uri, etc, etc
    1717
     
    2323use Sys::Hostname;
    2424my $host = hostname();
     25my $date = `date`;
    2526print "\n\n";
    26 print "Starting script $0 on $host\n\n";
     27print "Starting script $0 on $host at $date\n\n";
    2728
    2829use vars qw( $VERSION );
     
    7475my $addstar     = can_run('addstar')      or (warn "Can't find addstar"      and $missing_tools = 1);
    7576my $dvoMakeCorr = can_run('dvoMakeCorr')  or (warn "Can't find dvoMakeCorr"  and $missing_tools = 1);
    76 my $detselect   = can_run('detselect')    or (warn "Can't find detselect"    and $missing_tools = 1);
    77 my $dettool     = can_run('dettool')      or (warn "Can't find dettool"      and $missing_tools = 1);
    78 my $flatcorr    = can_run('flatcorr')     or (warn "Can't find flatcorr"     and $missing_tools = 1);
    79 
    80 if ($missing_tools) { 
     77my $detselect   = can_run('detselect')    or (warn "Can't find detselect"    and $missing_tools = 1);
     78my $dettool     = can_run('dettool')      or (warn "Can't find dettool"      and $missing_tools = 1);
     79my $flatcorr    = can_run('flatcorr')     or (warn "Can't find flatcorr"     and $missing_tools = 1);
     80
     81if ($missing_tools) {
    8182    warn ("Can't find required tools");
    82     exit($PS_EXIT_CONFIG_ERROR); 
     83    exit($PS_EXIT_CONFIG_ERROR);
    8384}
    8485
     
    9596$ipprc->outroot_prepare($outcorr);
    9697
    97 if (not -e "$dvodb/flatcorr") { 
     98if (not -e "$dvodb/flatcorr") {
    9899    mkdir "$dvodb/flatcorr" or &my_die ("Unable to make output directory for relphot $dvodb/flatcorr", $corr_id, 3);
    99100}
     
    104105my ($DECs, $DECe) = split (",", $coords[1]);
    105106
    106 # Run addstar -resort to ensure the db is indexed 
     107# Run addstar -resort to ensure the db is indexed
    107108# XXX addstar should be able to recognize and skip indexed tables
    108109{
    109     my $command = "$addstar -resort"; 
     110    my $command = "$addstar -resort";
    110111    $command .= " -D CATDIR $dvodb";
    111112    $command .= " -region $RAs $RAe $DECs $DECe";
    112113
    113114    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    114         run(command => $command, verbose => $verbose);
    115 
    116     unless ($success) { 
    117         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    118         &my_die ("Unable to perform addstar -resort for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);
     115        run(command => $command, verbose => $verbose);
     116
     117    unless ($success) {
     118        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     119        &my_die ("Unable to perform addstar -resort for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);
    119120    }
    120121}
     
    135136
    136137    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    137         run(command => $command, verbose => $verbose);
    138 
    139     unless ($success) { 
    140         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    141         &my_die ("Unable to perform relphot -grid for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);
     138        run(command => $command, verbose => $verbose);
     139
     140    unless ($success) {
     141        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     142        &my_die ("Unable to perform relphot -grid for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);
    142143    }
    143144}
     
    176177
    177178# Push the results into the database
    178 { 
     179{
    179180    my $command = "$flatcorr -addprocess";
    180181    $command .= " -corr_id $corr_id";
     
    184185    unless ($no_update) {
    185186
    186         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    187             run(command => $command, verbose => $verbose);
    188         unless ($success) {
    189             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    190             warn ("Unable to perform regtool -addprocessedimfile: $error_code");
    191             exit($error_code);
    192         }
     187        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     188            run(command => $command, verbose => $verbose);
     189        unless ($success) {
     190            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     191            warn ("Unable to perform regtool -addprocessedimfile: $error_code");
     192            exit($error_code);
     193        }
    193194    } else {
    194         print "skipping command: $command\n";
     195        print "skipping command: $command\n";
    195196    }
    196197}
     
    218219        &my_die("Unable to parse metadata list", $corr_id, $PS_EXIT_PROG_ERROR);
    219220
    220     # check for existence 
     221    # check for existence
    221222    my $file = $$files[0];
    222223    my $chip_id = $file->{chip_id};
     
    228229# flatcorr -inputimfile -chip_id $chip_id
    229230sub get_imfiles {
    230     my $chip_id = shift; 
     231    my $chip_id = shift;
    231232
    232233    my $command = "$flatcorr -inputimfile";
     
    273274
    274275    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    275         run(command => $command, verbose => $verbose);
    276 
    277     unless ($success) { 
    278         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    279         &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);
     276        run(command => $command, verbose => $verbose);
     277
     278    unless ($success) {
     279        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     280        &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);
    280281    }
    281282
     
    298299
    299300    foreach my $file (@$files) {
    300         # create the detrend correction for the imfiles based on the input imfiles
    301         my $reffile = $file->{uri};
    302         my $class_id = $file->{class_id};
    303 
    304         my $uri = $ipprc->filename("DVOCORR.OUTPUT", $outcorr, $class_id);
    305         unless ($uri) {
    306             &my_die ("Unable to find DVOCORR.OUTPUT in filerules", $corr_id, $PS_EXIT_PROG_ERROR);
    307         }
    308 
    309         my $command = "$dvoMakeCorr $outcorr";
    310         $command .= " -file $outgrid.fits";
    311         $command .= " -ref $reffile";
    312 
    313         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    314             run(command => $command, verbose => $verbose);
    315 
    316         unless ($success) {
    317             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    318             &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);
    319         }
    320 
    321         # register the detrend correction imfile
    322         $command = "$dettool -register_detrend_imfile";
    323         $command .= " -det_id $det_id";
    324         $command .= " -class_id $class_id";
    325         $command .= " -uri $uri";
    326         $command .= " -dbname $dbname" if defined $dbname;
    327 
    328         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    329             run(command => $command, verbose => $verbose);
    330 
    331         unless ($success) {
    332             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    333             &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);
    334         }
     301        # create the detrend correction for the imfiles based on the input imfiles
     302        my $reffile = $file->{uri};
     303        my $class_id = $file->{class_id};
     304
     305        my $uri = $ipprc->filename("DVOCORR.OUTPUT", $outcorr, $class_id);
     306        unless ($uri) {
     307            &my_die ("Unable to find DVOCORR.OUTPUT in filerules", $corr_id, $PS_EXIT_PROG_ERROR);
     308        }
     309
     310        my $command = "$dvoMakeCorr $outcorr";
     311        $command .= " -file $outgrid.fits";
     312        $command .= " -ref $reffile";
     313
     314        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     315            run(command => $command, verbose => $verbose);
     316
     317        unless ($success) {
     318            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     319            &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);
     320        }
     321
     322        # register the detrend correction imfile
     323        $command = "$dettool -register_detrend_imfile";
     324        $command .= " -det_id $det_id";
     325        $command .= " -class_id $class_id";
     326        $command .= " -uri $uri";
     327        $command .= " -dbname $dbname" if defined $dbname;
     328
     329        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     330            run(command => $command, verbose => $verbose);
     331
     332        unless ($success) {
     333            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     334            &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);
     335        }
    335336    }
    336337}
     
    345346    if (not $no_update) {
    346347        my $command = "$flatcorr -addprocess";
    347         $command .= " -corr_id $corr_id";
     348        $command .= " -corr_id $corr_id";
    348349        $command .= " -fault $exit_code";
    349350        $command .= " -hostname $host" if defined $host;
Note: See TracChangeset for help on using the changeset viewer.