Astro-E2 XRS event simulation using xrssim

Last updated 2004-07-08

xrssim is an XRS event simulator, which can produce simulated XRS event lists similar to the actual XRS data. There will be two cases when xrssim simulation if effective: (1) Simulation of diffuse sources to know number of counts expected on each pixel, (2) Simulation of bright point sources to see ratios for Hi-res, Mid-res, and Low-res events. Below, we explain how to carry out XRS simulations using xrssim for these two cases.

Simulation of Diffuse Sources

Determine the pointing direction

Let's take an example of the CAS-A eastern part from the Science Working Group target list. The pointing direction is (350.9175, 58.8002), and exposure is 50 ksec. The roll angle, which is defined from North to DETY axis in counter-clockwise, is not specified yet, since it may be constrained by the solar condition and observational season. Let's assume roll = 45 degree in our simulation. We can put our simulated XRS field of view on ds9 by making the region file with a Perl script mkxrsreg.pl.

Astro-E2 attitude is defined with Z-Y-Z Euler angles, where Z-axis is the pointing direction. Therefore, (Euler1, 90.0-Euler2) is the equatorial coordinates of the pointing direction, and (90-Euler3) gives the roll angle. mkxrsreg.pl needs these three Euler angles of the observation to calculate the sky region to project XRS pixels. In our case, the Euler angles are (350.9175, 31.1998, 45.0).

   perl mkxrsreg.pl 350.9175 31.1998 45.0 > casa.reg

Let's look at an Chandra HRC archival data of CAS-A, ObsID 1505 (left below; taken from ftp://cdaftp.harvard.edu/pub/science/ao01/cat5/1505/primary/hrcf01505N004_full_img2.jpg). The fits file is found at ftp://cdaftp.harvard.edu/pub/science/ao01/cat5/1505/primary/hrcf01505N004_full_img2.fits.gz. We will use this image FITS file as an input of "mkphlist" to create a photon-list, which will be an input of xrssim. In the right figure below, we show our simulated observation region with casa.reg (in green). Also, for your information, SWG observations of Cas A West (50 ksec;350.8004, 58.8111) and Cas A North (50 ksec; 350.8488, 58.8396) are indicated. Again, roll angle is arbitrary assumed as 45 degree, which may not be true.

Run mkphlist

"mkphlist" makes a photon-list to represent the photon distribution on the sky. It requires the sky image, spectral distribution file (easily made with xspec), and photon flux (photon/s/cm2) for the total energy band and the total sky region. "mkphlist" produces randomized photon lists according to the input sky and energy distribution.

If you want to carry out more sophisticated simulation, you may create photon lists which have complicated spatial dependence of energy distribution. For example, you may run mkphlist several times for different regions of the extended sources (e.g., center and outer regions of the cluster of galaxies with different temperatures). Then xrssim can read up to eight photon lists, and make a single event list corresponding to these input photons.

Obviously, the Cas-A spectrum is very complicated, but for simplicity, let's assume simple, but more or less reasonable spectral shape and photon flux. We will use ASCA SIS spectrum produced in the ASCA pipe-line processing to estimate counting rates and spectral shape. The spectral file and responses are available at the following:
ftp://legacy.gsfc.nasa.gov/asca/data/rev2/50018010/spectra/ad50018010s010102_1.pi.gz
ftp://legacy.gsfc.nasa.gov/asca/data/rev2/50018010/spectra/ad50018010s010102_1.arf.gz
ftp://legacy.gsfc.nasa.gov/asca/data/rev2/50018010/spectra/ad50018010s010102_1.rmf.gz

We crudely fit the spectrum with two temperature mekal plasma models with interstellar absorption as follows. Left is the fitting results, right is the input model.

We are going to use this spectral model for our XRS simulation. The photon model file may be obtained in xspec as follows:

  XSPEC>iplot
  PLT> we casa_spec_model
  PLT> q
Then in the current directory, casa_spec_model.qdp and casa_spec_model.pco are made. The former is used for the input of mkphlist. We need to obtain the photon flux as well, to be used later in mkphlist.
   XSPEC>flux 0.3 12
   Model flux  0.4486     photons ( 1.6065E-09 ergs)cm**-2 s**-1 (  0.300- 12.000)
This is the photon flux of the model in 0.3 - 12 keV.

Let's run mkphlist.

   mkphlist photon_flux=0.4486 flux_emin=0.3 flux_emax=12 spec_mode=0 qdp_spec_file=casa_spec_model.qdp \
   image_mode=0 fits_image_file=hrcf01505N004_full_img2.fits time_mode=1 limit_mode=1 exposure=50000 outfile=casa.photon
