Sinusoidal Sunlight

(leancrew.com)

75 points | by surprisetalk 21 hours ago ago

25 comments

  • hprotagonist 40 minutes 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.

  • froggerexpert 7 hours 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?

  • searke 5 hours 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 3 hours 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 an hour ago

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

  • antognini an hour 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

  • crackalamoo 2 hours ago

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

  • PaulHoule 5 hours 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.

  • jmward01 4 hours 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 3 hours 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.

  • amenghra 3 hours 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 2 hours 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.

  • enriquto 6 hours 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 6 hours 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 6 hours 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 5 hours 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 an hour 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.

  • knappa 5 hours 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 2 hours 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 20 minutes 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!

  • GistNoesis 6 hours 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 5 hours 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.