wndsn-tycho
A Python client for the Tycho calculators: the Sun, stars, sight reduction, the Moon, map scale, range and height from angular size, dip of the horizon, elevation, the shadow square, and Duv.
- One typed method per calculator, with arguments checked before anything is sent and results as dataclasses with named fields.
- Standard library only, Python 3.10+.
- Polite by default: at most one request per second, a User-Agent naming the package, retries on HTTP 429/5xx.
- An optional on-disk cache, so tests and repeated runs need no network.
Install
pip install wndsn-tycho
Examples
from wndsn_tycho import Tycho
tycho = Tycho()
# Sun at 52.5° N on the June solstice
sun = tycho.sun(52.5, longitude=13.3, tz=1, date="2026-06-21")
sun.diurnal.noon_altitude # 60.93...
sun.longitudinal.sunrise_time # "03:44" (clock times are text, here UTC+1)
sun.longitudinal.astronomical_dawn # None: no astronomical night in June at 52.5°
# Without a date, give the declination; notes say what needs a date
tycho.sun(52.5, declination=20).notes
# Range: any two of angle, size and distance give the third (d = s / tan α)
tycho.range(alpha=2, size=1.8).distance # 51.545256
tycho.range(alpha=35, size=1.8, angular_unit="mil").distance
# Height from a known distance, h = d · tan α
tycho.height(100, 10).height # 17.632698
# Shadow square: umbra recta 12, umbra versa 8
s = tycho.shadow(umbra_recta=12, umbra_versa=8)
s.tan, s.arctan, s.complement # 0.666667, 33.690068, 56.309932
# Sight reduction
tycho.sight(52.5, 20, lha=40).hc # 45.198923...
# The Moon
moon = tycho.moon(date="2026-11-15", lat=52.5, lon=13.3)
moon.phase_of_moon.phase, moon.moon_of_the_day.moonrise
Module-level shortcuts use one shared default client:
import wndsn_tycho
wndsn_tycho.range(alpha=2, size=1.8).distance
wndsn_tycho.configure(cache=True) # change the default client
Calculators
| Method | Computes |
|---|---|
sun(latitude, *, date, declination, longitude, tz, dst, sun_altitude) |
noon altitude, sunrise/sunset azimuths and times, twilight, equation of time, unequal hours |
star(latitude, *, declination, star, altitude) |
rising/setting azimuths, culminations, azimuth and hour angle at an altitude |
sight(latitude, declination, *, lha, gha, longitude, ho) |
computed altitude Hc, azimuth Zn, intercept |
moon(*, date, time, clock, utc, lat, lon, age, illum, wax) |
phase, position, moonrise/transit/moonset, unequal hours |
scale(scale, *, map_distance, map_unit, ground_distance, ground_unit) |
map ⇄ ground distance in every unit |
range(*, alpha, size, distance, multiplier, angular_unit, unit, solve) |
distance, size or angle; the multiplier 1/tan α; MIL/NATO-MIL/MOA |
height(known_distance, alpha, *, angular_unit) |
height from distance and angle |
dip(h1, *, h2, h1_unit, h2_unit) |
distance to the horizon, and at which a light is seen |
elevation(*, gamma, beta, size, a, b, c, unit) |
height and distance from two angles and a baseline |
shadow(*, umbra_recta, umbra_versa, angle, tan, cot) |
tan, cot, angle and its complement |
duv(*, x, y, u, v) |
CCT and Duv of a chromaticity |
Each returns a result dataclass (SunResult, RangeResult, ...) from wndsn_tycho.results.
Every result also has input (what Tycho was given), notes (Tycho's notes, a tuple),
digits, raw (the whole answer) and as_dict().
Bad arguments raise ValueError or TypeError without a request: an unknown keyword, a latitude
of 95°, a size over Tycho's limit of 65536, three of range's three values. Input that only Tycho
can judge raises TychoInputError (with .notes). TychoHTTPError means Tycho could not be
reached or answered with an error.
Raw queries
get sends any parameters unchecked and returns Tycho's answer as it is: parsed JSON, or the
text for XML and CSV.
tycho.get("sun", latitude=52.5, date="2026-06-21") # dict with input, output, digits
tycho.get("range", {"alpha": 2, "size": 1.8}, fmt="csv")
Cache
Off by default. Turn it on for repeated runs, or to run tests offline:
Tycho(cache=True) # the user cache directory (see user_cache_dir())
Tycho(cache="tests/tycho-cache") # a directory of your choice, e.g. committed with tests
Tycho(cache="tests/tycho-cache", mode="offline") # cache only: a miss raises CacheMiss
Tycho(cache="tests/tycho-cache", mode="refresh") # fetch everything again
The default mode is fill: read the cache, fetch only what is missing. Each query is one JSON
file, <cache>/<calculator>/<key>.json, holding the query, its URL, when it was fetched, and the
answer. The key is a hash of the canonical query, so the order of parameters and 1 vs 1.0
don't matter. Refresh a committed cache after a Tycho release and read the diff.
Options
Tycho(cache=None, mode="fill", base_url="https://tycho.wndsn.com", digits=6, min_interval=1.0, timeout=20.0, retries=2, user_agent=...)
digits: precision Tycho rounds to, 0–9 (Tycho's own default is 2).moontakes at most 4.min_interval: seconds between live requests. Against tycho.wndsn.com it can't be below 1; all clients in a process share one throttle. A local copy of the site (base_url) may go faster.
Command line
wndsn-tycho sun latitude=52.5 date=2026-06-21
wndsn-tycho range alpha=2 size=1.8 --format csv
python -m wndsn_tycho height known_distance=100 alpha=10 --cache
The API
docs/api.md describes the HTTP API: parameters, limits, output fields, and the
quirks the client handles (height's flat answer, range's size limit, sun without a date,
moon's digits).
Tests
python -m unittest discover -s tests -t .
The unit tests run against a fake Tycho that serves real recorded answers, with no network. The live test sends one query per calculator to tycho.wndsn.com (about 15 s):
TYCHO_LIVE=1 python -m unittest tests.test_live -v
Versioning
Semantic versioning; the version is in src/wndsn_tycho/_version.py,
changes in CHANGELOG.md, and releases are tagged vX.Y.Z.
Licence
MIT, see LICENSE.
Metadata
Release files for wndsn-tycho 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wndsn_tycho-0.1.0.tar.gz | 35.7 kB | With provenance | Details for wndsn_tycho-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wndsn_tycho-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for wndsn_tycho-0.1.0-py3-none-any.whl |
Total release size: 58.1 kB
Release files / wndsn_tycho-0.1.0.tar.gz
| Download URL | wndsn_tycho-0.1.0.tar.gz |
|---|---|
| Size | 35.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3720741a657417a5668b189f62b7f3bf037b17aab16ee7cb96ac57ae8f7ae61
|
|
BLAKE2b-256 checksum How to use checksums |
293d840c422e1f5f161213588edc409e22b230bcf0cb03c02fc8407e3655102d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logRelease files / wndsn_tycho-0.1.0-py3-none-any.whl
| Download URL | wndsn_tycho-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9a86b561002338ccad8e88b207d93aa7fa608bf95d3aa2f4d024cd38a1dcd24
|
|
BLAKE2b-256 checksum How to use checksums |
6a74f9b56c4dbc69f555bfe5acfb3941e3a5445de05c82ec07f4fe4953daedf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logSecurity for wndsn-tycho 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for wndsn_tycho-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logA 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.