Complex lineshape models (pesfit.lineshape)

class pesfit.lineshape.MultipeakModel(model=[], n=0, lineshape=[], background=[], op=<built-in function add>, preftext='lp', **kws)

Composite lineshape model consisting of multiple (sets of) identical peak profiles.

Parameters

model: instance of lmfit.model.Model | []

An existing lineshape model.

n, lineshape: int, lmfit.model.Model | 0, []

Basis lineshape and the number of it. Their way of combination is defined by the op.

background: list/tuple or instance of lmfit.model.Model | []

Functional model to approximate the signal background. If multiple operations are needed (e.g summation and multiplication), a precomposed background function should be supplied.

op: func | operator.add

Operator used to combine lineshape components and between them and the signal background.

preftext: str | ‘lp’

Prefix for the basis lineshape components. If it is set to 'lp', the automatically generated lineshapes will be named as 'lp1_', 'lp2_', etc.

**kws: keyword argument

Additional keyword arguments passed to lmfit.Model class, including 'independent_vars' and 'missing'.

_make_all_args(params=None, **kwargs)

Generate all function arguments for all functions.

_parse_params()

Parsing and merging parameters from constituent models.

_reprstring(long=False)

Representation string for the multipeak model.

_tmp(*args, **kws)

Dummy function (essential, don’t delete!).

components()

All components for a multipeak model. Override the property constraint.

eval(params=None, **kwargs)

Evaluate the entire model.

eval_components(**kwargs)

Component-wise evaluation, which returns an OrderedDict of name, numerical results for each lineshape component.

multi_eval(op, objs, fevs, *args, **kwargs)

Evaluate multiple components with a defined operator using map-reduce operation, returns a list.

Parameters

op: func

Functional operator used to reduce the terms.

objs: iterable

Collection of objects to evaluate on.

fevs: iterable (list/tuple of functions)

Collection of functions to map to objects.

*args: arguments

Additional arguments for the mapped function (every entry in fevs).

**kwargs: keyword arguments

Additional keyword arguments for the mapped function (every entry in fevs).

multi_retrieve(prop, op=<built-in function add>, init=[])

Retrieve the specified properties for all components in the multipeak model.

Parameters

prop: str

Namestring of the property to retrieve.

op: func | operator.add

Functional operator used to reduce the terms.

property ncomp

Number of components in a multipeak model.

property param_names

All parameter names for a multipeak model.

property prefixes

Collection of prefixes for all lineshape components.

class pesfit.lineshape.MultipeakModelPP(lineshape=None, n=1, model=[], background=[], op=<built-in function add>, preftext='lp', **kws)

Composite lineshape model consisting of multiple (sets of) identical peak profiles. This version has preserves the property type of model components (self.components), therefore called property-preserved (PP) version.

_make_all_args(params=None, **kwargs)

Generate all function arguments for all functions.

_model_convert(test_obj)

Convert into an lmfit Model object.

_parse_params()

Parsing and merging parameters from constituent models.

_reprstring(long=False)

Representation string for the multipeak model.

property components

All components for a multipeak model.

eval(params=None, **kwargs)

Evaluate the entire model.

eval_components(**kwargs)

Return OrderedDict of name, results for each component.

multi_eval(op, objs, fevs, *args, **kwargs)

Evaluate multiple components with a defined operator using map-reduce operation, returns a list.

Parameters

op: func

Functional operator used to reduce the terms.

objs: iterable

Collection of objects to evaluate on.

fevs: iterable (list/tuple of functions)

Collection of functions to map to objects.

*args: arguments

Additional arguments for the mapped function (every entry in fevs).

**kwargs: keyword arguments

Additional keyword arguments for the mapped function (every entry in fevs).

multi_retrieve(prop, op=<built-in function add>)

Retrieve the specified properties for all components in the multipeak model.

Parameters

prop: str

Namestring of the property to retrieve.

op: func | operator.add

Functional operator used to reduce the terms.

property ncomp

Number of components for a multipeak model.

property param_names

All parameter names in a multipeak model.

property prefixes

Collection of prefixes for all lineshape components.

pesfit.lineshape.dict_merge(elems, init={}, op_dict=<class 'collections.OrderedDict'>)

Dictionary merging by reduce operation.

pesfit.lineshape.map_reduce_attr(attr, elems, op, init)

Execute map-reduce on instance attributes (non-callable).

pesfit.lineshape.map_reduce_meth(meth, elems, op, init, **kwargs)

Execute map-reduce on instance methods (callable).

pesfit.lineshape.mr_dict_merge(meth, elems, op_dict=<class 'collections.OrderedDict'>, **kwargs)

Dictionary merging using map-reduce operations.