Sunday, July 8, 2018

Python code for Williamson-Hall plot

In this post I am adding a new calculator for crystallite size and strain calculation. This is based on  Williamson-Hall plot. However, this time calculator is written in python language and anyone can download this small code snippet as a local copy on your computer to calculate size and strain.

Before you use this calculator, you need to install the following  on your computer.

1. Python 2.7 or more
2. numpy
3. scipy
4. matplotlib

You can google it and install the above very easily.
  1. You download the file williamson-hall_plot.py file
  2.  Prepare a data file with peak position in column-1 and fwhm in column-2.
  3. Save this file as "data.txt" . You can use another name for this file provided you could able to change the same in the *.py file.
  4. You open a terminal (in linux and OSX) or cmd window in WINDOWS.
  5. Direct the terminal to the place where you want to work. Means move to that folder where your *.py  and "data.txt" file exists.
  6. run the command "python williamson-hall_plot.py
That generates a plot with size and strain printed in the terminal as well as it saves the png file.  The *py file and example data file are zipped and can be downloaded here. You can edit the data file with your own data.


Please read about Williamson-Hall plot before using this code.
In due course of time I will add more notes to this post. Till then
enjoy calculation.

In case of any difficulty please post a comment.

3 comments:

  1. it is not working. Please explain with a video, if possible

    ReplyDelete
    Replies
    1. Before you use this calculator, you need to install the following on your computer.

      1. Python 2.7 or more
      2. numpy
      3. scipy
      4. matplotlib

      Then just follow the instructions.

      Delete