class xspec.Response(parent, respTuple)

Detector response class.


  • setPars

  • show

Attributes (get-only unless stated otherwise)

  • arf

    Get/Set the arf filename string. Enter None or empty string to remove an existing arf.

  • chanEnergies

    Tuple of floats, the detector channel energies in keV. These are the energies normally stored in the EBOUNDS extension.

  • energies

    Tuple of floats, the photon energies in keV. These are the energies normally stored in the MATRIX extension.

  • gain

    A response model object (class RModel) for applying a shift in response file gain.

    (Also see Response.setPars() for setting multiple gain parameters at a time.)

    When gain is turned ON, it creates two variable fit Parameter object members:

    >>> gain.slope   # (default = 1.0)
    >>> gain.offset  # (default = 0.0)

    To turn gain ON simply assign a value to EITHER parameter, ie.:

    >>> gain.slope = 1.05

    This automatically also creates a gain.offset parameter with default value 0.0, which you may want to re-adjust. Examples:

    >>> gain.offset = .02
    >>> gain.offset.values = ".015,.001,,,,0.1"

    slope and offset are of the same type as regular model parameters, and therefore have the same functions, attributes, and syntax rules for setting values. (See the Parameter class help for more details.)

    To turn gain OFF, call its off() method:

 restores the response to its original state, and renders the slope and offset parameters inaccessible.

  • rmf

    The response file name string.

  • sourceNumber

    The 1-based source number for which the response is assigned. This is normally always 1 unless multiple sources are loaded for multiple-model evaluation.


Set multiple response parameters with a single function call.

Similar to the Model.setPars() function, this allows multiple response parameters to be changed with just a SINGLE recalculation performed at the end.


An arbitrary number of CONSECUTIVE parameter values to be matched 1-to-1 with the response model's parameters.

Currently just 1 response model is available (gain), which has 2 response parameters (slope and offset).


s = Spectrum("file1")
resp = s.response

# 'gain' is off by default and response parameters don't yet exist.
#   The following call automatically turns 'gain' on and creates
#   both 'slope' and 'offset' parameters even though it is only
#   assigning to 'slope'.  'offset' will retain its default value
#   of 0.0.
resp.setPars(1.05)  # Equivalent to doing: resp.gain.slope = 1.05

# This is equivalent to: resp.gain.slope = .995
#                        resp.gain.offset = .08
#   except that the recalculation is only performed at the end
#   rather than after each parameter is changed:
resp.setPars(.995, .08)

# Can also assign auxiliary values by passing 1 or 2 string
#   arguments.

# Remove gain and restore response to original state:

Display response information including (optional) response parameters.