Skip to main content

troi

The shared core of the Borevitz Lab software ecosystem — one Troi (Time and Region Of Interest), one Config, used by every lab package.

License: MIT Python 3.11+ Borevitz Lab

from datetime import date
from troi import Troi

troi = Troi(
    bbox=[148.36265, -33.52606, 148.38265, -33.50606],  # [W, S, E, N]
    start=date(2024, 1, 1),
    end=date(2024, 12, 31),
    stub='my_farm',
)

Every downstream package takes a Troi and answers it — same identity, same caches, same reproducibility guarantees everywhere.

Package Built on this core What it does
pysentinel2 Troi, Config Self-filling local Sentinel-2 datacube — nothing downloaded twice
pysilo Troi, Config Cached SILO daily climate — fetch once per ~5 km grid point
pyozwald Troi, Config Cached OzWALD meteorology + 8-day biophysical series — fetch once per grid point
pycopdem Troi, Config Cached Copernicus 30 m DEM + on-read slope/TWI/aspect/HLI — one download per chunk
pyslga Troi, Config Cached SLGA soil properties (16 attributes × 6 depths) — one download per chunk
PaddockTS Troi, Config Paddock segmentation, time series, phenology, reports

Troi — the identity layer

A frozen, hashable request: this region, this date range. Two queries with the same inputs are the same troi — they share every cached artefact on disk.

q.bbox_hash    # region identity  (bbox snapped to ~100 m, then SHA-256)
q.time_hash    # date-range identity
q.out_dir      # final outputs for this stub
q.tmp_dir      # scratch space for this stub

Storage layout is not Troi's concern — packages derive their own cache locations (usually from the hashes) in their own Paths class.

Three ways to build one:

Troi(bbox=[w, s, e, n], start=..., end=..., stub='site_a')

Troi.from_lat_lon(lat=-34.38, lon=148.48, buffer_km=2.0,
                   start=..., end=..., stub='site_b')

Troi.build_from_paddocks(paddocks_filepath='paddocks.gpkg',   # .gpkg / .shp / .geojson
                          start=..., end=..., stub='site_c')

Every constructed troi is recorded in a file-locked registry ({out_dir}/queries.json). Re-running an identical troi is a no-op; reusing a stub for different inputs raises ValueError — stubs uniquely name a troi, forever.

Config — the environment layer

Where data lives and which credentials to use. Loaded once, from the first source found:

Source Example
~/.config/Troi.json {"out_dir": "...", "email": "...", "tern_api_key": "..."}
TROI_* env vars TROI_OUTDIR, TROI_TMPDIR, TROI_EMAIL, TROI_TERN_KEY
Built-in defaults ~/Documents/Troi-Outputs · ~/Downloads/Troi-Tmp

Or bypass files entirely:

from troi import Config

cfg = Config(out_dir='/data/outputs', tmp_dir='/data/tmp')
q = Troi(..., config=cfg)

Design rules

The conventions every lab package follows:

  • No inheritance. One generic Troi; packages compose with it (functions and small classes taking a Troi/Config), never subclass it.
  • Config vs Paths. User-settable inputs live on Config; locations derived from a Troi or Config live on a per-package Paths class.
  • Layered APIs. Data-layer functions are troi-agnostic (bbox, start, end); thin *_troi adapters connect them to the reproducibility layer.

📚 Reference documentation: docs/ — the Troi class, Config resolution, the registry, and the ecosystem conventions.

Install

Just this package

pip install pytroi           # from PyPI (distribution name pytroi, import troi)
# or straight from GitHub:
pip install git+https://github.com/thestochasticman/troi.git

(For the whole pipeline, install paddocktimeseries — its pip install . pulls troi and the five data stores from GitHub.)

From source

git clone https://github.com/thestochasticman/troi.git
cd troi
pip install -e .

Optional extra for Troi.build_from_paddocks:

pip install -e '.[paddocks]'   # adds geopandas

Test

python -m troi.troi     # True
python -m troi.config   # prints the resolved config

License

MIT · Borevitz Lab, Australian National University

Download files

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

Source Distribution

troi_core-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

troi_core-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file troi_core-0.1.0.tar.gz.

File metadata

  • Download URL: troi_core-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for troi_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 82165aac4c71cc85203e8e50e06fe871b333932c2036eb023f51291b7cacb297
MD5 44bf453863847ca2075147de4c87dd2b
BLAKE2b-256 94be6d955689d07fc3535c61df9ed0b411035d9a7f23f116e4b87cdf8a2b948f

See more details on using hashes here.

File details

Details for the file troi_core-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: troi_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for troi_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a17b772f9612b29544f13e972fb3c22adf9566324a67b402840c3d5d5b80769
MD5 f5597f94e674c33882e31f9bacf9941c
BLAKE2b-256 c2a5cceaf17f90a383b6baa8a14bd8afbfbd44a9e084523fa195eb53d9609ccd

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page