Note that we used the photon flux obtained from Cas A, but mkphlist assumes this is for the entire input image. Namely, we ignored effects of X-ray and non X-ray background for simplicity.

Now, the output FITS file casa.photon has photon lists which are expected to be incident to the telescope. There are 25,734,391 photons, each of which has simulated arrival time, energy and sky positions, and the file size is over 500 Mbytes!

Run xrssim

Next, let's run xrssim
   xrssim ea_phi=350.9175 ea_theta=31.1998 ea_psi=45 infile1=casa.photon infile2=none xrs_efficiency=yes fw_file=none xrs_pixel_select=no outfile=casa.events
In addition, you have to specify calibration files; just use default ones included in the package. In the example above, we specified xrs_pixel_select=no, which is required only to draw nice contour map of the input photons with xrsqlp. Only to calculate number of XRS events, you may specify xrs_pixel_select=yes, then the output event file will be much smaller.

The output casa.events is a standard event file, which may be "analyzed" by generic tools. One caveat is that the sky X and Y coordinate values in the xrssim output files are NOT realistic. In real XRS event files, discrete XRS pixel center position projected on the sky is recorded for each event (we do not know the actual event location within an XRS pixel). On the other hand, in the xrssim output file, actual projected sky position for each simulated photon is written in the sky X and Y columns.

There are 4,571,703 events in this file, but those having PIXEL=-1 are the events which do not fall on the XRS pixels (these events are included in the output file since we specified "xrs_pixel_select=no"). Number of events on the XRS pixel may be seen as,

   fdump infile="casa.events[PIXEL>=0]"
Then NAXIS2=801856 tells the number of events fallen on the XRS pixels. For 50 ksec exposure, this corresponds to 16.0 counts/s.

Browse the xrssim output with xrsqlp

We developed an ftool named xrsqlp to display xrssim output file. To compile this ftool, you will have to have the ftools package built from the source. After untar the package, just enter $LHEASOFT/BUILD_DIR/hmake.

The following is an example of running xrsqlp on the casa.events file we have created.

   xrsqlp casa.events
   xrsqlp ver 2.3 (2004-05-28)
   Output graphic device[/xs]
   Output in a single page (yes) or not (no)[no]
   Sky image binning[2]
   Input image smoothing width[5]
   Draw contour in log scale (yes) or not (no)[no]
   Number of contours to display[16]
   Output FITS image file name[tmp.fits] casa.xrs.img
The following is examples of xrsqlp output. The left figure is the sky image, and the right one is detector image (number of counts is shown on each pixel). The postscript file of all the output is also available.

Also, xrsqlp outputs the XRS sky "image" in the FITS format (in this example, "casa.xrs.img"), which may be displayed with, e.g., ds9, as follows:

Extract image, light curve and spectra with xselect

The xrssim output file may be read in xselect to browse and/or extract images, spectrum and light curve.

   xselect

			    **  XSELECT V2.2   **

   > Enter session name >[xsel]
   xsel:ASCA > read
   DEFAULT             -->  default linking of event and hk names
   HK                  -->  enter only HK files
   EVENTS              -->  enter only event files
   QUIT                -->  quit read
   > Enter readin mode >[events]
   > Enter the Event file dir >[.]
   > Enter Event file list >[casa.events]
   Got new mission: ASTRO-E
   > Reset the mission ? >[yes]

    Notes: XSELECT set up for      ASTRO-E
    Time keyword is TIME       in units of s
    Default timing binsize =   16.000

   Setting...
    Image  keywords   = X          Y           with binning =    4
    WMAP   keywords   = DETX       DETY        with binning =    4
    Energy keyword   = PI                     with binning =    1

   Getting Min and Max for Energy Column...
   Got min and max for PI:     1  16384

   Got the minimum time resolution of the read data:  0.50863E-05
    Number of files read in:  1

   ******************** Observation Catalogue ********************

   Data Directory is: /home/ebisawa/ASTRO-E2/2004-06-21-Web/
   HK Directory is: /home/ebisawa/ASTRO-E2/2004-06-21-Web/


	   OBJECT      DATE-OBS    TIME-OBS    DATE-END    TIME-END
	 1 XRS-Simulat 2000-01-01  00:00:00.00 2000-01-01  13:53:20.00

   xsel:ASTRO-E-XRS-STANDARD > select events "PIXEL>=0"
   Processing file: /home/ebisawa/ASTRO-E2/2004-06-21-Web/casa.events
   xsel:ASTRO-E-XRS-STANDARD > extract all
   extractor v4.36     31 Oct 2003
    Getting FITS WCS Keywords
    Doing file: /home/ebisawa/ASTRO-E2/2004-06-21-Web/xsel_work1001.xsl
   100% completed
	     Total      Good    Bad: Region      Time     Phase     Grade     Cut
	    801856    801856              0         0         0         0         0
   ===============================================================================
      Grand Total      Good   Bad:  Region      Time     Phase     Grade    Cut
	   801856    801856              0         0         0         0         0
      in  50000.     seconds
    Fits light curve has   801856 counts for  16.04     counts/sec
    Spectrum         has   801856 counts for  16.04     counts/sec
    ... written the PHA data Extension
    Image            has   801856 counts for  16.04     counts/sec
   xsel:ASTRO-E-XRS-STANDARD > plot image
   xsel:ASTRO-E-XRS-STANDARD > plot curve
   PLT> q
   xsel:ASTRO-E-XRS-STANDARD > plot spec
   PLT> quit
   xsel:ASTRO-E-XRS-STANDARD > save spec outfile=casa.xrs.spec group_spectrum=no
   Wrote spectrum to casa.xrs.spec
   xsel:ASTRO-E-XRS-STANDARD > exit
   > Save this session? >[no]
