diffpy.srmise.baselines package
Submodules
diffpy.srmise.baselines.nanospherical module
- class diffpy.srmise.baselines.nanospherical.NanoSpherical(Cache=None)[source]
Bases:
BaselineFunction
Methods for evaluation of baseline of spherical nanoparticle of uniform density.
Allowed formats are internal: [scale, radius]
Given nanoparticle radius R, the baseline is -scale*r*(1-(3r)/(4R)+(r^3)/(16*R^3)) in the interval (0, abs(R)), and 0 elsewhere. Internally, both scale and radius are unconstrained, but negative values are mapped to their physically meaningful positive equivalents.
The expression in parentheses is gamma_0(r) for a sphere. For a well normalized PDF the scale factor is 4*pi*rho_0, where rho_r is the nanoparticle density.
gamma_0(r) Reference: Guinier et al. (1955). Small-angle Scattering from X-rays. New York: John Wiley & Sons, Inc.
diffpy.srmise.baselines.arbitrary module
- class diffpy.srmise.baselines.arbitrary.Arbitrary(npars, valuef, jacobianf=None, estimatef=None, Cache=None)[source]
Bases:
BaselineFunction
Methods for evaluating a baseline from an arbitrary function.
Supports baseline calculations with arbitrary functions. These functions, if implemented, must have the following signatures and return values: valuef(pars, x) ==> numpy.array of length x if x is a sequence
==> number if x is a number
- jacobianf(pars, x, free) ==> list, each element a numpy.array of length x if
x is a sequence or None if value of free for that parameter is False.
- ==> list, each element a number if x is a number
or None if value of free for that parameter is False
estimatef(x, y) ==> numpy.array of length npars
- estimate_parameters(r, y)[source]
Estimate parameters for data baseline.
- Parameters:
r (array-like) – The data along r from which to estimate
y (array-like) – The data along y from which to estimate
- Returns:
The numpy array of parameters in the default internal format.
we raise NotImplementedError if no estimation routine is defined, and
SrMiseEstimationError if parameters cannot be estimated for any other.
diffpy.srmise.baselines.fromsequence module
- class diffpy.srmise.baselines.fromsequence.FromSequence(*args, **kwds)[source]
Bases:
BaselineFunction
Methods for evaluation of a baseline from discrete data via interpolation.
FromSequence uses cubic spline interpolation (no smoothing) on discrete points to approximate the baseline at arbitrary points within the interpolation domain. This baseline function permits no free parameters.
- estimate_parameters(r, y)[source]
Return empty numpy array.
A FromSequence object has no free parameters, so there is nothing to estimate.
- Parameters:
r (array-like) – The data along r from which to estimate, Ignored
y (array-like) – The data along y from which to estimate, Ignored
- Returns:
The empty numpy array
- Return type:
array-like
diffpy.srmise.baselines.polynomial module
- class diffpy.srmise.baselines.polynomial.Polynomial(degree, Cache=None)[source]
Bases:
BaselineFunction
Methods for evaluation and parameter estimation of a polynomial baseline.
- estimate_parameters(r, y)[source]
Estimate parameters for polynomial baseline.
Estimation is currently implemented only for degree < 2. This very rudimentary method assumes the baseline crosses the origin, and y=baseline+signal, where signal is primarily positive.
- Parameters:
r (array-like) – The data along r from which to estimate
y (array-like) – The data along y from which to estimate
- Returns:
The Numpy array of parameters in the default internal format. Raises NotImplementedError if estimation is not implemented for this degree, or SrMiseEstimationError if parameters cannot be estimated for any other reason.
- Return type:
array-like
diffpy.srmise.baselines.base module
- class diffpy.srmise.baselines.base.Baseline(owner, pars, free=None, removable=False, static_owner=False)[source]
Bases:
ModelPart
Represents a baseline associated with a BaselineFunction subclass.
- class diffpy.srmise.baselines.base.BaselineFunction(parameterdict, parformats, default_formats, metadict, base=None, Cache=None)[source]
Bases:
BaseFunction
Base class for functions which represent some data’s baseline term.
Class members
- parameterdict: dict
The dictionary mapping string keys to their index in the sequence of parameters. These keys apply only to the default “internal” format.
- parformats: array-like
The sequence of strings defining what formats are recognized by a baseline function.
- default_formats: dict
The dictionary which maps the strings “default_input” and “default_output” to strings also appearing in parformats. “default_input”-> format used internally within the class “default_output”-> Default format to use when converting parameters for outside use.
Class methods (implemented by inheriting classes)
estimate_parameters() (optional) _jacobianraw() (optional, but strongly recommended) _transform_derivativesraw() (optional, supports propagation of uncertainty for different paramaterizations) _transform_parametersraw() _valueraw()
Class methods
actualize()
Inherited methods
jacobian() value() transform_derivatives() transform_parameters()