How to do batch processing of XRD data using Gaussian Fitting?

529 views
Skip to first unread message

Gaoming Zhu

unread,
Mar 16, 2017, 11:53:29 AM3/16/17
to fityk-users
Hi,
I have many XRD results by Synchrotron Radiation, these data are similar but have intensity change and very little 2θ shift. I want to analyze these data to get the peak center, FWHM, peak intensity and peak area. Is it possible to do this by Fityk? But I have very limited programming experience, only some classes of C++ when I was a graduate student. Does anyone have any experience in this field? 
I have uploaded two files of XRD data. I can do it one by one use my mouse, but I don't know how to do by batch processing.
Thank you very much.

---
Gaoming Zhu
Shanghai Jiao Tong Univesity, Shanghai, China


SSRF-1.csv
SSRF-2.csv

Alexander Selyutin

unread,
Mar 16, 2017, 12:29:32 PM3/16/17
to fityk...@googlegroups.com
You can do batch processing by any programming lang and fityk. Several years ago I used python and fit template file where python changed several parametrs and run fit template after.
Fit file did several operations: remove background, fit peaks, export peaks. Python script changed step by step file name.
I tried to find python script, but cannot, only fit template was found.


I attached fit template. 
It's not so clean, but may be usefull. 

--
Regards,
Alexander Selyutin
template_old.fit

Marcin Wojdyr

unread,
Mar 16, 2017, 12:38:56 PM3/16/17
to fityk...@googlegroups.com
Hi Gaoming,
how many datasets do you have?
If you have 20 or 200 it may be more convenient to load them all and
analyze them manually with mouse - but operating on all datasets
together.
Because when working interactively you can quickly go through all the
datasets and check if everything looks fine.
If you select all datasets on the right hand panel all operations will
be performed on all datasets simultaneously - you just need to be
careful to make sure that the operations work for all datasets.
How many peaks do you want to fit in a single diffractogram?

If you want a script for batch processing you just copy the commands
shown in the output window to a file and then execute them as a
script.
For example to fit only the first peak that's around 2θ=14°:

@*: A = 13 < x and x < 15
@*: guess PseudoVoigt
@*: fit
@*: info peaks

the first line ignores points outside of (13,15), then you fit a
single PseudoVoigt function (fits better than Gaussian), and finally
you show the result.
"@*:" at the beginning tells the program to run the command for in all datasets.

Marcin
> --
> http://groups.google.com/group/fityk-users
> ---
> You received this message because you are subscribed to the Google Groups
> "fityk-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to fityk-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Gaoming Zhu

unread,
Mar 19, 2017, 5:09:42 AM3/19/17
to fityk-users
Hi Alexander,
Thank you very much for your fit template, I am working on it now. But I don't know how to import data and export results automatically, is it feasible in Fityk? Actually I did batch processing in Origin before, Origin can import, analyse and export automatically, it is very easy to use. But in my data, three peaks have very close postions, I think the fitting results by Origin is not very accurate especially for peak area and FWHM.

Best wishes,
Gaoming Zhu

在 2017年3月17日星期五 UTC+8上午12:29:32,Alexander Selyutin写道:

Alexander Selyutin

unread,
Mar 19, 2017, 5:25:39 AM3/19/17
to fityk...@googlegroups.com
Marcin idea is better. But if you want you can use template like mine. Export is easy, 
in script you can use
p title, '%f1', %f1.center, %f1.FWHM, %f1.Area, %f1.Height,  '%f2', %f2.center, %f2.FWHM, %f2.Area, %f2.Height >> '{{ FILE_OUT }}'
where {{ FILE_OUT }} is destination file
p title, '%f1', %f1.center, %f1.FWHM, %f1.Area, %f1.Height,  '%f2', %f2.center, %f2.FWHM, %f2.Area, %f2.Height >> '/home/user/fitykexported.txt'          in linux/mac
p title, '%f1', %f1.center, %f1.FWHM, %f1.Area, %f1.Height,  '%f2', %f2.center, %f2.FWHM, %f2.Area, %f2.Height >> 'C:\documents\/fitykexported.txt'     in windows, but did not tested
and output file will be like list of raws with data, each new raw by new input file. 
import is more complexy. 
@+ <'{{ FILE_IN }}'
where FILE_IN is new file and it should get values from the list of files. I used for that script in python.


--
Regards,
Alexander Selyutin

Gaoming Zhu

unread,
Mar 19, 2017, 5:35:37 AM3/19/17
to fityk-users
Hi Marcin,
Thank you for your fityk, it is very useful for fiting. I have more than one thousand XRD datasets by synchrotron radiation, and I want to fit all peaks in a single diffractogram. The commands you wrote is very useful for me, I can easier to get fitting results than by  mouse. However, it need a lot of time too, I am wondering that if it is possible that the Fityk can import, analyse and export automatically?

Regard,
Gaoming

在 2017年3月17日星期五 UTC+8上午12:38:56,Marcin Wojdyr写道:
Reply all
Reply to author
Forward
0 new messages