Metadata-Version: 2.4
Name: pylogdigitizer
Version: 0.1.3
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Development Status :: 3 - Alpha
Requires-Dist: numpy
Requires-Dist: pillow
Requires-Dist: tifffile
Requires-Dist: lasio
Requires-Dist: pandas
Requires-Dist: pyyaml
Requires-Dist: opencv-python
Requires-Dist: scikit-image
Requires-Dist: scipy
Requires-Dist: rapidocr>=3,<4
Requires-Dist: onnxruntime
Requires-Dist: numba
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: httpx
Requires-Dist: matplotlib
License-File: LICENSE
License-File: NOTICE
Summary: Semi-automatic and ML-assisted digitization of raster scans of petrophysical well logs
Author: Larry Syu-Heng Lai
License-Expression: AGPL-3.0-or-later
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/GeoLarryLai/pyLogDigitizer
Project-URL: Issues, https://github.com/GeoLarryLai/pyLogDigitizer/issues
Project-URL: Repository, https://github.com/GeoLarryLai/pyLogDigitizer

<p align="center"><img src="image/logo.png" alt="pyLogDigitizer" width="220"></p>
<p align="center">
<a href="https://doi.org/10.5281/zenodo.23832013"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23832013-blue" alt="DOI"></a> <a href="https://github.com/GeoLarryLai/pyLogDigitizer/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-lightgrey" alt="License"></a>
<br>
<a href="https://pypi.org/project/pylogdigitizer/"><img src="https://img.shields.io/badge/python-3.10%2B-lightgrey" alt="Python versions"></a> <a href="https://pypi.org/project/pylogdigitizer/"><img src="https://img.shields.io/pypi/v/pylogdigitizer?color=orange" alt="PyPI version"></a> <a href="https://pepy.tech/projects/pylogdigitizer"><img src="https://img.shields.io/pepy/dt/pylogdigitizer?label=pypi%20downloads&color=orange" alt="PyPI downloads"></a> <a href="https://anaconda.org/conda-forge/pylogdigitizer"><img src="https://img.shields.io/conda/vn/conda-forge/pylogdigitizer?label=conda-forge&color=green" alt="conda-forge version"></a> <a href="https://anaconda.org/conda-forge/pylogdigitizer"><img src="https://img.shields.io/conda/dn/conda-forge/pylogdigitizer?label=conda%20downloads&color=green" alt="conda downloads"></a>
</p>

# pyLogDigitizer

> [!WARNING]
> **pyLogDigitizer** is under active development, and many functions are still experimental and not fully validated. Please use with caution.

**pyLogDigitizer** turns scanned paper well logs (TIFF) into LAS files. Lots of older wells only exist as paper scans, and digitizing them by hand is slow and hard to check. So I built a tool that does the tedious parts (finding tracks and grids, reading depth labels, tracing curves) and gives you a local browser app to check and fix every step. Curves that run off the track and come back on a backup scale get unwrapped automatically. Everything runs on your own machine and nothing is uploaded.

## Installation

```bash
pip install pylogdigitizer
```

From source (builds the Rust tracer, needs a Rust toolchain):

```bash
git clone https://github.com/GeoLarryLai/pyLogDigitizer && cd pyLogDigitizer
pip install .
```

Or `conda env create -f environment.yml && conda activate pylogdigitizer`, then `maturin develop --release`.
Without the Rust part everything still works, only slower.

## Citation

Lai, L.S.-H. (2026) pyLogDigitizer. *Zenodo*, [https://doi.org/10.5281/zenodo.23832013](https://doi.org/10.5281/zenodo.23832013)

![From a scanned paper log to a LAS curve](image/hero_scan_to_las.png)
*The whole idea in one picture: a scanned paper log going in and a LAS curve coming out.*

## What it can do

- Find tracks and grids, deskew the scan, read depth labels (OCR) and calibrate scales, including backup-scale wraparound
- Trace curves with a fast dynamic-programming tracer (Rust, with a Python fallback)
- Fix a trace in the app: click the real curve to pin it, drag a pin, or re-trace just the part inside a cursor circle
- Nudge track edges, set a scale from two grid lines, and click any OCR word in the header to correct it (the scale is re-fitted)
- Optionally train a U-Net cost map on your own corrected traces; batch runs send low-confidence curves to review
- Compare results against a reference LAS and write LAS 2.0
- Work through one local browser app, the command line or Python

## Examples

![Tracing in the app](image/app_07_trace.png)
*The guided app with a traced curve laid over the scan, ready for you to review and fix.*

![Digitized vs reference LAS](image/ex_qc_vs_reference_las.png)
*A curve digitized with the assisted workflow, checked against the paired Kansas Geological Survey (KGS) LAS.*

![ML vs conventional cost map](image/ex_ml_vs_conventional.png)
*On held-out Kansas wells, correlation and error against the reference LAS for the conventional and the ML cost map.*

Notebooks: `notebooks/01_conventional_vs_assisted.ipynb` (one scan, step by step) and
`notebooks/02_kansas_ml_train_batch.ipynb` (train the cost map and batch-digitize). Example scans and LAS files are
from the [Kansas Geological Survey](https://www.kgs.ku.edu/) (`example_data/SOURCES.txt`).

## Quick start

```bash
pylogdigitizer info example_data/USA_A_16_15-055-20536/4342.tif   # scan size and resolution
pylogdigitizer-app .                        # the app at http://127.0.0.1 (local only); `pylogdigitizer editor .` is an alias
```

The ML cost map (`cost_mode="ml"` or `"blend"`) needs PyTorch (`pip install torch`) and a trained checkpoint. Without
them the tracer uses the conventional cost map.

The same from Python:

```python
from pylogdigitizer import workflows as wf
R = wf.digitize_curve("example_data/USA_A_16_15-055-20536/4342.tif", track="track1", scale=(0, 150),
                      first_depth=1500, depth_range=(1500, 7030), backup=(150, 300))
R["depth"], R["value"], R["conf"]           # then las_export.resample + write_las
```

`backup=(150, 300)` is the **backup scale**: when a curve runs off the edge of its track it is redrawn from the other
edge on a second scale, and the tracer unwraps it.

Third-party notices and data credits: [`NOTICE`](NOTICE).

