troi
The shared core of the Borevitz Lab software ecosystem — one
Troi (Time and Region Of Interest), one Config, used by every lab
package.
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 aTroi/Config), never subclass it. ConfigvsPaths. User-settable inputs live onConfig; locations derived from aTroiorConfiglive on a per-packagePathsclass.- Layered APIs. Data-layer functions are troi-agnostic
(
bbox, start, end); thin*_troiadapters 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 troi-core # from PyPI (distribution name troi-core, 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
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 troi_core-0.1.1.tar.gz.
File metadata
- Download URL: troi_core-0.1.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73038cd259bb3435108587465812c7c20a23fa059fb345cf16afdc7c45afbe1e
|
|
| MD5 |
9279257ea739d55be8e239079f6ae6cd
|
|
| BLAKE2b-256 |
3f7a49c71939d82df2a18c72db0de8e56cb7931be2ca07ea234613890d15c626
|
File details
Details for the file troi_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: troi_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c8062b6ae366286843eda9f203aa89e0547f295fff02467e067865281a2d0c
|
|
| MD5 |
ea720c2421528e78439861b58eabb62c
|
|
| BLAKE2b-256 |
2ebde0d4e405943cc375db94f7d082a1af2d6ba5ffad1942acc93712e77eb70d
|