pg_orrery/test/expected/v012_features.out
Ryan Malloy a349f5505a Add v0.13.0: nutation, make_equatorial constructor, rise/set predictions
Integrate IAU 2000B nutation (~9 arcsec) into the solar system observation
pipeline via precess_and_nutate_j2000_to_date(). Affects all planet, star,
moon, and small body RA/Dec and az/el values. Satellite SGP4/TEME pipeline
unchanged.

Add make_equatorial(ra_hours, dec_deg, distance_km) constructor to replace
error-prone text literal casts.

Add 8 rise/set prediction functions (planet_next_rise/set, sun_next_rise/set,
moon_next_rise/set, sun_next_rise/set_refracted) using bisection algorithm
adapted from satellite pass prediction. Returns NULL for circumpolar and
polar night edge cases.

Fix DE fallback test fragility: replace exact float equality with tolerance
comparisons to handle GCC LTO inlining divergence across translation units.

132 -> 141 SQL objects. 22 -> 24 regression suites. All 24 passing.
2026-02-25 13:53:22 -07:00

134 lines
6.2 KiB
Plaintext

-- v0.12.0 feature tests: DE moon equatorial functions
-- ============================================================
-- Test 1: galilean_equatorial_de fallback matches VSOP87 variant
-- Without DE configured, DE variant should produce identical results
-- ============================================================
SELECT 'galilean_eq_de_fallback' AS test,
moon_id,
round(eq_ra(galilean_equatorial_de(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) AS de_ra,
round(eq_ra(galilean_equatorial(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) AS vsop_ra,
round(eq_ra(galilean_equatorial_de(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) =
round(eq_ra(galilean_equatorial(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) AS match
FROM generate_series(0, 3) AS moon_id
ORDER BY moon_id;
test | moon_id | de_ra | vsop_ra | match
-------------------------+---------+--------+---------+-------
galilean_eq_de_fallback | 0 | 4.1956 | 4.1956 | t
galilean_eq_de_fallback | 1 | 4.1949 | 4.1949 | t
galilean_eq_de_fallback | 2 | 4.1936 | 4.1936 | t
galilean_eq_de_fallback | 3 | 4.2056 | 4.2056 | t
(4 rows)
-- ============================================================
-- Test 2: saturn_moon_equatorial_de fallback (Titan, id=5)
-- ============================================================
SELECT 'saturn_eq_de_fallback' AS test,
round(eq_ra(saturn_moon_equatorial_de(5, '2024-06-15 12:00:00+00'))::numeric, 4) AS de_ra,
round(eq_ra(saturn_moon_equatorial(5, '2024-06-15 12:00:00+00'))::numeric, 4) AS vsop_ra,
round(eq_ra(saturn_moon_equatorial_de(5, '2024-06-15 12:00:00+00'))::numeric, 4) =
round(eq_ra(saturn_moon_equatorial(5, '2024-06-15 12:00:00+00'))::numeric, 4) AS match;
test | de_ra | vsop_ra | match
-----------------------+---------+---------+-------
saturn_eq_de_fallback | 23.3909 | 23.3909 | t
(1 row)
-- ============================================================
-- Test 3: uranus_moon_equatorial_de fallback (Titania, id=3)
-- ============================================================
SELECT 'uranus_eq_de_fallback' AS test,
round(eq_ra(uranus_moon_equatorial_de(3, '2024-06-15 12:00:00+00'))::numeric, 4) AS de_ra,
round(eq_ra(uranus_moon_equatorial(3, '2024-06-15 12:00:00+00'))::numeric, 4) AS vsop_ra,
round(eq_ra(uranus_moon_equatorial_de(3, '2024-06-15 12:00:00+00'))::numeric, 4) =
round(eq_ra(uranus_moon_equatorial(3, '2024-06-15 12:00:00+00'))::numeric, 4) AS match;
test | de_ra | vsop_ra | match
-----------------------+--------+---------+-------
uranus_eq_de_fallback | 3.5123 | 3.5123 | t
(1 row)
-- ============================================================
-- Test 4: mars_moon_equatorial_de fallback (Phobos + Deimos)
-- ============================================================
SELECT 'mars_eq_de_fallback' AS test,
moon_id,
round(eq_ra(mars_moon_equatorial_de(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) AS de_ra,
round(eq_ra(mars_moon_equatorial(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) AS vsop_ra,
round(eq_ra(mars_moon_equatorial_de(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) =
round(eq_ra(mars_moon_equatorial(moon_id, '2024-06-15 12:00:00+00'))::numeric, 4) AS match
FROM generate_series(0, 1) AS moon_id
ORDER BY moon_id;
test | moon_id | de_ra | vsop_ra | match
---------------------+---------+--------+---------+-------
mars_eq_de_fallback | 0 | 2.1850 | 2.1850 | t
mars_eq_de_fallback | 1 | 2.1850 | 2.1850 | t
(2 rows)
-- ============================================================
-- Test 5: All DE moon equatorial return valid RA/Dec ranges
-- ============================================================
SELECT 'de_moon_eq_valid' AS test,
'galilean' AS family,
moon_id,
eq_ra(galilean_equatorial_de(moon_id, '2024-06-15 12:00:00+00')) BETWEEN 0 AND 24 AS ra_valid,
eq_dec(galilean_equatorial_de(moon_id, '2024-06-15 12:00:00+00')) BETWEEN -90 AND 90 AS dec_valid
FROM generate_series(0, 3) AS moon_id
ORDER BY moon_id;
test | family | moon_id | ra_valid | dec_valid
------------------+----------+---------+----------+-----------
de_moon_eq_valid | galilean | 0 | t | t
de_moon_eq_valid | galilean | 1 | t | t
de_moon_eq_valid | galilean | 2 | t | t
de_moon_eq_valid | galilean | 3 | t | t
(4 rows)
-- ============================================================
-- Test 6: Invalid body_id rejection for all 4 families
-- ============================================================
DO $$
BEGIN
PERFORM galilean_equatorial_de(5, '2024-06-15 12:00:00+00');
RAISE EXCEPTION 'should have failed';
EXCEPTION WHEN numeric_value_out_of_range THEN
RAISE NOTICE 'galilean_eq_de_invalid: correctly rejected';
END;
$$;
NOTICE: galilean_eq_de_invalid: correctly rejected
DO $$
BEGIN
PERFORM saturn_moon_equatorial_de(8, '2024-06-15 12:00:00+00');
RAISE EXCEPTION 'should have failed';
EXCEPTION WHEN numeric_value_out_of_range THEN
RAISE NOTICE 'saturn_eq_de_invalid: correctly rejected';
END;
$$;
NOTICE: saturn_eq_de_invalid: correctly rejected
DO $$
BEGIN
PERFORM uranus_moon_equatorial_de(5, '2024-06-15 12:00:00+00');
RAISE EXCEPTION 'should have failed';
EXCEPTION WHEN numeric_value_out_of_range THEN
RAISE NOTICE 'uranus_eq_de_invalid: correctly rejected';
END;
$$;
NOTICE: uranus_eq_de_invalid: correctly rejected
DO $$
BEGIN
PERFORM mars_moon_equatorial_de(2, '2024-06-15 12:00:00+00');
RAISE EXCEPTION 'should have failed';
EXCEPTION WHEN numeric_value_out_of_range THEN
RAISE NOTICE 'mars_eq_de_invalid: correctly rejected';
END;
$$;
NOTICE: mars_eq_de_invalid: correctly rejected
-- ============================================================
-- Test 7: Negative body_id rejection
-- ============================================================
DO $$
BEGIN
PERFORM galilean_equatorial_de(-1, '2024-06-15 12:00:00+00');
RAISE EXCEPTION 'should have failed';
EXCEPTION WHEN numeric_value_out_of_range THEN
RAISE NOTICE 'galilean_eq_de_negative: correctly rejected';
END;
$$;
NOTICE: galilean_eq_de_negative: correctly rejected