Top
Best
New

Posted by surprisetalk 10/23/2024

Sinusoidal Sunlight(leancrew.com)
100 points | 33 comments
froggerexpert 10/24/2024|
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 10/24/2024||
So a toroidal illustration of our trip around the sun with the “amount of sunlight” graph along it … someplace.

Sounds neat!

froggerexpert 10/24/2024|||
Yes, exactly!
Centigonal 10/24/2024|||
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 10/24/2024||
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 10/25/2024||
It's Blender! Great OSS project.
jpm_sd 10/24/2024||
Related:

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

searke 10/24/2024||
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 10/24/2024||
>> 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 10/24/2024||
What a great title! Sending warmth to you this winter from Wisconsin.
crackalamoo 10/24/2024||
I wonder if this discrepancy can be explained by the equation of time? https://en.wikipedia.org/wiki/Equation_of_time
hprotagonist 10/24/2024||
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 10/24/2024||
> 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 10/24/2024|
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 10/24/2024||
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 10/24/2024||
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 10/24/2024||
> 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 10/24/2024|
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 10/24/2024||
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 10/24/2024||
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 10/24/2024||
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 10/24/2024||
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 10/24/2024||
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 10/24/2024||
That's true. It offsets both sunrise and sunset the same amount.
amenghra 10/24/2024|
“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 10/24/2024|
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.

More comments...