====== GrainSpotter loop for olivine ======
Below is an example of a GrainSpotter loop for olivine. You can run it by typing
gsLoop.sh > gsLoop.log
The output of the loop will be saved in ''gsLoop.log''.
===== Main idea =====
The loop can run //nLoops// indexings (typically 3). For each, the loop runs
* 6 iterations of 100000 GrainSpotter orientation searches with the following threshold
* minNPeaks = 20
* minCompleteness = 0.5
* Δ2θ = 0.06°
* Δη = 1°
* Δω = 1°
* maximum deviation nσ = 2
* 5 iterations of 100000 GrainSpotter orientation searches with
* minNPeaks = 20
* minCompleteness = 0.5
* Δ2θ = 0.06°
* Δη = 2°
* Δω = 2°
* maximum deviation nσ = 2
* 5 iterations of 100000 GrainSpotter orientation searches with
* minNPeaks = 20
* minCompleteness = 0.3
* Δ2θ = 0.06°
* Δη = 2°
* Δω = 2°
* maximum deviation nσ = 2
* 5 iterations of 100000 GrainSpotter orientation searches with
* minNPeaks = 20
* minCompleteness = 0.3
* Δ2θ = 0.06°
* Δη = 3°
* Δω = 3°
* maximum deviation nσ = 2
* 5 iterations of 100000 GrainSpotter orientation searches with
* minNPeaks = 20
* minCompleteness = 0.3
* Δ2θ = 0.10°
* Δη = 3°
* Δω = 3°
* maximum deviation nσ = 2
At the end of the loop, all results for the corresponding loop number are saved in a folder called ''Indexing-$loop'', where ''$loop'' is the loop number. Merged grains are in a file called ''merge-grains.log'' and their Euler angles in ''merge-grains-euler.txt''.
===== Getting some idea on indexing capabilities =====
There is now a dedicated TIMEleSS tool to [[evaluation:evaluate_indexing_statistics|evaluate your indexing performance]].
===== The loop =====
You wanted it?! Here is the source code for the loop above
#!/bin/bash
# Starting GVE file
startGVE=../LTC_05_01_s26_t50_ol-seb-edit.gve
# Starting GVE file
crystalSymmetryCode=3
# Number of indexings
nLoops=3
# Update parameters above as well as in
# - create_GS_init
# - fine details in indexing_loop
# Location of executables
GrainSpotter=/usr/local/bin/GrainSpotter.0.90
clearGVE=/usr/bin/timelessClearGVEGrains
mergeGrains=/usr/bin/timelessGrainSpotterMerge
extractEuler=timelessExtractEulerAngles
# Global parameter. Used to pass list of files between functions
grainlist=""
#-----------------------------------------------------------------------------------------------
#
# Call to create GrainSpotter input
# 3 parameters
# - first: name of GrainSpotter output file
# - second: name gve file
# - third: name of grain output file
# - forth : min_measurments
# - fifth : min_completeness
# - sixth : sigma_tth
# - seventh : sigma_eta
# - eighth : sigma_omega
#
#-----------------------------------------------------------------------------------------------
create_GS_init () {
cat > $1 <<- EOM
spacegroup 62 ! spacegroup [space group nr]
! dsrange 0 0.34 ! dsrange [min max], d-spacing range, multiple ranges can be specified
tthrange 2 10.2 ! tthrange [min max], multiple ranges can be specified
! tthrange 2 8.8 ! tthrange [min max], multiple ranges can be specified
! tthrange 9 10.2 ! tthrange [min max], multiple ranges can be specified
tthrange 10.5 14.4 ! tthrange [min max], multiple ranges can be specified
! tthrange 14.6 17 ! tthrange [min max], multiple ranges can be specifie
etarange 0 360 ! etarange [min max], multiple ranges can be specified
domega 0.5 ! domega [stepsize] in omega, degrees
omegarange -21 13 ! omegarange [min max] degrees, multiple ranges can be specified
filespecs $2 $3 ! filespecs [gvecsfile grainsfile]
cuts $4 $5 0.5 ! cuts [min_measuments min_completeness min_uniqueness]
eulerstep 5 ! eulerstep [stepsize] : angle step size in Euler space
uncertainties $6 $7 $8 ! uncertainties [sigma_tth sigma_eta sigma_omega] in degrees
nsigmas 2 ! nsigmas [Nsig] : maximal deviation in sigmas
! minfracg 1 ! stop search when minfracg (0..1) of the gvectors have been assigned to grains
! Nhkls_in_indexing 15 ! Nhkls_in_indexing [Nfamilies] : use first Nfamilies in indexing
random 100000 ! use randomly chosen orientation seeds #trials
! positionfit ! fit the position of the grain
! genhkl ! generate list of hkl's based on space group and cell parameters in gve file
EOM
}
#-----------------------------------------------------------------------------------------------
#
# Actual indexing loop
# Runs tens of GrainSpotter iterations with decreasing tolerances
# Runs in the current folder
#
#-----------------------------------------------------------------------------------------------
indexing_loop () {
echo "#"
echo "#"
echo "# Running first GS iteration. Starting from $startGVE, GS parameters in index-0.ini, grains saved in grains0.log"
echo "#"
echo "#"
create_GS_init index-0.ini $startGVE grains-0.log 20 0.5 0.06 1 1
$GrainSpotter index-0.ini
echo "#"
echo "#"
echo "# Done with iteration 0. New list of GVE will be peaks_after_step-0.gve"
echo "#"
echo "#"
$clearGVE grains-0.log $startGVE peaks_after_step-0.gve
grainlist="grains-0.log"
for i in {1..5}
do
j="$((i - 1))"
echo "#"
echo "#"
echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
echo "#"
echo "#"
# Use from previous step and create grains$i.log
create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 20 0.5 0.06 1 1
$GrainSpotter index-$i.ini
echo "#"
echo "#"
echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
echo "#"
echo "#"
$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
grainlist="$grainlist grains-$i.log"
done
for i in {6..10}
do
j="$((i - 1))"
echo "#"
echo "#"
echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grain-$i.log"
echo "#"
echo "#"
create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 20 0.5 0.06 2 2
$GrainSpotter index-$i.ini
echo "#"
echo "#"
echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
echo "#"
echo "#"
# Remove peaks that have been indexed
$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
grainlist="$grainlist grains-$i.log"
done
for i in {11..15}
do
j="$((i - 1))"
echo "#"
echo "#"
echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
echo "#"
echo "#"
create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 20 0.3 0.06 2 2
$GrainSpotter index-$i.ini
echo "#"
echo "#"
echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
echo "#"
echo "#"
# Remove peaks that have been indexed
$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
grainlist="$grainlist grains-$i.log"
done
for i in {16..20}
do
j="$((i - 1))"
echo "#"
echo "#"
echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
echo "#"
echo "#"
# Use from previous step and create grains$i.log
create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 20 0.3 0.06 3 3
$GrainSpotter index-$i.ini
# Remove peaks that have been indexed
echo "#"
echo "#"
echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
echo "#"
echo "#"
$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
grainlist="$grainlist grains-$i.log"
done
for i in {21..25}
do
j="$((i - 1))"
echo "#"
echo "#"
echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
echo "#"
echo "#"
# Use from previous step and create grains$i.log
create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 20 0.3 0.1 3 3
$GrainSpotter index-$i.ini
# Remove peaks that have been indexed
echo "#"
echo "#"
echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
echo "#"
echo "#"
$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
grainlist="$grainlist grains-$i.log"
done
}
#-----------------------------------------------------------------------------------------------
#
# Indexing loop, runs tens of GrainSpotter iterations with decreasing tolerances
# Runs in the current folder
#
#-----------------------------------------------------------------------------------------------
for (( loop=1; loop<=$nLoops; loop++ ))
do
echo "#----------------------------------------------------------------------------------------"
echo "#"
echo "# Full indexing loop number $loop"
echo "# Data saved in folder: Indexing-$loop"
echo "#"
echo "#----------------------------------------------------------------------------------------"
echo ""
folder="Indexing-$loop"
\rm -rf $folder
mkdir $folder
grainlist=""
indexing_loop
$mergeGrains -c $crystalSymmetryCode -o merge $grainlist
$extractEuler -o merge-grains-euler.txt merge-grains.log
mv grains-* $folder
mv peaks_after_step* $folder
mv merge-* $folder
mv index-*.ini $folder
echo ""
echo ""
echo "#----------------------------------------------------------------------------------------"
echo "#"
echo "# Done with indexing loop number $loop"
echo "# Data saved in folder: Indexing-$loop"
echo "#"
echo "#----------------------------------------------------------------------------------------"
echo ""
echo ""
done
exit