Subsections


10. RGS Data Processing (Command Line and GUI)

Many files are associated with an RGS dataset, and it is easy to be overwhelmed. The INDEX.HTM file, and links therein, are viewable with a web browser and will help you navigate the dataset. The different types of files are discussed in more detail in Chapter 1.

As ever, it is strongly recommended that you keep all reprocessed data in its own directory! SAS places output files in whichever directory it is in when a task is called. Throughout this primer, it is assumed that the Pipleline Processed data are in the PPS directory, the ODF data (with upper case file names, and uncompressed) are in the directory ODF, the reprocessing and analysis is taking place in the PROC directory, and the CCF data are in the directory CCF.

If you have just received your data from the SOC, it has been processed with the most recent version of SAS, and you should not need to repipeline it (though no harm is done if you do); you need only to gunzip the files and prepare the data for processing (see §6). However, if the data are older than about 1 year old, it is very likely that you will want to repipeline your data. Further, even if the data are “fresh”, the repiplining software needs to be rerun if you want to apply a new temporal filter in order to remove any soft proton flares.

If you decide that reprocessing is unnecessary, you need only to gunzip the files and rename event files for easier handling. For example, for the RGS1 event list,

 cp PPS/PiiiiiijjkkR1lEVENLInmmm.FIT PROC/r1_evt.fits

where

 iiiiiijjkk - observation number
l - scheduled (S) or unscheduled (U) obseravtion
n - spectral order number
mmm - source number

As noted in Tables 3.2 and 3.3 you can view images of your data. While the zipped FITS files may need to be unzipped before display in ds9 (depending on the version of ds9), they can be displayed when zipped using fv. As usual, there are some HTML products to help you inspect the data. These have file names of the form:

 PPiiiiiijjkkAAAAAA000_0.HTM

where

 iiiiiijjkk - Observation number
jj - observation ID - target number in proposal
kk - observation ID - observation number for target
AAAAAA - Group ID (see Table 3.2)

You will find a variety of RGS-specific files in XMM-Newton data sets. Generally there are two of each because there are two RGS instruments. Table 3.3 lists typical file names, their purpose, the file format, and a list of tools that will enable the user to inspect their data. Remember that the INDEX.HTM file will help you navigate.

Various analysis procedures are demonstrated using the Capella dataset, ObsID 0134720401, The following procedures are applicable to all XMM-Newton datasets, so it is not required that you use this particular dataset; any observation should be sufficient.


10.1 Rerun the Pipeline

We assume that the data were prepared and environment variables were set according to §6. In the window where SAS was initialized, in your processing directory PROC, run the task rgsproc:

 rgsproc

If using the GUI, from the upper window where the tasks are, select rgsproc. As with all SAS tasks in the GUI, double-clicking the task will bring up pop-up windows that will allow you to change the parameters. For rgsproc, the default values are fine, so just click “Run”.

This takes several minutes, and outputs 12 files per RGS, plus 3 general use FITS files. Running rgsproc through its last stage automatically produces the redistribution maxtrix files (RMFs) for each RGS instrument and each order. RGS spectra do not need ancillary files (ARFs) like EPIC spectra do, so we have everything that is needed to fit the data in a software package like Xspec or Sherpa (§12.2). However, there are still things to check before we do so.

In the vast majority of cases, the default output is fine and we can move on to looking for periods of high backgrounds, but it is nonetheless a good idea to take a look and make sure there are no issues. This is particularly important if your target happens to be an extended source, such as a supernova remnant or planetary nebula. To save a bit of typing, we will change the name of the event file; sharp-eyed readers who recall the previous chapters on EPIC data may notice that we are not making a soft link this time. This is because we will use rgsproc later to apply a temporal filter, which will overwrite the files made in previous calls.

 cp *R1*EVENLI*FIT r1_evt1.fits


10.1.1 Things to Check in your RGS Data

It is a good idea to verify that your data are ready to use. Things to look for are discussed below.

Are the source coordinates OK?

First, verify that the source coodinates are correct. Many things, including the wavelength calibration, hinge critically on them. They can be found in the source list, which follows the naming convention “*SRCLI_0000.FIT” and can be viewed with fv. The source list for this observation is shown in Figure 10.1.1.

 ftools
