SSM-JTK – Data & Calibration — Pre-processing (2.3)

What to do before fitting or scoring (always-on pipeline)

1) Siderealization (if your source is tropical)
Convert tropical longitudes to Lahiri sidereal before any modeling.
lon_sidereal_lahiri_deg = wrap360( lon_tropical_deg - ayanamsa_deg )
ayanamsa_deg = A0_deg + rate_deg_per_year * years_since_2000
A0_deg = 23.857625
rate_deg_per_year = 50.290966 / 3600
years_since_2000 = ( JD(date) - JD(2000-01-01) ) / 365.2425
wrap360(x) = ((x % 360) + 360) % 360
(Any equivalent wrap360 is acceptable; the modulo-safe form above is easy to implement.)

2) Unwrapping for fits/events (build a continuous series y)
Let L_sid[i] be the daily sidereal angles in degrees. Create an unwrapped series y[i] by adding or subtracting full turns so neighbors stay continuous.
y[0] = L_sid[0]
For i > 0, choose integer k minimizing | (L_sid[i] + 360*k) - y[i-1] |, then set
y[i] = L_sid[i] + 360*k.
Use y (unwrapped) for OLS regression and event detection; reserve wrap360 for final display only.

3) Derivatives (central differences; Δt in days)
Compute smooth speed/curvature from the unwrapped series for event logic and auxiliary losses.
v[i] ≈ ( y[i+1] - y[i-1] ) / (2*Δt) (deg/day)
a2[i] ≈ ( y[i+1] - 2*y[i] + y[i-1] ) / (Δt^2)
(Use one-sided differences at endpoints; keep Δt = 1 for daily grids.)

Navigation
Back: SSM-JTK – Data & Calibration — Sources + Time & frame (2.1 + 2.2)
Next: SSM-JTK – Data & Calibration — Sampling modes (2.4)