#! /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/pspcxspec # 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/pspcxspec." 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/pspcxspec." 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 ##!/usr1/local/bin/perl use Getopt::Std; use Astro::FITS::CFITSIO qw( :shortnames :constants ); use HEACORE::HEAINIT; use HEACORE::HEAUTILS; use HEACORE::PIL; getopt(); if (defined $opt_h) { print</dev/null`; if ($result !~ /heraXPA/) { $heraXPA = $pow; } if ( !(-e $srcregfile) ) { print "Error:source region file has not been saved!\n"; exit 1; } print "Select region done\n"; # if ($return_value >0) { # return $return_value; # } @list = split(/\//,$eventsfile); $eventsfile = $list[$#list]; # print "filter region $srcregfile \n"; # system("cat $srcregfile"); # print "filter region $backregfile \n"; # system("cat $backregfile"); # system("echo \"$help\" |xpaset $pow helpPage 2>/dev/null"); open FD,">comfile.xco"; print FD "\n"; print FD "set datadir ./\n"; print FD "read events $eventsfile reset_miss=yes\n"; if ( -e $timerngfile ) { print FD "filter time file \"$timerngfile\" \n" } print FD "filter region $srcregfile \n"; print FD "extract spectrum \n"; print FD "save spectrum $srcphafile group_spectrum=yes\n\n"; print FD "clear region\n\n"; if ( -e $backregfile ) { print FD "filter region $backregfile \n"; print FD "extract spectrum \n"; print FD "save spectrum $backphafile group_spectrum=yes\n\n"; } print FD "quit \n\n\n"; close FD; print "Run xselect \@comfile "; system("xselect \@comfile"); system ("rm -rf comfile.xco"); # system("echo \"$help\" |xpaset $pow helpPage"); print "Run pcarf $srcphafile CALDB $srcarffile CALDB\n"; system("pcarf $srcphafile CALDB '!$srcarffile' CALDB"); # system("fkeypar $srcarffile\[1\] RESPFILE\n"); system("fkeypar $srcarffile+1 RESPFILE\n"); $tmprmffile = `pquery fkeypar value`; $tmprmffile =~ s/\'//g; chop ($tmprmffile); print "cp $tmprmffile $srcrmffile\n"; system("cp $tmprmffile $srcrmffile"); system("fparkey $srcrmffile $srcphafile\[1\] RESPFILE add=yes"); system("fparkey $srcarffile $srcphafile\[1\] ANCRFILE add=yes"); system("fparkey $backphafile $srcphafile\[1\] BACKFILE add=yes"); open FD,">comfile.xcm"; print FD "data $srcphafile\n"; # if ( -e $backphafile ) { # print FD "backgrnd $backphafile\n"; # } # print FD "response $srcrmffile\n"; # print FD "arf $srcarffile\n"; print FD "show\n"; print FD "cpd $device \n\n"; print FD "ignore bad \n\n"; print FD "setplot energy \n\n"; print FD "plot data \n\n"; close FD; $helpfile = "$helpdir/pspcxspec_1.html"; #system("cat $helpfile |xpaset $pow helpPage 2>/dev/null"); system("echo \"$helpfile\" |xpaset $heraXPA helpPage 2>/dev/null"); print "Run xspec - comfile.xcm\n"; system("xspec - comfile.xcm"); # system ("rm -rf comfile.xcm $srcphafile $backphafile $srcarffile $tmpimgfile "); # system ("rm -rf comfile.xcm $srcphafile $backphafile $srcarffile $tmpimgfile "); system ("rm -rf comfile.xcm $tmpimgfile "); return 0; } sub pspcxspec_getpar { if (PILGetString("infile",$infile)) { print "Error to get parameter \"infile\"\n"; exit(-1); } if (PILGetString("xcol",$xcol)) { print "Error to get parameter \"xcol\"\n"; exit(-1); } if (PILGetString("ycol",$ycol)) { print "Error to get parameter \"ycol\"\n"; exit(-1); } if (PILGetString("ra",$ra)){ print "Error to get parameter \"ra\"\n"; exit(-1); } if (PILGetString("dec",$dec)){ print "Error to get parameter \"dec\"\n"; exit(-1); } if (PILGetString("radius",$radius)){ print "Error to get parameter \"radius\"\n"; exit(-1); } if (PILGetString("bin",$bin)){ print "Error to get parameter \"bin\"\n"; exit(-1); } if (PILGetString("tbin",$tbin)){ print "Error to get parameter \"tbin\"\n"; exit(-1); } if (PILGetString("srcregfile",$srcregfile)){ print "Error to get parameter \"srcregfile\"\n"; exit(-1); } if (PILGetString("backregfile",$backregfile)){ print "Error to get parameter \"backregfile\"\n"; exit(-1); } if (PILGetString("timerngfile",$timerngfile)){ print "Error to get parameter \"timerngfile\"\n"; exit(-1); } if (PILGetString("srcphafile",$srcphafile)){ print "Error to get parameter \"srcphafile\"\n"; exit(-1); } if (PILGetString("backphafile",$backphafile)){ print "Error to get parameter \"backphafile\"\n"; exit(-1); } if (PILGetString("srcarffile",$srcarffile)){ print "Error to get parameter \"srcarffile\"\n"; exit(-1); } if (PILGetString("srcrmffile",$srcrmffile)){ print "Error to get parameter \"srcarffile\"\n"; exit(-1); } if (PILGetString("tmpimgfile",$tmpimgfile)){ print "Error to get parameter \"tmpimgfile\"\n"; exit(-1); } if (PILGetString("device",$device)){ print "Error to get parameter \"device\"\n"; exit(-1); } if (PILGetReal("timeout",$timeout)){ print "Error to get parameter \"timeout\"\n"; exit(-1); } }