refraction function

double refraction(
  1. double altitude, {
  2. double pressure = 1010,
  3. double temperature = 10,
})

Atmospheric refraction in degrees for the geometric (airless) altitude altitude in degrees: Sæmundsson's formula (J. Meeus, Astronomical Algorithms, eq. 16.4, made exactly zero at the zenith), scaled for air pressure (millibars) and temperature (°C).

For yellow light and a standard atmosphere; near the horizon real refraction varies by around 0.3° from this mean value. Below −1° the value at −1° is returned (the body is not visible there anyway).

Implementation

double refraction(
  double altitude, {
  double pressure = 1010,
  double temperature = 10,
}) {
  final h = math.max(altitude, -1.0);
  final arcminutes =
      1.02 / math.tan((h + 10.3 / (h + 5.11)) * _degree) + 0.0019279;
  return arcminutes / 60 * (pressure / 1010) * (283 / (273 + temperature));
}