load_ascii_with_errors
- sherpa.astro.ui.load_ascii_with_errors(id, filename=None, colkeys: Optional[Sequence[str]] = None, sep: str = ' ', comment: str = '#', func: Callable = <function average>, delta: bool = False) None
Load an ASCII file with asymmetric errors as a data set.
Create a dataset with asymmetric error bars which can be used with resample_data to fit a model using the asymmetric errors with a parametric bootstrap approach. Note that the func argument is used to provide an estimate for a symmetric error (the default is to average the low and high limits) which is then used with calls like calc_stat and fit.
- 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 theid
andfilename
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 errorselo
andehi
.elo
andehi
assumed to be positive values. They are used to calculatestaterror
forfit
withchi2
statistics. Note thatset_stat
will not impact the statistics values for the fitting this type of data andfit
will always usestaterror
in this case.resample_data
will assumeset_stat
setting in calculating the statistics for bootstrap sampling.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. The
func
argument is used to calculate the error based on the elo and ehi column values, and uses the RMS value of the low and high values:>>> def rms(lo, hi): ... return numpy.sqrt(lo * lo + hi * hi) ... >>> load_ascii_with_errors('sources.dat', func=rms)