PyXspec  1.1.0
Public Member Functions | Public Attributes
DataManager Class Reference

List of all members.

Public Member Functions

def __init__
def __call__
def __isub__
def __iadd__
def clear
def diagrsp
def dummyrsp
def fakeit
def ignore
def notice
def removeDummyrsp
def show

Public Attributes

 The number of data groups [int].
 The number of loaded spectra [int].

Detailed Description

Spectral data container.

This is a singleton - only 1 instance allowed

Public instance attributes, GET only unless stated otherwise.

   nGroups  -- The number of data groups [int].
   nSpectra -- The number of loaded spectra [int].

Constructor & Destructor Documentation

def __init__ (   self)

Member Function Documentation

def __call__ (   self,
DataManager get or set spectra.

  expr -- An integer referring to the spectrum index number.  Returns
    the spectrum, or raises an Exception if the integer is out
    of range.
  expr -- A string following the same syntax rules as Xspec's
    traditional "data" command handler. 

def __iadd__ (   self,
Add 1 spectrum to the data container.

spectra - the data filename string.

def __isub__ (   self,
Remove 1 or all spectra from the data container.

spectra - either a single spectrum index number (int), a single
  Spectrum object, or the string "*" to remove all. 

def clear (   self)
Remove all spectra from the data container.
def diagrsp (   self)
Diagonalize the current response matrix for ideal response.

All currently loaded responses will be replaced with diagonal
response matrices.  The energy range and channel binning
information are retained from the original response, as is the
effective area.  The channel values are mapped directly into the
corresponding energy ranges to simulate a detector with perfect
spectral resolution.

To remove diagonal responses and restore the originals, call the
AllData.removeDummyrsp() method.

def dummyrsp (   self,
  lowE = None,
  highE = None,
  nBins = None,
  scaleType = None,
  chanOffset = None,
  chanWidth = None 
Create a dummy response and apply it to all spectra.

   Input arguments, all are optional:
     lowE  - Input response energy lower bound, in keV. [float]
     highE - Input response energy higher bound, in keV. [float]
     nBins - Number of bins into which the energy range is divided
     scaleType - "log" or "lin" [string]
     chanOffset - Starting value of dummy channel energies. [float]
     chanWidth  - Energy width of the channel bins.  [float]
             If this is set to 0, the dummy response
             can only be used for evaluating model arrays,
             and not for fitting to spectra.


# All values are optional, use keywords to enter values
# non-consecutively.  Unspecified values revert to the
# current defaults.
AllData.dummyrsp(.3, 30., 100, chanWidth=.5)
AllData.dummyrsp(highE = 50.)
AllData.dummyrsp(.1,10.,100,"lin",.0, 1.0)

Initial defaults:  lowE = .1, highE = 50., nBins = 50, scaleType = "log"
   chanOffset = .0, chanWidth = .0             
The defaults for lowE, highE, nBins, scaleType, and chanOffset will be
modified for each explicit new entry.  chanWidth always defaults to 0.

To remove dummy responses and restore actual responses (if any), call
the removeDummyrsp() method.

To apply a dummy response to just a single spectrum, use the 
Spectrum.dummyrsp method.

def fakeit (   self,
  nSpectra = 1,
  settings = None,
  applyStats = True,
  filePrefix = "",
  noWrite = False 
Produce spectra with simulated data using XSPEC's fakeit command.

Note that if this method is run when spectra are currently loaded, it
will follow the same rule as the standard XSPEC fakeit function:
It will REMOVE ALL pre-existing spectra and replace each one with
a simulated spectrum (even if nSpectra is less than the number 
originally loaded).  

All arguments are optional:

  nSpectra   -- The number of fake spectra to produce.  [int]
        If there are nOrig pre-existing spectra loaded at the
        time this function is called and nSpectra < nOrig,
        nSpectra will be RESET to nOrig (see note above).
        If nSpectra == nOrig, then each of the fake spectra 
        will use the settings from the respective original
        spectra for their defaults (see the FakeitSettings 
        class description).
        If nSpectra > nOrig, then settings for the fake spectra 
        numbered above nOrig will not be based on pre-existing
        spectra (if any).
  settings   -- A collection of 0 to nSpectra FakeitSettings objects,
        which may be entered as a list, a dictionary, a
        single FakeitSettings object, or None.
        If settings is a dictionary, the key,value pairs should
        be the spectrum index number (1 is lowest) and the
        FakeitSettings object.
        This function will match up FakeitSettings objects
        1-to-1 with the nSpectra fake spectra to be created.
        If user provides FEWER than nSpectra FakeitSettings 
        objects, fakeit will generate the necessary additional
        objects with their default settings.  
        If MORE than nSpectra FakeitSettings objects are
        provided, the extra objects will be ignored.
  applyStats -- If set to True, statistical fluctuations will be
        included in the generation of fake spectra.  [bool]
  filePrefix -- Optional string to attach as a prefix to default fakeit
        output file names.  Note that this only applies when
        using the default file names.  If a file name is
        explicitly entered in the FakeitSettings.fileName
        attribute, it will not make use of this.
  noWrite    -- If set to True, no fakeit output files will be generated.
        Default is False.  [bool]

   # Assume no data is loaded, but a model is defined:
   # Creates 1 fake spectrum using the default FakeitSettings object,
   # which has all input strings empty.  So it will use XSPEC's internal
   # dummy response and its output file name will be dummy_rsp_1.fak.
   # Now assume AllData contains 2 spectra PRIOR to running EACH of the
   # following commands, then:
   # Creates 2 fake spectra with all settings (response, arf,
   # background, exposure, corrscale, backExposure, filenames) based
   # on the original spectra.  The original 2 spectra are removed from
   # AllData.
   # Creates the first 2 spectra as above.  The 3rd fake spectrum is
   # based on the default FakeitSettings object and its output filename
   # will be dummy_rsp_3.fak
   fs = FakeitSettings(background="back1.pha", exposure=2000.0)
   sl = 3*[fs]
   AllData.fakeit(3, sl)
   # Same as above, but all 3 fake spectra will have a background file
   # based on back1.pha, and exposure time = 2000.0 sec.
   AllData.fakeit(3, sl, False, "my_fake_")
   # Same as above, but no statistical fluctuations will be applied to
   # fake spectra, and all output files will have the "my_fake_"
   # prefix attached.
   fs1 = FakeitSettings("resp1.rmf","arf1.pha",exposure=1500.)
   fs2 = FakeitSettings(fs1)
   fs2.response = "resp2.rmf"
   sd = {3:fs1, 5:fs2}
   AllData.fakeit(5, sd)
   # Creates 5 fake spectra.  The first 2 use the settings from the
   # originally loaded data.  Spectra 3 and 5 use the settings from
   # the fs1 and fs2 FakeitSettings objects, which differ only in their
   # response names.  Spectrum 4 uses the default FakeitSettings object.
def ignore (   self,
Apply an ingore channels range to multiple loaded spectra.

ignoreRange -- String specifying the spectra ranges and/or
         channel ranges to ignore, or "bad".
         This follows the same syntax as used in the standard
         Xspec "ignore" command, except that the spectrum range
         always defaults to ALL spectra.
         If the channel ranges are floats rather than ints, 
         they will be treated as energies or wavelengths 
         (depending on the Plot settings).
def notice (   self,
Apply a notice channels range to multiple loaded spectra.

noticeRange -- String specifying the spectra ranges and/or channel 
         ranges to notice.  This follows the same syntax as 
         used in the standard Xspec "notice" command, except
         that the spectrum range always defaults to ALL spectra.
         If the numbers are floats rather than ints, they will 
         be treated as energies or wavelengths (depending on 
         the Plot settings).  If the string is "all", it will 
         notice all channels in all spectra.

def removeDummyrsp (   self)
Remove all dummy responses, restore original responses (if any).
def show (   self)
Display information for all loaded spectra.

Member Data Documentation

The number of data groups [int].

The number of loaded spectra [int].

The documentation for this class was generated from the following file: