To extract Spectrum and Light Curve using LAXPCSOFTWARE (Format-B)

Before you begin, ensure that you have a directory named “LAXPCSOFTWARE” in your home or working directory. Please visit the ASSC webpage or TIFR webpage to download the latest software version, which is v3.0 and contains updated background spectra. Note that the recent version and release date of LAXPC Level-1 Data is version 3.4.3, with a release date of 07 May 2022.

To begin, download the data from the astrobrowser portal. In this tutorial, we will be analyzing the Black Hole source Swift J1658.2-42 with observation ID 20180220T02_004T01_9000001910 and orbit no. 12977.

$ unzip LEVL1AS1LXP20180220T02_004T01_9000001910_12977.zip
$ cd  20180220T02_004T01_9000001910_level1/laxpc/12977

In this directory, there are five directories named lxp1, lxp2, lxp3, aux, hk, and two files, .mkf and .xml. The lxp1, lxp2, and lxp3 directories are used to extract data for laxpc10, laxpc20, and laxpc30, respectively.

To generate the lightcurve and spectra of laxpc10, 20, and 30, navigate to the lxp1, lxp2, and lxp3 directories, respectively. The directories contain two modes of data: modeBB and modeEA. Since we are working with event mode data, navigate to the modeEA directory with the following commands:

$ cd lxp1/modeEA/
$ cd ../lxp2/modeEA/
$ cd ../lxp3/modeEA/

LAXPCSOFTWARE (Format-B) Installation

$ tar -zxvf laxpcsoftv3.0.tar.gz

To use LAXPCSOFTWARE for a given data, open the findfile and give the path after the find and before a name.
Edit the path to the data in the file by replacing the current path with the following command:

$ gedit findfile

Then, edit the path to the data in the file by replacing the current path with the following:

find /home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc -name "00000$1.*" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1

Original file:

#find /mnt/Data/Data/level-2/ -name "00000$1.???" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “pha$” | grep -v “orb$” | grep -v “att$” | grep -v “lbt$” | grep -v frame | sort > ls2
#find /mnt/Data/Data/level-1/ -name "00000$1lxp1EA_level1.fits" | sort > ls1
#find /mnt/Data/Data/level-1/ -name "00000$1.
" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1
find /mnt/Data/Data/level-1/000$1 -name "00000$1." | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1
#find /mnt/Data/Data/level-1/forD/000$1 -name "00000$1.
" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1

Edited file:

#find /mnt/Data/Data/level-2/ -name "00000$1.???" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “pha$” | grep -v “orb$” | grep -v “att$” | grep -v “lbt$” | grep -v frame | sort > ls2
#find /mnt/Data/Data/level-1/ -name "00000$1lxp1EA_level1.fits" | sort > ls1
#find /mnt/Data/Data/level-1/ -name "00000$1.
" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1
find /home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc -name "00000$1." | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1
#find /mnt/Data/Data/level-1/forD/000$1 -name "00000$1.
" | grep -v lxp2 | grep -v lxp3 | grep -v issdc | grep -v “gti$” | grep -v “frt$” | grep -v “xml$” | grep -v “hk$” | grep -v “orb$” | grep -v “txt$” | grep -v “bti$” | grep -v “aux1” | grep -v “aux2” | grep -v frame | grep -v “.tar” | sort > ls1

Inside ls1, all four required data files will be saved.

$ sh findfile T02_004T01_9000001910

Verify that all the necessary files are present in ls1, which include four files: .mkf, .tct, and two .fits files. The following files and paths are required: (1) .mkf file contains information on pointing and orbit, (2) .tct file from the aux subdirectory is needed for converting from Instrument to UTC time, (3) .fits file from ModeBB is required for BBC mode data, and (4) .fits file from ModeEA is necessary for Event mode data.

$ more ls1
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/AS1T02_004T01_9000001910lxp_level1.mkf
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/aux/AS1T02_004T01_9000001910lxp_level1.tct
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/lxp1/modeBB/AS1T02_004T01_9000001910lxp1BB_level1.fits
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/lxp1/modeEA/AS1T02_004T01_9000001910lxp1EA_level1.fits
mv ls1 laxpcl1.inp
 more laxpcl1.inp

/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/AS1T02_004T01_9000001910lxp_level1.mkf
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/aux/AS1T02_004T01_9000001910lxp_level1.tct
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/lxp1/modeBB/AS1T02_004T01_9000001910lxp1BB_level1.fits
/home/iucaa/Desktop/laxpcsoft_format_B/20180220_T02_004T01_9000001910_level1/laxpc/12977/lxp1/modeEA/AS1T02_004T01_9000001910lxp1EA_level1.fits
$ ls *.f
  backshift.f laxpcl1.f

