Sinusoidal Sunlight

(leancrew.com)

100 points | by surprisetalk 8 months ago ago

38 comments

  • froggerexpert 8 months ago

    The sunlight plot is interesting.

    Since Dec wraps around to Jan, you can fold the left and right to make a tube.

    Since 23:59 wraps to 00:00 you can fold the top and bottom of the tube, making a torus (a donut).

    For a fixed lat/long, each point on the torus corresponds to the sunlight observed at a particular time throughout the year. Why bother with a torus? The shape itself embeds the continuity of time across days/years that is otherwise left implicit in the typical 2D plot.

    I've wanted to plot this in 3D or have it printed on a ring, but never got round to it.

    Any one seen anyone do this?

    • jagged-chisel 8 months ago

      So a toroidal illustration of our trip around the sun with the “amount of sunlight” graph along it … someplace.

      Sounds neat!

    • Centigonal 8 months ago

      You got me curious, so I gave it a try with the graphic in the article!

      https://www.loom.com/share/5665143f2d274bd0bf65ef378fad39a3

      There's two toruses in the clip, one with the daylight on the inside, one with the daylight on the outside.

      One thought I had while making this is that you could visualize multiple years, or even someone's whole life, as a string winding a long spiraling path down the length of a helix.

      • froggerexpert 8 months ago

        Very cool. What program is that?

        It'd also be nice if the colour was not just day/night, but the actual predicted daylight at the time of day, which would result in a continuously changing colour.

        I guess at that point, the sine approximation from OP would no longer apply, and https://en.m.wikipedia.org/wiki/Sunrise_equation would have to be used.

        • Centigonal 8 months ago

          It's Blender! Great OSS project.

    • 8 months ago
      [deleted]
    • jpm_sd 8 months ago
  • searke 8 months ago

    You might want to use Fourier analysis instead. I did this project but with temperature :

    https://searke.github.io/2017/01/08/TemperatureGraph.html

    Also, coincidentally enough, for Chicago using Wolfram Language. Great minds think alike I guess.

    • phkahler 8 months ago

      >> You might want to use Fourier analysis instead.

      Yep. There error plot clearly shows a 3rd harmonic dominating. IIRC the length of day is constant at the equator and the light/time function is a distorted sinewave as you go north or south from there. I am curious about the slope within a day. It seem to "get dark quickly" these day vs July.

    • url00 8 months ago

      What a great title! Sending warmth to you this winter from Wisconsin.

      • 8 months ago
        [deleted]
  • crackalamoo 8 months ago

    I wonder if this discrepancy can be explained by the equation of time? https://en.wikipedia.org/wiki/Equation_of_time

  • hprotagonist 8 months ago

    The analemma graph shape happens because you're adding sinusoids: https://en.wikipedia.org/wiki/Equation_of_time

    See also, https://www.gaisma.com/en/ for some really good interactive sunlight graphs.

  • SideQuark 8 months ago

    > how close to a sine wave is the Daylight line?

    It's as close as the Earth's orbit is to a perfect circle and that the shapes of the earth and sun are to perfect spheres and as the axis of the earth has no wobble and no precession and the sun's rays are truly parallel and and there is no drag in space sapping energy from the dynamics and general relativity effects are sent to zero and so on.

    Once everything is perfectly circular and simple and Euclidean, then it does become a perfect sinewave. Then the sinewave has period = 1 year, the amplitude is symmetric by latitude, and it's pretty easy to derive.

    All the above (and more) all intorduce measurable errors from the perfect sinewave.

    • rachofsunshine 8 months ago

      Or for those who prefer their deviations from ideal behavior in pretty curve form, the analemma [1] captures the way in which the Sun's fails to return to the same point in the sky each day:

      - The north-south component comes from the Earth's axial tilt

      - The asymmetry from north to south comes from the elliptical nature of Earth's orbit, which is closer/faster in northern winter + further/slower in northern summer.

      - The east-west movement comes from the equation of time, which is mostly a mix of the Earth's axial tilt and the eccentricity of its orbit.

      [1] https://en.wikipedia.org/wiki/Analemma

  • PaulHoule 8 months ago

    My first take is that you can represent any function like this with a sum of sinusoids as it is a periodic function and

    https://en.wikipedia.org/wiki/Fourier_analysis

    applies. Note the error looks a lot like a higher frequency sinusoid and if you added in that high frequency sinusoid the error would look like a much higher frequency sinusoid. Traditionally people who did celestial mechanics and positional astronomy would expand everything in terms of sinusoids until they got good enough accuracy.

  • antognini 8 months ago

    Last year I made an interactive plot so that you can see how much the length of a day changes over the course of the year as a function of latitude. It goes through the math of how you can make the calculation.

    You can check it out here: https://joe-antognini.github.io/astronomy/daylight

  • jmward01 8 months ago

    > You can decide for yourself whether an error like this—7 minutes out of 9 hours—makes the real data “close” to a sine wave.

    I think the most interesting part of this article is the bit at the end. What really is 'close'? We have so many 'rules of thumb' here but a real definition to target is elusive. Do you go off of pure utility? 'using this definition achieves my requirement to be corret xxx% of the time and now I make money using it' Or do you go off of something more like information content: 'when plotting the error it conforms to a normal curve...' Anyone got a good rule for 'close'?

    • abnry 8 months ago

      I don't think there will ever be an answer to this. There's a similar problem with choosing a threshold for a decision. The common thing to do is to make a RoC curve to compare the trade-off between true positive rate and false positive rate.

      If you have a system you can reason about completely, then sometimes you have a number that gives the absolute answer. Say you get error below floating point resolution.

      But I guess it's otherwise what is perceptible or meaningful, either in quantity or percentage. A penny is not a life changing amount of money and something happening 0.01% of the time is rare enough to be tolerable.

  • enriquto 8 months ago

    A difficult problem related to this: prove that, for any location in the earth, the longest night of the year is adjacent to the shortest day.

    This is infuriatingly difficult (because the lenght of a consecutive day-night pair needs not be 24 hours), and I'm beginning to think that it may not even be true.

    • jvanderbot 8 months ago

      I'll try using solar noon as a fixed duration.

      We know that the duration between solar noons is the same every day (24hrs + a little bit). So let's slice that up into day and night. Consider the two solar noons that adjoin the maximum night duration. I claim one of those two noons happens during the shortest day.

      We have

      midnight -> Sunrise -> noon -> sunset -> midnight -> sunrise -> noon -> sunset.

      We know noon .. noon is fixed at 24hrs +a bit. Same with midnight..midnight. We know that midnight..noon is about 12 hours (+ half a bit). This is just orbital mechanics.

      We know sunset..midnight..sunrise is periodic over the year, with one maximum duration.

      Therefore we know that noon..midnight..noon contains a periodic amount of dark time with one maximum. Let that time be |D|.

      Let |L| be the "light time" either the preceeding or following midnight..noon..midnight period - whichever has less light.

      Since midnight..noon..midnight..noon has 36 hrs (ish), then |D|+|L| = 36 (ish), so maximum darkness must have a minimum light time.

    • ben_w 8 months ago

      Solar day or legal day?

      The former trivially proven true, because the sum is constant.

      I bet the latter has a counter example somewhere where the summer/winter time transition means the day (or night) length changes more than the difference between then and the solstice.

      Even if not that, time zones and calendars can be changed by law, so there's been a few entirely absent days — one of my dad's stamp collection anecdotes was about post where the response was dated before the original message, and neither was incorrect, because one was Gregorian and the other Julian.

      • Sharlin 8 months ago

        The length of the solar day is not constant, for two primary reasons (non-circularity of Earth's orbit, and the obliquity of the ecliptic [1]). It varies from the length of the mean solar day by up to 30 seconds, accumulating a seasonal error of up to 15 minutes or so compared to wallclock time.

        [1] https://en.wikipedia.org/wiki/Solar_time#Apparent_solar_time

        • jvanderbot 8 months ago

          But it varies continuously on scales much smaller than seasonal changes. And seasonal changes are what affect day/night times. Without discrete jumps, you can actually consider a solar-noon to solar-noon time cycle as a day, and see that day + night must add up to a constant for any given cycle, therefore more night means less day.

          • Sharlin 8 months ago

            That's true. It offsets both sunrise and sunset the same amount.

  • amenghra 8 months ago

    “The error varies in a sort of sinusoidal fashion” and if you. Approximate the error with a sin, you’ll get another sort of sinusoïdal delta, and so on. The process is essentially a Fourier transform.

    • mturmon 8 months ago

      OP did allow the base frequency to vary when he did the fit. So if you found the first residual and then used the same varying-frequency fit, you might not get an exact harmonic of the base frequency. That would not be the Fourier transform!

      But suppose you fixed the base frequency (which wouldn't be a bad idea). You still seem to have a nonlinear fit, because the phase (the "f" in the model equation in OP) is buried inside sin(). Why are we needing a nonlinear function-fitting process when the Fourier transform is linear?

      Of course, you can bring the phase outside by adding in a cos() term with its own amplitude. Now instead of the phase "f" you have an interplay between the amplitude of the sin and cos terms, and those amplitudes are linear in the data.

      The resulting fit (or recursive sequence of fits) would indeed be the Fourier transform.

      The key property is the orthogonality of the various harmonics. That's what allows the sequence of single-frequency fits to not step on each other.

  • knappa 8 months ago

    Instead of trying to fit a sine wave this way, one can also take the Fourier transform and read off the largest value and its location.

  • dakiol 8 months ago

    A bit off-topic but I couldn't overlook that Chicago reminds me of Munich (in terms of daylight).

    I have lived in Spain (Santiago de Compostela) and I absolutely loved that in the summer time the sun sets around 10pm. Even in winter time the sun sets around 6:30pm. I have lived in Munich, and it was depressing as hell in winter because the sun sets at around 4pm.

    I also hated that in summer in Munich, the sun rised around 5am. I'm not a morning person, I never cared for how much daylight I was getting before 9am (which is more or less the time I wake up)

    • Gare 8 months ago

      Major reason sun sets so late in Spain is because they're in the "wrong" timezone.

      Daylight in Santiago is only 40 minutes longer during winter solstice. And during summer solstice Munich has longer daylight!

      • ncruces 8 months ago

        Particularly Galicia (Santiago), which should really use the Portuguese timezone.

        Or not: you cross the border and don't “fix” your watch, because mealtimes, etc, are all shifted an hour in the opposite direction.

    • themaninthedark 8 months ago

      And this is why we have daylight savings time...

    • 8 months ago
      [deleted]
  • GistNoesis 8 months ago

    I find the wikipedia article https://en.wikipedia.org/wiki/Sunrise_equation more complete as I was wondering about latitude and the fact that north poles sometimes don't even see the light for days, a sinusoid wouldn't fit.

    Now wondering how accurate a location we can get from the observation of sunrise and sunset from the formula (in the case I got stranded on a desert island :) ).

    • madcaptenor 8 months ago

      If you look at sunrise times at places just south of the Arctic Circle it's pretty obvious that day length is not exactly a sinusoid. See for example Reykjavik: https://www.timeanddate.com/sun/iceland/reykjavik

      Ignoring refraction, you have cos(omega_O) = - tan(phi) * tan(delta), where:

      - omega_0 is the hour angle at sunrise/sunset (basically the time)

      - phi is the observer's longitude

      - delta is the sun's declination, which varies over the year.

      delta is not exactly sinusoidal but that doesn't seem to be the major problem.

      The hour angle at sunrise is

      omega_O = arccos(-tan(phi) * tan(delta))

      and if delta varies sinusoidally then I think we can wave our hands and say "small angle approximation" to get an approximate sinusoid out the other end, but if tan(phi) gets large enough the approximation breaks down.

    • 8 months ago
      [deleted]