DOI: 10.5281/zenodo.17605591
These are the instructions for the workflow provided in this git repository. Please read all the way to the bottom before using the scripts the first time.
Note
This repository automatically installs the pyFAI library using pip For more information about this powerful library, see the pyFAI documentation
Below are the instructions to install the pyFAI library and all other required libraries for this workflow:
Tip
It is also HIGHLY recommended to run this workflow within its own Python virtual environment. Please see this link to learn more about virtual environments, or look them up online. There are lots of useful resources on the topic.
- Open a terminal session
- Navigate to the parent directory into which you want to clone the repository
cd /path/to/parent/directory
- Clone the git repository
git clone https://github.com/aaronzwells/Analysis_pyFAI.git
- Go to the cloned repository
cd Analysis_pyFAI
- Create the virtual environment
python3 -m venv .venv
- Activate the virtual environment associated with the repository
source .venv/bin/activate
- Install the required packages
pip install -r pyFAI/requirements.txt
- Open Command Prompt or PowerShell
- Navigate to the parent directory
cd C:\path\to\parent\directory
- Clone the git repository
git clone https://github.com/aaronzwells/Analysis_pyFAI.git
- Go to the cloned repository
cd Analysis_pyFAI
- Create the virtual environment
python -m venv .venv
- Activate the virtual environment
.venv\Scripts\activate
- Install the required packages
pip install -r pyFAI\requirements.txt
Analysis_pyFAI/ is the main directory where all inputs and output subdirectories are located, as well as the script files (*.py).
InputFiles/ is the directory where all user-provided input images are housed. It is not included in the git repository, and should be created by the user. It was excluded due to the size of the folders.
OutputData/OutputFiles*/ directories are generated automatically during script generation. These are named with the following format: "OutputFiles_<kind_of_output>_<sample_name>_<date_and_time>"
OutputMaps_*/ directories are created to house the final stress and strain maps. Each map directory is time stamped and uses the above ^^ naming convention.
PeakFinding/ is where the reference peak data is stored after running 1.FindingRefPeaks.py
ValidationOutputFiles/ is where the data from 2.StrainCalc-SingleImage.py are saved
calibration/ is the directory where pyFAI calibration data should be stored. (The user is responsible for storing the data here. It does not auto-save to this directory.) This data includes all .npt, .poni, .json files related to calibration. It is also recommended that .tif calibration images be saved to this folder, as it is a convenient way to keep everything nicely contained.
pyFAI/ is the directory where the pyFAI program is installed. For details on this installation see the PyFAI Documentation page.
pycache/ is a folder that houses all cached data from the batch processing steps. There is no need for the user to ever interact with this directory as it is auto-generated.
Before executing the workflow, 1.FindingRefPeaks.py can be used to run the peak fitting math. This is useful for ensuring the peaks are being correctly fit to given input data. FunctionLibrary.py contains all the functions used and called in the below scripts.
Note
The main workflow scripts are numbered and may be referred to as "Script 1", "Script 2", etc.
-
The first true workflow script is
1.GettingPeakLocs.py. This script allows the user to input their calibration .poni file and a representative .tif or .tiff file and have PyFAI determine good initial guesses for the first 9 peaks by fitting to the Pseudo-Voigt function. It then outputs this data to a folder, named after your input file, within theValidationOutputFiles/PeakFinding/directory. -
The second workflow script is
2.StrainCalcs-SingleImage.py. This is the script that finds the reference q0 values for all future strain calculations. If using it to find the reference, setq0_reference_filetoNone. Otherwise, provide the path to the already foundq0_reference_file. It is recommended to input the values from Script 1 forinitial_q_guesses. Other parameters should be set via the user's experimental conditions and desired processing parameters.
Tip
Using relative paths when updating script variables is accepted and encouraged to keep the main directory organized.
-
The third workflow script is
3.StrainCalcs-BatchProcess.py. This script is the main data analysis script. It requires similar inputs (housed inconfig, lines 208-243) as Script 2, though it only needs the parent directory in which the input TIFs are housed. This script will output a significant amount of data housed in anOutputFiles_Data_*/directory matching the user-defined sample name prefix in the variable calledSampleName. -
The mapping scripts are either
4.MappingStrain.pyand5.MappingStress.py. These two scripts map the strain based upon the generatedstrain_tensor_summary.jsonfrom Script 3. The outputs are saved to an output directory using the same naming conventions as the outputs from Script 3.
Note
Script 5 requires the input of material properties and is only set up to solve for perfectly elastic materials using Hooke's Law.
All of these scripts contain the prefix Utility- and can be used or adapted to perform different functions. The first three should work, but Utility-ReconstructingRingsFromStress.py was never completed.
Note
See the comments in the code for a definition of each variable
Lines 8-9
poni_filetif_file
Lines 35-63
poni_fileq0_reference_filetif_filemask_filesave_chi_filessave_adjusted_tifmask_threshnum_azim_binsq_min_nm1npt_raddelta_tolwavelength_nmsolved_strain_componentsMAD_thresholdinitial_q_guessestol_arrayeta0
Lines 208-243
input_dirsampleNameponi_fileq0_reference_filemask_filesave_chi_filesplot_q_vs_chiplot_strain_vs_chisave_adjusted_tifnum_jobs_parallelmask_threshnum_azim_binsq_min_nm1npt_raddelta_tolwavelength_nmsolved_strain_componentsMAD_thresholdinitial_q_guessestol_arrayeta0min_rsquared
Lines 8-27
json_pathsample_namesolved_strain_componentsn_steps_xn_steps_ydXdYpixel_size_mapstart_xygap_mmmap_offset_xytrim_negative_xymap_x_limitsmap_y_limitscolor_limit_windowcolorbar_scalecolorbar_binstitle_and_labels
Lines 15-38
json_pathsample_nameyoungs_moduluspoissons_ration_steps_xn_steps_ydXdYpixel_size_mapstart_xygap_mmmap_offset_xytrim_negative_xymap_x_limitsmap_y_limitscolor_limit_windowcolorbar_scalemap_name_pfx