#! /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/xsl_suzaku_xis_rebinspec # 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/xsl_suzaku_xis_rebinspec." 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/xsl_suzaku_xis_rebinspec." 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! #------------------------------------------------------------------------------- #! /usr/bin/perl # This script rebins a Suzaku XIS spectrum then use grppha to set the bad channels $version ="1.00"; $date ="2008-03-17"; $author = "kaa"; # define the binning breaks $chan1 = 700; $chan2 = 2696; # set the speed (to match xsl_suzaku_xis_makeresp) # The three speed options are as follows : # fast : channel binning 2x then 4x from $chan1 and 8x from $chan2 # medium : channel binning 1x then 2x from $chan1 and 4x from $chan2 # slow : no channel binning $speed = "medium"; if(@ARGV < 1 || @ARGV > 3) { print "\n usage : xsl_suzaku_xis_rebinspec infile outfile echo?\n\n"; print "Runs rbnpha to bin up infile and return outfile\n"; print "them using marfrmf then optionally rebins the response using rbnrmf\n\n"; exit(0); } $filename = $ARGV[0]; $outfile = $ARGV[1]; $echo = "no"; if ( @ARGV >= 3 && $ARGV[2] eq "yes" ) { $echo = "yes"; } $dot = index($filename,"."); $rootname = substr($filename, 0, $dot); $tmpfile = $rootname . ".tmp"; # set up the text file needed to do the rebinning $chan1_1 = $chan1 - 1; $chan2_1 = $chan2 - 1; if ( $speed eq "fast" ) { open(TMPFILE,">chanfile.txt"); print TMPFILE "0 $chan1_1 2\n"; print TMPFILE "$chan1 $chan2_1 4\n"; print TMPFILE "$chan2 4095 8\n"; close(TMPFILE); } elsif ( $speed eq "medium" ) { open(TMPFILE,">chanfile.txt"); print TMPFILE "0 $chan1_1 1\n"; print TMPFILE "$chan1 $chan2_1 2\n"; print TMPFILE "$chan2 4095 4\n"; close(TMPFILE); } # rebin the input spectrum file if the medium or fast options are given if ( $speed eq "fast" || $speed eq "medium" ) { $command = "rbnpha infile=$filename binfile=chanfile.txt outfile=$tmpfile properr=yes clobber=yes"; if ( $echo eq "yes" ) { print $command,"\n"; } system($command); } else { rename($filename, $tmpfile); } # use grppha to set the default bad channels if ( $speed eq "fast" ) { $grpstr = "\"bad 0-40,822-1023&exit\""; } elsif ( $speed eq "medium" ) { $grpstr = "\"bad 0-81,1645-2047&exit\""; } elsif ( $speed eq "slow" ) { $grpstr = "\"bad 0-81,3290-4095&exit\""; } $command = "grppha infile=$tmpfile outfile=$outfile comm=$grpstr chatter=0"; if ( $echo eq "yes" ) { print $command,"\n"; } system($command); # tidy up temporary file if ( $debug eq "no" ) { unlink("chanfile.txt"); unlink("$tmpfile"); }