fv P0134720401R1S007SRCLI_0000.FIT &

Figure 10.1: The source list for the RGS observation.

\includegraphics[scale=0.2]{Capella_fv_srccoords.eps}

The coordinates in the PROPOSAL row are taken from the proposal, while the ones in ONAXIS are the average pointing coordinates of the spacecraft during the observation. (If you are using the PPS data, there could be more entries in this file, as sources in the EPIC detectors are added to this list.)

We can also make sure that the source extraction regions are centered on the source by the looking at the spatial dispersion plot (photon position in wavelength or beta space) and energy dispersion plot (photon energy in wavelength or beta space) and overlaying the selected region masks:

 evselect table=P0134720401R1S007EVENLI0000.FIT imageset=xd_mlambda.fits \
$   $ xcolumn=M_LAMBDA ycolumn=XDSP_CORR imagebinning=imageSize
$   $ ximagesize=600 yimagesize=600

evselect table=P0134720401R1S007EVENLI0000.FIT imageset=pi_mlambda.fits \
$   $ xcolumn=M_LAMBDA ycolumn=PI imagebinning=imageSize ximagesize=600 \
$   $ yimagesize=600 \
$   $ expression='REGION(P0134720401R1S007SRCLI_0000.FIT:RGS1_SRC1_SPATIAL,M_LAMBDA,XDSP_CORR)'

where

 table - event list
imageset - output image file
xcolumn - name of column with spatial x-coordinates
ycolumn - name of column with spatial y-coordinates
imagebinning - how to bin the image
ximagesize - size of x axis in pixels
yimagesize - size of y axis in pixels
expression - filtering expression

To this with the GUI,

 1) Call evselect.
2) In the "General" tab, in “table”, load the event list P0134720401R1S007EVENLI0000.FIT. In the “Image” tab, check the withimageset box and enter the name of the output file, xd_mlambda.fits, in “imageset”. Set the xcolumn and ycolumn values to M_LAMBDA and XDSP_CORR, respectively. Verify that “Binning” is set to imageSize, and ximagesize and yimagesize are both set to 600.
3) click “Run”.

and

 1) Call evselect.
2) In the "General" tab, in “table”, load the event list P0134720401R1S007EVENLI0000.FIT. In the “Image” tab, check the withimageset box and enter the name of the output file, pi_mlambda.fits, in “imageset”. Set the xcolumn and ycolumn values to M_LAMBDA and PI, respectively. Verify that “Binning” is set to imageSize, and ximagesize and yimagesize are both set to 600.
3) Click “Run”.

We can view the plots with rgsimplot. They are shown in Figure 10.2.

 rgsimplot endispset=pi_mlambda.fits spatialset=xd_mlambda.fits srcidlist=1 \
$   $ srclistset=P0134720401R1S007SRCLI_0000.FIT device=/xs

To do this with the GUI,

 1) Call rgsimplot.
2) In the “0” tab, set spatialset to xd_mlambda.fits, and endispset to pi_mlambda.fits, srcidlist to 1, srcidlistset to P0134720401R1S007SRCLI_0000.FIT, and device to /xs.
3) Click “Run”.

Figure 10.2: The extraction regions (cyan curves) for the RGS observation overlaid on the spatial dispersion plot (top) and the energy dispersion plot (bottom). Note that in the lower plot, there are also four cyan boxes; these are for calibration and can be ignored.

\includegraphics[scale=0.2]{Capella_banana_overlay.eps}

In these plots, the extraction area is well-centered on the source. If the source coordinates were incorrect, the spectrum would fall outside the extraction region or be off the image entirely. If you are working with a different dataset where that is the case, there are a couple ways to fix it, but the simplest is to rerun rgsproc with the correct RA and declination in decimal degrees. Here, we will use the example dataset simply to demonstrate how to do that:

 rgsproc withsrc=yes srclabel='my_Capella_extraction' \
$   $ srcra=79.17233795 srcdec=+45.99798652

To do this with the GUI,

 1) Call rgsproc.
2) In the “events” tab, go to the “rgssources” tab. Check the withsrc box. In srclabel, enter the name of the output file, my_Capella_extraction. In srcra and srcdec, enter 79.17233795 and +45.99798652, respectively.
3) Click “Run”.

