#!/usr/bin/perl use strict; use warnings; # # Makes light curves for the event files that are input. # # Requirements: # 0) must be in same directory as input event files. # 1) text file which lists the events file(s) to process, one per line # # Set the environment variables. my $currLine; my @files; my $file; my $inst; my $r1_evt; my $r2_evt; my $process_r1 = 0; my $process_r2 = 0; my $r1_scrli; my $r2_scrli; my @res1; my $baseDir; my $currDir; chomp ($currDir = `pwd`); 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"; } # # Get important information. # print "Enter the file listing the event file(s): "; chomp (my $event_file = <> ); $event_file = $currDir."/".$event_file; my $lcbin = 0 ; print "Please enter the size of the time bins in seconds for the light curves. \n "; chomp ($lcbin = <>) ; # Check the headers to find out which instruments we need. if (-e $event_file) { open(EVENTS, "<", $event_file); while ($currLine = ) { $currLine = $currDir."/".$currLine; chomp ($currLine); @files = split (/\s/, $currLine); foreach $file (@files) { $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. \n" ; exit; } # # Make the light curves. # print "Making light curves. \n"; if (! -d $currDir.'/lightcurve') { `mkdir lightcurve`; } my $r1_evt_cp; my $r2_evt_cp; my $r1_srcli = glob ("*R1*SRCLI*"); my $r2_srcli = glob ("*R2*SRCLI*"); my $r1_srcli_cp; my $r2_srcli_cp; if ($process_r1 eq 1) { $r1_evt_cp = $currDir."/lightcurve/r1_evt_cp"; $r1_srcli_cp = $currDir."/lightcurve/r1_srcli_cp"; `cp $r1_evt $r1_evt_cp`; `cp $r1_srcli $r1_srcli_cp`; } if ($process_r2 eq 1) { $r2_evt_cp = $currDir."/lightcurve/r2_evt_cp"; $r2_srcli_cp = $currDir."/lightcurve/r2_srcli_cp"; `cp $r2_evt $r2_evt_cp`; `cp $r2_srcli $r2_srcli_cp`; } chdir $currDir.'/lightcurve'; if ($process_r1 eq 1) { `evselect table=r1_evt_cp withrateset=yes rateset='r1_ltcrv_bin$lcbin.fits' maketimecolumn=yes timebinsize=$lcbin makeratecolumn=yes expression='(CCDNR==9)&&(REGION(r1_srcli_cp:RGS1_BACKGROUND,M_LAMBDA,XDSP_CORR))'`; } if ($process_r2 eq 1) { `evselect table=r2_evt_cp withrateset=yes rateset='r2_ltcrv_bin$lcbin.fits' maketimecolumn=yes timebinsize=$lcbin makeratecolumn=yes expression='(CCDNR==9)&&(REGION(r2_srcli_cp:RGS2_BACKGROUND,M_LAMBDA,XDSP_CORR))'`; } # Clean up... `rm r1_evt_cp`; `rm r2_evt_cp`; `rm r1_srcli_cp`; `rm r2_srcli_cp`; print "Done. \n";