Changeset 37833 for trunk/ippScripts/scripts/sc_mk_stack_mdc.pl
- Timestamp:
- Jan 12, 2015, 12:53:36 PM (12 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
sc_mk_stack_mdc.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts
- Property svn:mergeinfo set to
-
trunk/ippScripts/scripts/sc_mk_stack_mdc.pl
r36844 r37833 1 1 #! /usr/bin/env perl 2 3 2 use Carp; 4 3 use warnings; 5 4 use strict; 6 5 6 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 7 use Pod::Usage qw( pod2usage ); 8 9 10 my $remote_root = '/scratch3/watersc1/'; 11 12 my ($compmap_file); 13 GetOptions( 14 'compmap=s' => \$compmap_file, 15 ) or pod2usage( 2 ); 16 17 pod2usage( -msg => "Required options: --compmap", -exitval => 3) unless 18 defined($compmap_file); 19 20 my %component_map = (); 21 open(CM,$compmap_file) || die "Cannot find requested compmap file"; 22 while(<CM>) { 23 chomp; 24 my ($symbolic_name,$disk_name) = split /\s+/; 25 $component_map{$symbolic_name} = $disk_name; 26 } 27 close(CM); 28 7 29 my $counter = 0; 8 30 9 31 foreach 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 18 66 $counter++; 19 67 } 68 69 sub 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.
