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 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

Metadata

Release files for troi-core 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for troi-core 0.1.1
File Size Uploaded Provenance Actions
troi_core-0.1.1.tar.gz 11.7 kB Without provenance Details for troi_core-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for troi-core 0.1.1
File Interpreter ABI Platform Actions
troi_core-0.1.1-py3-none-any.whl Python 3 none any Details for troi_core-0.1.1-py3-none-any.whl

Total release size: 22.1 kB

Release files / troi_core-0.1.1.tar.gz

Download URL troi_core-0.1.1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
73038cd259bb3435108587465812c7c20a23fa059fb345cf16afdc7c45afbe1e
BLAKE2b-256 checksum
How to use checksums
3f7a49c71939d82df2a18c72db0de8e56cb7931be2ca07ea234613890d15c626
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / troi_core-0.1.1-py3-none-any.whl

Download URL troi_core-0.1.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65c8062b6ae366286843eda9f203aa89e0547f295fff02467e067865281a2d0c
BLAKE2b-256 checksum
How to use checksums
2ebde0d4e405943cc375db94f7d082a1af2d6ba5ffad1942acc93712e77eb70d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for troi-core 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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