Astro-Sunrise

 view release on metacpan or  search on metacpan

doc/astronomical-notes.pod  view on Meta::CPAN

This text is an integral part of the module's distribution package.
So you can read it on web pages generated from CPAN
(for example L<https://metacpan.org>).
But it is not used during the module installation process.
So, I guess it will not appear in C<.deb> or C<.rpm> packages.

Although this text  is stored in the  L<Astro::Sunrise> repository, it
also  documents the  L<DateTime::Event::Sunrise> module,  which has  a
very  similar core  (astronomical computations)  and a  different API.
Since both  modules move at different  speeds, it may happen  that the
text you  are reading is  not synchronised with  the L<Astro::Sunrise>
module.

=head1 Why This Text? For Whom?

The main purpose of this text is to explain how the sunrises
and sunsets are computed. These explanations are much too long
to be included into the module's POD section.

=head2 For Whom? For My Teddy Bear

doc/astronomical-notes.pod  view on Meta::CPAN

everybody knows that the day lasts 24 hours (the mean
solar day, not the sidereal day). Yet, as I have read it
somewhere, in paleontological times, it used to last
22 hours or so.

The variation of the duration of the day is a tiny
variation, but with our modern measure instruments, we
can measure it. Since the time when scientists abolished the
astronomical standard of time for an atomic
standard, it has been necessary to add 27 leap seconds
over 47 years to synchronise the atomic timescale with
the Earth's spin.

For the moment, all adjustments have consisted in
adding a leap second. But it can happen that we
would have to synchronise in the other direction by removing
a second. So this phenomenon produces fluctuations
rather than a slow drift in a single direction.

=head3 The Equation Of Time

There are other fluctuations, easier to measure and with a more
"meteorological" and less "climatic" timescale. The I<true> solar noon
does not occur on the same precise time as the I<mean> solar noon.
There are two reasons.

doc/astronomical-notes.pod  view on Meta::CPAN


In the following, it is useful to imagine a virtual Sun which would use an constant
angular speed (either in equatorial coordinates or ecliptic coordinates, depending on
which is more convenient).

The concept of I<Mean Sun> is a virtual Sun like this, calibrated so it crosses
the meridian at 12:00 (Local Mean Time) each day, and which minimizes the difference
between the real local noon and the mean local noon. 

I will also consider several "virtual homocinetic suns" or VHS (no relation with
magnetic tapes). These virtal suns are synchronised with the real Sun at some 
convenient point and then move with a constant angular speed.

=head1 Computing Sunrise and Sunset

Computing sunrise and sunset consists in taking in account both the variation of
day's length and the equation of time to pinpoint when the Sun reaches the
altitude that corresponds to sunrise or sunset.

In the schema below, the variation of day's length results in a bobbing up and
down of the sinusoidal curve (and less obviously, a vertical stretch or compression 

doc/astronomical-notes.pod  view on Meta::CPAN

speed. In the end, it is better than the basic algorithm, which uses an approximate
but still wrong orbital speed, but for the whole span of 3 h, 59 mn and 57 s.

=head2 What Happened in Spring 2020?

Let us look a bit farther into  the past. In January 2019, I published
version  0.98   of  L<Astro::Sunrise>,  with  the   precise  algorithm
implemented as explained in the  preceding paragraph. For test data, I
did not know how to cross-check  with authoritative sources, so I just
checked  they  looked plausible  and  that  the iterative  computation
stopped after  a few iterations. At  this time, I did  not synchronise
L<DateTime::Event::Sunrise> with L<Astro::Sunrise>, because it was not
the proper time yet.

Then in  April 2020, a user  created an RT ticket,  explaining that he
had   compared  the   results   of  L<DateTime::Event::Sunrise>   with
authoritative websites and  that the results were  not precise enough.
Of course  the results were  not precise,  I had not  yet synchronised
L<DateTime::Event::Sunrise>  with L<Astro::Sunrise>.  Yet this  ticket
gave  me two  things: first,  a  website which  would provide  precise
day-after-day computations of sunrise, sunset and real solar noon, and
second a few round tuits to upgrade L<DateTime::Event::Sunrise> to the
same level as L<Astro::Sunrise>, with real tests values.

There   was   a   glitch.    The   precise   algorithm   copied   from
L<Astro::Sunrise> and  the test  data from the  NOAA website  were not
matching. After  tweaking the algorithm  and asking for advice  on the
DateTime mailing-list

doc/notes-astronomiques.pod  view on Meta::CPAN

temps « plutôt météorologique »). Mais elles varient sur un intervalle de
temps nettement plus long (ou un intervalle « plutôt climatique »).
Par exemple, il est acquis que le jour dure 24 h (le jour solaire moyen, pas le jour
sidéral). J'ai lu quelque part qu'aux temps paléontologiques, le jour durait
22 heures environ.

La variation est lente, mais avec nos moyens modernes, il est possible de la mesurer.
Depuis que les scientifiques ont adopté un étalon atomique pour le temps, abandonnant
l'étalon astronomique, il a été nécessaire d'ajouter 
27 L<secondes intercalaires|http://michel.lalos.free.fr/cadrans_solaires/doc_cadrans/seconde_intercalaire/seconde_intercalaire.html>
en 47 ans pour resynchroniser l'échelle de temps atomique avec
l'échelle de temps astronomique.

Pour l'instant, les interventions pour cette resynchronisation ont toujours consisté
à ajouter une seconde intercalaire. Mais la possibilité théorique existe de synchroniser
dans l'autre sens, en supprimant une seconde. Le phénomène peut donc, semble-t-il, se manifester
par des fluctuations au lieu d'une dérive toujours dans le même sens.

=head3 Équation du temps

Il existe d'autres fluctuations, qui sont plus faciles à mesurer et qui se déroulent
sur une échelle plus S<« météorologique »> et moins S<« climatique »>.
Le midi solaire I<vrai> ne correspond pas avec le midi solaire I<moyen>.
Il y a deux raisons pour cela.

doc/notes-astronomiques.pod  view on Meta::CPAN


Dans la suite de la discussion, il est utile d'imaginer un soleil dont la vitesse
angulaire serait constante (soit en coordonnées équatoriales, soit en coordonnées
écliptiques, selon le cas).

On parle ainsi du S<« Soleil> S<moyen »>, qui est censé passer au méridien à 12:00
pile lorsque l'on utilise le S<« temps> solaire S<moyen »> et qui minimise l'écart
tout au long de l'année entre le midi solaire moyen et le midi solaire vrai.

Je prendrai en considération également des soleils virtuels homocinétiques, ou SVH. Ces
soleils virtuels sont synchronisés avec le Soleil réel à un instant donné et
ensuite bougent avec une vitesse angulaire constante.

=head1 Calcul du lever et du coucher du Soleil

Le calcul du lever et du coucher du Soleil consiste à tenir compte à
la fois de la variation de la longueur de la journée et de
l'équation du temps pour savoir quand le Soleil atteint 
la hauteur qui correspond au lever ou au coucher du Soleil.

Dans le schéma ci-dessous, la variation de la longueur de la



( run in 0.300 second using v1.01-cache-2.11-cpan-0d8aa00de5b )