These are two Fortran programs (1) laxpcl1.f : To process the level-1 data and generate the eventfile, light curve, spectrum for source and background as well as GTI file(2) backshift.f: To apply gain shift to align the background spectrum with the source spectrum and identify the required response file

$ cp makefile.gfortran makefile
$ make laxpcl1
$ gfortran -O3 -o laxpcl1.e laxpcl1.f

This command will compile the program and create an executable file with the extension .e.

$ ./laxpcl1.e

The following information pertains to generating a light curve from LAXPC detector data:

lxp: S. no. of LAXPC detector (1-3) where 1 represents LAXPC10 and 3 represents LAXPC30.
tbin: Time bin for the light curve, which can be 1, 2, or 3 seconds.
ian: Anodes to be used for the light curve or spectrum, where 0 represents all anodes, 1 represents layer 1, 2 represents Anode 2, 3 represents layer 2, 4 represents Anode 4, 5 represents layer 3 (Anode 5), 6 represents layer 4 (Anode 6), and 7 represents layer 5 (Anode 7).

Please specify the channel range for the light curve. The channel range refers to the range of channel numbers to be used in the light curve, which is from 0 to 1023. If you wish to use all channels, simply type “/”. If you want to select a specific channel number for a particular energy range, you need to refer to the corresponding channel number in the detector response file (fv or fdump *.rmf). LAXPC10 and LAXPC30 detectors use 512 channels binned, so you need to multiply by 2 for the light curve. Similarly, LAXPC20 uses 256 channels and needs to be multiplied by 4 for the light curve.

Specify the number of channels in the spectrum: 1024/512/256. For LX10 and LX30 detectors, use 512 channels (type 512), while for LX20 detector, use 256 channels (type 256). Specify the following parameters: uld bin (nul), Earth occultation (je), event flag (iev)

Note: nul, je, iev

first input “nul” : 0 (for ULD BG model) or -1 (for lat and long model in 2 dimension) or -3 (same with 3 dimension).
nul: ULD bin, used to generate spectrum for a specified value (1-4)

Spectrum will be averaged over time when ULD count is in the specified ULD bin. The background spectrum would be for the respective bin. This is useful only for generating background spectrum in different ULD bins.

nul=0: All ULD values are combined to get source spectrum.

The background spectrum will combine observed background spectra from all bins in correct proportion

nul=-1: The source spectrum will include full observation

while the background spectrum is scaled from observed spectrum by a factor which is determined by fit to background counts with latitude and longitude.

nul=-2: The source spectrum will include full observation

while the background spectrum is scaled from observed spectrum for layer 1 in channel range (0-200, < approx 20 keV) by a factor which is determined by fit to background counts with
latitude and longitude. This option should be used for faint sources when it will use background fit to layer 1 count rate in channel range
0-200 (< approx 20 keV).

nul=-3: Similar to nul=-1, except that background fit in 3D is used. The default value is nul=-1

2nd input ``je":

je=1: The source spectrum is generated,
je=-1: The spectrum during Earth occultation is generated.

3rd input iev:

iev<0, the event files (.evn and .evn1) are written out. These are large files and suppressing these files will speed-up the program.
iev>=0, the event files are not written out
iev=1 or -1, only single events where all energy is deposited in one of the main anodes are selected.
abs(iev).ne.1, double events where at least one energy is the Xe k X-ray range are also selected. It is difficult to account for these events when the gain of the detector has shifted. For some cases it may be better to suppress these, though it will reduce the efficiency of the detector.

Output files: All output file have prefix lxpi, where i can be 1,2 or 3 depending on which detector is chosen (input parameter LXP).

Since writing of full event file takes too long, that part can be controlled by using the parameter iev. The following output files are produced:

lxpilevel2.event: Summary of frames read from level1 EA mode file

Example with an input parameter without filter of uld bin,Earth occultation, event flag :

$ ./laxpcl1.e
 Type lxp,tbin,anode [1 1.0 0]
$ 2 1 0
 Type channel range for light curve [0 1023]
$ 0 1023
 Type No. of channels in spectrum: 1024/512/256 [         256 ]
