IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 4:08:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging trunk (r25026) to get up-to-date on old branch.

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/tools/ipp_apply_burntool.pl

    r23585 r25027  
    2020use Pod::Usage qw( pod2usage );
    2121
    22 my ( $class_id, $dateobs_begin, $dateobs_end, $skip_burned, $dbname, $verbose, $save_temps);
     22my ( $class_id, $dateobs_begin, $dateobs_end, $skip_burned, $rerun_from_first, $dbname, $logfile, $verbose, $save_temps);
    2323GetOptions(
    2424    'class_id=s'        => \$class_id, # chip identifier
     
    2626    'dateobs_end=s'     => \$dateobs_end, # exposure date/time range stop
    2727    'dbname|d=s'        => \$dbname, # Database name
     28    'logfile=s'         => \$logfile,
    2829    'skip_burned'       => \$skip_burned,   # Print to stdout
     30    'rerun_from_first'  => \$rerun_from_first,   # Print to stdout
    2931    'verbose'           => \$verbose,   # Print to stdout
    3032    'save-temps'        => \$save_temps, # Save temporary files?
     
    4143    defined $dbname;
    4244
     45if ($skip_burned and $rerun_from_first) { &my_die("-rerun_from_first and -skip_burned are incompatible"); }
     46
    4347my $missing_tools;
    4448my $regtool  = can_run('regtool')  or (warn "Can't find regtool" and $missing_tools = 1);
     
    5761$command .= " -dateobs_begin $dateobs_begin";
    5862$command .= " -dateobs_end $dateobs_end";
    59 # $command .= " -limit 20";
     63$command .= " -ordered_by_date";
    6064$command .= " -dbname $dbname" if defined $dbname;
    6165
     
    8791my $ipprc = PS::IPP::Config->new() or my_die("Unable to set up");
    8892
     93$ipprc->redirect_output($logfile) if $logfile;
     94
    8995my $Nfiles = @files;
    9096print "files: $Nfiles\n";
    9197
    9298my $REALRUN = 1;
     99my $RAWTABLES = 1;
     100# XXX if we want to avoid using the raw tables in this script, we need to delay deletion of the tempfile until the next pass.
     101
     102# first pass: mark the db entries to catch failures
     103# these will not be identified as burned by chip processing (user_1 > 0.5)
     104if (! $skip_burned)  {
     105    foreach my $file (@files) {
     106       
     107        # rerun_from_first treats the first image as already burned (if it is already burned)
     108        # the artifact table from the first file is used for the rest of the sequence.
     109        if ($rerun_from_first) {
     110            $skip_burned = 1;
     111            $rerun_from_first = 0;
     112            next;
     113        }
     114        my $exp_id = $file->{exp_id};
     115
     116        my $status;
     117        $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -user_1 0.1", 1);
     118        if ($status) {
     119            &my_die("failed to update imfile");
     120        }
     121        $file->{user_1} = 0.1;
     122    }
     123}
    93124
    94125my $prevFileOpt = "";
    95126foreach my $file (@files) {
    96127    my $exp_id = $file->{exp_id};
    97     if ($skip_burned and ($file->{user_1} > 0.5)) { next; }
    98128
    99129    my $rawImfile = $file->{uri};
     
    104134        ($rawImfileReal) = $rawImfile =~ m|^neb:/(.*)|;
    105135    }
    106     # print "rawImfile: $rawImfile -> $rawImfileReal\n";
     136    print "rawImfile: $rawImfile -> $rawImfileReal\n";
    107137
    108138    # mangle name, create tmp file (always a UNIX file)
     
    120150    # print "outImfile: $outImfile -> $outImfileReal\n";
    121151
    122     # destination for the burntool artifacts
    123     my $artImfile = $rawImfile;
    124     $artImfile =~ s/fits$/burn.tbl/;
    125     my $artImfileReal = $ipprc->file_resolve($artImfile, 1);
    126     # print "artImfile: $artImfile -> $artImfileReal\n";
    127 
    128     # uncompress the image (do we need to check if it is compressed?)
    129     my $status = vsystem ("$funpack -S $rawImfileReal > $tmpImfileReal", $REALRUN);
    130     if ($status) {
    131         &my_die("failed on funpack");
    132     }
    133 
    134     $status = vsystem ("$burntool $tmpImfileReal out=$artImfileReal $prevFileOpt", $REALRUN);
    135     if ($status) {
    136         &my_die("failed on burntool");
    137     }
    138 
    139     # compress the image (do we need to check if it is compressed?)
    140     $status = vsystem ("$fpack -S $tmpImfileReal > $outImfileReal", $REALRUN);
    141     if ($status) {
    142         &my_die("failed on fpack");
    143     }
    144 
    145     $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -user_1 1.0", 1);
    146     if ($status) {
    147         &my_die("failed to update imfile");
    148     }
    149 
     152    # burntool now can write the artifacts to the fits file.
     153    # destination for the burntool artifacts.  use this if RAWTABLES is set.
     154    my $artImfile;
     155    my $artImfileReal;
     156    if ($RAWTABLES) {
     157        $artImfile = $rawImfile;
     158        $artImfile =~ s/fits$/burn.tbl/;
     159        $artImfileReal = $ipprc->file_resolve($artImfile, 1);
     160        # print "artImfile: $artImfile -> $artImfileReal\n";
     161    }
     162
     163    print "$rawImfile : $skip_burned, $file->{user_1}\n";
     164
     165    if (! ($skip_burned and ($file->{user_1} > 0.5))) {
     166        print "running on: $rawImfile\n";
     167        # uncompress the image (do we need to check if it is compressed?)
     168        my $status = vsystem ("$funpack -S $rawImfileReal > $tmpImfileReal", $REALRUN);
     169        if ($status) {
     170            &my_die("failed on funpack");
     171        }
     172
     173        if ($RAWTABLES) {
     174            $status = vsystem ("$burntool $tmpImfileReal out=$artImfileReal $prevFileOpt", $REALRUN);
     175        } else {
     176            $status = vsystem ("$burntool $tmpImfileReal $prevFileOpt", $REALRUN);
     177        }
     178        if ($status) {
     179            &my_die("failed on burntool");
     180        }
     181
     182        # compress the image (do we need to check if it is compressed?)
     183        $status = vsystem ("$fpack -S $tmpImfileReal > $outImfileReal", $REALRUN);
     184        if ($status) {
     185            &my_die("failed on fpack");
     186        }
     187
     188        $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -user_1 1.0", 1);
     189        if ($status) {
     190            &my_die("failed to update imfile");
     191        }
     192        print "\n";
     193    }
    150194    # save the artifact file for the next image
    151     $prevFileOpt = "in=$artImfileReal";
    152     print "\n";
     195    if ($RAWTABLES) {
     196        $prevFileOpt = "in=$artImfileReal";
     197    } else {
     198        $prevFileOpt = "infits=$artImfileReal";
     199    }
    153200}
    154201
Note: See TracChangeset for help on using the changeset viewer.