User Tools

Site Tools


evaluation:extractgrainsizes

This is an old revision of the document!


Determine Grain Sizes

The TIMEleSS tools contain two scripts to determine the volume of each grain in the sample. These are timelessExtractGrainSizes.py to obtain relative grain volume and timelessRelToAbsGrainSize.py to convert these relative grain sizes into absolute values. The scripts provide both a list of the grain volumes and a simple histogram of the grain size distribution.

Method

The idea behind the scripts is to compare the theoretical peak intensity with the actual peak intensity from the experiment. This comparison gives a size value for each grain, which is proportional to the volume of the grain. As a result, the script provides a list of those relative grain volumes.

In a second step, the sum of this list of relative grain volumes is put in relation to the illuminated volume of the sample chamber. The result of this second step is a factor, which tells you, how many units of relative grain volume represent 1 µm^3. This is then used to re-write the list of relative grain volumes to a list of absolute grain volumes.

Usage

To use the scripts, the process of indexing must be finished already, i.e. a GrainSpotter output file is required. Then, execute the two scripts sequentially.

1. Extract relative grain sizes

Try this:

timelessGrainSizes.py -o myoutputfile.txt -w 0.3738 -HV True mylogfile.log peaks-t100.flt crystal.cif

This command should do the following:

  1. Display a number of rejected grains in the command window
  2. Display the relative grain volumes in the command window
  3. Save the list of grain volumes into the file myoutputfile.txt and
  4. Plot a simple histogram of the grain volumes

Help message:

Estimation of relative grain volumes based on diffraction intensities

Example:
    timelessGrainSizes.py -w 0.3738 mylogfile.log peaks-t100.flt crystal.cif

This is part of the TIMEleSS project
http://timeless.texture.rocks

positional arguments:
  logfile               Path and name for GrainSpotter output file
  fltfile               Path and name for fltfile
  ciffile               Path and name for CIF file

optional arguments:
  -h, --help            show this help message and exit
  -w WAVELENGTH, --wavelength WAVELENGTH
                        Wavelength (angstrom, required)
  -m TTHETA_MIN, --ttheta_min TTHETA_MIN
                        If set, minimum 2 theta for calculation of peaks from cif file (degrees). Guessed from GS output file otherwise.
  -M TTHETA_MAX, --ttheta_max TTHETA_MAX
                        If set, maxium 2 theta for calculation of peaks from cif file (degrees). Guessed from GS output file otherwise.
  -o OUTPUT, --output OUTPUT
                        If set, saves result to this file. Default is None (no filter)
  -HV HISTOGRAM_VOL, --histogram_vol HISTOGRAM_VOL
                        If set, plots a histogram of the grain volumes on the screen. Default is False
  -HR HISTOGRAM_RAD, --histogram_rad HISTOGRAM_RAD
                        If set, plots a histogram of the grain radii on the screen. Default is False
  -b HISTOGRAM_BINS, --histogram_bins HISTOGRAM_BINS
                        Sets the number of histrogram bins. Only works if histogram is set True. Default is 60
  -r REJECT, --reject REJECT
                        Reject grains with AverageI > reject*MedianI. Default is 20.0

Rejected grains

Since the script is based on the analysis of the peak intensities, it also detects outliers in a grain, e.g. if one of the peaks is significantly more intense than the others. If this mismatch is above a certain threshold, the grain is rejected by the script. You can adjust the threshold by adding the parameter -r when executing the script (see help message above).

List of relative grain volumes

The command line will show a list of relative grain volumes. If you chose the option -o, it will also save this list in a file. Note that this file is necessary if you want to convert the relative grain sizes to absolute ones later.

Histogram

Histogram example

2. Convert to absolute grain sizes

Try this:

timelessRelToAbsGrainSize.py 

evaluation/extractgrainsizes.1618924739.txt.gz · Last modified: 2021/04/20 13:18 by matthias