Last modified: December 2023

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


AHELP for CIAO 4.16 Sherpa

load_ascii_with_errors

Context: data

Synopsis

Load an ASCII file with asymmetric errors as a data set.

Syntax

load_ascii_with_errors(id, filename=None, colkeys=None, sep=' ',
comment='#', func=average, delta=False)

id - int or str, optional
filename - str
sep - str, optional
comment - str, optional
func - python function, optional
delta - boolean, optional

Examples

Example 1

Read in the first four columns of the file, as the independent (X), dependent (Y), error low (ELO) and error high (EHI) columns of the default data set:

>>> load_ascii_with_errors('sources.dat')

Example 2

Read in the first four columns (x, y, elo, ehi) where elo and ehi are of the form y - delta_lo and y + delta_hi, respectively.

>>> load_ascii_with_errors('sources.dat', delta=True)

Example 3

Read in the first four columns (x, y, elo, ehi) where elo and ehi are of the form delta_lo and delta_hi, respectively.

>>> def rms(lo, hi):
...     return numpy.sqrt(lo * lo + hi * hi)
...
>>> load_ascii_with_errors('sources.dat', func=rms)

Example 4

Read in the first four columns (x, y, elo, ehi) where elo and ehi are of the form delta_lo and delta_hi, respectively. The `func` argument is used to calculate the error based on the elo and ehi column values.


PARAMETERS

The parameters for this function are:

Parameter Definition
id The identifier for the data set to use. If not given then the default identifier is used, as returned by `get_default_id` .
filename The name of the file to read in. Selection of the relevant column depends on the I/O library in use (Crates or AstroPy).
sep The separator character. The default is ' ' .
comment The comment character. The default is '#' .
func The function used to combine the lo and hi values to estimate an error. The function should take two arguments (lo, hi) and return a single NumPy array, giving the per-bin error. The default function used is numpy.average.
delta The flag is used to indicate if the asymmetric errors for the third and fourth columns are delta values from the second (y) column or not. The default value is False

Notes

The function does not follow the normal Python standards for parameter use, since it is designed for easy interactive use. When called with a single un-named argument, it is taken to be the `filename` parameter. If given two un-named arguments, then they are interpreted as the `id` and `filename` parameters, respectively. The remaining parameters are expected to be given as named arguments.

The column order for the different data types are as follows, where x indicates an independent axis, y the dependent axis, the asymmetric errors elo and ehi .

Identifier Required Fields
Data1DAsymmetricErrs x, y, elo, ehi

Bugs

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

See Also

data
load_ascii, resample_data