IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 24, 2021, 5:04:01 PM (5 years ago)
Author:
eugene
Message:

add option to skip missing inputs and make a stack anyway

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20211108/ippScripts/scripts/stack_skycell.pl

    r37833 r41938  
    6666    and defined $run_state;
    6767
    68 # lists of file rules which we expect to produce output output
     68# lists of file rules which we expect to produce output when convolving
    6969my @outputList = qw(
    7070PPSTACK.OUTPUT
     
    7474PPSTACK.OUTPUT.EXPNUM       
    7575PPSTACK.OUTPUT.EXPWT
    76 PPSTACK.OUTPUT.JPEG1       
    77 PPSTACK.OUTPUT.JPEG2       
    78 PPSTACK.CONFIG             
     76PPSTACK.TARGET.PSF         
    7977);
     78
    8079# produced if we run photometry
    8180my @outputListPhotom = qw(
    8281PSPHOT.OUT.CMF.MEF
    8382);
    84 # extra outputs when convolving
     83
     84# list of file rules produced if convolution is false
    8585my @outputListUnconv = qw(
    86 PPSTACK.TARGET.PSF         
    8786PPSTACK.UNCONV
    8887PPSTACK.UNCONV.MASK
     
    9190PPSTACK.UNCONV.EXPNUM       
    9291PPSTACK.UNCONV.EXPWT
     92PPSTACK.OUTPUT.JPEG1       
     93PPSTACK.OUTPUT.JPEG2       
     94PPSTACK.CONFIG             
    9395);
    9496
     
    208210my $output_logflux = metadataLookupBool($recipe, 'OUTPUT.LOGFLUX'); # change filerules to produce logflux compressed output images.
    209211my $replicate_outputs = (defined($neb) and metadataLookupBool($recipe, 'OUTPUT.REPLICATE')); # replicate output images
     212my $skip_missing_inputs = metadataLookupBool($recipe, 'SKIP.MISSING.INPUTS'); # ignore missing inputs
    210213if ($output_nocomp and $output_logflux) {
    211214    &my_die("Unable to not compress and logflux compress simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR);
     
    225228    $num++;
    226229
    227 #    my $image = $file->{uri};   # Image name
    228     my $image = $ipprc->filename("PSWARP.OUTPUT", $file->{path_base} ); # Image name
    229     my $mask = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name
    230     my $weight = $ipprc->filename( "PSWARP.OUTPUT.VARIANCE", $file->{path_base} ); # Weight name
    231     my $psf = $convolve ? $ipprc->filename( "PSPHOT.PSF.SKY.SAVE", $file->{path_base} ) : undef; # PSF name
    232     my $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base}); # Sources name
    233 
     230    # select the input files
     231    my $image    = $ipprc->filename("PSWARP.OUTPUT", $file->{path_base} ); # Image name
     232    my $mask     = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name
     233    my $weight   = $ipprc->filename( "PSWARP.OUTPUT.VARIANCE", $file->{path_base} ); # Weight name
     234    my $psf      = $convolve ? $ipprc->filename( "PSPHOT.PSF.SKY.SAVE", $file->{path_base} ) : undef; # PSF name
     235    my $sources  = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base}); # Sources name
    234236    my $bkgmodel = $ipprc->filename("PSWARP.OUTPUT.BKGMODEL", $file->{path_base});
    235237
    236     &my_die("Image $image does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image );
    237     &my_die("Mask $mask does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $mask );
    238     &my_die("Weight $weight does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $weight );
    239     &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) if ($convolve and not $ipprc->file_exists( $psf ));
    240     &my_die("Sources $sources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $sources );
    241 
    242     print $listFile "\tIMAGE\tSTR\t" . $image . "\n";
    243     print $listFile "\tMASK\tSTR\t" . $mask . "\n";
    244     print $listFile "\tVARIANCE\tSTR\t" . $weight . "\n";
    245     print $listFile "\tPSF\tSTR\t" . $psf . "\n" if $convolve;
    246     print $listFile "\tSOURCES\tSTR\t" . $sources . "\n";
     238    my $have_image   = $ipprc->file_exists( $image );
     239    my $have_mask    = $ipprc->file_exists( $mask );
     240    my $have_weight  = $ipprc->file_exists( $weight );
     241    my $have_sources = $ipprc->file_exists( $sources );
     242    my $have_psf     = $convolve and $ipprc->file_exists( $psf );
     243
     244    if ($skip_missing_inputs) {
     245        my $missing_inputs = false;
     246        unless ($have_image)  { print "WARNING: MISSING INPUT $input  \n"; $missing_inputs = true; }
     247        unless ($have_mask)   { print "WARNING: MISSING INPUT $mask   \n"; $missing_inputs = true; }
     248        unless ($have_weight) { print "WARNING: MISSING INPUT $weight \n"; $missing_inputs = true; }
     249        unless ($have_sources){ print "WARNING: MISSING INPUT $sources\n"; $missing_inputs = true; }
     250        if ($convolve) { unless ($have_psf) { print "WARNING: MISSING INPUT $psf\n"; $missing_inputs = true;}}
     251        if ($missing_input) { next; }
     252    } else {
     253        &my_die("Image $image does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $have_image;
     254        &my_die("Mask $mask does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $have_mask;
     255        &my_die("Weight $weight does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $have_weight;
     256        &my_die("Sources $sources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $have_sources;
     257        &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) if ($convolve and not $have_psf);
     258    }
     259
     260    print $listFile "\tIMAGE\tSTR\t"    . $image    . "\n";
     261    print $listFile "\tMASK\tSTR\t"     . $mask     . "\n";
     262    print $listFile "\tVARIANCE\tSTR\t" . $weight   . "\n";
     263    print $listFile "\tPSF\tSTR\t"      . $psf      . "\n" if $convolve;
     264    print $listFile "\tSOURCES\tSTR\t"  . $sources  . "\n";
    247265    print $listFile "\tBKGMODEL\tSTR\t" . $bkgmodel . "\n" if $ipprc->file_exists( $bkgmodel );
    248266
     
    255273# Prepare the output files
    256274my @outputFiles;
    257 prepare_outputs(\@outputFiles, \@outputList, $outroot);
     275prepare_outputs(\@outputFiles, \@outputList,       $outroot) if $convolve;
    258276prepare_outputs(\@outputFiles, \@outputListPhotom, $outroot) if $photometry;
    259 prepare_outputs(\@outputFiles, \@outputListUnconv, $outroot) if $convolve;
     277prepare_outputs(\@outputFiles, \@outputListUnconv, $outroot); # unconvolved output always go here
    260278
    261279# we need the output image name for the database
Note: See TracChangeset for help on using the changeset viewer.