Thread: [PyMca] Call PyMca Functions for Batch Fitting
Brought to you by:
vasole
|
From: PyMca g. p. m. list. <pym...@li...> - 2018-07-24 22:59:40
|
Hello, I primarily use R for data processing and analysis. I am trying to integrate PyMca and am able to import the package but have not been able to figure out how to call functions to perform fitting. From presentations found online, I have the following Python code that was used to embed PyMca into other programs: >From PyMca import McaAdvancedFit fitWindow = McaAdvancedFit.McaAdvancedFit() fitWindow.setData(x,y) fitWindow.show() I'm wondering if this code doesn't work with the newer releases of PyMca and if you have any suggestions for running a batch fit from command line. Thank you for a great program! Nick |
|
From: PyMca g. p. m. list. <pym...@li...> - 2018-07-25 13:13:17
|
Hello,
When abandoning PyQwt I had to use a different namespace in order not to
break anybody's code. The code you have sent can still be used provided
you replace:
from PyMca import McaAdvancedFit
by
from PyMca5.PyMca import McaAdvancedFit
However, that code assumes you are already using PyQt. If you do not
want to use any graphical user interface, then the code you need is more
in the lines of the code below. Please, keep in mind that to set up the
fit configuration without the interface can be error prone.
The most basic ( and unoptimized) fitting without logic assuming your
fit configuration is in file named "configuration.cfg" and your spectrum
is in the variables channels and counts
from PyMca5.PyMca import ConfigDict
from PyMca5.PyMca import ClassMcaTheory
config = ConfigDict.ConfigDict()
config.read("configuration.cfg")
mcaFit = ClassMcaTheory.ClassMcaTheory()
mcaFit.configure(config)
mcaFit.setData(channels, counts) # you can specify the xmin and xmax
mcaFit.estimate()
fitResult = mcaFit.startfit(digest=1) # I will change this to startFit
at a certain point but this will keep working, take a look at the method
for the additional arguments.
You can start from scratch:
from PyMca5.PyMca import ClassMcaTheory
mcaFit = ClassMcaTheory.ClassMcaTheory()
config = mcaFit.configure()
(modify the config dictionary the way you need, keep in mind that you
can use the same configuration for fitting many spectra because the
configure method is very slow)
mcaFit.configure(config)
mcaFit.setData(channels, counts) # you can specify the xmin and xmax
mcaFit.estimate()
fitResult = mcaFit.startfit(digest=1)
For the maximum speed, take a look at the FastXRFLinearFit.py module.
Best regards,
Armando
On 24.07.2018 15:25, PyMca general purpose mailing list. wrote:
> Hello,
>
> I primarily use R for data processing and analysis. I am trying to
> integrate PyMca and am able to import the package but have not been
> able to figure out how to call functions to perform fitting. From
> presentations found online, I have the following Python code that was
> used to embed PyMca into other programs:
>
> From PyMca import McaAdvancedFit
>
> fitWindow = McaAdvancedFit.McaAdvancedFit()
>
> fitWindow.setData(x,y)
>
> fitWindow.show()
>
> I'm wondering if this code doesn't work with the newer releases of
> PyMca and if you have any suggestions for running a batch fit from
> command line.
>
> Thank you for a great program!
>
> Nick
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> PyMca-users mailing list
> PyM...@li...
> https://lists.sourceforge.net/lists/listinfo/pymca-users
|
|
From: PyMca g. p. m. list. <pym...@li...> - 2018-07-25 13:24:50
|
On 24.07.2018 15:25, PyMca general purpose mailing list. wrote: > if you have any suggestions for running a batch fit from > command line. > The code below should allow to fit a stack of spectra stored into a single dataset inside an HDF5 file at full speed: python –m PyMca5.PyMcaPhysics.xrf.FastXRFLinearFit –cfg=configuration_file --weight=0 –tif=1 –concentrations=0 –refit=0 filename::dataset_path You also have the builtin application pymcabatch that can be called with arguments in order to skip the GUI. You can type "man pymcabatch" in your linux installation or look at: https://github.com/vasole/pymca/blob/master/doc/man/pymcabatch.1 Armando |
|
From: PyMca g. p. m. list. <pym...@li...> - 2018-07-25 14:49:56
|
Thank you so much. This code is working perfectly. I always explore the data first in the GUI and develop my config files there. The integration with R is to save me some manual steps when merging the data. Thanks again, Nick -----Original Message----- From: PyMca general purpose mailing list. <pym...@li...> Sent: Wednesday, July 25, 2018 6:25 AM To: pym...@li... Subject: Re: [PyMca] Call PyMca Functions for Batch Fitting On 24.07.2018 15:25, PyMca general purpose mailing list. wrote: > if you have any suggestions for running a batch fit from command line. > The code below should allow to fit a stack of spectra stored into a single dataset inside an HDF5 file at full speed: python –m PyMca5.PyMcaPhysics.xrf.FastXRFLinearFit –cfg=configuration_file --weight=0 –tif=1 –concentrations=0 –refit=0 filename::dataset_path You also have the builtin application pymcabatch that can be called with arguments in order to skip the GUI. You can type "man pymcabatch" in your linux installation or look at: https://github.com/vasole/pymca/blob/master/doc/man/pymcabatch.1 Armando ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ PyMca-users mailing list PyM...@li... https://lists.sourceforge.net/lists/listinfo/pymca-users |