$ 256
Type uld bin,Earth occultation, event flag [-1 1 2]
$ -1 1 2
       33379           4
       5390   75630418.517600000        1110.4633000046015    
      18210   75636688.763249993        1201.2135799974203    
       29559   75641715.796959996        46.482339993119240    
       30754   75642958.657330006        1242.8603700101376    
   256846904.00000000        256863328.00000000        75644000.899480000    
         957        1010   256863283.00000000    
         957   256846844.00000000        1349440.8425156251        75627516.377759993        0.0000000000000000    
           7        8438      104205    24301440
       97039         957      100002       16423   75627578.000000000        75644000.899480000        256863283.00000000        256863328.63004142   
        8019           4
           4        8019
       97039         957      100002           0       16423   75627578.000000000        75644000.899480000        256863283.00000000        256863328.63004142        75644000.734999999               94
           2
   75644000.899480000        75643846.432400003        256863283.00000000        256846844.00000000        256863328.63004142        256846904.96563107        75643955.130820006        75627516.377759993    
 tobs=   9276.0000000000000       0.73856000602245331    
   9275.2614399939775        619.22550555178600    
         502       16423   75644011.103000000        16439.000000000000        75627577.951000005    
           4         164       16433
           0   9275.0000000000000        398.19761082340943        404.99218685800366    
  0.19708108582507036       0.21326031558546768    
 uld fraction:  2.2695E-03  3.6323E-01  4.2429E-01  1.7119E-01  4.1284E-02  0.0000E+00
 count   5594515.0000000000          5170050
           4     5594515
       16384   6.1035156250000000E-005
           0
  1.00000E+00  5.64807E-01  9.76928E-01  1.21788E-04

Example with an input parameter with filter of uld bin,Earth occultation, event flag:

$ ./laxpcl1.e
 Type lxp,tbin,anode [1 1.0 0]
$ 2 1 0
 Type channel range for light curve [0 1023]
$ /
Type No. of channels in spectrum: 1024/512/256 [         512 ]
$ 256
Type uld bin,Earth occultation, event flag [-1 1 2]
$ -1 1 2
       33379           4
        5390   75630418.517600000        1110.4633000046015    
       18210   75636688.763249993        1201.2135799974203    
       29559   75641715.796959996        46.482339993119240    
       30754   75642958.657330006        1242.8603700101376    
   256846904.00000000        256863328.00000000        75644000.899480000    
         957        1010   256863283.00000000    
         957   256846844.00000000        1349440.8425156251        75627516.377759993        0.0000000000000000    
           7        8438      104205    24301440
       97039         957      100002       16423   75627578.000000000        75644000.899480000        256863283.00000000        256863328.63004142    
        8019           4
           4        8019
       97039         957      100002           0       16423   75627578.000000000        75644000.899480000        256863283.00000000        256863328.63004142        75644000.734999999               94
           2
   75644000.899480000        75643846.432400003        256863283.00000000        256846844.00000000        256863328.63004142        256846904.96563107        75643955.130820006        75627516.377759993    
 tobs=   9276.0000000000000       0.73856000602245331    
   9275.2614399939775        619.22550555178600    
         502       16423   75644011.103000000        16439.000000000000        75627577.951000005    
           4         164       16433
           0   9275.0000000000000        280.00449816544494        286.89382462559718    
   9.1128172290055057E-002  0.62567358107381210    
 uld fraction:  2.2695E-03  3.6323E-01  4.2429E-01  1.7119E-01  4.1284E-02  0.0000E+00
 count   5594515.0000000000          5591914
           4     5594515
       16384   6.1035156250000000E-005
           0
  1.00000E+00  5.64807E-01  9.69406E-01  1.21788E-04

To show Time interval in .gti file. It has total four columns; 1st two are start and end time in instrument time while last two are in UTC time. No of rows will depends on how many good time segment are presnt.

$  more lxp2level2.gti
  5
 7.56275810000000E+07  7.56284780000000E+07  2.56846908623209E+08  2.56847805636685E+08
 7.56312500000000E+07  7.56343750000000E+07  2.56850577678320E+08  2.56853702725256E+08
 7.56343800000000E+07  7.56347470000000E+07  2.56853707725331E+08  2.56854074730846E+08
 7.56370940000000E+07  7.56409510000000E+07  2.56856421766102E+08  2.56860278823955E+08
 7.56429700000000E+07  7.56440000000000E+07  2.56862297854383E+08  2.56863327869853E+08

To move the created GTI file to gti.inp, use the following command:

 $ mv lxp2level2.gti gti.inp  

Once this is done, you can proceed to create the spectral file by going back to the previous step.

 $ ./laxpcl1.e
 Type lxp,tbin,anode [1 1.0 0]
$ 2 1 0
 Type channel range for light curve [0 1023]
$ /
 Type No. of channels in spectrum: 1024/512/256 [         256]
$ 256
 Type uld bin,Earth occultation, event flag [-1 1 2]
