#! /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/xtefilt # 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/xtefilt." 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/xtefilt." 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 # # # Mike Tripicco # 31 Jan 1996 # XTE GSFC/NASA # # version 1.3 04 June 1996 - changed handling of timestep/deltat since # it is now a prompted-for parameter in fcollect # # version 1.4 21 Jan 1997 - modified inspection of stderr file to allow # for "ld.so:" type warnings # # version 1.5 16 Jun 1998 - changed help section to reflect new features # in fcollect/xtederive # # version 1.6 15 Jul 1998 - modified "ridiculous kludge" to be a little less # ridiculous; it will now properly identify the # correct directory/FIST* file to modify in nonstd # cases (eg, mixed production and realtime data) # # version 1.7 12 Feb 1999 - added flexibility to -p option (can specify FMI file # as long as it begins "FMI") to mirror changes made # to fcollect (v5.2) # # version 1.8 01 Jul 2008 - added '-b' (PCA breakdown file) option to pass to # fcollect (v5.8) # if ($VMS){ die("Sorry, this Perl script is not operational under VMS"); }else{ use Getopt::Std; #============================================================# # # See if there are any flags: # $bailout="bailout"; getopts('a:b:f:g:o:p:t:chis'); if (defined $opt_h) { print <); if($obsid =~ /^./ ){ chop($obsid); } else{ $obsid = $dum[0]; } } if(defined $opt_p) { print "Pathname provided was: $opt_p \n"; $fdpath = $opt_p; } else { @dum=&runcom('pget fcollect fdpath'); chop($dum[0]); print "Path to XTE FITS Database: [$dum[0]] "; ($fdpath = ); if($fdpath =~ /^./ ){ chop($fdpath); } else{ $fdpath = "$dum[0]"; } } if(defined $opt_a) { print "AppID file provided was: $opt_a \n"; $appidfile = $opt_a; } else { @dum=&runcom('pget fcollect appidfile'); chop($dum[0]); print "File containing AppID list: [$dum[0]] "; ($appidfile = ); if($appidfile =~ /^./ ){ chop($appidfile); } else{ $appidfile = "$dum[0]"; } } if(defined $opt_t) { print "Timestep provided was: $opt_t \n"; $deltat = $opt_t; } else { @dum=&runcom('pget fcollect deltat'); chop($dum[0]); print "Timestep: [$dum[0]] "; ($deltat = ); if($deltat =~ /^./ ){ chop($deltat); } else{ $deltat = "$dum[0]"; } } @dum=&runcom('pget fcollect outfile'); chop($dum[0]); $outfile=$dum[0]; #@dum=&runcom('pget fcollect deltat'); #chop($dum[0]); #$deltat=$dum[0]; @dum=&runcom('pget fcollect maxgap'); chop($dum[0]); $maxgap=$dum[0]; @dum=&runcom('pget fcollect clobber'); chop($dum[0]); $clobber=$dum[0]; if(defined $opt_c) { $clobber="yes"; print "enabling clobber\n"; } else { $clobber="no"; } if(defined $opt_b) { $breakfile=$opt_b; } else { $breakfile="NONE"; } # # Normally, we'll accept whatever is in the fcollect.par # file unless overridden on the command line. In this case, # we REALLY don't want to clobber files unless explicitly # asked for via the -c switch. # #if(defined $opt_t) { # print "timestep provided was: $opt_t \n"; # $deltat=$opt_t; #} if(defined $opt_g) { print "maxgap provided was: $opt_g \n"; $maxgap=$opt_g; } if(defined $opt_f) { print "output filename provided was: $opt_f \n"; $outfile=$opt_f; } if(defined $opt_s) { $stdprod="yes"; $outfile="XFD"; if(defined $opt_f) { print "Sorry, overriding your output filename (since\n"; print "files written in stdprod/ must have standard names)\n"; } } else { $stdprod="no"; } if(defined $opt_i) { $confirm="yes"; print "xtefilt will prompt before modifying stdprod index file\n"; } else { $confirm="no"; } if ($fdpath !~ /FMI/) { $fmifile = $fdpath."/FMI"; } else { $fmifile = $fdpath; substr($fdpath,index($fdpath,'/FMI')) = ''; } #print "\n##########################################\n"; $fcollect_string = "fcollect obsid='$obsid' "; #$fcollect_string .= "fdpath='$fdpath' appidfile='$appidfile' "; $fcollect_string .= "fdpath='$fmifile' appidfile='$appidfile' "; $fcollect_string .= "outfile='$outfile' deltat=$deltat "; $fcollect_string .= "breakfile='$breakfile' "; $fcollect_string .= "maxgap=$maxgap clobber='$clobber' mode='ql'"; print "\nabout to run:\n $fcollect_string\n"; if ($VMS){ @result=&runcom($fcollect_string); } else{ @result=system($fcollect_string); } if ($result[0] != 0){ die "FCOLLECT failed ($result[0])"; } @dum=&runcom('pget fcollect fname'); chop($dum[0]); $fname=$dum[0]; $xtederive_string = "xtederive infile='$fname' clobber='$clobber' "; print "\nabout to run:\n $xtederive_string\n"; $xdflag=0; if ($VMS){ @result=&runcom($xtederive_string); } else{ system("$xtederive_string 2> /tmp/xterr$$"); open(ERRFIL,"/tmp/xterr$$"); if (!eof(ERRFIL)) { # # Skip any lines containing "ld.so" or which are all blanks. # If anything remains there's been a real error - print it # and prepare to die... # while ( ($_ = ) =~ /(ld\.so|^\s*\n$)/ ) { ; } if ( $_ ) { $xdflag=1; print $_; while(){ print $_; } } } close(ERRFIL); unlink("/tmp/xterr$$"); } if ($xdflag == 1){ die "XTEDERIVE failed"; } unlink($fname); $fchecksum_string = "fchecksum infile='$fname.xfl' update+ datasum+"; #print "\nabout to run:\n $fchecksum_string\n"; print "\nUpdating checksums on $fname.xfl\n"; @result=&runcom($fchecksum_string); if ($stdprod eq "yes"){ # # The next bit is a ridiculous kludge to determine the name of the # Standard Products directory, the FIST index file, and the number # rows in the latter. # # @result=&runcom("fdump infile='$fdpath/FMI' outfile=STDOUT columns=Std_Prod_Index_File rows='-' prhead=no page=no"); # @foo=grep(/$obsid\/FIST/,@result); # @result=&runcom("fdump infile='$fdpath/FMI' outfile=STDOUT columns=ObsId rows='-' prhead=no page=no"); @result=&runcom("fdump infile='$fmifile' outfile=STDOUT columns=ObsId rows='-' prhead=no page=no"); @obsline=grep(/$obsid\s/,@result); @tmp=split(' ',$obsline[0]); $rownum=$tmp[0]; # @result=&runcom("fdump infile='$fdpath/FMI' outfile=STDOUT columns=Std_Prod_Index_File rows='$rownum' prhead=no page=no"); @result=&runcom("fdump infile='$fmifile' outfile=STDOUT columns=Std_Prod_Index_File rows='$rownum' prhead=no page=no"); if ($#foo == -1){ @foo=grep(/FIST/,@result); } @bar=split(' ',$foo[0]); $spidx=$fdpath . "/" . $bar[1] . "[1]"; $spidx0=$fdpath . "/" . $bar[1]; @dum=split(/\//,$bar[1]); $obsdir=$fdpath . "/" . join('/',@dum[0 .. $#dum-1]); @result=&runcom("fkeyprint infile='$spidx' outfile=STDOUT keynam=NAXIS2"); @foo=grep(/=/,@result); @bar=split(' ',$foo[0]); $nrows=$bar[2]; $ffloc="stdprod/$fname.xfl"; # unless (-e "$obsdir/stdprod/$fname.xfl" && ($clobber eq "no")){ @result=system("mv $fname.xfl $obsdir/stdprod/$fname.xfl"); if ($result[0] != 0){ die "mv failed ($fname.xfl to $obsdir/stdprod/$fname.xfl)($result[0])"; } print "\nMoved $fname.xfl into $obsdir/stdprod/\n"; print "\nReady to write '$ffloc' into all $nrows rows\n"; print "of the 'Filter_File' column in the index file[ext#]:\n"; print "$spidx\n"; if ($confirm eq "yes"){ $doit = &yesOrNo("\nContinue?"); }else{ $doit = 1; } if ($doit){ print "\n"; for (1 .. $nrows) { print "updating row $_\n"; $fpt_string="fpartab value='$ffloc' fitsfile='$spidx' "; $fpt_string=$fpt_string . "column='Filter_File' row='$_'"; @result=&runcom($fpt_string,$bailout,$fpt_string); } print "\nupdating checksums..."; $fcksm_string="fchecksum infile='$spidx0' update+ datasum+"; @result=&runcom($fcksm_string,$bailout,$fcksm_string); print "done\n"; } }else{print "Sorry, clobber flag not set, can't overwrite files\n";} } print "\n##########################################\n"; print "XTEFILT finished \n"; } sub bailout{ unlink("$obsdir/stdprod/$fname.xfl"); die("Fatal Error in $_[0]"); }