About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 16 Feb 2005
Hardcopy (PDF): A4 | Letter

Creating an Image of the PSF



Overview

Last Update: 16 Feb 2005 - reviewed for CIAO 3.3: no changes

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.

Proceed to the HTML or hardcopy (PDF: A4 | letter) version of the thread.




Contents



Get Started

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

Sample ObsID used: 942 (ACIS-S, NGC 4244)

File types needed: 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 (marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits) can be examined with dmlist:

unix% dmlist marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits blocks
 
--------------------------------------------------------------------------------
Dataset: 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 110323   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 482      rows


unix% dmlist 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          256491602.0:256491802.6024337113 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.3422) +TAN[(-0.000136667)* (sky(X)-(+4096.50))]
           (DEC)   (+37.7807 )      (+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 (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)'
0027 SRC_THET                     5.9490 [arcmin]        Real8        input THETA
0028 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 acisf00942N002_evt2.fits
dmcoords>: MSC 5.9490 197.740
(RA,Dec):     12:16:56.922    +37:43:35.29   
(RA,Dec):      184.23718       37.72647 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.25        753.80
TDET              3448.25       2455.80

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

unix% dmcoords acisf00942N002_evt2.fits opt=msc theta=5.9490 phi=197.740
unix% pget dmcoords x y
4704.006877489704
3699.928443272795

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

Rounding to 0.5 pixel, the binning factor is [bin x=4448.5:4960.5:1,y=3443.5:3955.5:1].


Create the image

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

unix% dmcopy \
      "marx_HRMA_theta5.949_phi197.7_en1.7_d2.fits[bin x=4448.5:4960.5:1,y=3443.5:3955.5:1]" \
      psf_512.fits

Figure 1 [Link to Image 1: 512 by 512 pixel image of PSF] shows the the image displayed in ds9.



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 \
      "acisf00942N002_evt2.fits[ccd_id=6,sky=region(ds9.reg)][bin sky=2]" \
      942_image.fits

The resulting image can be seen in Figure 2 [Link to Image 2: Image of the event data (ObsID 942)].

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 \
      "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 &

results in Figure 3 [Link to Image 3: Image of the PSF matched to the data]. It is easy to see that the location of the PSF (left frame) corresponds to the source (right frame) chosen in 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 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 [Link to Image 4: Sub-pixelated PSF image from good event file] 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.

If the image has boxy features, as shown in Figure 5 [Link to Image 5: Sub-pixelated PSF image from bad event file], something was done wrong. 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 \
      "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

Figure 6 [Link to Image 6: Sub-pixelated PSF image created with dmcopy] shows the image displayed in ds9.



Caveats

Encircled-energy fractions

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

unix% dmstat psf_512.fits centroid=no sigma=no
EVENTS_IMAGE
    min:        0             @:        ( 4449 3444 )
    max:        2064          @:        ( 4701 3701 )
   mean:        0.41767883301 
    sum:        109492  
   good:        262144 
   null:        0 

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

dmstat psf_match.fits  centroid=no sigma=no
EVENTS_IMAGE
    min:        0             @:        ( 3802.8 2769 )
    max:        6749          @:        ( 4700.8 3701 )
   mean:        0.19580470484 
    sum:        110287  
   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

Return to Threads Page
Hardcopy (PDF): A4 | Letter
Last modified: 16 Feb 2005


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-2004. All rights reserved.