$ -1 1 2
       33379           4
        5390   75630418.517600000        1110.4633000046015    
       18210   75636688.763249993        1201.2135799974203    
       29559   75641715.796959996        46.482339993119240    
       30754   75642958.657330006        1242.8603700101376    
   256846904.00000000        256863328.00000000        75644000.899480000    
         957        1010   256863283.00000000    
         957   256846844.00000000        1349440.8425156251        75627516.377759993        0.0000000000000000    
           7        8438      104205    24301440
       97039         957      100002       16423   75627578.000000000        75644000.899480000        256863283.00000000        256863328.63004142    
        8019           4
           4        8019
       97039         957      100002           0       16423   75627578.000000000        75644000.899480000        256863283.00000000        256863328.63004142        75644000.734999999               94
           2
   75644000.899480000        75643846.432400003        256863283.00000000        256846844.00000000        256863328.63004142        256846904.96563107        75643955.130820006        75627516.377759993    
 tobs=   9276.0000000000000       0.73856000602245331    
   9275.2614399939775        619.22550555178600    
         502       16423   75644011.103000000        16439.000000000000        75627577.951000005    
           4         164       16433
           0   9275.0000000000000        280.00449816544494        286.89382462559718    
   9.1128172290055057E-002  0.62567358107381210    
 uld fraction:  2.2695E-03  3.6323E-01  4.2429E-01  1.7119E-01  4.1284E-02  0.0000E+00
 count   5594515.0000000000          5591914
           4     5594515
       16384   6.1035156250000000E-005
           0
  1.00000E+00  5.64807E-01  9.69406E-01  1.21788E-04

After generating the light curve and spectra, follow the below steps to create a background spectral file and response file:

 $ make backshiftv3
 $ gfortran -w -O3 -o backshiftv3.e backshiftv3.f
$ ./backshiftv3.e
 type lxp,anode,idi [1 0 0]
2 0 0
 Type time-bin, channel range for light curve, nul [1 0 1023 -1]
1 0 / -1
          66        1188
          23           4          69
 type .pha file name [ lxp2level2back.pha ]
lxp2level2back.pha
          16          16         870         876
 background feb18 chosen
 Source-ch= 224.4  back-ch= 224.5  shift=  -0.0
          14  0.28523559570311363    
 Mean count rate:   200.0   199.9  ratio=   1.001
           4         139  -3.2450358072916665E-004
 change in count rate=  0.15263149810536447    
 Response-ch= 224.1  shift=   0.3
 use the response file  lx20v1.0.rmf                  
 Use gain-offset =  -0.17 keV

Output:  lxp2level2.spec ; lxp2level2back_shifted.spec ; lxp2level2.lcurv ; response (lx20v1.0.rmf )

Copy the above output files from LAXPCSOFTWARE directory to the working directory where the data is present. If the LAXPCSOFTWARE and data are in the same directory, then copying is not necessary.


To plot lightcurve

 $ lcurve
 
lcurve 1.0 (xronos6.0)
Number of time series for this task[2] 1
Ser. 1 filename +options (or @file of filenames +options)[Back_lightcurve_3.0_80.0keV.lc] lxp2level2.lcurv
 Series 1 file    1:lxp2level2.lcurv
 Selected FITS extensions: 1 - RATE TABLE;
 Source ............ Swift J1658.2-42    Start Time (d) .... 18169 18:21:48.623
 FITS Extension ....  1 - `RATE      `   Stop Time (d) ..... 18169 22:55:28.870
 No. of Rows .......         9220        Bin Time (s) ......    1.000
 Right Ascension ...                     Internal time sys.. Converted to TJD
 Declination .......                     Experiment ........ ASTROSAT LAXPC
 Filter ............ A1-A7  All Event
 Corrections applied: Vignetting - Yes; Deadtime - Yes; Bkgd - No ; Clock - YES
             values: 1.00000000       1.00000000       1.00000000
 Selected Columns:  1- Time;  2- Y-axis;  3- Y-error;
 File contains binned data.
Name of the window file ('-' for default window)[-]
 Expected Start ... 18169.76514610197  (days)      18:21:48:623  (h:m:s:ms)
 Expected Stop .... 18169.95519525313  (days)      22:55:28:870  (h:m:s:ms)
 Minimum Newbin Time    1.0000000      (s)
 for Maximum Newbin No..            16421
 Default Newbin Time is:   32.108421    (s) (to have 1 Intv. of     512 Newbins)
 Type INDEF to accept the default value
Newbin Time or negative rebinning[1]
 Newbin Time ......     1.0000000      (s)
 Maximum Newbin No.             16421
 Default Newbins per Interval are:         512
 (giving      33 Intervals of          512 Newbins each)
 Type INDEF to accept the default value
Number of Newbins/Interval[7183] 16421
 Maximum of       1 Intvs. with        16421 Newbins of       1.00000     (s)
Name of output file[97020.flc]
$ Do you want to plot your results? yes
$ Enter PGPLOT device /xw
   16421 analysis results per interval
100% completed
 Intv    1   Start 18169 18:21:50
     Ser.1     Avg  509.7        Chisq 0.3115E+05   Var  1722.     Newbs.   9220
               Min  366.7          Max  716.4    expVar  509.7      Bins   9220
$ PLT> exit