I am using lmfit to do small angle X-ray scattering pattern fitting. To this end, I use the Model class to wrap my functions and to make Composite Models which works well. However, it happened that I wrote all my function with 'q'
as the independent variable (convention in the discipline). Now I wanted to combine some of those q-functions with some of the built-in models. It clashes, because the independent_variable for those is 'x'
. I have tried to do something like modelBGND = lmfit.models.ConstantModel(independent_vars=['q'])
, but it gives the error:
ValueError: Invalid independent variable name ('q') for function constant
Of course this can be solved, by either rewriting the built-in function again in 'q'
, or by recasting all my previously written functions in terms of 'x'
. I am just curious to hear if there was a more straight forward approach?
Sorry, I don't think that is possible.
I think you will have to rewrite the functions to use q
instead of x
. That is, lmfit.Model
uses function inspection to determine the names of the function arguments, and most of the built-in models really do require the first positional argument to be named x
.