IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 12, 2015, 12:53:36 PM (12 years ago)
Author:
eugene
Message:

merging changes from ipp-pv3-20140717 (via branches/eam_branches/ipp-pv3-20140717-merge)

Location:
trunk/ippScripts/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts

  • trunk/ippScripts/scripts/sc_mk_stack_mdc.pl

    r36844 r37833  
    11#! /usr/bin/env perl                                                                                                                                                       
    2 
    32use Carp;
    43use warnings;
    54use strict;
    65
     6use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     7use Pod::Usage qw( pod2usage );
     8
     9
     10my $remote_root = '/scratch3/watersc1/';
     11
     12my ($compmap_file);
     13GetOptions(
     14    'compmap=s'   => \$compmap_file,
     15    ) or pod2usage( 2 );
     16
     17pod2usage( -msg => "Required options: --compmap", -exitval => 3) unless
     18    defined($compmap_file);
     19
     20my %component_map = ();
     21open(CM,$compmap_file) || die "Cannot find requested compmap file";
     22while(<CM>) {
     23    chomp;
     24    my ($symbolic_name,$disk_name) = split /\s+/;
     25    $component_map{$symbolic_name} = $disk_name;
     26}
     27close(CM);
     28
    729my $counter = 0;
    830
    931foreach my $path_base (@ARGV) {
    10     print "INPUT${counter}  METADATA\n";
    11     print "   IMAGE           STR     ${path_base}.fits\n";
    12     print "   MASK            STR     ${path_base}.mask.fits\n";
    13     print "   VARIANCE        STR     ${path_base}.wt.fits\n";
    14     print "   PSF             STR     ${path_base}.psf\n";
    15     print "   SOURCES         STR     ${path_base}.cmf\n";
    16     print "   BKGMODEL        STR     ${path_base}.mdl.fits\n";
    17     print "END\n\n";
     32    my $mdc_content = "";
     33    my $file = "";
     34    my $error = 0;
     35
     36#   print "PB: $path_base\n";
     37
     38    #header
     39    $mdc_content .= "INPUT${counter}  METADATA\n";
     40
     41    # check each file against its possible locations, incrementing the error counter if not found
     42    $file = do_checks("${path_base}.fits",$error);
     43    $mdc_content .=  "   IMAGE           STR     $file\n";
     44
     45    $file = do_checks("${path_base}.mask.fits",$error);
     46    $mdc_content .=  "   MASK            STR     $file\n";
     47
     48    $file = do_checks("${path_base}.wt.fits",$error);
     49    $mdc_content .=  "   VARIANCE        STR     $file\n";
     50   
     51    $file = do_checks("${path_base}.psf",$error);
     52    $mdc_content .=  "   PSF             STR     $file\n";
     53   
     54    $file = do_checks("${path_base}.cmf",$error);
     55    $mdc_content .=  "   SOURCES         STR     $file\n";
     56
     57    # This is static, and isn't used by ppStack, but I believe needs to exist in the mdc. 2014-08-28 czw
     58    $mdc_content .=  "   BKGMODEL        STR     ${path_base}.mdl.fits\n";
     59    $mdc_content .=  "END\n\n";
     60#    print "MDC: $mdc_content\n";
     61    # If we had no errors, print it and move on.
     62    if ($error == 0) {
     63        print $mdc_content;
     64    }
     65
    1866    $counter++;
    1967}
     68
     69sub do_checks {
     70    my ($cfile,$error) = @_;
     71#    print  ">$cfile<\n";
     72    if (! ((-e $cfile)&&(-s $cfile))) { # This cfile does not exist or is zero size.
     73        my $disk = $component_map{$cfile};
     74        $cfile = "${disk}";
     75        if (! ((-e $cfile)&&(-s $cfile))) { # The other expected cfile did not exist.
     76#           $cfile = '';
     77            $error++;
     78            die "Missing cfile $cfile!";
     79        }
     80    }
     81    return($cfile);
     82}
     83   
Note: See TracChangeset for help on using the changeset viewer.