Are source and background extraction areas OK?

Next, we will verify the validity of the source and background extraction areas. The accuracy of the flux measurement depends on a) having a source extraction area that is large enough to capture the source photons and b) not having contaminating photons in the background extraction region. This is particularly relevant for extended sources. Luckily, we can change the source and background extraction areas if we need to. We can take a look at our source and background extraction regions by overplotting them on the spatial dispersion image. Prior to viewing the image in ds9, we must first make region files that ds9 can read (remember to use different colors for the source and background regions when loading them into ds9):

 cxctods9 table='P0134720401R1S007SRCLI_0000.FIT:RGS1_SRC1_SPATIAL' \
$   $ regtype=linear -V 0 > src.reg
cxctods9 table='P0134720401R1S007SRCLI_0000.FIT:RGS1_BACKGROUND' \
$   $ regtype=linear -V 0 > bkg.reg
ds9 xd_mlambda.fits &

where the parameters are as defined previously, and

 regtype - type of coordinate system that the coordinates of the regions' reference points
$   $ are to be associated with

The cxctods9 task is not available in the GUI at present.

For our example observation, seen in the left-most image in Figure 10.3, the default source region captures the source photons well, and the background regions do not show contamination from either the target or another source.

If we were working with a different dataset - say, one with a source that extended beyond the default source region, or one that had a nearby X-ray source contaminating the background region - we could change the source and background regions with the rgsregions command and make spectra using these new regions. Here, we will use the example dataset simply to demonstrate how to do that and make the associated ds9 regions files using cxctods9 as above.

 rgsregions srclist=P0134720401R1S007SRCLI_0000.FIT evlist=r1_evt1.fits \
$   $ xpsfbelow=98 xpsfabove=98 xpsfexcl=99
cxctods9 table='P0134720401R1S007SRCLI_0000.FIT:RGS1_SRC1_SPATIAL' \
$   $ regtype=linear -V 0 > src_98_98_99.reg
cxctods9 table='P0134720401R1S007SRCLI_0000.FIT:RGS1_BACKGROUND' \
$   $ regtype=linear -V 0 > bkg_98_98_99.reg
ds9 xd_mlambda.fits &

where, in the rgsregions call,

 evlist - the event list
xpsfbelow - the size of the image region, expressed as a percent of the
$   $ cross-dispersion PSF covered between the source cross-dispersion off-axis angle
$   $ and the lower of each pair of vertices with the same dispersion coordinate
xpsfabove - the size of the image region, expressed as a percent of the
$   $ cross-dispersion PSF covered between the source cross-dispersion off-axis angle
$   $ and the upper of each pair of vertices with the same dispersion coordinate
xpsfexcl - the size of the exclusion regions in the background regions, expressed
$   $ as a percent of the cross-dispersion PSF covered between each pair of vertices with
$   $ the same dispersion coordinate and associated source

To use rgsregions with the GUI,

 1) Call rgsregions.
2) In the srclist box, enter the source list, P0134720401R1S007SRCLI_0000.FIT. In the evlist box, enter the name of the event file, r1_evt1.fits. In the xpsfbelow and xpsfabove boxes, enter 98. In the xpsfexcl box, enter 99.
3) Click “Run”.

The rgsregions task parameters can be hard to parse at first, so it can be instructive to see how changing the xpsfbelow, xpsfabove, and xpsfexcl parameters change the areas. In Figure 10.3, some source and background extraction regions that were made using different percentages are shown.

Figure 10.3: The source and background extraction regions (green and yellow, respectively) overlaid on the spatial dispersion plot, with the spectral data in shades of blue for contrast, for different parameter settings in rgsregions. In each, the red “not” sections refer to areas that are not included in the background, and the source regions are contained within the green lines (which is to say, ignore the red slashes when looking at the source regions). The left-most image shows the default extraction regions, with xpsfbelow and xpsfabove set at 95% and xpsfexcl set to 98% of the relevant cross-dispersion PSF areas. The middle image shows the regions when these parameters are set to 95% and 99%, respectively. The right-most image corresponds to these parameters being set to 98% and 99%, respectively.

