#! /bin/sh # This is the LHEA perl script: /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/runpcabackest # The purpose of this special block is to make this script work with # the user's local perl, regardless of where that perl is installed. # The variable LHEAPERL is set by the initialization script to # point to the local perl installation. #------------------------------------------------------------------------------- eval ' if [ "x$LHEAPERL" = x ]; then echo "Please run standard LHEA initialization before attempting to run /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/runpcabackest." exit 3 elif [ "$LHEAPERL" = noperl ]; then echo "During LHEA initialization, no acceptable version of Perl was found." echo "Cannot execute script /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/runpcabackest." exit 3 elif [ `$LHEAPERL -v < /dev/null 2> /dev/null | grep -ic "perl"` -eq 0 ]; then echo "LHEAPERL variable does not point to a usable perl." exit 3 else # Force Perl into 32-bit mode (to match the binaries) if necessary: if [ "x$HD_BUILD_ARCH_32_BIT" = xyes ]; then if [ `$LHEAPERL -V 2> /dev/null | grep -ic "USE_64_BIT"` -ne 0 ]; then VERSIONER_PERL_PREFER_32_BIT=yes export VERSIONER_PERL_PREFER_32_BIT fi fi exec $LHEAPERL -x $0 ${1+"$@"} fi ' if(0); # Do not delete anything above this comment from an installed LHEA script! #------------------------------------------------------------------------------- #! /usr1/local/bin/perl5 # # Script to run pcabackest and create several output files and # a file containing their names ready to be used as input for SAEXTRCT # # Brian K. Elza 8/19/96 # XTE GSFC/NASA # # 10/23/97 Zhiyu Guo cut the last part of the script which calls for SAEXTRCT. use Getopt::Std; #============================================================# # # See if there are any flags: # getopts('h'); if (defined $opt_h) { print <); #if($answer =~ /^[yY]/){ # } #else{ # } print " Running RUNPCABACKEST version 4.0 \n"; print "===========================================\n"; @infile2=&runcom('pget pcabackest infile'); chop($infile2[0]); print "List of Standard mode 2 Science array FITS files (\@filename):[$infile2[0]]"; ($infile = ); if($infile =~ /^./ ){ chop($infile); } else{ $infile = $infile2[0]; } $origfile = $infile; print "Output file which will contain the LIST of output files?:[outlist]"; ($outlist = ); if($outlist =~ /^./){ chop($outlist);} else{ $outlist = outlist; } @infile2=&runcom('pget pcabackest outfile'); chop($infile2[0]); print "Suffix appended to the output background files (after underscore _):[$infile2[0]]"; ($outroot = ); if($outroot =~ /^./){ chop($outroot);} else{ $outroot = $infile2[0]; } @infile2=&runcom('pget pcabackest filterfile'); chop($infile2[0]); print "XTE Filter file:[$infile2[0]]"; ($filterfile = ); if($filterfile =~ /^./){ chop($filterfile);} else{ $filterfile = $infile2[0]; } @infile2=&runcom('pget pcabackest modelfile'); chop($infile2[0]); print "PCA Background model file:[$infile2[0]]"; ($modelfile = ); if($modelfile =~ /^./){ chop($modelfile);} else{ $modelfile = $infile2[0]; } @infile2=&runcom('pget pcabackest interval'); chop($infile2[0]); print "Seconds between succesive estimates:[$infile2[0]]"; ($interval = ); if($interval =~ /^./){ chop($interval);} else{ $interval = $infile2[0]; } #@infile2=&runcom('pget pcabackest propane'); #chop($infile2[0]); #print "Include propane layer spectra? (Yes, No):[$infile2[0]]"; #($propane = ); #if($propane =~ /^./){ # chop($propane);} #else{ # $propane = $infile2[0]; #} $modeltype = "BOTH"; $propane = "no"; $interpolate = "yes"; $maxmodels = "256"; @infile2=&runcom('pget pcabackest layers'); chop($infile2[0]); print "Include individual xenon layer spectra? (Yes, No):[$infile2[0]]"; ($layers = ); if($layers =~ /^./){ chop($layers);} else{ $layers = $infile2[0]; } @infile2=&runcom('pget pcabackest gaincorr'); chop($infile2[0]); print "Correct for PCU Xenon gain variations? (Yes, No):[$infile2[0]]"; ($gaincorr = ); if($gaincorr =~ /^./){ chop($gaincorr);} else{ $gaincorr = $infile2[0]; } if($gaincorr =~ /^[Yy]/){ @infile2=&runcom('pget pcabackest gcorrfile'); chop($infile2[0]); print "EDS gain correction file (CALDB) :[$infile2[0]]"; ($gcorrfile = ); if($gcorrfile =~ /^./){ chop($gcorrfile);} else{ $gcorrfile = $infile2[0]; } $fullspec = 'yes'; } else { $gcorrfile = ' '; @infile2=&runcom('pget pcabackest fullspec'); chop($infile2[0]); print "Expand xenon layer spectra to 256 channels? (Yes, No):[$infile2[0]]"; ($fullspec = ); if($fullspec =~ /^./){ chop($fullspec);} else{ $fullspec = $infile2[0]; } } ### By ZG, add saahfile to the parameter list ### @infile2=&runcom('pget pcabackest saahfile'); chop($infile2[0]); print "PCA SAA passage history file:[$infile2[0]]"; ($saahfile = ); if($saahfile =~ /^./){ chop($saahfile);} else{ $saahfile = $infile2[0]; } ################################################# @infile2=&runcom('pget pcabackest syserr'); chop($infile2[0]); print "Compute systematic error estimate? (Yes, No):[$infile2[0]]"; ($syserr = ); if($syserr =~ /^./){ chop($syserr);} else{ $syserr = $infile2[0]; } $k=$outroot; $count=0; print "Outfile will be ${outlist}\n\n"; if($infile =~ /^@/ ){ $infile =~ s/^@//; # Remove the @ symbol open(INPUT_FILE,"$infile") || die "Sorry can't find $infile\n"; # Open the input file open(OUTPUT_FILE,"> $outlist") || die "Sorry can't open $outlist\n"; # Open a unique output file while() { next if ( /^ *$/ ); # guard against blank or empty lines $count++; # How many files are being processed? chomp($_); # not chop() in case there is no in last file s/ //; # Remove any blanks that are lest in the names. @list = split(/\//); # Split up the string using / $length_of_list = @list; # How many elements are there? $outall=$list[$length_of_list-1]."_".$k; # Create the output filename. print OUTPUT_FILE $outall."\n"; # Copy files from INFILE to OUTPUT $pcabackest_string = "pcabackest infile='".$_."' outfile='".$outall."' "; $pcabackest_string .= "filterfile='".$filterfile."' "; $pcabackest_string .= "modelfile='".$modelfile."' saahfile='".$saahfile."' modeltype=both interval=$interval "; $pcabackest_string .= "propane=no layers=$layers "; $pcabackest_string .= "gaincorr=$gaincorr gcorrfile='".$gcorrfile."' "; $pcabackest_string .= "fullspec=$fullspec interp=yes syserr=$syserr clobber=yes mode=no "; print "Calling pcabackest with string:\n$pcabackest_string\n\n"; system($pcabackest_string); print "Generated output file: ${outall}. Continuing...\n\n"; } close(INPUT_FILE); # We are finished with the input file. close(OUTPUT_FILE); # Close up the output file too. print "Generated output file: ${outlist}. \nThis file contains the names of the output files.\n"; print "This file can be input into SAEXTRCT using the \@filename option.\n"; } else { $count++; # How many files are being processed? open(OUTPUT_FILE,"> $outlist") || die "Sorry can't open $outlist\n"; # open a unique output file $infile=~ s/ //; # Remove any blanks that are lest in the names. @list = split(/\//,$infile); # Split up the string using / $length_of_list = @list; # How many elements are there? $outall=$list[$length_of_list-1]."_".$k; # Create the output filename. print OUTPUT_FILE $outall."\n"; # Copy the filename to output file. $pcabackest_string = "pcabackest infile='".$infile."' outfile='".$outall."' "; $pcabackest_string .= "filterfile='".$filterfile."' " ; $pcabackest_string .= "modelfile='".$modelfile."' saahfile='".$saahfile."' modeltype=both interval=$interval "; $pcabackest_string .= "propane=$propane layers=$layers "; $pcabackest_string .= "gaincorr=$gaincorr gcorrfile='".$gcorrfile."' "; $pcabackest_string .= "fullspec=$fullspec interp=yes syserr=$syserr clobber=yes mode=no "; print "Calling pcabackest with string:\n$pcabackest_string\n\n"; system($pcabackest_string); print "Generated output file: ${outall}. Continuing...\n\n"; close(OUTPUT_FILE); # Close the output file. } #@infile2=&runcom("pset pcabackest infile='".$infile."' "); #@infile2=&runcom("pset pcabackest outfile='".$outroot."' "); #@infile2=&runcom("pset pcabackest modelfile='".$modelfile."' "); #@infile2=&runcom("pset pcabackest saahfile='".$saahfile."' "); #@infile2=&runcom("pset pcabackest interval='".$interval."' "); #@infile2=&runcom("pset pcabackest layers='".$layers."' "); #@infile2=&runcom("pset pcabackest gaincorr='".$gaincorr."' "); #@infile2=&runcom("pset pcabackest gcorrfile='".$gcorrfile."' "); #@infile2=&runcom("pset pcabackest fullspec='".$fullspec."' "); #@infile2=&runcom("pset pcabackest syserr='".$syserr."' "); print "Update Parameter file for PCABACKEST? (Yes, No):"; $fupdate = ; if($fupdate =~ /^[Yy]/){ @infile2=&runcom("pset pcabackest infile='".$origfile."' outfile='".$outroot."' filterfile='".$filterfile."' modelfile='".$modelfile."' saahfile='".$saahfile."' interval='".$interval."' layers='".$layers."' gaincorr='".$gaincorr."' gcorrfile='".$gcorrfile."' fullspec='".$fullspec."' syserr='".$syserr."'"); print "PCABACKEST parameter file updated.\n"; }