I recently wrote a script to fit transmission data, which uses the LMFIT package (Getting started with Non-Linear Least-Squares Fitting — Non-Linear Least-Squares Minimization and Curve-Fitting for Python) to minimise chi2 for a model to the data.
Can anyone advise me on how to add this package to mantid? thx!
From what I can tell lmfit uses least squares fitting, which Mantid already can offer. Anyhow, it is possible to install python packages for use in Mantid.
On Mac, download the
get-pip.py script from pip’s own website. I saved this file to my Desktop, and then in a terminal run these lines (to install pip and use it to install lmfit):
/Applications/MantidWorkbench.app/Contents/Frameworks/Python.framework/Versions/3.7/bin/python get-pip.py --user
/Applications/MantidWorkbench.app/Contents/Frameworks/Python.framework/Versions/3.7/bin/python -m pip install lmfit --user
then within Mantid you should just be able to use
Note that this will work if you’re using Mantid version 5.0. If you’re using 4.2 or earlier then you should just have to change
2.7. Tell me if this works for you or not!
Thanks! Will try this. btw will the above also work if I swap out MantidWorkbench for MantidPlot?
Hi Daniel, so it worked and then I hit the next problem. The script calls matplotlib.pyplot to display data and it did not like that. the main error is:
ValueError: shape mismatch: objects cannot be broadcast to a single shape
Before diving into this, I’m starting to wonder if I am approaching my task in the correct way?
The end goal is a mantid algorithm. required are both input from user, calculation, plotting of data and then further input from user to direct the next calculation.
Is this something that’s possible via scripting? Or should I be instead focusing on a full algorithm?
Would you be able to send the script and anything else relevant to me: firstname.lastname@example.org
I’m not sure I understand all of the inputs you require but it sounds like this should be possible in a script.
have emailed the script. thx!