Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: 29 Mar 2013

URL: http://cxc.harvard.edu/chart/threads/psf_image/

Creating an Image of the PSF


Overview

Synopsis:

The output of MARX is a pseudo event file containing a list of rays that have been projected onto the detector (recall that MARX includes the instrumental response when doing this). This thread shows how to bin the output file into an image that (optionally) matches that of your data. This image can then be used in your scientific analysis.

It is important to read the caveats before using the ChaRT PSF simulations in analysis.

Last Update: 29 Mar 2013 - updated file names from N003 to N004


Contents


Get Started

This example uses offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits, which was created in the Using MARX to Create an Event File thread. Also:

Download the sample data: 942 (ACIS-S, NGC 4244)

unix% download_chandra_obsid 942 evt2

Examine the Data

The following sections describe how to create an image of the PSF that is either centered on the PSF or matches an existing image of the dataset.

The projected rayfile (offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits) can be examined with dmlist:

unix% dmlist offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits blocks
 
--------------------------------------------------------------------------------
Dataset: offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits
--------------------------------------------------------------------------------
 
     Block Name                          Type         Dimensions
--------------------------------------------------------------------------------
Block    1: NULL                           Null
Block    2: EVENTS                         Table        22 cols x 116315   rows
Block    3: GTI4                           Table         2 cols x 1        rows
Block    4: GTI5                           Table         2 cols x 1        rows
Block    5: GTI6                           Table         2 cols x 1        rows
Block    6: GTI7                           Table         2 cols x 1        rows
Block    7: GTI8                           Table         2 cols x 1        rows
Block    8: GTI9                           Table         2 cols x 1        rows
Block    9: MARX_PAR                       Table         1 cols x 480      rows

unix% dmlist offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits cols
 
--------------------------------------------------------------------------------
Columns for Table Block EVENTS
--------------------------------------------------------------------------------
 
ColNo  Name                 Unit        Type             Range
   1   TIME                 s            Real8          362912400.0:362912600.6024336219 time since observation start
   2   CCD_ID                            Int2           0:9                  CCD id number
   3   NODE_ID                           Int2           -                    0-4
   4   EXPNO                             Int4           0:2147483647         Exposure number
   5   chip(CHIPX,CHIPY)    pixel        Int2           2:1023               CHIP X
   6   tdet(TDETX,TDETY)    pixel        Int4           2:8191               Detector X
   7   det(DETX,DETY)       pixel        Real8          0.50:     8192.50    Focal Plane X
   8   sky(X,Y)             pixel        Real8          0.50:     8192.50    sky X pixel
   9   PHA                  adu          Int4           0:36855              Total PHA for event
  10   ENERGY               eV           Real4          0:  1000000.0        Nominal energy of event
  11   PI                   Chan         Int2           -                    pulse invariant energy of event
  12   FLTGRADE                          Int2           0:255                Event Grade Code
  13   GRADE                             Int2           -                    ACIS grade code
  14   STATUS[2]                         Bit(2)                              status flags
  15   SHELL                             Int2           -                    Mirror Shell (0=1,1=3,2=4,3=6)
  16   ZCOS                              Real4          -Inf:+Inf            Z direction cosine
  17   YCOS                              Real4          -Inf:+Inf            Y direction cosine
  18   XCOS                              Real4          -Inf:+Inf            X direction cosine
  19   ZPOS                 mm           Real4          -Inf:+Inf            Z position in MARX coords
  20   YPOS                 mm           Real4          -Inf:+Inf            Y position in MARX coord system
  21   XPOS                 mm           Real4          -Inf:+Inf            X position in MARX coord system
  22   MARX_ENERGY          keV          Real4          -Inf:+Inf            Energy of ray

--------------------------------------------------------------------------------
World Coord Transforms for Columns in Table Block EVENTS
--------------------------------------------------------------------------------

ColNo    Name
8:    EQPOS(RA ) = (+184.3430) +TAN[(-0.000136667)* (sky(X)-(+4096.50))]
           (DEC)   (+37.7809 )      (+0.000136667)  (   (Y) (+4096.50))

Note that the table contains coordinates for the events in a number of coordinate systems. We shall assume that we want an image of the PSF in SKY coordinates.


Centering the PSF

Get the coordinates