In this example, we plot image, curve and spectrum, and save spectral file as "casa.xrs.spec". select events "PIXEL>=0" is not required, if you have specified "xrs_pixel_select=yes". Do not specify to group the spectrum, so that number of channels in the spectral file matches with that of the current response. You may carry out more specific analysis, e.g., by selecting events only from pixels on the region you are interested. Please be careful that the "image" here is not a realistic one, since in reality we do not know the event position within an XRS pixel.

Analyze simulated spectrum with xspec

Spectral file extracted with xselect can be read with xspec, and fitted with the standard responses. See "XRS Responses for Simulations" for the explanation of the XRS respones and download them.
    xspec

		  Xspec 11.3.0    21:55:42 24-Jun-2004

    For documentation, notes, and fixes see  http://xspec.gsfc.nasa.gov/

    Plot device not set, use "cpd" to set it

    Type "help" or "?" for further information
   XSPEC>  data 1:1 "casa.xrs.spec";
    Net count rate (cts/s) for file   1   16.04    +/-  1.7992E-02
      1 data set is in use

   XSPEC>  response 1 "xrs_ao1.rmf";
    *WARNING*:  Response and data file telescope ID mismatch
    (Astro-E2,ASTRO-E) for file   1
    *WARNING*:  Response and data file channel type mismatch
    (PHA,PI) for file   1

   XSPEC>  arf 1 "xrs_onaxis_open_ao1.arf";
    *WARNING*:  Aux. Resp. and data file telescope ID mismatch
    (Astro-E2,ASTRO-E) for file   1

Note, the standard ARF, xrs_onaxis_open_ao1.arf, is created assuming a point source on-axis, integrating over all the XRS pixels. Because XRT point spread function is comparable to the XRS size, this ARF is not precisely correct for diffuse source analysis. In fact, XRS has a rather complicated response (throughput) for extended sources. See XRS response for extended sources for details.

In any case, the following is an example of "fitting" with two mekal models using standard responses, which was originally assumed as an input.

Simulation of Bright Point Sources

xrssim assigns event grade (High, Middle or Low-res; Mid and Low primary or secondary) on each event taking account of the time intervals between two succeeding events. This is useful to simulate bright sources and to know fraction of the event grades. Figures in the technical appendix to indicate the event branching ratio were created running xrssim with different input source fluxes.

Let's run xrsqlp on a simulate Crab event list. Scripts to create Crab event list with mkphlist and xrssim are included in the xrssim package (crab-gen.sh and crab-obs.sh). Postscript file of the xrsqlp output images is available.

In the left figure below, we show all the events (High, Mid and Low-res). We can see that the central PSF core is the brightest as expected. In the right figure, we show only High + Mid-primary events. We can see that there are hardly High + Mid-primary events in the center, and those numbers increase outward. Namely, near the PSF core, most events will be Low-res or Mid-secondary, since event rate is so high. You may carry out similar bright source simulation in different conditions, for example, by putting Be filter, to find a condition to maximize the number of Hi+Med-primary events.

As explained in Techical description, mid-res secondary events have a large low-energy tail which reduces their resolution significantly relative to Mid-res primary events. These secondary events require a post-processng correction that is still under development. Therefore, it is suggested to exclude secondary events from simulations.