IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 9, 2011, 3:07:11 PM (15 years ago)
Author:
bills
Message:

Optionally replicate stack outputs if outroot is in nebulous. (Default recipe is set to replicate))

File:
1 edited

Legend:

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

    r30636 r30840  
    6565    and defined $run_state;
    6666
     67# lists of file rules which we expect to produce output output
     68my @outputList = qw(
     69PPSTACK.OUTPUT
     70PPSTACK.OUTPUT.MASK
     71PPSTACK.OUTPUT.VARIANCE
     72PPSTACK.OUTPUT.EXP         
     73PPSTACK.OUTPUT.EXPNUM       
     74PPSTACK.OUTPUT.EXPWT
     75PPSTACK.TARGET.PSF         
     76PPSTACK.OUTPUT.JPEG1       
     77PPSTACK.OUTPUT.JPEG2       
     78PPSTACK.CONFIG             
     79);
     80# produced if we run photometry
     81my @outputListPhotom = qw(
     82PSPHOT.OUT.CMF.MEF
     83);
     84# extra outputs when convolving
     85my @outputListUnconv = qw(
     86PPSTACK.UNCONV
     87PPSTACK.UNCONV.MASK
     88PPSTACK.UNCONV.VARIANCE
     89PPSTACK.UNCONV.EXP         
     90PPSTACK.UNCONV.EXPNUM       
     91PPSTACK.UNCONV.EXPWT
     92);
     93
    6794my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6895$| = 1;
     
    73100my $logDest = "$outroot.log";
    74101
    75 my $do_stats;
    76 if ($run_state eq 'new') {
    77     $do_stats = 1;
    78 } else {
     102if ($run_state eq 'update') {
    79103    $logDest .= ".update";
    80104}
    81105
    82106$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     107
     108my $neb;
     109my $scheme = file_scheme($outroot);
     110if ($scheme and $scheme eq 'neb') {
     111    $neb = $ipprc->nebulous();
     112}
     113
    83114
    84115my $temp_images_exist = 0;
     
    173204my $output_nocomp = metadataLookupBool($recipe, 'OUTPUT.NOCOMP'); # change filerules to produced uncompressed output images
    174205my $output_logflux = metadataLookupBool($recipe, 'OUTPUT.LOGFLUX'); # change filerules to produce logflux compressed output images.
    175 
     206my $replicate_outputs = (defined($neb) and metadataLookupBool($recipe, 'OUTPUT.REPLICATE')); # replicate output images
    176207if ($output_nocomp and $output_logflux) {
    177208    &my_die("Unable to not compress and logflux compress simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR);
     
    212243print "I've checked everything: $stack_id\n";
    213244
    214 # Get the output filenames
    215 my $outputName = $ipprc->filename("PPSTACK.OUTPUT", $outroot);
    216 my $outputMask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $outroot);
    217 my $outputWeight = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $outroot);
    218 my $outputSources = $photometry ? $ipprc->filename("PSPHOT.OUT.CMF.MEF", $outroot) : undef; ## this must be consistent with the value in diff_skycell.pl:101
     245# Prepare the output files
     246my @outputFiles;
     247prepare_outputs(\@outputFiles, \@outputList, $outroot);
     248prepare_outputs(\@outputFiles, \@outputListPhotom, $outroot) if $photometry;
     249prepare_outputs(\@outputFiles, \@outputListUnconv, $outroot) if $convolve;
     250
     251# we need the output image name for the database
     252my $outputName = $outputFiles[0];
    219253
    220254## use an explicit stack name for psphot output objects
    221 #my $bin1Name =  $ipprc->filename("PPSTACK.BIN1", $outroot);
    222 #my $bin2Name =  $ipprc->filename("PPSTACK.BIN2", $outroot);
    223 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
    224 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
    225 $traceDest .= ".update" if $run_state eq 'update';
    226 my $configuration = $ipprc->filename("PPSTACK.CONFIG", $outroot);
     255my $do_stats = 1;   
     256my $outputStats;
     257my $traceDest;
     258if ($run_state eq 'new') {
     259    $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1);
     260    $traceDest = prepare_output("TRACE.EXP", $outroot, 1);
     261} else {
     262    # we need to do stats regardless because we need the quality flag
     263    # $do_stats = 0;
     264    $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1) if $do_stats;
     265    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1);
     266}
     267my $configuration = prepare_output("PPSTACK.CONFIG", $outroot, 1);
    227268$temp_images_exist = 1;  # failures after this point should attempt to delete the temp images
    228269
    229 # for update we need to resolve the config filename here because the code that reads it
    230 # doesn't know how to resolve paths. (The information is stored in the configuration file)
    231 $configuration = $ipprc->file_resolve($configuration) if ($run_state eq 'update');
    232 
    233270my $cmdflags;
    234 
    235271
    236272# Perform stacking
    237273unless ($no_op) {
    238274    my $command = "$ppStack -input $listName $outroot";
    239     $command .= " -stats $outputStats" if $do_stats;;
     275    $command .= " -stats $outputStats" if $do_stats;
    240276    $command .= " -recipe PPSTACK $recipe_ppStack";
    241277    $command .= " -recipe PPSUB $recipe_ppSub";
     
    311347
    312348    if (!$quality) {
    313         &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
    314         &my_die("Couldn't find expected output file: $outputMask", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    315         &my_die("Couldn't find expected output file: $outputWeight", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
    316         if ($photometry) {
    317             &my_die("Couldn't find expected output file: $outputSources", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    318         }
     349        check_outputs(\@outputFiles, $replicate_outputs);
    319350        if ($run_state eq 'new') {
    320351            &my_die("Couldn't find expected output file: $configuration", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
    321         }
    322 #       &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
    323 #       &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
     352            $ipprc->replicate_file($outputStats) if $neb;
     353        }
    324354    }
    325355
     
    357387}
    358388
    359 print "I've updated teh database: $stack_id\n";
     389print "I've updated the database: $stack_id\n";
    360390
    361391
     
    423453    }
    424454}
     455sub prepare_output
     456{
     457    my $filerule = shift;
     458    my $outroot  = shift;
     459    my $delete = shift;
     460    $delete = 0 if !defined $delete;
     461
     462    my $error;
     463    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
     464                    or &my_die("failed to prepare output file for: $filerule", $stack_id, $error);
     465    return $output;
     466}
     467
     468sub prepare_outputs
     469{
     470    my $fileList = shift;
     471    my $ruleList = shift;
     472    my $outroot = shift;
     473   
     474    foreach my $rule (@$ruleList) {
     475        push @$fileList, prepare_output($rule, $outroot, 1);
     476    }
     477}
     478
     479sub check_output
     480{
     481    my $file = shift;
     482    my $replicate = shift;
     483
     484    if (!defined $file) {
     485        return;
     486    }
     487
     488    &my_die("Couldn't find expected output file: $file",  $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     489
     490    if ($replicate and $neb) {
     491        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $stack_id, $PS_EXIT_SYS_ERROR);
     492    }
     493}
     494
     495sub check_outputs
     496{
     497    my $fileList = shift;
     498    my $replicate = shift;
     499    foreach my $file (@$fileList) {
     500        check_output($file, $replicate);
     501    }
     502}
    425503
    426504print "I've reached the end of processing with a code of $?: $stack_id\n";
     
    432510}
    433511
     512
    434513__END__
Note: See TracChangeset for help on using the changeset viewer.