IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 8, 2011, 4:44:37 PM (15 years ago)
Author:
bills
Message:

use ipprc->prepare_output() to manage exisiting input files. Replicate sources and jpegs

File:
1 edited

Legend:

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

    r30599 r30826  
    6868my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6969
    70 # XXX camera is not known here; cannot use filerules...
     70my $neb;
     71my $scheme = file_scheme($outroot);
     72if ($scheme and $scheme eq 'neb') {
     73    $neb = $ipprc->nebulous();
     74}
     75
     76# XXX camera is not known here; cannot use filerules...
     77# bills 2011-03-07 This is unfortunate because it prevents us from using prepare_output ...
    7178# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    7279my $logDest = "$outroot.log";
    73 $logDest .= ".update" if $run_state eq "update";
     80if ($run_state eq 'update') {
     81    $logDest .= '.update';
     82    # ... well we can just do the dirty work here
     83    $ipprc->kill_file($logDest);
     84}
    7485$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    7586
     
    249260
    250261# Get the output filenames
    251 my $outputName = $ipprc->filename("PPSUB.OUTPUT", $outroot);
    252 my $outputMask = $ipprc->filename("PPSUB.OUTPUT.MASK", $outroot);
    253 my $outputVariance = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $outroot);
    254 my $outputSources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $outroot);
    255 my $jpeg1Name = $ipprc->filename("PPSUB.OUTPUT.JPEG1", $outroot);
    256 my $jpeg2Name = $ipprc->filename("PPSUB.OUTPUT.JPEG2", $outroot);
    257 my $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
    258 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
    259 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
    260 
    261 if ($run_state eq 'update') {
    262     $traceDest .= '.update';
    263     $outputStats .= '.update';
    264 
     262my $configuration;
     263my $outputStats;
     264my $traceDest;
     265my $do_photom = 1;
     266my $dump_config = 1;
     267if ($run_state eq 'new') {
     268    $configuration = prepare_output("PPSUB.CONFIG", $outroot, 1);
     269    $traceDest = prepare_output("TRACE.EXP", $outroot, 1);
     270    $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1);
     271} else {
     272    $do_photom = 0;
     273    $dump_config = 0;
     274    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1);
     275    # we rerun stats because we need the quality value
     276    $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1);
     277    $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
     278    if (!$ipprc->file_exists($configuration)) {
     279       print STDERR "WARNING: Config dump file $configuration is missing. Using current recipes and file rules.\n";
     280       $configuration = undef;
     281    }
     282    # use WARPSTATS if we're updating, as we don't care about the new stuff from the STACK and DIFF STATS recipes
    265283    $recipe_ppstats = 'WARPSTATS';
    266284}
     285
     286my $outputName = prepare_output("PPSUB.OUTPUT", $outroot, 1);
     287my $outputMask = prepare_output("PPSUB.OUTPUT.MASK", $outroot, 1);
     288my $outputVariance = prepare_output("PPSUB.OUTPUT.VARIANCE", $outroot, 1);
     289my $outputSources = prepare_output("PPSUB.OUTPUT.SOURCES", $outroot, 1) if $do_photom;
     290my $jpeg1Name = prepare_output("PPSUB.OUTPUT.JPEG1", $outroot, 1);
     291my $jpeg2Name = prepare_output("PPSUB.OUTPUT.JPEG2", $outroot, 1);
    267292
    268293my ($inverseName, $inverseMask, $inverseVariance, $inverseSources);
    269294if ($inverse) {
    270     $inverseName = $ipprc->filename("PPSUB.INVERSE", $outroot);
    271     $inverseMask = $ipprc->filename("PPSUB.INVERSE.MASK", $outroot);
    272     $inverseVariance = $ipprc->filename("PPSUB.INVERSE.VARIANCE", $outroot);
    273     $inverseSources = $ipprc->filename("PPSUB.INVERSE.SOURCES", $outroot);
     295    $inverseName = prepare_output("PPSUB.INVERSE", $outroot, 1);
     296    $inverseMask = prepare_output("PPSUB.INVERSE.MASK", $outroot, 1);
     297    $inverseVariance = prepare_output("PPSUB.INVERSE.VARIANCE", $outroot, 1);
     298    $inverseSources = prepare_output("PPSUB.INVERSE.SOURCES", $outroot, 1) if $do_photom;
    274299}
    275300
     
    289314    $command .= " -stats $outputStats";
    290315    $command .= " -threads $threads" if defined $threads;
    291     if ($run_state eq "new") {
     316    if ($dump_config) {
    292317        $command .= " -dumpconfig $configuration";
    293     } else {
    294         my $configurationReal = $ipprc->file_resolve($configuration) or &my_die("Couldn't resolve configuration file: $configuration", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    295         $command .= " -ipprc $configurationReal";
     318    } elsif ($configuration) {
     319        $command .= " -ipprc $configuration";
    296320    }
    297321    $command .= " -save-inconv" if defined $saveInConv and $run_state eq "new";
     
    303327    $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF";
    304328    $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF";
    305     if ($run_state eq "new") {
     329    if ($do_photom) {
    306330        $command .= " -photometry";
    307331    } else {
     
    322346        }
    323347
     348        check_output($outputStats, 1);
    324349        my $outputStatsReal = $ipprc->file_resolve($outputStats);
    325         &my_die("Couldn't find expected output file: $outputStats", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
    326350
    327351        # measure chip stats
     
    341365
    342366        if (!$quality) {
    343             &my_die("Couldn't find expected output file: $outputName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
    344             &my_die("Couldn't find expected output file: $outputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    345             &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
    346             &my_die("Couldn't find expected output file: $outputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    347             &my_die("Couldn't find expected output file: $jpeg1Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1Name);
    348             &my_die("Couldn't find expected output file: $jpeg2Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2Name);
     367            check_output($outputName, 0);
     368            check_output($outputMask, 0);
     369            check_output($outputVariance, 0);
     370            check_output($outputSources, 1) if $do_photom;
     371            check_output($jpeg1Name, 1);
     372            check_output($jpeg2Name, 1);
    349373            if ($inverse) {
    350                 &my_die("Couldn't find expected output file: $inverseName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseName);
    351                 &my_die("Couldn't find expected output file: $inverseMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseMask);
    352                 &my_die("Couldn't find expected output file: $inverseVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseVariance);
    353                 &my_die("Couldn't find expected output file: $inverseSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseSources);
     374                check_output($inverseName, 0);
     375                check_output($inverseMask, 0);
     376                check_output($inverseVariance, 0);
     377                check_output($inverseSources, 1) if $do_photom;
    354378                if ($run_state eq 'new') {
    355                     &my_die("Couldn't find expected output file: $configuration", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
     379                    check_output($configuration, 1);
    356380                }
    357381            }
     
    391415    }
    392416}
     417exit 0;
     418
     419
     420# Prepare to write to an output file
     421#   Lookup the filename in the rules.
     422#   Make sure that if file exists and is a nebulous file that there is only one instance
     423#   Deal with files that have been lost.
     424sub prepare_output
     425{
     426    my $filerule = shift;
     427    my $outroot  = shift;
     428    my $delete = shift;
     429    $delete = 0 if !defined $delete;
     430
     431    my $error;
     432    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
     433                    or &my_die("failed to prepare output file for: $filerule", $diff_id, $skycell_id, $error);
     434    return $output;
     435}
     436
     437sub check_output
     438{
     439    my $file = shift;
     440    my $replicate = shift;
     441
     442    if (!defined $file) {
     443        return;
     444    }
     445
     446    &my_die("Couldn't find expected output file: $file",  $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     447
     448    if ($replicate and $neb) {
     449        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     450    }
     451}
    393452
    394453
Note: See TracChangeset for help on using the changeset viewer.