Skip to main content

Transformation functions for Tyche market data pipelines

Project description

Tyche Transforms

This package provides the transformation functions defined in MARKETS_INFO.md for Tyche market data pipelines, operating on xarray DataArray inputs. The intent is to keep the same implementations between local development and the Chainlink adapter.

Install

uv pip install tyche-transforms

For development:

uv pip install -e ".[test]"

Usage

import pandas as pd
import xarray as xr
from tyche_transforms.transforms import daily_average, hdd, runlen_lt

times = pd.date_range("2024-01-01", periods=3)
data = xr.DataArray([15.0, 10.0, 8.0], dims="time", coords={"time": times})
print(daily_average(data))
print(hdd(data))
print(runlen_lt(data, threshold=9.0))

GitHub Actions

This repo includes a workflow that runs tests on every push/PR and publishes to PyPI when you push a tag matching v* (for example v0.2.0). To enable publishing:

  1. Add a repository secret named PYPI_API_TOKEN containing your PyPI token.
  2. Push a version tag:
git tag v0.2.0
git push origin v0.2.0

Transformation Functions

DataArray -> DataArray

  • CONVERT_M_TO_MM (0 args): convert meters to millimeters.
  • CONVERT_KELVIN_TO_CELSIUS (0 args): convert Kelvin to Celsius.
  • CUMULATIVE_TO_INCREMENT (0 args): convert cumulative totals to daily increments.
  • DAILY_AVERAGE (0 args): resample to daily mean values.
  • DAILY_SUM (0 args): resample to daily sum values.
  • DAILY_MAX (0 args): resample to daily maximum values.
  • DAILY_MIN (0 args): resample to daily minimum values.
  • HDD (0 args): daily temperature -> HDD series (base 18 C).
  • CDD (0 args): daily temperature -> CDD series (base 18 C).

DataArray -> Scalar

  • SUM (0 args): sum over window -> scalar.
  • AVG (0 args): average over window -> scalar.
  • MAX (0 args): max over window -> scalar.
  • MIN (0 args): min over window -> scalar.
  • DATE_MAX (0 args): timestamp of the max value -> scalar (timestamp).
  • DATE_FIRST:threshold (1 arg): timestamp of first value > threshold, or epoch pd.Timestamp(0) if none -> scalar (timestamp).
  • RUNLEN_LT:threshold (1 arg): longest run length where value < threshold -> scalar.
  • RUNLEN_GT:threshold (1 arg): longest run length where value > threshold -> scalar.

Scalar -> Scalar

  • ABS (0 args): absolute value of a scalar -> scalar.
  • SUBTRACT_V:threshold (1 arg): subtract a scalar to the given threshold -> scalar.

2 Scalar -> Scalar

  • SUBTRACT (0 args): for exactly 2 locations, return scalar = loc1 - loc0 -> scalar.

Project details


Download files

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

Source Distribution

tyche_transforms-0.1.5.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

tyche_transforms-0.1.5-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file tyche_transforms-0.1.5.tar.gz.

File metadata

  • Download URL: tyche_transforms-0.1.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tyche_transforms-0.1.5.tar.gz
Algorithm Hash digest
SHA256 64e3b0271ac6115cf02e292053907b0c86f0bcfe30876cd4fac7fbd6871e9dbb
MD5 ce71dc79ad6b53a9d503f0290429cb58
BLAKE2b-256 6c70e58d7bfa51420eca904f0185f0e5e3270e0fed2481c61be660829ee80a18

See more details on using hashes here.

File details

Details for the file tyche_transforms-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for tyche_transforms-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 32b3d94c70c5bf38dd5c5311da1c1c5926eaf4ff7ed6d6745ceba570235c026f
MD5 b7435c53361abfd929e6f00631ab38b0
BLAKE2b-256 b071adbe9ab956ba2da66926a7565dc21a3e9257d92d720e18a1bb1407eb0620

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page