The center of the PSF can be found by using the dmcoords tool to convert the input THETA and PHI values used to create the PSF into SKY coordinates. Note that "centering" may be a bit of a misnomer; far off-axis, it is likely that the "center" of the PSF is not coincident with either the centroid and/or the sky pixel matching the off-axis angle.

The necessary values are both recorded in the filename (offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits) and in the header of the original ChaRT output (HRMA_theta5.949_phi197.7_en1.7_d2.fits):

unix% dmlist HRMA_theta5.949_phi197.7_en1.7_d2.fits header | egrep 'SRC_(THET|PHI)'
0011 SRC_THET                     5.9490 [arcmin]        Real8        input THETA
0012 SRC_PHI                    197.740 [degrees]        Real8        input PHI

dmcoords can now be used to convert between this position (in the msc coordinate system) and the sky coordinate system. This conversion depends on the aspect solution, which varies with time; we use the nominal aspect solution (as given by the RA_NOM, DEC_NOM, and DEC_NOM keywords in the header of the event file:

unix% punlearn dmcoords
unix% dmcoords acisf00942N004_evt2.fits asol=pcadf075214790N004_asol1.fits
dmcoords>: MSC 5.9490 197.740
(RA,Dec):     12:16:57.136    +37:43:35.90
(RA,Dec):      184.23807       37.72664 deg
THETA,PHI          5.949'        197.74 deg
(Logical):        4704.01       3699.93
SKY(X,Y):         4704.01       3699.93
DETX,DETY         3405.51       3875.45
CHIP ACIS-S2       573.44        753.80
TDET              3448.44       2455.80

This step could also be done with dmcoords in non-interactive mode:

unix% dmcoords acisf00942N004_evt2.fits asol=pcadf075214790N004_asol1.fits opt=msc theta=5.9490 phi=197.740
unix% pget dmcoords x y
4704.010656034712
3699.93423167626

Calculate the binning factor

We choose to create a 512 x 512 pixel image around the central position (with a binning factor of 1) in order to encompass most of the PSF signal. To calculate a 512 x 512 region centered at (4704.01, 3699.93):

512/2 = 256

X direction: 4704.01-256 = 4448.01
	     4704.01+256 = 4960.01

Y direction: 3699.93-256 = 3443.93
	     3699.93+256 = 3955.93

The binning factor is [bin x=4448.01:4960.01:1,y=3443.93:3955.93:1].


Create the image

Now we can use dmcopy with the binning syntax to create an image:

unix% dmcopy \
      "offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits[bin x=4448.01:4960.01:1,y=3443.93:3955.93:1]" \
      psf_512.fits
[Thumbnail image: 512 by 512 pixel image of PSF]

[Version: full-size]

[Print media version: 512 by 512 pixel image of PSF]

Figure 1: Image of the PSF

The PSF image is 512 x 512 pixels.


Binning the Rayfile to Match an Image

An alternative approach is to bin the PSF image to match an existing image of your data. The image of the data in this example was made by creating an event file of chip S2 (ccd_id=6) and simultaneously binning it into an image:

unix% more ds9.reg
# Region file format: CIAO version 1.0
rotbox(4552.2734,3517.8837,1071.6108,1064.0118,38.490129)

unix% dmcopy \
      "acisf00942N004_evt2.fits[ccd_id=6,sky=region(ds9.reg)][bin sky=2]" \
      942_image.fits
[Thumbnail image: Image of the event data (ObsID 942)]

[Version: full-size]

[Print media version: Image of the event data (ObsID 942)]

Figure 2: Image of the event data

The event file for ObsID 942 is filtered on ccd_id=6 and sky, then binned by a factor of 2 to create an image.

The get_sky_limits script (part of the CIAO Scripts distribution) can be used to find out the necessary DM binning specification to match the PSF to this image:

unix% get_sky_limits 942_image.fits verbose=1
Checking binning of image: 942_image.fits
  Image has 751 x 750 pixels
  Lower left (0.5,0.5) corner is x,y= 3801.8, 2768.0
  Upper right (751.5,750.5) corner is x,y= 5303.8, 4268.0
  DM filter is:
    x=3801.8:5303.8:#751,y=2768.0:4268.0:#750
  mkexpmap xygrid value is:
    3801.8:5303.8:#751,2768.0:4268.0:#750

Finally, use dmcopy to create the image:

unix% dmcopy \
      "offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits[bin x=3801.8:5303.8:#751,y=2768.0:4268.0:#750]" \
      psf_match.fits

Displaying the two images side-by-side:

unix% ds9 psf_match.fits 942_image.fits &
[Thumbnail image: Image of the PSF matched to the data in ds9]

[Version: full-size]

[Print media version: Image of the PSF matched to the data in ds9]

Figure 3: Image of the PSF matched to the data

The PSF image is on the left and the event data is on the right. It is easy to see that the PSF lines up with the chosen source (see the Preparing to Run ChaRT thread).


Create a Sub-pixelated PSF Image

Viewing in ds9

Since the projected event file contains X and Y values without any pixel quantization, a 2-D histogram image can be made at any desired sub-pixel scale. To visualize this with ds9, load the event file:

unix% ds9 offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits &

Using the Bin and Zoom menus, zoom in and center on the object. Select "Bin -> Binning Parameters" from the menu bar. By changing the "Bin Factor" in the pop-up window, you can adjust the scale size of a bin.

Figure 4 shows the sub-pixelated PSF image resulting from a 0.1 pixel bin factor. The smooth distribution of events verifies that the simulation was done correctly.

[Thumbnail image: Sub-pixelated PSF image from good event file]

[Version: full-size]

[Print media version: Sub-pixelated PSF image from good event file]

Figure 4: Sub-pixelated PSF image from good event file

This sub-pixelated PSF image was made with a 0.1 pixel bin factor. The smooth distribution of events verifies that the simulation was done correctly.

If the image has boxy features, as shown in Figure 5, something was done wrong.

[Thumbnail image: Sub-pixelated PSF image from bad event file]

[Version: full-size]

[Print media version: Sub-pixelated PSF image from bad event file]

Figure 5: Sub-pixelated PSF image from bad event file

This image was created from a similar MARX run as used in the Using MARX to Create an Event File thread, but with DitherModel set to NONE; the event file therefore does not contain sub-pixel resolution.


Binning with dmcopy

To create the sub-pixelated image with dmcopy, use a similar filter to the one given in the Centering the PSF section. Since the binning factor has been decreased from 1.0 to 0.1, the limits have been changed to +/- 25.6 pixels to create the 512 square pixel image:

unix% dmcopy \
      "offset_marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits[bin x=4678.41:4729.61:0.1,y=3674.33:3725.53:0.1]" \
      psf_subpix.fits
[Thumbnail image: Sub-pixelated PSF image created with dmcopy]

[Version: full-size]

[Print media version: Sub-pixelated PSF image created with dmcopy]

Figure 6: Sub-pixelated PSF image created with dmcopy

A 512 square pixel image of the PSF created at a binning of 0.1.


Caveats

Encircled-energy fractions

The images created above are unlikely to contain all the flux of the PSF. The output of MARX contains 114776 rays (as shown in the Examine the Data section). The first image we create from the rayfile contains only 113861 rays, as shown by dmstat:

unix% dmstat psf_512.fits centroid=no sigma=no
EVENTS_IMAGE
    min:        0             @:        ( 4449 3444 )
    max:        2097          @:        ( 4702 3701 )
   mean:        0.44020843506
    sum:        115398
   good:        262144
   null:        0

In comparison, running the same command on psf_match.fits reveals a total of 114732 rays in that image:

unix% dmstat psf_match.fits centroid=no sigma=no
EVENTS_IMAGE
    min:        0             @:        ( 3802.8 2769 )
    max:        7034          @:        ( 4700.8 3701 )
   mean:        0.2064198846
    sum:        116266
   good:        563250
   null:        0

Since we chose a large region around the PSF center, virtually all the rays were included. For smaller regions the loss will be larger. This factor will need to be included in calculations of the encircled-energy fraction for an aperture.


Summary

These images of the PSF can now be used in a CIAO analysis session.


History

27 Jun 2003 original version, updated for CIAO 3.0: layout
16 Feb 2005 reviewed for CIAO 3.3: no changes
18 Aug 2008 updated for CIAO 4.0: version N003 event file, minor changes to screen output; converted images to inline
17 Feb 2010 reviewed for CIAO 4.2: minor updates to screen output
15 Dec 2010 reviewed for CIAO 4.3: no changes
29 Mar 2013 updated file names from N003 to N004


Last modified: 29 Mar 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email:   cxcweb@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2014. All rights reserved.