\includegraphics[scale=0.14]{Capella_compare_extraction_regions_trim.eps}

New spectra can be made using the new extraction areas:

 rgsspectrum evlist=r1_evt1.fits srclist=P0134720401R1S007SRCLI_0000.FIT

To do this with the GUI,

 1) Call rgsspectrum.
2) In the evlist box, enter the event file, r1_evt1.fits. In the srclist box, enter the source list, P0134720401R1S007SRCLI_0000.FIT. 3) Click “Run”.

In the case of a bright nearby X-ray source contaminating the background, we could also have chosen to exclude it using a different method. The first step would have been to enter its coordinates to the already existing source list:

 rgssources srclist=P0134720401R1S007SRCLI_0000.FIT \
$   $ addusersource=yes label='contaminating_background_object' \
$   $ ra=RA_in_decimal_degrees dec=dec_in_decimal_degrees bkgexclude=yes

To do this with the GUI,

 1) Call rgssources.
2) In the “General” tab, in the srclist box, enter the name of the source list, P0134720401R1S007SRCLI_0000.FIT. In the “add_sources” tab, verify that addusersource is checked, then in label, enter the name of the background source, contaminating_background_object, and its RA and Dec in units of decimal degrees. Verify that the bkgexclude box is checked.
3) Click “Run”.

Then, we would compute the new source and background extraction masks:

 rgsregions srclist=P0134720401R1S007SRCLI_0000.FIT evlist=r1_evt1.fits \
$   $ procsrcsexpr='INDEX==1'

where parameters are as defined previously and

 procsrcsexpr - which entry in the source list we are making the extraction mask for \
$   $ (the first one,“PROPOSAL”, in this case)

To do this with the GUI,

 1) Call rgsregions.
2) In the srclist box, enter the name of the source list, P0134720401R1S007SRCLI_0000.FIT. In the evlist box, enter the event list, r1_evt1.fits. In the procsrcsexpr box, enter INDEX==1.
3) Click “Run”.

Lastly, we would extract the spectra as before, but this time using the bkgcorrect parameter:

 rgsspectrum evlist=r1_evt1.fits srclist=P0134720401R1S007SRCLI_0000.FIT bkgcorrect=yes

To do this with the GUI,

 1) Call rgsspectrum.
2) In the evlist box, enter the event list, r1_evt1.fits. In the srclist box, enter the name of the source list. Set the bkgcorrect parameter to yes.
3) Click “Run”.

Is there a bright optical source nearby?

Finally, it may be that your source has a bright optical source near the target. If the data includes a nearby bright optical source, with certain pointing angles, zeroth-order optical light may be reflected off the telescope optics and onto the RGS CCD detectors. If it falls on an extraction region, the energy calibration will require a wavelength-dependent offset. Stray light can be detected on RGS diagnostic images taken before, during, and after the observation, but it is not tested for by default before delivery - so any offset correction that might be needed is not applied.

Please note that if a source is very bright, the diagnostic data that the test relies on may not have been downloaded from the telescope in order to save bandwidth. Also, the target itself cannot be the source of optical photons, as the spectrum's zero-order falls far from the RGS chip array.

To check for stray optical light and apply the appropriate offsets, we only need to rerun the pipeline with the appropriate parameter set:

 rgsproc calcoffsets=yes

where

 calcoffsets - calculate PHA offsets from diagnostic images

To do this with the GUI,

 1) Call rgsproc.
2) In the “events” tab, in the “rgsoffsetcalc” tab, check the calcoffsets box.
3) Click “Run”.

We can now turn our attention to soft proton contamination.


10.2 Create and Display a Light Curve

The soft proton flaring background (§4.2) is assessed through examination of the light curve. We will extract a region, CCD9, that is most susceptible to soft proton events and generally records the least source events due to its location close to the optical axis. Also, to avoid confusing flares for source variability, a region filter that removes the source from the final event list should be used. The region filters are kept in the source file product *SRCLI_*.FIT.

First, let's prepare a directory to keep things organized:

 mkdir ltcrv
cd ltcrv
ln -s ../r1_evt.fits

To create a light curve, type

 evselect table=r1_evt1.fits withrateset=yes rateset=r1_ltcrv.fits \
