BHoM / LadybugTools_Toolkit

GNU Lesser General Public License v3.0
2 stars 2 forks source link

Running `hours_sunrise_sunset` plot fails on locations where the sun doesn't set #236

Open Tom-Kingstone opened 1 month ago

Tom-Kingstone commented 1 month ago

Description:

When running hours_sunrise_sunset on a location where any of the sunset times cannot be retrieved, the plot fails and doesn not output anything (due to a.normalize() not working when sunset/sunrise times are null).

Steps to reproduce:

Run hours_sunrise_sunset on a location where the sun does not set (this includes twilight zones), e.g. Aberdeen.

Expected behaviour:

A plot that shows the hours sunrise sunset where in the middle, the block spans the height of the plot.

Test file(s):

using a suitable location

hours_sunrise_sunset(location=location)

Additional Comments

This also appears to affect hours_sunlight as well, but doesn't show errors and plots the following: sun_up_hours

Tom-Kingstone commented 1 month ago

doing a bit of digging, the cause seems to stem from sunrise_sunset outputting a df where the start and end times are set to NaT image Likely the solution to this would be when the start and end times are NaT, fill in start time = current index date at 00:00, then end time = current index data + 1 day at 00:00

Tom-Kingstone commented 1 month ago

Above solution has its limits - for a location within the arctic circle, there are days where there is no sun, so this case needs to be handled as well. Currently produces produces errors for hours_sunrise_sunset and plots for hours_sunlight that look like this for files within the arctic circle: sun_up_hours

tg359 commented 1 month ago

This is my favourite issue. I've been waiting to see if anyone ever tries to put an EPW/Location through it from the arctic circle! When I originally coded it up I did think about handling it, but thought it would be unlikely to ever happen ... and then started thinking about whether it could be expanded to include sunrise/set time on other planets, which then led to non-24-hour time systems and how on earth (pun intended) to geo(is geo even appropriate?)-locate positions on other planets too.

I then got distracted by other stuff, but thank-you for reminding me about this one 😄

tg359 commented 1 month ago

Also, would there be such a thing as nautical twilight on a planet without liquid water?