seasons function

Map<Season, double> seasons(
  1. Ephemeris ephemeris,
  2. int year
)

The equinoxes and solstices of year (calendar year as in julianDay), as Julian days in Terrestrial Time: the moments when the apparent geocentric longitude of the Sun is 0°, 90°, 180° and 270°.

Implementation

Map<Season, double> seasons(Ephemeris ephemeris, int year) {
  final start = julianDayTT(julianDay(year, 1, 1));
  final end = julianDayTT(julianDay(year + 1, 1, 1));
  return {
    for (final c in longitudeCrossings(
      bodyLongitude(ephemeris, Naif.sun),
      start,
      end,
      period: 90,
      step: 5,
    ))
      Season.values[(c.longitude / 90).round() % 4]: c.jdTT,
  };
}