#! /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/make2region # 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/make2region." 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/make2region." 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 # Authors: Ziqin Pan # Description: make2region creates and displays regions on POW window and save # them as a region file. # Modifiction: Original created on 12/08/04 # use Getopt::Std; use Math::Trig; use HEACORE::HEAINIT; use HEACORE::HEAUTILS; use HEACORE::PIL; getopt(); if (defined $opt_h) { print</dev/null`; if ($result !~ /heraXPA/) { $heraXPA = $pow; } print "Try to access to POWplot on $pow. Please wait!\n"; $lbx ="NULL"; while (($lbx =~ /NULL/) || ($lbx =~ /XPA/i) || ($lbx =="")) { if ($count > $val[6] ) { print "Access to POW plot timeout\n"; kill 9, $proc_id; return 1; } sleep 5; $value = `xpaget $pow bounds 2>/dev/null`; ($lbx,$lby,$rtx,$rty) = split(/ /,$value,4); chop($lbx); $count =$count+5; } ($lbx,$lby,$rtx,$rty) = split(/ /,$value,4); if ( $val[3] eq "def") { $val[3] = ($lbx+$rtx)/2.; if ($val[3] < 0 ) { $val[3] =-$val[3]; $ah = $val[3]/15.; $h =int($ah); $am = 60.*($ah-$h); $m =int($am); $s =int(60.*($am -$m)); $h =0-$h; $val[3] = join(':',$h,$m,$s); } else { $ah = $val[3]/15.; $h =int($ah); $am = 60.*($ah-$h); $m =int($am); $s =int(60.*($am -$m)); $val[3] = join(':',$h,$m,$s); } } else { } if ($val[4] eq "def") { $val[4] = ($lby+$rty)/2.; if ($val[4] <0) { $val[4] =-$val[4]; $ah = $val[4]; $h =int($ah); $am = 60.*($ah-$h); $m =int($am); $s =int(60.*($am -$m)); $h =0-$h; $val[4] = join(':',$h,$m,$s); } else { $ah = $val[4]; $h =int($ah); $am = 60.*($ah-$h); $m =int($am); $s =int(60.*($am -$m)); $val[4] = join(':',$h,$m,$s); } } else { } if ( $val[5] eq "def" ) { $val[5] = ($rty -$lby)/8.*60; if( $val[5] <0) { $val[5] =-$val[5] ; } } $helpfile = "$helpdir/make2region_1.html"; if (-e $outputfile1 ) { system("rm -f $outputfile1"); } $region ="fk5; circle($val[3],$val[4],$val[5]')"; system("xpaset -p $pow scope 100 100"); system("xpaset -p $pow regionTool -open"); system("xpaset -p $pow regionName $outputfile1"); system("echo \"$region\" |xpaset $pow regions"); ######################### # Pan Chai - XPA entry point heraXPA will now handle all help pages. ######################### system("echo \"$helpfile\" |xpaset $heraXPA helpPage"); #system("cat \"$helpfile\" |xpaset $heraXPA helpPage"); $return_value= `xpaget $pow regionTool -wait`; ######################### # Pan Chai - wait command will now returned immediately. Scripts needs to check every # 2 seconds to see if the status has changed. ######################### while ($return_value eq "NOT_YET") { sleep 2; $return_value= `xpaget $pow regionTool -wait`; } system("xpaset -p $pow regionTool -close"); ######################### # Pan Chai - close of helpPage is just withdraw the widget ######################### system("xpaset -p $heraXPA helpPage -close"); if ( !(-e $outputfile1) ) { $helpfile = "$helpdir/make2region_2.html"; ######################### # Pan Chai - XPA entry point heraXPA will now handle all help pages. ######################### system("echo \"$helpfile\" |xpaset $heraXPA helpPage 2>/dev/null"); #system("cat \"$helpfile\" |xpaset $heraXPA helpPage 2>/dev/null"); print "Error:source region file has not been saved!\n"; exit 1; } if (-e $outputfile2 ) { system("rm -f $outputfile2"); } $helpfile = "$helpdir/make2region_3.html"; ######################### system("xpaset -p $pow regionTool -open"); system("xpaset -p $pow regionName $outputfile2"); system("echo \"$region\" |xpaset $pow regions"); ######################### # Pan Chai - XPA entry point heraXPA will now handle all help pages. ######################### system("echo \"$helpfile\" |xpaset $heraXPA helpPage"); #system("cat \"$helpfile\" |xpaset $heraXPA helpPage"); $return_value= `xpaget $pow regionTool -wait`; ######################### # Pan Chai - wait command will now returned immediately. Scripts needs to check every # 2 seconds to see if the status has changed. This will work with old way # since the return_value in old way will return either 0 or 1 after user inputs. ######################### while ($return_value eq "NOT_YET") { sleep 2; $return_value= `xpaget $pow regionTool -wait`; } system("xpaset -p $pow close"); ######################### # Pan Chai - close of helpPage is just withdraw the widget ######################### if ( $heraXPA !~ /^pow$/ ) { system("xpaset -p $heraXPA helpPage -close"); } } return 0; } sub make2region_getpar { if (PILGetString("infile",$infile)) { print "Error to get parameter \"infile\"\n"; exit(-1) } if (PILGetString("regionfile1",$regionfile1)){ print "Error to get parameter \"regionfile1\"\n"; exit(-1) } if (PILGetString("regionfile2",$regionfile2)){ print "Error to get parameter \"regionfile2\"\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 (PILGetReal("timeout",$timeout)){ print "Error to get parameter \"timeout\"\n"; exit(-1) } }