Skip to content

wlanghans/ore-detection-api

Repository files navigation

Ore Detection API

This project is a Python API designed to compute the likelihood of ore detection based on various geological and geographical inputs. It utilizes a configuration file in YAML format to specify parameters such as rock types, locations, and input files.

Project Structure

ore-detection-api
├── src
│   ├── main.py          # Entry point of the API
│   ├── config.py        # Configuration file parser
│   ├── detector.py      # Detection logic with Gaussian Process predictions
│   ├── constants.py     # Constants and configuration values
│   ├── gp_utils.py      # Gaussian Process utilities for spatial predictions
│   ├── gpd_utils.py     # GeoPandas utilities for spatial operations
│   └── grid_utils.py    # Grid creation and visualization utilities
├── example_config
│   └── config.yaml      # Example YAML configuration file
├── input_data
├── tests
│   ├── __init__.py      # Marks the tests directory as a package
│   ├── test_config.py   # Unit tests for the config module
│   ├── test_detector.py # Unit tests for the detector
│   └── test_gpd_utils.py # Unit tests for GeoPandas utilities
├── ore_detection_tutorial.ipynb    # Notebook tutorial demonstrating detection API design/usage
├── pyproject.toml       # Project metadata and dependencies
└── README.md            # Project documentation

Installation

To set up the project, clone the repository, create a virtual environment, and install it in development mode:

git clone <repository-url>
cd ore-detection-api
python -m venv .venv
source .venv/bin/activate
pip install -e .

To also install development dependencies (for testing):

pip install -e ".[dev]"

Configuration

The API requires a YAML configuration file located at example_config/config.yaml. This file should contain the following sections:

  • rocks: A list of rock types (minimum 2 elements).
  • locations: A list of [easting, northing] coordinates in UTM format (can be empty).
  • inputs: A list of input file names (minimum 1 element).
  • length_scale: (Optional) The Gaussian Process length scale parameter for spatial predictions (default: 10000.0).

Example Configuration

Here is the current configuration file (example_config/config.yaml):

rocks:
  - serpentinente ultramafic rock
  - ultramafic rock
  - granodioritic intrusive rock

locations:
  - [550000, 5584000]
  - [548000, 5583000]
  - [540000, 5575000]

inputs:
  - BedrockP.gpkg
length_scale: 5574.0

Usage

To run the API, execute the following command:

ore-detection-api

This will use the default configuration file at example_config/config.yaml. To use a different configuration file, provide the path as an argument:

ore-detection-api /path/to/custom/config.yaml

The application will load the configuration, validate it, and compute the likelihood of ore detection based on the provided parameters in the configuration.

Alternatively, you can run it directly as a Python module:

python -m main

Tutorial

To get a better understanding of how predictions are made, the notebook ore_detection_tutorial.ipynb provides a tutorial that explains the framework chosen for data processing and statistical modeling. A step-by-step guide is provided with illustrations.

Testing

Unit tests are located in the tests directory. To run the tests, use the following command:

pytest tests/

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

An Ore detection API based on Gaussian process regression

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published