#! /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/saplot # 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/saplot." 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/saplot." 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/perl # # Script to run saextrct and fplot one after the other and create # an output file and display it. You can add more files as needed. # # Brian K. Elza 3/7/95 # XTE GSFC/NASA # # A C-shell script performing similar operations will also exist. # version 1.0.0 3/7/95 use Getopt::Std; #============================================================# # # See if there are any flags: # getopts('h'); if (defined $opt_h) { print < command option. PARAMETERS EXAMPLES 1. saplot NOTES: BUGS Please report problems to xtehelp\@athena.gsfc.nasa.gov. Provide a detailed description of the problem and an e-mail address at which you can be reached if further information is required. Before reporting a bug please check your .PAR file. At the moment all comparisons are CASE SENSITIVE. SEE ALSO SAEXTRCT and FPLOT for more information EOHELP1 exit; } # now onto the program ... require "utils.pl"; print "Do you want full filtering capability (Yes/No)?"; chop($answer = ); if($answer =~ /^[yY]/){ } else{ } @infile2=&runcom('pget saextrct infile'); chop($infile2[0]); print "Input file name or \@file-of-filenames:[$infile2[0]]"; ($infile = ); if($infile =~ /^./ ){ chop($infile); } else{ $infile = $infile2[0]; } $origfile = $infile; # Now we will test to see if the input file is a LIST of files. If it is # then we will copy all of the files contained within this file to a # unique filename if($infile =~ /^@/ ){ $infile =~ s/^@//; # Remove the @ symbol $origfile = $infile; # Store the filename in origfile open(INPUT_FILE,"$infile") || die "Sorry can't find $infile\n"; # Open the input file open(OUTPUT_FILE,">outfile_${$}") || die "Sorry can't open outfile_${$}\n"; # Open a unique output file while() { print OUTPUT_FILE $_; # Copy files from INFILE to OUTPUT } close(INPUT_FILE); # We are finished with the input file. close(OUTPUT_FILE); # Close up the output file too. print "output file created was outfile_${$}\n"; } else { open(OUTPUT_FILE,">outfile_${$}") || die "Sorry can't open outfile_${$}\n"; # open a unique output file print OUTPUT_FILE "$infile \n"; # Copy the filename to output file close(OUTPUT_FILE); # Close the output file. } if($answer =~ /^[yY]/){ @infile2=&runcom('pget saextrct gtiorfile'); chop($infile2[0]); print "Input GTI files to be OR'd with INFILE:[$infile2[0]]"; ($gtiorfile = ); if($gtiorfile =~ /^./){ chop($gtiorfile);} else{ $gtiorfile = $infile2[0]; } @infile2=&runcom('pget saextrct gtiandfile'); chop($infile2[0]); print "Input GTI files to be AND'd with INFILE:[$infile2[0]]"; ($gtiandfile = ); if($gtiandfile =~ /^./){ chop($gtiandfile);} else{ $gtiandfile = $infile2[0]; } } @infile2=&runcom('pget saextrct outroot'); chop($infile2[0]); print "Root name for output file:[$infile2[0]]"; ($outroot = ); if($outroot =~ /^./){ chop($outroot);} else{ $outroot = $infile2[0]; } @infile2=&runcom('pget saextrct accumulate'); chop($infile2[0]); print "Accumulate (ONE) or (MANY) Spectral/Light Curves:[$infile2[0]]"; ($accumulate = ); if($accumulate =~ /^./){ chop($accumulate);} else{ $accumulate = $infile2[0]; } @infile2=&runcom('pget saextrct timecol'); chop($infile2[0]); print "Name of TIME column:[$infile2[0]]"; ($timecol = ); if($timecol =~ /^./){ chop($timecol);} else{ $timecol = $infile2[0]; } @infile2=&runcom('pget saextrct columns'); chop($infile2[0]); print "Name of COLUMN to be accumulated:[$infile2[0]]"; ($columns = ); if($columns =~ /^./){ chop($columns);} else{ $columns = $infile2[0]; } @infile2=&runcom('pget saextrct binsz'); chop($infile2[0]); print "Input the binsize in seconds, use 0.1 etc. if nec (INDEF):[$infile2[0]]"; ($binsz = ); if($binsz =~ /^./){ chop($binsz);} else{ $binsz = $infile2[0]; } if($answer =~ /^[yY]/){ @infile2=&runcom('pget saextrct mfracexp'); chop($infile2[0]); print "Minimum acceptable fractional exposure (INDEF):[$infile2[0]]"; ($mfracexp = ); if($mfracexp =~ /^./){ chop($mfracexp);} else{ $mfracexp = $infile2[0]; } } @infile2=&runcom('pget saextrct printmode'); chop($infile2[0]); print "Chose print option, LIGHTCURVE, SPECTRUM, or BOTH:[$infile2[0]]"; ($printmode = ); if($printmode =~ /^./){ chop($printmode);} else{ $printmode = $infile2[0]; } @infile2=&runcom('pget saextrct lcmode'); chop($infile2[0]); print "Type of binning for LIGHTCURVE: (SUM, RATE, MEAN):[$infile2[0]]"; ($lcmode = ); if($lcmode =~ /^./){ chop($lcmode);} else{ $lcmode = $infile2[0]; } @infile2=&runcom('pget saextrct spmode'); chop($infile2[0]); print "Type of binning for SPECTRUM (SUM, RATE, MEAN):[$infile2[0]]"; ($spmode = ); if($spmode =~ /^./){ chop($spmode);} else{ $spmode = $infile2[0]; } if($answer =~ /^[yY]/){ @infile2=&runcom('pget saextrct mlcinten'); chop($infile2[0]); print "Maximum acceptable intensity for Light Curve (INDEF):[$infile2[0]]"; ($mlcinten = ); if($mlcinten =~ /^./){ chop($mlcinten);} else{ $mlcinten = $infile2[0]; } @infile2=&runcom('pget saextrct mspinten'); chop($infile2[0]); print "Maximum acceptable intensity for Spectrum (INDEF):[$infile2[0]]"; ($mspinten = ); if($mspinten =~ /^./){ chop($mspinten);} else{ $mspinten = $infile2[0]; } @infile2=&runcom('pget saextrct timemin'); chop($infile2[0]); print "Starting time for summation in seconds (INDEF):[$infile2[0]]"; ($timemin = ); if($timemin =~ /^./){ chop($timemin);} else{ $timemin = $infile2[0]; } @infile2=&runcom('pget saextrct timemax'); chop($infile2[0]); print "Ending time for summation in seconds (INDEF):[$infile2[0]]"; ($timemax = ); if($timemax =~ /^./){ chop($timemax);} else{ $timemax = $infile2[0]; } @infile2=&runcom('pget saextrct timeint'); chop($infile2[0]); print "Input time intervals t1-t2,t3-t4 in seconds (INDEF):[$infile2[0]]"; ($timeint = ); if($timeint =~ /^./){ chop($timeint);} else{ $timeint = $infile2[0]; } @infile2=&runcom('pget saextrct chmin'); chop($infile2[0]); print "Minimum energy bin to include in Spectra (INDEF) or 0-255:[$infile2[0]]"; ($chmin = ); if($chmin =~ /^./){ chop($chmin);} else{ $chmin = $infile2[0]; } @infile2=&runcom('pget saextrct chmax'); chop($infile2[0]); print "Maximum energy bin to include in Spectra (INDEF) or 0-255:[$infile2[0]]"; ($chmax = ); if($chmax =~ /^./){ chop($chmax);} else{ $chmax = $infile2[0]; } @infile2=&runcom('pget saextrct chint'); chop($infile2[0]); print "Input energy intervals to be retained 0-1,2-255 (INDEF):[$infile2[0]]"; ($chint = ); if($chint =~ /^./){ chop($chint);} else{ $chint = $infile2[0]; } @infile2=&runcom('pget saextrct chbin'); chop($infile2[0]); print "Input channels for each bin 0-5,6-255 (INDEF):[$infile2[0]]"; ($chbin = ); if($chbin =~ /^./){ chop($chbin);} else{ $chbin = $infile2[0]; } @infile2=&runcom('pget saextrct ephem'); chop($infile2[0]); print "Input the ephemeris of the phase in seconds (INDEF):[$infile2[0]]"; ($ephem = ); if($ephem =~ /^./){ chop($ephem);} else{ $ephem = $infile2[0]; } @infile2=&runcom('pget saextrct period'); chop($infile2[0]); print "Input the period in seconds, use 0.1 etc. if nec (INDEF):[$infile2[0]]"; ($period = ); if($period =~ /^./){ chop($period);} else{ $period = $infile2[0]; } @infile2=&runcom('pget saextrct phaseint'); chop($infile2[0]); print "Input phase interval 0.0-0.5,0.75-1.0 (INDEF):[$infile2[0]]"; ($phaseint = ); if($phaseint =~ /^./){ chop($phaseint);} else{ $phaseint = $infile2[0]; } } if($answer =~ /^[yY]/){ $tmp_file='@'."outfile_${$}"; $saextrct_string = "saextrct infile='".$tmp_file."' gtiorfile=$gtiorfile " ; $saextrct_string .= "gtiandfile=$gtiandfile gticols='START STOP' "; $saextrct_string .= "outroot=$outroot extenpha='.pha' extenlc='.lc' "; $saextrct_string .= "phasefile=' ' accumulate=$accumulate timecol=$timecol "; $saextrct_string .= "columns='".$columns."' multiple='no' "; $saextrct_string .= "binsz=$binsz mfracexp=$mfracexp tnull=0.0 printmode=$printmode "; $saextrct_string .= "lcmode=$lcmode spmode=$spmode mlcinten=$mlcinten "; $saextrct_string .= "mspinten=$mspinten writesum='-' writemean='-' "; $saextrct_string .= "timemin=$timemin timemax=$timemax "; $saextrct_string .= "timeint='".$timeint."' "; $saextrct_string .= "chmin=$chmin chmax=$chmax "; $saextrct_string .= "chint=$chint chbin=$chbin ephem=$ephem period=$period "; $saextrct_string .= "phaseint=$phaseint obsdate='MJDREF' obstime='TSTART TSTOP' "; $saextrct_string .= "sensecase=no "; $saextrct_string .= "chkit=no clobber=yes negative=IGNORE dryrun=no bailout='no' mode='h' "; } else { $tmp_file='@'."outfile_${$}"; $saextrct_string = " saextrct infile='".$tmp_file."' gtiorfile='-' " ; $saextrct_string .= "gtiandfile='-' gticols='START STOP' "; $saextrct_string .= "outroot=$outroot extenpha='.pha' extenlc='.lc' "; $saextrct_string .= "phasefile=' ' accumulate=$accumulate timecol=$timecol "; $saextrct_string .= "columns='".$columns."' multiple='no' "; $saextrct_string .= "binsz=$binsz mfracexp='INDEF' tnull=0.0 printmode=$printmode "; $saextrct_string .= "lcmode=$lcmode spmode=$spmode mlcinten='INDEF' "; $saextrct_string .= "mspinten='INDEF' writesum='-' writemean='-' "; $saextrct_string .= "timemin='INDEF' timemax='INDEF' "; $saextrct_string .= "timeint='INDEF' "; $saextrct_string .= " chmin='INDEF' chmax='INDEF' "; $saextrct_string .= "chint='INDEF' chbin='INDEF' ephem='INDEF' period='INDEF' "; $saextrct_string .= "phaseint='INDEF' obsdate='MJDREF' obstime='TSTART TSTOP'" ; $saextrct_string .= " sensecase=no "; $saextrct_string .= "chkit='no' clobber='yes' negative='IGNORE' dryrun='no' bailout='no' mode='h' "; } $extenpha = '.pha'; $extenlc = '.lc'; print "\n\nRunning saextrct - be patient, this takes lots of time!\n"; print "Calling SAEXTRCT with the following:\n"; print "$saextrct_string\n"; @result=&runcom($saextrct_string); print "@result"; print "\n\n"; $length_of_array = @result; $i_count=0; for($i_count=0; $i_count <= $length_of_array; $i_count++){ if($result[$i_count] =~ /^Total number of columns output is:/) { @temp_array = split(/:/,$result[$i_count]); chop($temp_array[1]); $temp_holder = $temp_array[1]; $temp_holder--; $temp_holder++; $number_of_columns = $temp_holder; } } print "The number of output columns found: $number_of_columns \n"; print "\n"; print "###########################################################\n"; print "Completed running saextrct\n"; print "Calling FPLOT\n\n"; if($printmode =~ /^both/i){ print "Do you want to plot the light-curve (l), spectra (s), or both (b): [l,s,b]"; $answer2 = ; if($answer2 =~ /^./){ chop($answer2);} else{ print "Defaulting to plotting both...\n"; $answer2 = 'b' } if($answer2 =~ /^[Bb]/){ print "Since you have selected both, lets deal with the LIGHT-CURVE first.\n"; } } if($printmode =~ /^lightcurve/i){ $pltfilelc = "$outroot" . "$extenlc"; $xparmlc = "TIME"; if($lcmode =~ /^sum/i){ $yparmlc = "COUNTS"; }elsif($lcmode =~ /^rate/i){ $yparmlc = "RATE"; }elsif($lcmode =~ /^mean/i){ $yparmlc = "MEAN"; }else { print "ERROR LCMODE can only be SUM, RATE, or MEAN\n"; } } elsif($printmode =~ /^spectrum/i){ $pltfilesp = "$outroot" . "$extenpha"; $xparmsp = "CHANNEL"; if($spmode =~ /^sum/i){ $yparmsp = "COUNTS"; }elsif($spmode =~ /^rate/i){ $yparmsp = "RATE"; }elsif($spmode =~ /^mean/i){ $yparmsp = "MEAN"; }else { print "ERROR SPMODE can only be SUM, RATE, or MEAN\n"; } }elsif($printmode =~ /^both/i){ if($answer2 =~ /^[Ll]/ || $answer2 =~ /^[Bb]/){ $pltfilelc = "$outroot" . "$extenlc"; $xparmlc = "TIME"; if($lcmode =~ /^sum/i){ $yparmlc = "COUNTS"; }elsif($lcmode =~ /^rate/i){ $yparmlc = "RATE"; }elsif($lcmode =~ /^mean/i){ $yparmlc = "MEAN"; }else { print "ERROR LCMODE can only be SUM, RATE, or MEAN\n"; } } if($answer2 =~ /^[Ss]/ || $answer2 =~ /^[Bb]/){ $pltfilesp = "$outroot" . "$extenpha"; $xparmsp = "CHANNEL"; if($spmode =~ /^sum/i){ $yparmsp = "COUNTS"; }elsif($spmode =~ /^rate/i){ $yparmsp = "RATE"; }elsif($spmode =~ /^mean/i){ $yparmsp = "MEAN"; }else { print "ERROR SPMODE can only be SUM, RATE, or MEAN\n"; } } } if($answer2 =~ /^[Ll]/ || $answer2 =~ /^[Bb]/){ print"\nPlotting Light-curve with FPLOT\n"; } if(($number_of_columns > 1) && ($answer2 =~ /^[Ll]/ || $answer2 =~ /^[Bb]/)){ print "Plot all (max 8) columns? (Default: plot first column) [Yes, No]"; chop($answer3 = ); if($answer3 =~ /^[Yy]/){ if($number_of_columns > 8){ print "Fplot can only disply 8 columns!\n"; print "Displaying first 8 values.\n"; $number_of_columns = 8; } $temp_parm=$yparmlc; $i_count=2; while ($i_count <= $number_of_columns){ $temp_parm = "$temp_parm, ".$yparmlc.$i_count; $i_count++; } $yparmlc = $temp_parm; } elsif($answer3 =~ /^[Nn]/){ print "Please enter column numbers to be plotted separated by commas. [2,3,6,8]"; chop($answer4 = ); @col_array = split(/,/,$answer4); for($i_count=0; $col_array[$i_count]; $i_count++){ $temp_holder = $col_array[$i_count]; $temp_holder++; $temp_holder--; $col_array[$i_count]=$temp_holder; } print "User specified list of $i_count columns\n"; $number_input = $i_count-1; if($number_input >= 8){ print "Fplot can only disply 8 columns!\n"; print "Truncating to first 8 values.\n"; $number_input = 7; } if($col_array[0] != 1){ $temp_parm=$yparmlc.$col_array[0]; } else { $temp_parm=$yparmlc; } for($i_count=1; $i_count <= $number_input; $i_count++){ if($col_array[$i_count] == 1){ $temp_parm = "$temp_parm, ".$yparmlc; } else { $temp_parm = "$temp_parm, ".$yparmlc.$col_array[$i_count]; } } $yparmlc = $temp_parm; } else { print "No choice made - defaulting to plotting only the FIRST column.\n"; } } if($answer2 =~ /^[Ll]/ || $answer2 =~ /^[Bb]/){ @infile2=&runcom('pget fplot rows'); chop($infile2[0]); print "Lists of rows:[$infile2[0]]"; ($rows = ); if($rows =~ /^./){ chop($rows);} else{ $rows = $infile2[0]; } @infile2=&runcom('pget fplot device'); chop($infile2[0]); print "Device: /XWindow, /XTerm, /TK, /PS, etc:[$infile2[0]]"; ($device = ); if($device =~ /^./){ chop($device);} else{ $device = $infile2[0]; } @infile2=&runcom('pget fplot pltcmd'); chop($infile2[0]); print "Any legal PLT command:[$infile2[0]]"; ($pltcmd = ); if($pltcmd =~ /^./){ chop($pltcmd);} else{ $pltcmd = $infile2[0]; } $fplot_stringlc = "fplot infile=$pltfilelc xparm=$xparmlc yparm='".$yparmlc."' rows='".$rows."' device='".$device."' pltcmd='".$pltcmd." ' offset=no maxpts=10000 binmode=DEFAULT mode=h"; print "$fplot_stringlc\n"; system($fplot_stringlc); } if($answer2 =~ /^[Ss]/ || $answer2 =~ /^[Bb]/){ print "\nPlotting Spectra with FPLOT\n"; if($number_of_columns > 1){ print "\nFplot can not handle multiple column PHA files properly\n"; print "The default will plot ALL columns on one plot screen,\n"; print "or you can select one using the ROWS option that follows.\n\n"; } @infile2=&runcom('pget fplot rows'); chop($infile2[0]); print "Lists of rows:[$infile2[0]]"; ($rows = ); if($rows =~ /^./){ chop($rows);} else{ $rows = $infile2[0]; } @infile2=&runcom('pget fplot device'); chop($infile2[0]); print "Device: /XWindow, /XTerm, /TK, /PS, etc:[$infile2[0]]"; ($device = ); if($device =~ /^./){ chop($device);} else{ $device = $infile2[0]; } @infile2=&runcom('pget fplot pltcmd'); chop($infile2[0]); print "Any legal PLT command:[$infile2[0]]"; ($pltcmd = ); if($pltcmd =~ /^./){ chop($pltcmd);} else{ $pltcmd = $infile2[0]; } $fplot_stringsp = "fplot infile=$pltfilesp xparm=$xparmsp yparm='".$yparmsp."' rows='".$rows."' device='".$device."' pltcmd='".$pltcmd." ' offset=no maxpts=10000 binmode=DEFAULT mode=h"; print "$fplot_stringsp\n"; system($fplot_stringsp); } print "\n"; print "###########################################################\n"; print "Next file or list of files to be processed? (RETURN to end)\n"; $infile = ; if($infile =~ /^./){ chop($infile); $terminate=0;} else{ print "Terminating.... a list of all files processed is in outfile_${$}\n"; $terminate=1; } until($terminate){ if($infile =~ /^@/ ){ $infile =~ s/^@//; # Remove the @ symbol $origfile = $infile; # Store the filename in origfile open(INPUT_FILE,"$infile") || die "Sorry can't find $infile\n"; # Open the input file open(OUTPUT_FILE,">>outfile_${$}") || die "Sorry can't open outfile_${$}\n"; # Open a unique output file while() { print OUTPUT_FILE $_; # Copy files from INFILE to OUTPUT } close(INPUT_FILE); # We are finished with the input file. close(OUTPUT_FILE); # Close up the output file too. print "output file created was outfile_${$}\n"; } else { $origfile = $infile; open(OUTPUT_FILE,">>outfile_${$}") || die "Sorry can't open outfile_${$}\n"; # open a unique output file print OUTPUT_FILE "$infile \n"; # Copy the filename to output file close(OUTPUT_FILE); # Close the output file. } print "Calling saextrct\n"; system($saextrct_string); print "Calling fplot\n"; if($answer2 =~ /^[Ll]/ || $answer2 =~ /^[Bb]/){ print "Plotting Light-curve\n"; system($fplot_stringlc); } if($answer2 =~ /^[Ss]/ || $answer2 =~ /^[Bb]/){ print "Plotting Spectra\n"; system($fplot_stringsp); } print "Next file or list of files to be processed? (RETURN to end)\n"; $infile = ; if($infile =~ /^./){ chop($infile); $terminate=0;} else{ print "Terminating.... a list of all files processed is in outfile_${$}\n"; $terminate=1; } } @result=&runcom("pset saextrct infile='".$origfile."' "); print "Do you want to save this file? [Yes,No]"; chop($answer10 = ); if($answer10 =~ /^[Yy]/){ } else{ print "Deleting outfile_${$}\n"; unlink("outfile_${$}") || print "Having trouble deleting outfile_${$}\n"; # Remove the output file if not told to save it. }