Skip to the navigation links
Last modified: 17 Feb 2010
Hardcopy (PDF): A4 | Letter

Preparing to Run ChaRT

[S-Lang Syntax]



Overview

Last Update: 17 Feb 2010 - reviewed for CIAO 4.2: minor updates to screen output to match Sherpa 4.2; added Scripting It section

Synopsis:

This thread shows how to find the parameter values needed to run ChaRT. These values consist of the coordinates and spectral specifications (whether "energies with density" or "spectrum with exposure time") for the PSF. Note that the "spectrum with exposure time" works well for ACIS; for HRC, the "energies with density" option is recommended.

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




Contents



Get Started

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

File types needed: evt2

If you use a spectrum file as the spectral specification for your PSF, you will need to use the module, which is part of the CIAO Scripts distribution. The CIAO scripts package should be dated April 17 or newer:

unix% cat $ASCDS_CONTRIB/VERSION.CIAO_scripts
17 Apr 2009

Please check that you are using the most recent version before continuing. If you do not have the scripts installed or need to update to a newer version, refer to the Scripts page.



Determine the Off-axis Angle

It is necessary to find the location of the source (or position) for which you would like to generate a PSF. To find the coordinates of a source - that is, the offsets from the optical axis - display the event file in ds9:

unix% ds9 acisf00942N003_evt2.fits
[Thumbnail image: The entire field next to a close-up of the desired source displayed in ds9.]

[Version: full-size]

[Print media version: The entire field next to a close-up of the desired source displayed in ds9.]

Figure 1: Reading the off-axis angle

The entire field is shown in the left frame of ds9 with the source marked by a cross. In the right frame, the image is zoomed and the desired source is circled.

Simply read the sky (physical) coordinates from ds9 as you pass the cursor over the image.

(x,y) = (4704,3700)

Since ChaRT requires the position to be in terms of theta and phi, dmcoords is used to convert the values:

unix% dmcoords acisf00942N003_evt2.fits asol=pcadf075214790N003_asol1.fits opt=sky x=4704 y=3700 
unix% pget dmcoords theta phi
5.948632053025285
197.7438897007665

The position is therefore:

(theta,phi) = (5.949,197.74)

The values are given in the necessary units - theta in [arcmin] and phi in [deg]. This step could also be done with dmcoords in interactive mode:

unix%  dmcoords acisf00942N003_evt2.fits asol=pcadf075214790N003_asol1.fits 
dmcoords>: sky 4704 3700
(RA,Dec):     12:16:57.136    +37:43:35.94
(RA,Dec):      184.23807       37.72665 deg
THETA,PHI          5.949'        197.74 deg
(Logical):        4704.00       3700.00
SKY(X,Y):         4704.00       3700.00
DETX,DETY         3405.57       3875.41
CHIP ACIS-S2       573.49        753.83
TDET              3448.49       2455.83
dmcoords>: q

When running dmcoords interactively, a small value of theta is returned in [arcsec] and you must convert it to [arcmin]. For more information on coordinate definitions, read the CIAO thread on using ds9.

Caveat: if your event file has been reprojected (see reproject_events) dmcoords will not calculate theta and phi correctly; see the CIAO bugs page for more information. To avoid this bug, either use the original level=2 event file in this step or follow the workaround given on the bug page.



Spectral Specification of the PSF

The spectral information for the PSF may be provided as either a list of monochromatic energies and a ray density or a source spectrum file and an exposure time.

Energy & Density

Energy: a list of up to ten monochromatic energies between 0.2 and 10 keV. The values must be given in [keV] as well.

Density: a single value indicating the density of rays that will be generated at the entrance aperture. The allowed range is 0.001 to 10 rays/mm2. The number of rays that arrive at the focal plane is determined by the HRMA effective area at the input energies.

This option is useful when assembling a composite spectrum from several mono-energetic simulations, and it is the preferred method for the HRC, because the construction of a spectral file for the HRC is not straightforward.

