sync: add timing freeze and gulika fix
This commit is contained in:
+6
-3
@@ -60,13 +60,15 @@ def calculate_gulika(
|
||||
end_jd = daynight["sunset_jd_ut"] if is_day else daynight["sunrise_jd_ut"] + 1.0
|
||||
if end_jd <= start_jd:
|
||||
end_jd += 1.0
|
||||
start_year, start_month, start_day, _ = swe.revjul(start_jd + float(tz) / 24.0)
|
||||
period_weekday = datetime(int(start_year), int(start_month), int(start_day)).weekday()
|
||||
if method == "saturn_part_start":
|
||||
part_index = SATURN_PART_START[moment.weekday()][period]
|
||||
part_index = SATURN_PART_START[period_weekday][period]
|
||||
segment_fraction = part_index / 8.0
|
||||
ghatika_end = None
|
||||
elif method == "legacy_ghatika_end":
|
||||
part_index = None
|
||||
ghatika_end = GHATIKA_END[moment.weekday()][period]
|
||||
ghatika_end = GHATIKA_END[period_weekday][period]
|
||||
segment_fraction = ghatika_end / 30.0
|
||||
else:
|
||||
raise ValueError("method must be saturn_part_start or legacy_ghatika_end")
|
||||
@@ -79,7 +81,8 @@ def calculate_gulika(
|
||||
"sign_idx": int(longitude / 30) % 12,
|
||||
"degree_in_sign": round(longitude % 30, 6),
|
||||
"period": period,
|
||||
"weekday": moment.weekday(),
|
||||
"weekday": period_weekday,
|
||||
"moment_weekday": moment.weekday(),
|
||||
"method": method,
|
||||
"part_index": part_index,
|
||||
"segment_fraction": segment_fraction,
|
||||
|
||||
@@ -32,3 +32,10 @@ def test_gulika_matches_public_pyjhora_smoke_oracle() -> None:
|
||||
assert result["method"] == "saturn_part_start"
|
||||
assert result["sign_idx"] == expected["sign_index"]
|
||||
assert abs(result["degree_in_sign"] - expected["degree_in_sign"]) <= 0.5
|
||||
|
||||
|
||||
def test_gulika_night_uses_weekday_of_preceding_sunset() -> None:
|
||||
result = calculate_gulika(datetime(2023, 1, 27, 2, 30, 15), lat=23.0225, lon=72.5714, tz=5.5)
|
||||
assert result["period"] == "night"
|
||||
assert result["weekday"] == 3
|
||||
assert result["sign_idx"] == 7
|
||||
|
||||
Reference in New Issue
Block a user