aetherfield 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Heather Nightfall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: aetherfield
3
+ Version: 0.1.0
4
+ Summary: AetherField runtime ephemeris
5
+ Author: WitchMithras
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/WitchMithras/aetherfield
8
+ Keywords: time,calendar,lunar,astronomy
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: License :: Other/Proprietary License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pytz>=2023.3
17
+ Dynamic: license-file
18
+
19
+ AeTherField Staging
20
+ ===================
21
+
22
+ This folder stages a future standalone package for AetherField — a Skyfield-free
23
+ runtime ephemeris model that uses learned calibration/piecewise drift and offers
24
+ simple APIs for signs, longitudes, alignments, phases, and (now) sunrise/sunset
25
+ estimation.
26
+
27
+ Plan
28
+ - Extract reusable runtime core from the root `aetherfield.py`.
29
+ - Preserve public APIs: `aether_longitude`, `aether_sign`, `aether_alignments`, `moon_phase`.
30
+ - Add `sunrise_sunset(zone, coords, date, depression_deg)` for Moontime temporal hours.
31
+ - Keep calibration loaders and CLI tools in a tools subpackage.
32
+ - Console scripts (staging): `aetherfield-compare`, `aetherfield-benchmark`, `aetherfield-calibrate-all`.
33
+
34
+ Local Layout (staging)
35
+ - `src/aetherfield_pkg/` — package source (to be populated)
36
+ - `pyproject.toml` — packaging config (setuptools)
37
+
38
+ Dev Tips
39
+ - Create a venv and install local deps from the project root as usual.
40
+ - In staging, the package may re-export from the root `aetherfield.py` to avoid duplication.
41
+
42
+ CLI Usage (staging)
43
+ - Compare a single timestamp: `python -m aetherfield_pkg.cli.compare --body mars --dt 2025-06-21T12:00:00Z`
44
+ - Benchmark a range: `python -m aetherfield_pkg.cli.benchmark --start 2001-01-01T00:00:00Z --end 2001-12-31T00:00:00Z`
45
+ - Calibrate all: `python -m aetherfield_pkg.cli.calibrate_all --out aetherfield_calibration.json`
@@ -0,0 +1,27 @@
1
+ AeTherField Staging
2
+ ===================
3
+
4
+ This folder stages a future standalone package for AetherField — a Skyfield-free
5
+ runtime ephemeris model that uses learned calibration/piecewise drift and offers
6
+ simple APIs for signs, longitudes, alignments, phases, and (now) sunrise/sunset
7
+ estimation.
8
+
9
+ Plan
10
+ - Extract reusable runtime core from the root `aetherfield.py`.
11
+ - Preserve public APIs: `aether_longitude`, `aether_sign`, `aether_alignments`, `moon_phase`.
12
+ - Add `sunrise_sunset(zone, coords, date, depression_deg)` for Moontime temporal hours.
13
+ - Keep calibration loaders and CLI tools in a tools subpackage.
14
+ - Console scripts (staging): `aetherfield-compare`, `aetherfield-benchmark`, `aetherfield-calibrate-all`.
15
+
16
+ Local Layout (staging)
17
+ - `src/aetherfield_pkg/` — package source (to be populated)
18
+ - `pyproject.toml` — packaging config (setuptools)
19
+
20
+ Dev Tips
21
+ - Create a venv and install local deps from the project root as usual.
22
+ - In staging, the package may re-export from the root `aetherfield.py` to avoid duplication.
23
+
24
+ CLI Usage (staging)
25
+ - Compare a single timestamp: `python -m aetherfield_pkg.cli.compare --body mars --dt 2025-06-21T12:00:00Z`
26
+ - Benchmark a range: `python -m aetherfield_pkg.cli.benchmark --start 2001-01-01T00:00:00Z --end 2001-12-31T00:00:00Z`
27
+ - Calibrate all: `python -m aetherfield_pkg.cli.calibrate_all --out aetherfield_calibration.json`
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aetherfield"
7
+ version = "0.1.0"
8
+ description = "AetherField runtime ephemeris"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ authors = [{ name = "WitchMithras" }]
12
+ license = { text = "MIT" }
13
+
14
+ dependencies = [
15
+ "pytz>=2023.3",
16
+ ]
17
+
18
+ keywords = ["time", "calendar", "lunar", "astronomy"]
19
+ classifiers = [
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "License :: Other/Proprietary License",
23
+ "Operating System :: OS Independent"
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/WitchMithras/aetherfield"
28
+
29
+ [tool.setuptools]
30
+ package-dir = {"" = "src"}
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+ include = ["aetherfield_pkg*"]
35
+ exclude = ["tests*"]
36
+
37
+ [project.scripts]
38
+ aetherfield-compare = "aetherfield_pkg.cli.compare:main"
39
+ aetherfield-benchmark = "aetherfield_pkg.cli.benchmark:main"
40
+ aetherfield-calibrate-all = "aetherfield_pkg.cli.calibrate_all:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: aetherfield
3
+ Version: 0.1.0
4
+ Summary: AetherField runtime ephemeris
5
+ Author: WitchMithras
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/WitchMithras/aetherfield
8
+ Keywords: time,calendar,lunar,astronomy
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: License :: Other/Proprietary License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pytz>=2023.3
17
+ Dynamic: license-file
18
+
19
+ AeTherField Staging
20
+ ===================
21
+
22
+ This folder stages a future standalone package for AetherField — a Skyfield-free
23
+ runtime ephemeris model that uses learned calibration/piecewise drift and offers
24
+ simple APIs for signs, longitudes, alignments, phases, and (now) sunrise/sunset
25
+ estimation.
26
+
27
+ Plan
28
+ - Extract reusable runtime core from the root `aetherfield.py`.
29
+ - Preserve public APIs: `aether_longitude`, `aether_sign`, `aether_alignments`, `moon_phase`.
30
+ - Add `sunrise_sunset(zone, coords, date, depression_deg)` for Moontime temporal hours.
31
+ - Keep calibration loaders and CLI tools in a tools subpackage.
32
+ - Console scripts (staging): `aetherfield-compare`, `aetherfield-benchmark`, `aetherfield-calibrate-all`.
33
+
34
+ Local Layout (staging)
35
+ - `src/aetherfield_pkg/` — package source (to be populated)
36
+ - `pyproject.toml` — packaging config (setuptools)
37
+
38
+ Dev Tips
39
+ - Create a venv and install local deps from the project root as usual.
40
+ - In staging, the package may re-export from the root `aetherfield.py` to avoid duplication.
41
+
42
+ CLI Usage (staging)
43
+ - Compare a single timestamp: `python -m aetherfield_pkg.cli.compare --body mars --dt 2025-06-21T12:00:00Z`
44
+ - Benchmark a range: `python -m aetherfield_pkg.cli.benchmark --start 2001-01-01T00:00:00Z --end 2001-12-31T00:00:00Z`
45
+ - Calibrate all: `python -m aetherfield_pkg.cli.calibrate_all --out aetherfield_calibration.json`
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/aetherfield.egg-info/PKG-INFO
5
+ src/aetherfield.egg-info/SOURCES.txt
6
+ src/aetherfield.egg-info/dependency_links.txt
7
+ src/aetherfield.egg-info/entry_points.txt
8
+ src/aetherfield.egg-info/requires.txt
9
+ src/aetherfield.egg-info/top_level.txt
10
+ src/aetherfield_pkg/__init__.py
11
+ src/aetherfield_pkg/core.py
12
+ src/aetherfield_pkg/cli/benchmark.py
13
+ src/aetherfield_pkg/cli/calibrate_all.py
14
+ src/aetherfield_pkg/cli/compare.py
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ aetherfield-benchmark = aetherfield_pkg.cli.benchmark:main
3
+ aetherfield-calibrate-all = aetherfield_pkg.cli.calibrate_all:main
4
+ aetherfield-compare = aetherfield_pkg.cli.compare:main
@@ -0,0 +1 @@
1
+ pytz>=2023.3
@@ -0,0 +1 @@
1
+ aetherfield_pkg
@@ -0,0 +1,34 @@
1
+ """AetherField staging package shim.
2
+
3
+ For now, re-export selected APIs from the host project's `aetherfield.py` to
4
+ allow downstream packages to begin switching imports to `aetherfield_pkg`.
5
+
6
+ In a full extraction, we will move the implementation here and keep this API
7
+ surface stable.
8
+ """
9
+
10
+ from .core import (
11
+ aether_longitude,
12
+ aether_sign,
13
+ aether_alignments,
14
+ moon_phase,
15
+ sunrise_sunset,
16
+ AetherField,
17
+ DE421_START,
18
+ DE421_END,
19
+ ae_is_up,
20
+ summarize_is_up,
21
+ )
22
+
23
+ __all__ = [
24
+ "aether_longitude",
25
+ "aether_sign",
26
+ "aether_alignments",
27
+ "moon_phase",
28
+ "sunrise_sunset",
29
+ "AetherField",
30
+ "DE421_START",
31
+ "DE421_END",
32
+ "ae_is_up",
33
+ "summarize_is_up",
34
+ ]
@@ -0,0 +1,195 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ from dataclasses import dataclass
5
+ from datetime import datetime, timedelta
6
+ from statistics import mean, median
7
+ from typing import Dict, List, Optional, Sequence
8
+
9
+ import pytz
10
+ import aetherfield as af
11
+
12
+
13
+ UTC = pytz.utc
14
+ DE421_START = af.DE421_START
15
+ DE421_END = af.DE421_END
16
+
17
+
18
+ def parse_dt(s: str) -> datetime:
19
+ s = s.strip()
20
+ if s.endswith('Z'):
21
+ s = s[:-1]
22
+ dt = datetime.fromisoformat(s)
23
+ return dt.replace(tzinfo=UTC)
24
+ dt = datetime.fromisoformat(s)
25
+ if dt.tzinfo is None:
26
+ dt = dt.replace(tzinfo=UTC)
27
+ return dt.astimezone(UTC)
28
+
29
+
30
+ def wrap_delta_deg(a: float, b: float) -> float:
31
+ return (a - b + 540.0) % 360.0 - 180.0
32
+
33
+
34
+ def _drift_longitude(a: af.AetherField, dt: datetime, body: str, anchor_mode: str = 'nearest') -> float:
35
+ a._ensure_anchor(body) # type: ignore[attr-defined]
36
+ rate = a.rates_deg_per_day.get(body)
37
+ if rate is None:
38
+ raise KeyError(f"No drift rate for body: {body}")
39
+ dt = dt if dt.tzinfo else dt.replace(tzinfo=UTC)
40
+ dt = dt.astimezone(UTC)
41
+ if anchor_mode == 'nearest':
42
+ d_start = abs((dt - DE421_START).total_seconds())
43
+ d_end = abs((DE421_END - dt).total_seconds())
44
+ anchor_mode = 'start' if d_start < d_end else 'end'
45
+ if anchor_mode == 'start':
46
+ days = (dt - DE421_START).total_seconds() / 86400.0
47
+ return (a.anchors_min[body] + rate * days) % 360.0 # type: ignore[attr-defined]
48
+ else:
49
+ days = (dt - DE421_END).total_seconds() / 86400.0
50
+ return (a.anchors_max[body] + rate * days) % 360.0 # type: ignore[attr-defined]
51
+
52
+
53
+ def skyfield_longitudes(ts: Sequence[datetime], body: str) -> List[float]:
54
+ from skyfield.api import load
55
+ from skyfield.framelib import ecliptic_frame
56
+
57
+ eph = load('de421.bsp')
58
+ earth = eph['earth']
59
+ key = af._body_key(eph, body) # type: ignore[attr-defined]
60
+ tscale = load.timescale()
61
+ out: List[float] = []
62
+ for dt in ts:
63
+ t = tscale.from_datetime(dt.astimezone(UTC))
64
+ app = earth.at(t).observe(key).apparent()
65
+ lon, lat, dist = app.frame_latlon(ecliptic_frame)
66
+ out.append(float(lon.degrees) % 360.0)
67
+ return out
68
+
69
+
70
+ @dataclass
71
+ class BodyStats:
72
+ n: int
73
+ mae_mean: float
74
+ mae_piece: float
75
+ med_mean: float
76
+ med_piece: float
77
+ max_mean: float
78
+ max_piece: float
79
+
80
+
81
+ def benchmark(
82
+ bodies: Sequence[str],
83
+ start: datetime,
84
+ end: datetime,
85
+ step_days: int,
86
+ piecewise_step: int,
87
+ build_piecewise: bool,
88
+ fit_rates: bool,
89
+ drift_anchor: str,
90
+ load_cal: Optional[str],
91
+ save_cal: Optional[str],
92
+ ) -> Dict[str, BodyStats]:
93
+ r0 = max(start, DE421_START)
94
+ r1 = min(end, DE421_END)
95
+ if r1 < r0:
96
+ return {}
97
+ tlist: List[datetime] = []
98
+ step_days = max(1, int(step_days))
99
+ t = r0
100
+ while t <= r1:
101
+ tlist.append(t)
102
+ t = t + timedelta(days=step_days)
103
+
104
+ if load_cal:
105
+ a = af.AetherField.load_calibration(load_cal)
106
+ else:
107
+ a = af.AetherField()
108
+ if fit_rates:
109
+ try:
110
+ a.fit_rates()
111
+ except Exception:
112
+ pass
113
+ if build_piecewise:
114
+ try:
115
+ a.fit_piecewise(step_days=piecewise_step, bodies=tuple(bodies))
116
+ except Exception:
117
+ pass
118
+ if save_cal:
119
+ try:
120
+ a.save_calibration(save_cal)
121
+ except Exception:
122
+ pass
123
+
124
+ results: Dict[str, BodyStats] = {}
125
+ for body in bodies:
126
+ sky = skyfield_longitudes(tlist, body)
127
+ mean_preds = [_drift_longitude(a, dt, body, anchor_mode=drift_anchor) for dt in tlist]
128
+ if build_piecewise and (body in getattr(a, 'piecewise', {})):
129
+ piece_preds = [a.longitude_piecewise(dt, body, anchor_mode=drift_anchor) for dt in tlist]
130
+ else:
131
+ piece_preds = [a.longitude(dt, body) for dt in tlist]
132
+
133
+ mean_err = [abs(wrap_delta_deg(p, s)) for p, s in zip(mean_preds, sky)]
134
+ piece_err = [abs(wrap_delta_deg(p, s)) for p, s in zip(piece_preds, sky)]
135
+
136
+ stats = BodyStats(
137
+ n=len(sky),
138
+ mae_mean=mean(mean_err) if mean_err else float('nan'),
139
+ mae_piece=mean(piece_err) if piece_err else float('nan'),
140
+ med_mean=median(mean_err) if mean_err else float('nan'),
141
+ med_piece=median(piece_err) if piece_err else float('nan'),
142
+ max_mean=max(mean_err) if mean_err else float('nan'),
143
+ max_piece=max(piece_err) if piece_err else float('nan'),
144
+ )
145
+ results[body] = stats
146
+
147
+ return results
148
+
149
+
150
+ def main(argv=None) -> int:
151
+ parser = argparse.ArgumentParser(description="Benchmark AetherField mean drift vs piecewise against Skyfield/de421.")
152
+ parser.add_argument('--bodies', default='sun,moon,mercury,venus,mars,jupiter,saturn,uranus,neptune,pluto', help='Comma-separated list of bodies to evaluate.')
153
+ parser.add_argument('--start', required=True, help='Start datetime ISO8601 (e.g., 2001-01-01T00:00:00Z).')
154
+ parser.add_argument('--end', required=True, help='End datetime ISO8601 (inclusive).')
155
+ parser.add_argument('--step-days', type=int, default=5, help='Sampling step in days.')
156
+ parser.add_argument('--drift-anchor', choices=['start', 'end', 'nearest'], default='nearest', help='Anchor used for mean-drift and extrapolation.')
157
+ parser.add_argument('--piecewise', action='store_true', help='Build and use piecewise segments for evaluation.')
158
+ parser.add_argument('--piecewise-step', type=int, default=10, help='Step in days for fitting piecewise segments.')
159
+ parser.add_argument('--fit-rates', action='store_true', help='Fit mean drift rates from in-range samples before benchmarking.')
160
+ parser.add_argument('--load-calibration', default=None, help='Path to load saved calibration (rates/anchors/piecewise).')
161
+ parser.add_argument('--save-calibration', default=None, help='Path to save calibration after building.')
162
+ parser.add_argument('--json', action='store_true', help='Emit JSON summary instead of text table.')
163
+
164
+ args = parser.parse_args(argv)
165
+ bodies = [b.strip().lower() for b in args.bodies.split(',') if b.strip()]
166
+
167
+ start = parse_dt(args.start)
168
+ end = parse_dt(args.end)
169
+ stats = benchmark(
170
+ bodies=bodies,
171
+ start=start,
172
+ end=end,
173
+ step_days=args.step_days,
174
+ piecewise_step=args.piecewise_step,
175
+ build_piecewise=args.piecewise,
176
+ fit_rates=args.fit_rates,
177
+ drift_anchor=args.drift_anchor,
178
+ load_cal=args.load_calibration,
179
+ save_cal=args.save_calibration,
180
+ )
181
+
182
+ if args.json:
183
+ import json
184
+ print(json.dumps({k: vars(v) for k, v in stats.items()}, indent=2))
185
+ else:
186
+ for b, st in stats.items():
187
+ print(f"{b:9s} N={st.n:4d} MAE(mean)={st.mae_mean:6.3f}° MAE(piece)={st.mae_piece:6.3f}° "
188
+ f"MED(mean)={st.med_mean:6.3f}° MED(piece)={st.med_piece:6.3f}° "
189
+ f"MAX(mean)={st.max_mean:6.3f}° MAX(piece)={st.max_piece:6.3f}°")
190
+ return 0
191
+
192
+
193
+ if __name__ == '__main__':
194
+ raise SystemExit(main())
195
+
@@ -0,0 +1,61 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+
5
+ import aetherfield as af
6
+
7
+
8
+ DEFAULT_OUT = 'aetherfield_calibration.json'
9
+
10
+
11
+ def main(argv=None) -> int:
12
+ parser = argparse.ArgumentParser(description='Calibrate AetherField and save piecewise segments for all bodies.')
13
+ parser.add_argument('--out', default=DEFAULT_OUT, help='Output JSON path for calibration data.')
14
+ args = parser.parse_args(argv)
15
+
16
+ a = af.AetherField()
17
+
18
+ bodies_all = ('sun','moon','mercury','venus','mars','jupiter','saturn','uranus','neptune','pluto')
19
+ # Ensure anchors
20
+ for b in bodies_all:
21
+ a._ensure_anchor(b) # type: ignore[attr-defined]
22
+
23
+ # Fit mean drift from in-range samples (coarse global refinement)
24
+ try:
25
+ a.fit_rates()
26
+ except Exception:
27
+ pass
28
+
29
+ # Piecewise segments with tuned steps per group
30
+ groups = [
31
+ (('moon',), 1),
32
+ (('sun','mercury','venus'), 5),
33
+ (('mars',), 10),
34
+ (('jupiter','saturn'), 15),
35
+ (('uranus','neptune','pluto'), 30),
36
+ ]
37
+
38
+ summary = {}
39
+ for bodies, step in groups:
40
+ try:
41
+ created = a.fit_piecewise(step_days=step, bodies=bodies)
42
+ summary.update(created)
43
+ except Exception:
44
+ for b in bodies:
45
+ summary[b] = summary.get(b, 0)
46
+
47
+ # Persist
48
+ a.save_calibration(args.out)
49
+
50
+ # Print a compact summary
51
+ print(f"Saved calibration -> {args.out}")
52
+ for b in bodies_all:
53
+ n = summary.get(b, 0)
54
+ print(f" {b:9s} segments: {n}")
55
+
56
+ return 0
57
+
58
+
59
+ if __name__ == '__main__':
60
+ raise SystemExit(main())
61
+