XspecSettings

class xspec.XspecSettings

Storage class for Xspec settings.

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

Methods

  • addModelString

  • closeLog

  • delModelString

  • openLog

  • restore

  • save

Attributes ((*) = get-only)

  • abund

  • allowNewAttributes

  • allowPrompting

  • chatter

  • logChatter

  • cosmo

  • log*

  • modelStrings

  • parallel

  • seed

  • version*

  • xsect

addModelString(key, value)

Add a key,value pair of strings to XSPEC's internal database.

This database provides a way to pass string values to certain model functions which are hardcoded to search for "key". (See the XSPEC manual description for the "xset" command for a table showing model/key usage.)

If the key,value pair already exists, it will be replaced with the new entries.

closeLog()

Close XSPEC's current log file.

delModelString(key)

Remove a key,value pair from XSPEC's internal string database.

openLog(fileName)

Open a file and set it to be XSPEC's log file.

Args:

fileName: The name of the log file.

If Xspec already has an open log file, it will close it. Returns a Python file object for the new log file.

Once opened, the log file object is also stored as the Xset.log attribute.

Note

To ensure proper cleanup and file flushing, it is recommended that you call Xset.closeLog() before exiting PyXspec.

restore(fileName)

Restore the data/model configuration and settings.

This will restore the data, models, and settings from a previous PyXspec session, as saved in file generated by the Xset.save() function.

Args:

fileName: The output file from a previous Xset.save command.

save(fileName, info='a')

Save the data and model configuration and XSPEC settings

Args:

fileName: The name of the output file.

If the file name has no extension, '.xcm' will be appended.

info: A flag specifying which information to save:

  • 'a' = save all (the default)

  • 'f' = only save the data files information

  • 'm' = only save the model information

property abund

Get/Set the abundance table used in the plasma emission and photoelectric absorption models.

Set:

Enter one of the following:

The name of one of Xspec's built-in abundance tables:

'angr', 'aspl', 'feld', 'aneb', 'grsa', 'wilm', 'lodd'

'file <filename>' where <filename> contains 30 abundance

values, one per line.

A list or tuple containing 30 abundance values.

A single string containing 30 space-delimited values.

Get:

Returns the name of the input table followed by its 30 values [string].

property allowNewAttributes

Get/Set the flag which allows the setting of new instance attributes for ALL PyXspec classes [bool].

This is False by default, and is intended to catch the user's attention if they misspell an attribute name when attempting to set it. Under normal Python behavior, a misspelling would simply create a new attribute and issue no warnings or errors.

You must make sure this flag is set to True if you genuinely wish to add new attributes.

property allowPrompting

Get/Set flag determining whether user prompting occurs.

Get/Set whether user will be prompted in situations where XSPEC may require additional information to complete a task. Default is 'True'. [bool]

property chatter

Get/Set the console chatter level [int].

property cosmo

Get/Set the cosmology values.

Get: Returns a tuple of floats containing (H0, q0, l0), where
  • H0 is the Hubble constant in km/(s-Mpc),

  • q0 is the deceleration parameter, and

  • l0 is the cosmological constant.

Set: Enter a single string containing one or more of H0, q0, l0.

Examples:

Xset.cosmo = "100"  # sets H0 to 100.0
Xset.cosmo = ",0"   # sets q0 to 0.0
Xset.cosmo = ",,0.7"  # sets l0 to 0.7
Xset.cosmo = "50 .5 0." # sets H0=50.0, q0=0.5, l0=0.0
property log

Get only: Returns the currently opened log file object, or None if no log file is open (also see the openLog and closeLog methods).

property logChatter

Get/Set the log chatter level [int].

property modelStrings

XSPEC's internal database of <string_name>, <string_value> pairs for settings which may be accessed by model functions.

Get:

Returns a tuple of tuples, the inner tuples being composed of <string_name>,<string_value> string pairs.

Set:

Replaces ENTIRE database with user-supplied new database. Input may be a dictionary of <string_name>:<string_value> entries, or a tuple of (<string_name>,<string_value>) tuples.

For inserting and deleting INDIVIDUAL string name and value pairs, use the addModelString and delModelString methods.

property parallel

An attribute for controlling the number of parallel processes in use during various XSPEC contexts.

Examples:

# Use up to 4 parallel processes during
#   Levenberg-Marquardt fitting.   
Xset.parallel.leven = 4

# Use up to 4 parallel processes during
#   Fit.error() command runs.
Xset.parallel.error = 4

# Other available contexts are:
# Xset.parallel.steppar, walkers, and goodness.

# Display current settings of all parallel contexts.
Xset.parallel.show()

# Reset all contexts to single process usage.
Xset.parallel.reset()
property seed

Re-seed and re-initialize XSPEC's random-number generator with the supplied integer value (SET only).

property version

The version strings for PyXspec and standard XSPEC.

GET only, this returns a tuple containing:

(<PyXspec version string>,<standard XSPEC version string>)

property xsect

Get/set the photoelectric absorption cross-sections in use [string].

Available options: 'bcmc', 'obcm', 'vern'