$   $ maketimecolumn=yes timebinsize=100 makeratecolumn=yes\
$   $ expression= \
$   $ '(CCDNR==9) && (REGION(P0153950701R1S001SRCLI_0000.FIT:RGS1_BACKGROUND,M_LAMBDA,XDSP_CORR))'

where

 table - input event table
withrateset - make a light curve
rateset - name of output light curve file
maketimecolumn - control to create a time column
timebinsize - time binning (seconds)
makeratecolumn - control to create a count rate column, otherwise a count column will be created
expression - filtering criteria

To do this with the GUI,

 1) Call evselect.
2) In the “General” tab, in the table box, enter the event list, r1_evt1.fits, and the filtering expression to (CCDNR==9) && (REGION(P0153950701R1S001SRCLI_0000.FIT:RGS1_BACKGROUND,M_LAMBDA,XDSP_CORR)). In the ”Lightcurve” tab, check the withrateset box. In the rateset box, enter the name of the output light curve file, r1_ltcrv.fits. Check the maketimecolumn and makeratecolumn boxes, and set the timebinsize parameter to 100.
3) Click “Run”.

The output file r1_ltcrv.fits can be viewed using fv or dsplot:
 dsplot table=r1_ltcrv.fits x=TIME y=RATE &

where
 x - column for plotting on the X axis
y - column for plotting on the Y axis

The light curve is shown in Figure 10.4.

Figure 10.4: The event rate from the RGS1 CCD9 chip. The time corresponds to the elapsed mission time in seconds.

\includegraphics[scale=0.2]{Capella_light_curve.eps}


10.3 Generating the Secondary Good Time Interval (GTI) File and Applying It

We see that there are some flares at the start and end of the observation. It looks like the quiet part of the spectrum has $\le$ 0.1 c/s or so. The tabgtigen and gtibuild tasks can be used to make secondary GTI files for RGS in exactly the same way as EPIC. Here, we will use tabgtigen to make a filter that will keep only the times at low rates.

 tabgtigen table=r1_ltcrv.fits gtiset=gti.fits expression='RATE <= 0.1'

where parameters are as defined previously and

 gtiset - the secondary GTI file

To do this with the GUI,

 1) Call tabgtigen.
2) In the table box, enter the light curve and table, r1_ltcrv.fits:RATE. Set the filtering expression to RATE <= 0.1, and enter the name of the output file, gti.fits, in the gtiset box.
3) Click “Run”.

Now that we have the secondary GTI file, we can apply it to the event file by running rgsproc again. rgsproc is a complex task, running several steps, with five different entry and exit points. It is not necessary to rerun all the steps in the procedure, only the ones involving filtering.

To apply the GTI to the event file, type

 cd ..
rgsproc auxgtitables=ltcrv/gti.fits entrystage=3:filter finalstage=5:fluxing

where

 auxgtitables - gti file in FITS format
entrystage - stage at which to begin processing
finalstage - stage at which to end processing

To do this with the GUI,

 1) Call rgsproc.
2) In the “global” tab, set entrystage to 3:filter and finalstage to 5:fluxing. In the “filter” tab, enter the secondary GTI file, gti.fits.
3) Click “Run”.

We can rename the new filtered event files:

 cp *R1*EVENLI*FIT r1_evt2.fits
cp *R2*EVENLI*FIT r2_evt2.fits

At this point, we can look for pile up.

10.4 Check for Pile Up

It is always a good idea to check if your observation is piled up, especially if the object is bright (total count rate in all orders $>$ 12 c/s in RGS1, and 6 c/s in RGS2). Pile up occurs when a source is so bright that incoming X-rays strike two neighboring pixels or the same pixel in the CCD more than once per readout cycle. When this happens to photons in the 1st order spectrum, they are added together to form a single event that appears in the 2nd order spectrum at a position that corresponds to half the original wavelength. If the source is bright enough, the same will happen to photons in the 2nd order, with their sum showing up in the 3rd order, etc. In addition to this, there will be more events that strike several pixels, leading to complicated event pattern distributions that are automatically rejected by on-board processing. While this does not sound problematic in itself, it is worth noting that different areas of the CCDs in the different instruments are more susceptible to multiple-pixel event patterns than others. This means that pile up can and does differ between different CCD locations, and between RGS1 and RGS2. Therefore, for bright sources, we recommend that spectral features in RGS should not be trusted if they do not appear in both first and second orders.