Using the "energy & density" option

  1. The purpose of making the PSF
    1. To make a PSF with approximately the same number of counts as the source under investigation. For example, you may want to subtract the PSF at the source position in order to look for extended, low brightness emission around the source.

    2. To define the PSF with a much higher S/N than the data.

  2. Select an energy

    HRC: for most sources, a monochromatic PSF will suffice, with an energy input of 1 keV. For some sources, e.g. super soft sources, another monoenergy - maybe 0.2 keV - would be a better choice, or perhaps the simulation should include both 0.2 and 1 keV.

    ACIS: the user will have to decide if a single energy PSF is sufficient, and if not, the known or suspected source spectrum will dictate the choice of energies.

  3. Determine the necessary density

    Now we need to estimate density to input. Looking at the Effective Area (EA) curve for HRC-I in the POG, we can estimate the EA to be 200 cm2 at 1 keV. Since the ChaRT input requires units of rays/mm2, we can calculate a source density which is approximately

    (# counts in your source)/(20000 mm^2).
    

    If you want to create a PSF with a much higher S/N, you can increase the number of rays by some factor like 10 or 100 (so long as you don't exceed the maximum of 10 rays/mm2).


Spectrum & Exposure Time

Exposure Time: the desired exposure time for the simulation. It must be given in [ks] and be within the range of 0 to 200 ks.

The value is usually chosen to match the exposure time of the observation, which is stored in the EXPOSURE header keyword of the event file:

unix% dmkeypar acisf00942N003_evt2.fits exposure echo+
49215.214915137

The exposure time is returned in [s], so this observation is 49 ks long.

Spectrum: a file containing the definition of the source spectrum at the entrance aperture of the HRMA for which you would like a PSF to be simulated.

A common user error has proven to be using a file with incorrect units, which often results in ChaRT producing a PSF model that appears much too bright. The file must be energy [keV] vs flux [photons/cm2/s]. Currently, ChaRT will not complain if it appears that the file has incorrect units, so it is up to the user to check that the file is accurate.

For directions on creating a spectrum for your source, see the CIAO Imaging Spectroscopy threads. Then fit the data as described in the Fitting PHA Spectra Sherpa thread.

For this example, the spectrum is fit with a one-dimensional power law multiplied by a photoelectric absorption model.

unix% sherpa
-----------------------------------------------------
Welcome to Sherpa: CXC's Modeling and Fitting Package
-----------------------------------------------------
CIAO 4.2 Monday, November 30, 2009

sherpa> load_pha("3c273.pi");
sherpa> subtract;
sherpa> notice(0.4, 6.0);
sherpa> set_source(xsphabs.abs1 * powlaw1d.p1);
sherpa> abs1.nh = 0.07;
sherpa> freeze(abs1);
sherpa> guess(p1);
sherpa> fit;
Dataset               = 1
Method                = levmar
Statistic             = chi2gehrels
Initial fit statistic = 71.8133
Final fit statistic   = 23.6368 at function evaluation 16
Data points           = 42
Degrees of freedom    = 40
Probability [Q-value] = 0.981499
Reduced statistic     = 0.590919
Change in statistic   = 48.1766
   p1.gamma       2.13334
   p1.ampl        0.000220644

The script must be loaded into Sherpa before it can be run (this step is only necessary once per session):

sherpa> require("sherpa_chart");

If you would like to plot your spectrum, use the function plot_chart_spectrum(); the optional elow and ehigh values specify the minimum and maximum energies to include in the plot:

sherpa> plot_chart_spectrum();
sherpa> plot_chart_spectrum(;elow=1.0, ehigh=8.0);

Figure 2 shows the resulting plot.

[A plot of flux (photons per cm^2 per s) against energy (keV).]
[Print media version: A plot of flux (photons per cm^2 per s) against energy (keV).]

Figure 2: A plot of the ChaRT spectrum

The source model is plotted in units of photons per cm2 per s against energy (keV), as required by ChaRT.

The save_chart_spectrum() command is used to create the output file. In this example, we use the optional elow and ehigh arguments to restrict the output to the 1-8 keV range. If the bounds are omitted, the full energy range as determined by Sherpa is used.

sherpa> save_chart_spectrum("source_flux_chart.dat"; elow=1.0, ehigh=8.0);
Created: source_flux_chart.dat
sherpa> quit

The output produced by save_chart_spectrum is an ASCII file that contains two columns. The first column gives the center of the energy bin in [keV]. The second column is the flux in [photons/cm2/s].

unix% more source_flux_chart.dat
1.005   1.82537e-06
1.015   1.7956e-06
1.025   1.76639e-06
1.035   1.73775e-06
1.045   1.70966e-06
1.055   1.68211e-06
1.065   1.6551e-06
1.075   1.62822e-06
1.085   1.60202e-06
1.095   1.57659e-06
...
7.935   2.65464e-08
7.945   2.64753e-08
7.955   2.64045e-08
7.965   2.63339e-08
7.975   2.62637e-08
7.985   2.61937e-08
7.995   2.6124e-08


Scripting It

The file fit.sl is an S-Lang script which performs the primary commands used above; it can be executed by typing evalfile("fit.sl") on the Sherpa command line.




Summary

Since all the necessary information has been obtained, you are ready to run ChaRT.



History

14 Dec 2004 updated for CIAO 3.2: location of chart_spectrum.sl
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; the chart_spectrum.sl script must be run in CIAO 3.4 (a new version for CIAO 4 will be released as soon as it is available); updated to have inline image
08 Oct 2008 when using the Spectrum & Exposure Time method, exposure time may be up to 200 ks
02 Mar 2009 the chart_spectrum script has been updated for CIAO 4.1 - Python and S-Lang versions are available (revision "CIAO 4.1 - 1.0"); information Spectrum & Exposure Time section expanded
15 Apr 2009 The chart_spectrum script has been renamed to the sherpa_chart module; the write_chart_spectrum() has been renamed save_chart_spectrum(); the old version of the script and routine have been retained but are now deprecated; ahelp files are now available for save_chart_spectrum, plot_chart_spectrum, and get_chart_spectrum.
17 Feb 2010 reviewed for CIAO 4.2: minor updates to screen output to match Sherpa 4.2; added Scripting It section

Return to Threads Page

Hardcopy (PDF): A4 | Letter
Last modified: 17 Feb 2010