The sherpa.utils module

Objects and utilities used by multiple Sherpa subpackages

Functions

Knuth_close(x, y, tol[, myop])

Check whether two floating-point numbers are close together.

_guess_ampl_scale

The scaling applied to a value to create its range.

apache_muller(fcn, xa, xb[, fa, fb, args, ...])

An alternative implementation of Muller's method for root finding.

bisection(fcn, xa, xb[, fa, fb, args, ...])

A basic root finding algorithm that uses standard bisection

bool_cast(val)

Convert a string to a boolean.

calc_ftest(dof1, stat1, dof2, stat2)

Compare two models using the F test.

calc_mlr(delta_dof, delta_stat)

Compare two models using the Maximum Likelihood Ratio test.

calc_total_error([staterror, syserror])

Add statistical and systematic errors in quadrature.

create_expr(vals[, mask, format, delim])

Create a string representation of a filter.

dataspace1d(start, stop[, step, numbins])

Populates an integrated grid

dataspace2d(dim)

Populates a blank image dataset

demuller(fcn, xa, xb, xc[, fa, fb, fc, ...])

A root-finding algorithm using Muller's method.

erf(x)

Calculate the error function.

export_method(meth[, name, modname])

Given a bound instance method, return a simple function that wraps it.

extract_kernel(kernel, dims_kern, dims_new, ...)

Extract the kernel.

filter_bins(mins, maxes, axislist[, integrated])

What mask represents the given set of filters?

gamma(z)

Calculate the Gamma function.

get_error_estimates(x[, sorted])

Compute the median and (-1,+1) sigma values for the data.

get_fwhm(y, x[, xhi])

Estimate the width of the data.

get_keyword_defaults(func[, skip])

Return the keyword arguments and their default values.

get_keyword_names(func[, skip])

Return the names of the keyword arguments.

get_midpoint(a)

Estimate the middle of the data.

get_num_args(func)

Return the number of arguments for a function.

get_peak(y, x[, xhi])

Estimate the peak position of the data.

get_position(y, x[, xhi])

Get 1D model parameter positions pos (val, min, max)

get_valley(y, x[, xhi])

Estimate the position of the minimum of the data.

guess_amplitude(y, x[, xhi])

Guess model parameter amplitude (val, min, max)

guess_amplitude2d(y, x0lo, x1lo[, x0hi, x1hi])

Guess 2D model parameter amplitude (val, min, max)

guess_amplitude_at_ref(r, y, x[, xhi])

Guess model parameter amplitude (val, min, max)

guess_bounds(x[, xhi])

Guess the bounds of a parameter from the independent axis.

guess_fwhm(y, x[, xhi, scale])

Estimate the value and valid range for the FWHM of the data.

guess_position(y, x0lo, x1lo[, x0hi, x1hi])

Guess 2D model parameter positions xpos, ypos ({val0, min0, max0},

guess_radius(x0lo, x1lo[, x0hi, x1hi])

Guess the radius parameter of a 2D model.

guess_reference(pmin, pmax, x[, xhi])

Guess model parameter reference (val, min, max)

histogram1d(x, x_lo, x_hi)

Create a 1D histogram from a sequence of samples.

histogram2d(x, y, x_grid, y_grid)

Create 2D histogram from a sequence of samples.

igam(a, x)

Calculate the regularized incomplete Gamma function (lower).

igamc(a, x)

Calculate the complement of the regularized incomplete Gamma function (upper).

incbet(a, b, x)

Calculate the incomplete Beta function.

interpolate(xout, xin, yin[, function])

One-dimensional interpolation.

is_binary_file(filename)

Estimate if a file is a binary file.

lgam(z)

Calculate the log (base e) of the Gamma function.

linear_interp(xout, xin, yin)

Linear one-dimensional interpolation.

multinormal_pdf(x, mu, sigma)

The PDF of a multivariate-normal.

multit_pdf(x, mu, sigma, dof)

The PDF of a multivariate student-t.

nearest_interp(xout, xin, yin)

Nearest-neighbor one-dimensional interpolation.

neville(xout, xin, yin)

Polynomial one-dimensional interpolation using Neville's method.

neville2d(xinterp, yinterp, x, y, fval)

Polynomial two-dimensional interpolation using Neville's method.

new_muller(fcn, xa, xb[, fa, fb, args, ...])

Alternative implementation of Mueller's method for root finding

normalize(xs)

Normalize an array.

numpy_convolve(a, b)

Convolve two 1D arrays together using NumPy's FFT.

pad_bounding_box(kernel, mask)

Expand the kernel to match the mask.

parallel_map(function, sequence[, numcores])

Run a function on a sequence of inputs in parallel.

param_apply_limits(param_limits, par[, ...])

Apply the given limits to a parameter.

parse_expr(expr)

Convert a filter expression into its parts.

poisson_noise(x)

Draw samples from a Poisson distribution.

print_fields(names, vals[, converters])

Given a list of strings names and mapping vals, where names is a subset of vals.keys(), return a listing of name/value pairs printed one per line in the format '<name> = <value>'.

quantile(sorted_array, f)

Return the quantile element from sorted_array, where f is [0,1] using linear interpolation.

rebin(y0, x0lo, x0hi, x1lo, x1hi)

Rebin a histogram.

sao_arange(start, stop[, step])

Create a range of values between start and stop.

sao_fcmp(x, y, tol)

Compare y to x, using an absolute tolerance.

set_origin(dims[, maxindex])

Return the position of the origin of the kernel.

sum_intervals(src, indx0, indx1)

Sum up data within one or more pairs of indexes.

zeroin(fcn, xa, xb[, fa, fb, args, maxfev, tol])

Obtain a zero of a function of one variable using Brent's root finder.

Classes

NoNewAttributesAfterInit()

Prevents attribute deletion and setting of new attributes after __init__ has been called.