A good way to look for pile up is to compare the 1st and 2nd order fluxed spectra. For non-piled sources, these will agree to within a few percent, while piled sources will have 2nd order spectra that are brighter than they should be by 10% or more and have spurious line detections.

When rgsproc is run through the 5:fluxing stage, one of the outputs is fluxed spectra. They follow the naming convention *OBX*fluxed1000.FIT and *OBX*fluxed2000.FIT, for the 1st and 2nd orders, respectively. They can be viewed with fv.

 fv P0134720401OBX000fluxed1000.FIT &

In Figure 10.5, we have plotted the fluxed 1st and 2nd order spectra and zoomed in on sections at short and long wavelengths to facilitate comparison. On the the left side of Figure 10.5, there are many “emission lines” throughout the 2nd order spectrum at short wavelengths that are not there in the 1st order spectrum. Some of the more noticeable ones are marked with arrows at about 7.2, 7.5, 7.6, and 8.5 Å. These correspond to piled-up lines in the 1st order spectrum on the right side of Figure 10.5 at about 14.2, 15, 15.2, 17 Å.

Pile up can also be seen in the continuum, though not in this source, using the same method. This can be seen in Figure 10.6, which shows that for an observation of GRO J1655-40, the 2nd order spectrum is about 10-20% brighter than its 1st order spectrum.

Unfortunately, if the data are piled up, there is no way to mitigate it like there is with the EPIC detectors; the best way to deal with pile up is to set up your observation with its prevention in mind.

Figure 10.5: The 1st and 2nd order fluxed spectra (black and red lines, respectively), at short wavelengths (left panel) and long wavelengths (right panel). The arrows are color-coded to indicate the 2nd order pile up artifact in the left panel and the 1st order piled up emission line in the right panel.

\includegraphics[scale=0.6]{Capella_pileup_comparison_v2_trim.eps}

Figure 10.6: The 1st and 2nd order fluxed spectra (black and red lines, respectively), of GRO J1655-40 (top), and their ratio (bottom). The dashed gray line in the lower plot marks unity.

\includegraphics[scale=0.6]{GROJ1655-40_pileup.eps}


10.5 Creating the Redistribution Matrices (RMFs)

The task rgsproc generates a redistribution matrix automatically, and in the vast majority of cases, these will be fine. However, as noted in §10.1.1 the source coordinates are under the observer's control. The source coordinates have a profound influence on the accuracy of the wavelength scale as recorded in the RMF that is produced automatically by rgsproc, and each RGS instrument and each order will have its own RMF.

Making the RMF is easily done with the package rgsrmfgen. Please note that, unlike with EPIC data, it is not necessary to make ancillary response files (ARFs).

To make the RMFs, type

 rgsrmfgen spectrumset=P0153950701R1S001SRSPEC1001.FIT rmfset=r1_o1_rmf.fits \
$   $ evlist=r1_evt2.fits emin=0.4 emax=2.5 rows=4000

where
 spectrumset - spectrum file
evlist - event file
emin - lower energy limit of the response file
emax - upper energy limit of the response file
rows - number of energy bins; this should be greater than 3000
rmfset - output FITS file

RMFs for the RGS1 2nd order, and for the RGS2 1st and 2nd orders, are made in a similar way.


10.6 Combining Spectra

It is possible to merge spectra from the same order in RGS1 and RGS2 if they were reprocessed using rgsproc with spectrumbinning=lambda, which is the default, and if they have the same binning. Spectra of different orders, from one particular instrument, can also be merged if they were reprocessed using rgsproc with spectrumbinning=beta. The task rgscombine also merges response files and background spectra. While it is possible to merge spectra from different observations, great care should be taken if doing so, as any small pointing differences will affect the accuracy of the wavelength calibration. Further, the combination of spectra having very different intensities can give rise to erroneous results. Please note that we do not generally recommend merging spectra. Instead, simultaneous fitting of several spectra is preferred, if having the most accurate wavelength calibration is important to the science being done.

