项目作者: kglotfelty

项目描述 :
Make Color Color diagrams for X-ray data analysis
高级语言: Jupyter Notebook
项目地址: git://github.com/kglotfelty/ColorColor.git
创建时间: 2017-09-21T14:36:11Z
项目社区:https://github.com/kglotfelty/ColorColor

开源协议:

下载


Color-color diagram

color-color

In X-ray astronomy we usually define “color” as the hardness ratio.

The hardness ratio is the ratio of the difference in the
number of counts in two independent energy bands divided by the
total number of counts. The total number of counts may be the sum of
the two energy bands, or may be the total over a wider energy range
that full encloses the bands being used.

Thus defined, the hardness ratio will be between -1 and 1. Values closer
to -1 are “soft”, low energy band dominates. Values closer to 1 are “hard”,
high energy band dominates.

A color-color plot then shows the hardness ratio in 1 pair of
energy bands along the X-axis, and a different pair of energy bands
along the Y-axis.

This collection of classes simulates a spectrum with the user
specified spectral model and instrument response. Two of the model parameters
are varied over an input grid and the color in the different
energy bands is computed. This grid is then plotted in the color-color
diagram.

The idea is that for a source, if you compute the colors and assume a
spectral model shape, you can get an estimate of the model parameters
by looking at the color-color diagram.

These routines are dependent on Sherpa
for the models. Plotting is done using matplotlib.

Examples

Command line tool

The plot shown above was created using the following command line

  1. $ color_color acis.arf clr.fits mode=h showplot=yes outplot=clr.png \
  2. model="xsphabs.abs1*xspowerlaw.pwrlaw" \
  3. param1=pwrlaw.PhoIndex \
  4. grid1=1,2,3,4 \
  5. param2=abs1.nH \
  6. grid2=0.01,0.1,0.2,0.5,1,10 \
  7. soft=csc medium=csc hard=csc \
  8. clobber=yes

The values are also stored in the output file clr.fits

  1. $ dmlist clr.fits cols
  2. --------------------------------------------------------------------------------
  3. Columns for Table Block TABLE
  4. --------------------------------------------------------------------------------
  5. ColNo Name Unit Type Range
  6. 1 PhoIndex Real8 -Inf:+Inf
  7. 2 nH Real8 -Inf:+Inf
  8. 3 S_COUNTS Real8 -Inf:+Inf
  9. 4 M_COUNTS Real8 -Inf:+Inf
  10. 5 H_COUNTS Real8 -Inf:+Inf
  11. 6 HARD_HM Real8 -Inf:+Inf
  12. 7 HARD_MS Real8 -Inf:+Inf

Python module

  1. from color_color import *
  2. import sherpa.astro.ui as ui
  3. #
  4. # Define our energy bands
  5. #
  6. soft = EnergyBand( 0.5, 1.2, 'S')
  7. medium = EnergyBand(1.2, 2.0, 'M')
  8. hard = EnergyBand(2.0, 7.0, 'H')
  9. #
  10. # Define model
  11. #
  12. mymodel = ui.xswabs.abs1 * ui.xspowerlaw.pwrlaw
  13. arffile = "acissD2006-10-26pimmsN0009.fits"
  14. #
  15. # First model parameter axis
  16. #
  17. pho_grid = [ 1., 2., 3., 4. ]
  18. photon_index = ModelParameter( pwrlaw.PhoIndex, pho_grid)
  19. #
  20. # Second model parameter axis
  21. #
  22. sg = [ 1.e20, 1.e21, 2.e21, 5.e21, 1.e22, 1e23]
  23. nh_grid = [x/1e22 for x in sg ]
  24. absorption = ModelParameter( abs1.nH, nh_grid)
  25. #
  26. # Get to work.
  27. #
  28. hm_ms = ColorColor( mymodel, arffile )
  29. hm_ms_results = hm_ms( photon_index, absorption, soft, medium, hard)
  30. #
  31. # Setup plot styles
  32. #
  33. photon_index.set_curve_style(marker="", color="black" )
  34. absorption.set_curve_style(marker="", linestyle="--", color="forestgreen")
  35. absorption.set_label_style(color="forestgreen")
  36. hm_ms_results.plot("color_color.png")
  37. vals = hm_ms_results.get_results()

The output looks like

color-color diagram

Now suppose there was a source with (H-M)=-0.25 and (M-S)=-0.2.
If the assumption about the spectral model is correct, then it would
be expected to have a photon index between 2 and 3 and absorption between 0.2 and 0.5
e10^22.

Total energy band

If the total energy band is None then the routines will use the sum of
the individual bands independently for each axis. In this case the
color values will fill the entire -1:1 parameter space.

If the total energy band is specified, then it may be the case that only
part of the parameter space is filled.

Background

Background is not treated specifically with these routines, but you can
include the background term in the model expression, something like

  1. mymodel = ui.xswabs.abs1 * ui.xspowerlaw.pwrlaw + ui.const1d.bkg
  2. bkg.c0 = 0.01

to see how it affects things. The background model component
can be as complicated as needed.