#!/usr/bin/perl use strict; use warnings; # Makes PI vs. BETA_CORR and XDSP_CORR vs. images for event files supplied by user. # # # Requirements: # 0) must be in same directory as input event files. # 1) text file which lists the events files to process, one per line chomp ($currDir = `pwd`); my $unittype = 'N'; my $currLine; my @numbers; my @files; my $file; my $r1_evt; my $r2_evt; my $position_file=$currDir."/"."filler"; my $status=0; my $process_r1 = 0; my $process_r2 = 0; my $j; my $inst; my $coordflag; # Set the environment variables. my @res1; my $baseDir; if ($currDir =~ m/proc/) { @res1 = split(/proc/, $currDir); $baseDir = $res1[0]; } if (-d $baseDir."ODF") { $ENV{SAS_ODFPATH} = $baseDir."ODF"; my $sumsas = glob ($baseDir."ODF/*SUM.SAS"); $ENV{SAS_ODF} = $sumsas; $ENV{SAS_CCF} = $baseDir."ODF/ccf.cif"; } if (-d $baseDir."odf") { $ENV{SAS_ODFPATH} = $baseDir."odf"; my $sumsas = glob ($baseDir."odf/*SUM.SAS"); $ENV{SAS_ODF} = $sumsas; $ENV{SAS_CCF} = $baseDir."odf/ccf.cif"; } # On to the main event. print "Enter the file listing the event files: "; chomp (my $event_files = <> ); $event_files = $currDir."/".$event_files; print "Making banana plots. \n"; if (-e $event_files) { open(EVENTS, "<", $event_files); while ($currLine = ) { $currLine = $currDir."/".$currLine; chomp ($currLine); @files = split (/\s/, $currLine); foreach $file (@files) { # Check the headers to find out which instruments we need. $inst = $currDir."/"."instru.list"; `fkeyprint $file instrume outfile=$inst`; open (INSTRU, "<", $inst); while ($currLine = ) { if ($currLine =~ m/INSTRUME= 'RGS1 '/ ) { $r1_evt = $file; $process_r1 = 1; } if ($currLine =~ m/INSTRUME= 'RGS2 '/ ) { $r2_evt = $file; $process_r2 = 1; } } close (INSTRU); `rm $inst`; } } close (EVENTS); } else { print "No events file found; stopping here. \n" ; exit; } if (! -d $currDir.'/image') { `mkdir image`; } my $r1_evt_cp; my $r2_evt_cp; if ($process_r1 eq 1) { $r1_evt_cp = "image/r1_evt_cp"; `cp $r1_evt $r1_evt_cp`; } if ($process_r2 eq 1) { $r2_evt_cp = "image/r2_evt_cp"; `cp $r2_evt $r2_evt_cp`; } chdir $currDir.'/image'; if ($process_r1) { print "Making the RGS1 images... \n"; `evselect table=r1_evt_cp withimageset=yes imageset=r1_pi_bc_image.fits xcolumn=BETA_CORR ycolumn=PI imagebinning=imageSize ximagesize=600 yimagesize=600`; `evselect table=r1_evt_cp withimageset=yes imageset=r1_xd_bc_image.fits xcolumn=BETA_CORR ycolumn=XDSP_CORR imagebinning=imageSize ximagesize=600 yimagesize=600`; } if ($process_r2) { print "Making the RGS2 images... \n"; `evselect table=r2_evt_cp withimageset=yes imageset=r2_pi_bc_image.fits xcolumn=BETA_CORR ycolumn=PI imagebinning=imageSize ximagesize=600 yimagesize=600`; `evselect table=r2_evt_cp withimageset=yes imageset=r2_xd_bc_image.fits xcolumn=BETA_CORR ycolumn=XDSP_CORR imagebinning=imageSize ximagesize=600 yimagesize=600`; } # Next to godliness. if ($process_r1) { `rm r1_evt_cp`; } if ($process_r2) { `rm r2_evt_cp`; } print "Done. \n";