Nonetheless, it can be useful to merge spectra purely for a quick general comparison or to make a pretty picture for publication. An example of how to use this task is therefore included here.

To merge the first order RGS1 and RGS2 spectra, type

 rgscombine pha='P0153950701R1S001SRSPEC1001.FIT P0153950701R2S002SRSPEC1001.FIT'\
$   $ rmf='P0153950701R1S001RSPMAT1001.FIT P0153950701R2S002RSPMAT1001.FIT'\
$   $ bkg='P0153950701R1S001BGSPEC1001.FIT P0153950701R2S002BGSPEC1001.FIT'\
$   $ filepha='r12_o1_srspec.fits' filermf='r12_o1_rmf.fits' \
$   $ filebkg='r12_o1_bgspec.fits'

where
 pha - list of spectrum files
rmf - list of response matrices
bkg - list of bakcground spectrum files
filepha - output merged spectrum
filermf - output merged response matrix
filebkg - output merged badkground spectrum

To do this with the GUI,

 1) Call rgscombine.
2) In the pha, rmf, and bkg boxes, enter the spectra, RMFs, and background spectra to merge, respectively: P0153950701R1S001SRSPEC1001.FIT P0153950701R2S002SRSPEC1001.FIT,
P0153950701R1S001RSPMAT1001.FIT P0153950701R2S002RSPMAT1001.FIT, and
P0153950701R1S001BGSPEC1001.FIT P0153950701R2S002BGSPEC1001.FIT. In the filepha, filermf, and filebkg box, enter the output merged spectrum, merged RMF, and background spectrum, respectively: r12_o1_srspec.fits, r12_o1_rmf.fits, and r12_o1_bgspec.fits.
3) Click “Run”.

10.7 Scripts

To aid in scripting, the data preparation commands from §6.1 and §6.2 and the commands used in this chapter are consolidated below.

 cd ODF
setenv SAS_ODF `pwd` ; setenv SAS_ODFPATH `pwd`
cifbuild
setenv SAS_CCF `pwd`/ccf.cif
odfingest
setenv SAS_ODF `pwd`/*SUM.SAS

cd ..
mkdir PROC
cd PROC
rgsproc
cp *R1*EVENLI*FIT r1_evt1.fits
evselect table=r1_evt1.fits imageset=xd_mlambda.fits xcolumn=M_LAMBDA \
$   $ ycolumn=XDSP_CORR imagebinning=imageSize ximagesize=600 yimagesize=600
evselect table=r1_evt1.fits imageset=pi_mlambda.fits xcolumn=M_LAMBDA \
$   $ xcolumn=M LAMBDA ycolumn=PI imagebinning=imageSize ximagesize=600 yimagesize=600 \
$   $ expression='REGION(P0134720401R1S007SRCLI_0000.FIT:RGS1_SRC1_SPATIAL,M_LAMBDA,XDSP_CORR)'
rgsimplot endispset=pi_mlambda.fits spatialset=xd_mlambda.fits srcidlist=1 \
$   $ srclistset=P0134720401R1S007SRCLI_0000.FIT device=/xs
cxctods9 table='P0134720401R1S007SRCLI_0000.FIT:RGS1_SRC1_SPATIAL' \
$   $ regtype=linear -V 0 $>$ src.reg
cxctods9 table='P0134720401R1S007SRCLI_0000.FIT:RGS1_BACKGROUND' \
$   $ regtype=linear -V 0 $>$ bkg.reg

mkdir ltcrv
cd ltcrv
ln -s ../r1_evt.fits
evselect table=r1_evt1.fits withrateset=yes rateset=r1_ltcrv.fits maketimecolumn=yes \
$   $ timebinsize=100 makeratecolumn=yes \
$   $ expression= \
$   $ '(CCDNR==9)&&(REGION(P0153950701R1S001SRCLI_0000.FIT:RGS1_BACKGROUND,M_LAMBDA,XDSP_CORR))'
tabgtigen table=r1_ltcrv.fits gtiset=gti.fits expression='RATE <= 0.1'

cd ..
rgsproc auxgtitables=ltcrv/gti.fits entrystage=3:filter finalstage=5:fluxing