ChainManager

class xspec.ChainManager

Monte Carlo Markov Chain container.

PyXspec automatically creates a single object of this class, named AllChains.

Methods

  • __call__ (the ‘()’ operator)
  • __iadd__ (the ‘+=’ operator)
  • __isub__ (the ‘-=’ operator)
  • clear
  • show
  • stat

Attributes

These are the values which will be used when creating new Chain objects, unless they are explicitly overridden as arguments to the Chain class constructor. For more detail, see the descriptions for the corresponding attributes in the Chain class doc.

  • defAlgorithm
  • defBurn
  • defFileType
  • defLength
  • defProposal
  • defRand
  • defTemperature
  • defWalkers
__call__(index)

Get a Chain object from the AllChains container.

Args:
index: The index of a currently loaded chain file. The list
of currently loaded chains can be seen with the AllChains.show() method. The valid range is: 1 <= index <= nLoadedChains.

Note that the returned Chain object’s modifiable attributes will be initialized with the current AllChains def<attribute> settings:

# Example: Load 2 chains from pre-existing files:
AllChains += "chain1.fits"
AllChains += "chain2.fits"
# and use the __call__ method to retrieve a Chain object 
#   for the 2nd chain:
c2 = AllChains(2)
__iadd__(chain)

Load a pre-existing chain into the AllChains container.

Args:
chain: may be a currently existing chain object which had been

unloaded earlier:

>>> AllChains += myChain1

the filename of an existing chain file:

>>> AllChains += "chainFile.fits"

or the filename of a new chain:

>>> AllChains += "newChainFile.fits"

The last example will also perform a chain run using the default settings.

__isub__(chain)

Unload one or more chain objects from container.

Args:

chain: may either be a chain object:

>>> AllChains -= myChain1

a filename:

>>> AllChains -= "chainFile.fits"

the chain’s current index [int] in the AllChains container:

>>> AllChains -= 2

or a ‘*’ to unload ALL chains (equivalent to AllChains.clear()):

>>> AllChains -= '*'
clear()

Unload all chains from container

show()

Display information for current attributes and loaded chains.

stat(parIdx)

Display statistical information on a particular chain parameter.

Args:
parIdx: The parameter index number, including optional model
name: [<modName>:]<idx>. May be entered as a string or int (if no model name).
defAlgorithm

Default chain algorithm (orig = ‘gw’).

defBurn

Default burn length for new Chain objects (orig = 0).

defFileType

Default output file format (orig = ‘fits’).

defLength

Default chain length (orig = 100).

defProposal

Default chain proposal (orig = ‘gaussian fit’).

defRand

Default randomization setting (orig = False).

defTemperature

Default chain temperature (orig = 1.0).

defWalkers

Default walkers parameter for ‘gw’ chains (orig = 10).