Last modified: December 2020

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/fake_pha.html
Jump to: Description · Examples · PARAMETERS · Notes · Bugs · See Also


AHELP for CIAO 4.13 Sherpa v1

fake_pha

Context: data

Synopsis

Simulate a PHA data set from a model.

Syntax

fake_pha(id, arf, rmf, exposure, backscal=None, areascal=None,
grouping=None, grouped=False, quality=None, bkg=None)

id - int or str
arf - filename or ARF object
rmf - filename or RMF object
exposure - number
backscal - number, optional
areascal - number, optional
grouping - array, optional
grouped - bool, optional
quality - array, optional
bkg - optional

Description

The function creates a simulated PHA data set based on a source model, instrument response (given as an ARF and RMF), and exposure time, along with a Poisson noise term. A background component can be included.


Examples

Example 1

Estimate the signal from a 5000 second observation using the ARF and RMF from "src.arf" and "src.rmf" respectively:

>>> set_source(1, xsphabs.gal * xsapec.clus)
>>> gal.nh = 0.12
>>> clus.kt, clus.abundanc = 4.5, 0.3
>>> clus.redshift = 0.187
>>> clus.norm = 1.2e-3
>>> fake_pha(1, 'src.arf', 'src.rmf', 5000)

Example 2

Simulate a 1 mega second observation for the data and model from the default data set. The simulated data will include an estimated background component based on scaling the existing background observations for the source. The simulated data set, which has the same grouping as the default set, for easier comparison, is created with the 'sim' label and then written out to the file 'sim.pi':

>>> arf = get_arf()
>>> rmf = get_rmf()
>>> bkg = get_bkg()
>>> bscal = get_backscal()
>>> grp = get_grouping()
>>> qual = get_quality()
>>> texp = 1e6
>>> set_source('sim', get_source())
>>> fake_pha('sim', arf, rmf, texp, backscal=bscal, bkg=bkg,
...          grouping=grp, quality=qual, grouped=True)
>>> save_pha('sim', 'sim.pi')

PARAMETERS

The parameters for this function are:

Parameter Definition
id The identifier for the data set to create. If it already exists then it is assumed to contain a PHA data set and the counts will be over-written.
arf The name of the ARF, or an ARF data object (e.g. as returned by `get_arf` or `unpack_arf` ).
rmf The name of the RMF, or an RMF data object (e.g. as returned by `get_arf` or `unpack_arf` ).
exposure The exposure time, in seconds.
backscal The 'BACKSCAL' value for the data set.
areascal The 'AREASCAL' value for the data set.
grouping The grouping array for the data (see `set_grouping` ).
grouped Should the simulated data be grouped (see `group` )? The default is False . This value is only used if the `grouping` parameter is set.
quality The quality array for the data (see `set_quality` ).
bkg If left empty, then only the source emission is simulated. If set to a PHA data object, then the counts from this data set are scaled appropriately and added to the simulated source signal.

Notes

A model expression is created by using the supplied ARF and RMF to convolve the source expression for the dataset (the return value of `get_source` for the supplied `id` parameter). This expresion is evaluated for each channel to create the expectation values, which is then passed to a Poisson random number generator to determine the observed number of counts per channel. Any background component is scaled by appropriate terms (exsposure time, area scaling, and the backscal value) before adding to the simulated date. That is, the background component is not simulated.


Bugs

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

data
fake, get_arf, get_rmf, load_pha, pack_pha, unpack_bkg, unpack_pha