#! /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/exopha # 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/exopha." 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/exopha." 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 use Getopt::Std; require "interface.pl"; require "utils.pl"; # EXOPHA # This program will prompt the user for information to be included in # the call to the ascii2pha FTOOL. This program is intended strictly # for EXOSAT so it will assume certain default values. The inputs can also # be given on the command line. # # This is the command line syntax # # exopha -o outfile -r rate -e error -i instrume -f filter -x exposure # # where: # outfile - output FITS file # rate - count rate # error - error of count rate # instrume - instrument in use (CMA1 or CMA2) # filter - filter in use (3lx, 4lx, Al/P, Bor, PPL) # exposure - exposure time in seconds # # Some of the parameters are defined in the script and don't have to be # input by the user they are: # # telescope=EXOSAT # areascal=86.4 # detnam=" " # infile = ascii_cma.txt # chanpres = no # dtype = 2 # qerror = yes # rows= - # fchan = 1 # tlmin = 1 # detchans = 1 # equinox=1950.0 # # These are the default values # $telescope="EXOSAT"; $area_scal=86.4; $detnam="\" \" "; # Detector name $chat=9; $clobber="no"; $equinox=1950.0; $command_line=0; $runfile="exopharun"; $in_file="ascii_cma.txt"; $chanpres="no"; # Channel data present $dtype=2; # Input datatype 1=counts 2=rate $qerror="yes"; # Errors present? $rows="-"; # List of lines to be read in ASCII file $fchan=1; # First Channel Number present in ASCII file $tlmin=1; # First legal detector channel $detchans=1; # Number of legal detector channels getopts('o:r:e:i:f:x:yh'); #** Note for using Getopts ** # all arguments in Getopts that are followed by a colon require an argument # Example: # h as written above therefore doesn't require an argument # # Example 2: # &Getopts('cde:hmqvw:x:'); # e and w and x require arguments # c,d,e,h,m,q,and v do not #**************************** if ( defined $opt_h){ print < exopha -o output.pha -r 2e-3 -e 1e-3 -i cma1 -f 3Lx -x 2000 EOHELP1 &exit_wish; } open (TEMP,">$runfile"); # Read Command Line Arguments or Prompt User #Output FITS file name if(defined $opt_o){ $out_file=$opt_o; $command_line=1; }else{ $out_file= &getScalar("Enter output FITS file name"); } # Clobber any existing output file? if(defined $opt_y){ $clobber="yes"; }else{ #check if output file already exists if( -e $out_file){ $clobber=&MessageYesOrNo('n',"Output file already exists! Do you want to overwrite it?\n"); if($clobber){ $clobber="yes"; }else{ $clobber="no"; `rm $runfile`; die "exopha: $out_file unchanged.\n"; } } } # Count rate if(defined $opt_r){ $rate=$opt_r; }else{ $rate=&getScalar("Count rate",1,"rate"," "); if($rate == -999){ &exit_wish; } } $notrate=1; while($notrate){ if($rate !~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([DdEe]([+-]?\d+))?$/ ){ print("The count rate is not valid. Enter count rate.\n"); $rate=&getScalar("Count rate, -999 to quit",1,"rate"," "); if($rate == -999){ &exit_wish; } }else{ $notrate=0; } } # Count rate Error if(defined $opt_e){ $error=$opt_e; }else{ $error=&getScalar("Error",1,"error"," "); if($error == -999){ &exit_wish; } } $noterr=1; while($noterr){ if($error !~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([DdEe]([+-]?\d+))?$/ ){ print("The error is not valid. Enter error.\n"); $error=&getScalar("Error, -999 to quit",1,"error"," "); if($error == -999){ &exit_wish; } }else{ $noterr=0; } } #Instrument in use [CMA1 or CMA2] if(defined $opt_i){ $instrume=$opt_i; }else{ $instrume=&getScalar("Instrument in use (CMA1 or CMA2)"); } $instrume =~ tr/A-Z/a-z/; $notinst=1; if($instrume =~ /^(cma1|cma2)$/) { # print("The instrument you selected is ok!\n"); }else{ while($notinst){ print("Instrument incorrect. Please select another instrument \n"); $instrume=&getScalar("CMA1 or CMA2, -999 to quit"); $instrume =~ tr/A-Z/a-z/; if($instrume =~ /^(cma1|cma2)$/) { $notinst=0; }elsif($instrume == -999){ &exit_wish; } } } #Filter in use [3Lx, 4Lx, Al/P, Bor, PPL] if(defined $opt_f){ $filter=$opt_f; }else{ $filter=&getScalar("Filter in use (3Lx, 4Lx, Al/P, Bor, PPL)"); } $filter =~ tr/A-Z/a-z/; $notfilt=1; if($filter =~ /^(3lx|4lx|al\/p|bor|ppl)$/) { # print("The filter you selected is ok!\n"); }else{ while($notfilt){ print("Filter incorrect. Please select another filter \n"); $filter=&getScalar("3Lx, 4Lx, Al/P, Bor, PPL, -999 to quit"); $filter =~ tr/A-Z/a-z/; if($filter =~ /^(3lx|4lx|al\/p|bor|ppl)$/) { $notfilt=0; }elsif($filter == -999){ &exit_wish; } } } #Exposure time in seconds if(defined $opt_x){ $exposure=$opt_x; }else{ $exposure=&GetNumber("Exposure time in seconds",1,"exposure"," "); if($exposure == -999){ &exit_wish; } } if($exposure !~ /^(-?\d+\.?\d*|-?\.\d+)$/ ){ print("The exposure time is not valid. Enter exposure time.\n"); $exposure=&GetNumber("Exposure time",1,"exposure"," "); if($exposure == -999){ &exit_wish; } } # Create ASCII input file ascii_cma.txt open (ASCII_INPUT,">$in_file"); print ASCII_INPUT " $rate $error \n"; close ASCII_INPUT; #print "ascii2pha exposure=$exposure areascal=$area_scal infile=$in_file outfile=$out_file chanpres=$chanpres dtype=$dtype qerror=$qerror rows=$rows fchan=$fchan tlmin=$tlmin detchans=$detchans telescope=$telescope detnam=$detnam instrume=$instrume filter=$filter chatter=$chat clobber=$clobber equinox=$equinox\n"; print TEMP ("ascii2pha exposure=$exposure areascal=$area_scal infile=$in_file outfile=$out_file chanpres=$chanpres dtype=$dtype qerror=$qerror rows=$rows fchan=$fchan tlmin=$tlmin detchans=$detchans telescope=$telescope detnam=$detnam instrume=$instrume filter=$filter chatter=$chat clobber=$clobber equinox=$equinox\n"); close TEMP; chmod 0777, $runfile; @output=&runcom("$runfile > outerr"); # print "@output \n"; if($output[0] =~ /Error/i){ open(ERR,"outerr"); while($line=){ print("$line"); } close ERR; `rm outerr`; } open(ERR,"outerr"); while($line=){ print("$line"); } close ERR; `rm outerr`; `rm $in_file`; `rm $runfile`;