load_ascii_with_errors

sherpa.astro.ui.load_ascii_with_errors(id, filename=None, colkeys=None, sep=' ', comment='#', func=<function average>, delta=False)

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

Parameters
  • id (int or str, optional) – The identifier for the data set to use. If not given then the default identifier is used, as returned by get_default_id.

  • filename (str) – 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 (str, optional) – The separator character. The default is ' '.

  • comment (str, optional) – The comment character. The default is '#'.

  • func (python function, optional) – 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 (boolean, optional) – 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

See also

load_ascii

Load an ASCII file as a data set.

load_arrays

Create a data set from array values.

load_table

Load a FITS binary file as a data set.

load_image

Load an image as a data set.

resample_data

Resample data with asymmetric error bars.

set_data

Set a data set.

unpack_ascii

Unpack an ASCII file into a data structure.

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

Optional Fields

Data1DAsymmetricErrs

x, y, elo, ehi

Examples

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')

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)

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)

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.