Skip to main content

Petrology tools

Project description

Lydwhitt_tools

A collection of functions and tools I have developed and find useful during my volcanology PhD.

Whilst I have a lot of tools and functions on my computer that I use regularly, I haven't yet put them all in a place to help others. There are a lot of very simple tasks that waste time, which I've created tools to complete, and I will be adding them to this repository over time.

I started collating this in August 2025 — so bear with me whilst I get it going!


Install

pip install lydwhitt-tools


Quickstart

Here’s the simplest way to run the geochemical filter tool: import pandas as pd import lydwhitt_tools as lwt Load your geochemical dataset df = pd.read_csv("my_data.csv") Apply the filter (defaults: total_perc=96, percentiles=(98, 98)) filtered_df = lwt.geochemical_filter(df, phase="Cpx") print(filtered_df.head())


Detailed Usage

The geochemical_filter function filters geochemical datasets using the Mahalanobis distance method in two passes.

Function signature: lwt.geochemical_filter(df, phase, total_perc=None, percentiles=None)

Parameters:

  • phase (str) – e.g., "Cpx", "Plg", "Liq". Must match the suffix used after oxide wt% values in your dataset.
  • total_perc (float, optional) – Minimum total oxide percentage allowed. Defaults to 96.
  • percentiles (int, float, or tuple, optional) – Percentile cutoffs for Pass 1 and Pass 2.
    • Single value applies to both passes (e.g., percentiles=98).
    • Tuple gives different cutoffs for each pass (e.g., percentiles=(95, 99)).

Example: Use different percentiles for each pass filtered_df = lwt.geochemical_filter(df, phase="Plg", total_perc=97, percentiles=(95, 99))


Output

The function returns the filtered DataFrame, including flags for each pass:

  • Mahalanobis – Mahalanobis distance for each row in the given pass.
  • P1_Outlier – Boolean flag indicating if the row was an outlier in Pass 1.
  • P2_Outlier – Boolean flag indicating if the row was an outlier in Pass 2.

Features Coming Soon

This repository will grow to include: -formula recalculations for different phases -simple plotting frameworks -data re-oragnisation tools for popular gothermobarometry packages


License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lydwhitt_tools-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lydwhitt_tools-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file lydwhitt_tools-0.1.1.tar.gz.

File metadata

  • Download URL: lydwhitt_tools-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for lydwhitt_tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c868d6f976d6b1f85328807fce0e584fac608ee00d216b23bde49ddc9b10f7fb
MD5 bf1339d8e106e1b51298e3d51d8dbb02
BLAKE2b-256 27fb2089aabfe1ea2762219c2e37e24ae62c1ddb4ba79e8ffd85917df2ca40d0

See more details on using hashes here.

File details

Details for the file lydwhitt_tools-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lydwhitt_tools-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for lydwhitt_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15f5e7720c0792e76e94a873c09754c670e1fc052c9a2ef89c6e1c52396b8503
MD5 262c0d8fcf3c47c956059c6dba36aa18
BLAKE2b-256 24163f717e7ee3f3c4a953d8c9b93c35622358564f8ac42161745320e132d657

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page