Tools for quantifying grain size populations and paleopiezometry from thin sections
Project description
Maintained by Marco A. Lopez-Sanchez - This website was last modified: 2024-06-26
GrainSizeTools is a free, open-source, cross-platform script written in Python that provides tools for (1) quantifying and visualising grain size populations, (2) applying stereological methods to approximate the true grain size distribution from 2D sections and (3) estimating differential stress for different mineral phases via paleopiezometry. The script has been designed to be accessible to users with no previous experience of the Python programming language and focuses on scientific reproducibility by including several ready-made templates for the different use cases. For users with programming skills, the script is organised in a modular (functional) way to facilitate reuse and code extension.
Latest release: v3.2.0
Date: 2024-06-26
See notes at https://github.com/marcoalopez/GrainSizeTools/releases/tag/v3.2.0
View project on GitHub
Features at a glance
-
Import and manipulate tabular data sets including text, CSV, or Excel formats via Pandas.
-
Fully automated descriptive statistics of grain size populations including:
- Multiple averages (arithmetic and geometric means, median, and frequency peak ("mode") via Gaussian Kernel Density Estimator)
- Estimation of robust confidence intervals (including some specific methods for lognormal populations such as the modified Cox or the GCI method)
- Measures of dispersion and population shape
- Normality and lognormality tests
-
Estimation of differential stress using palaeopiezometers. It includes piezometric relations for quartz, olivine, calcite and feldspar (more to come!)
-
Ready-to-publish plots in bitmap or vector format (see screenshots below), including:
- Histograms and kernel density estimates
- Area or volume-weighted plots
- Normalized plots
- Quantile-quantile plots, and more
-
Stereology methods (approximating the true 3D grain size distribution from data collected in flat sections):
- Saltykov method
- Two-step method (log-normal fitting, shape characterization)
- Estimate the volume fraction occupied by any grain size range
Download
https://github.com/marcoalopez/GrainSizeTools/releases
Installation
GrainSizeTools uses uv for dependency and environment management.
1. Install uv
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Or via pip: pip install uv
2. Clone the repository
git clone https://github.com/marcoalopez/GrainSizeTools.git
cd GrainSizeTools
3. Create the environment and install dependencies
uv sync --all-groups
This creates a .venv virtual environment with Python 3.11 and installs all dependencies (numpy, scipy, matplotlib, pandas, pyyaml) along with JupyterLab for running notebooks.
4. Launch JupyterLab
uv run jupyter lab
Then open any of the template notebooks in grain_size_tools/ or the examples in grain_size_tools/example_notebooks/.
Running scripts directly
Any Python script or command can be run inside the managed environment using uv run:
uv run python your_script.py
Usage
GrainSizeTools is a proper Python package and can be imported directly:
import grain_size_tools as gst
# or import submodules individually
from grain_size_tools import summarize, plot, stereology, piezometers
Describe a grain size population
import numpy as np
import grain_size_tools as gst
# load your grain diameter data (in microns)
data = np.loadtxt('my_data.txt')
# print descriptive statistics with confidence intervals
gst.summarize(data)
# visualize the distribution
fig, ax = gst.plot.distribution(data)
Stereological correction (2D → 3D)
# Saltykov method
fig, axes = gst.stereology.Saltykov(data, numbins=12)
# Two-step method (returns lognormal parameters)
fig, ax = gst.stereology.two_step(data)
Paleopiezometry
# load the piezometric database
version, metadata, db = gst.piezometers.load_piezometers_from_yaml(None)
# list available piezometers
gst.piezometers.list_piezometers(db)
# estimate differential stress (MPa) from a grain size (microns)
gst.piezometers.calc_diffstress(db.quartz.__dict__['Stipp_Tullis'], grain_size=40.0)
Documentation
https://github.com/marcoalopez/GrainSizeTools/wiki
Screenshots
Citation guidelines
If you have used the script, please consider citing the following paper:
Lopez-Sanchez, Marco A. (2018). GrainSizeTools: a Python script for grain size analysis and paleopiezometry based on grain size. Journal of Open Source Software 3, 863, https://doi.org/10.21105/joss.00863
By citing this paper, you are giving proper credit to the author and acknowledging his work.
License
GrainSizeTools script is licensed under the Apache License, Version 2.0 (the "License")
The documentation of GrainSizeTools script is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0).
Community guidelines
The GitHub site where the project is hosted offers several options (you'll need a GitHub account, it's free!)::
- Open a discussion: This is a place to:
- Ask questions you are wondering about.
- Requests for specific features or share ideas.
- Interact with the developers.
- Open an issue: This is a place to report or track bugs.
- Make a pull request: You have modified, corrected or added a feature to one of the notebooks and send it to one of the developers to review it and add it to the main page.
Copyright © 2017-2024 Marco A. Lopez-Sanchez
[!WARNING] Please note that the information on this website and in the script documentation is provided without any warranty of any kind, either expressed or implied. It may therefore include technical inaccuracies or typographical errors. The author reserves the right to make changes or improvements to the content of this website and the script documentation at any time without notice. This website and its documentation are not responsible for the content of external links.
Hosted on GitHub Pages — This website was created with Typora
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grainsizetools_jwestraadt-3.2.1.tar.gz.
File metadata
- Download URL: grainsizetools_jwestraadt-3.2.1.tar.gz
- Upload date:
- Size: 7.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64873209b9b2e5c44577ab286743345cddd6c108c699af4bf00fea73d8dfbf24
|
|
| MD5 |
84fa1f886da5c0d6432b85c84939220c
|
|
| BLAKE2b-256 |
7c03155d598ce0e6686943f45dcf137acf9c0ff6ffa44a253abba036b0504e5c
|
File details
Details for the file grainsizetools_jwestraadt-3.2.1-py3-none-any.whl.
File metadata
- Download URL: grainsizetools_jwestraadt-3.2.1-py3-none-any.whl
- Upload date:
- Size: 781.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36cff8fc1c0bae9ac6ac5ebeafcf9a610f882a78cbb1234326b0f5f1040137d6
|
|
| MD5 |
298f73b2b10eb2b9ef66d9a0c689c1d0
|
|
| BLAKE2b-256 |
da6b5cadba01355b192d446950cc2b2f1a3a7912467926bbbc6bb5a0b1e76509
|