Created
November 12, 2025 08:30
-
-
Save thoughtfulbloke/497968677f417365f00acd1b622964dc to your computer and use it in GitHub Desktop.
Night at 2025-11-12 21:25 NZDT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(dplyr) | |
| library(geosphere) | |
| library(suncalc) | |
| library(lubridate) | |
| library(mapdata) | |
| source("~/theme.R") | |
| #21:25 locally is UTC 2025-11-11 08:25:00 at this time of year | |
| # -47.5, 166 | |
| # -34.5, 180 | |
| everywhere = expand.grid(lat = seq(from=-45.7,to=-34.5,by=.05), | |
| lon = seq(from=166,to=180,by=.05)) |> | |
| mutate(date = as.Date("2025-11-11")) | |
| nightgrid <- getSunlightTimes( | |
| data = everywhere, | |
| keep = c("nauticalDusk", "night"), | |
| tz = "UTC" | |
| ) | |
| Naut2Astro <- nightgrid |> | |
| mutate(attime = ymd_hms("2025-11-11 08:25:00"), | |
| difference = abs(as.numeric(difftime(nauticalDusk,attime, units="sec")))) |> | |
| arrange(lat,difference) |> | |
| group_by(lat) |> | |
| slice(1) |> | |
| ungroup() |> | |
| filter(difference < 10) |> | |
| select(lat,lon) |> | |
| mutate(boundry="Nautical to Astronomical Twilight") | |
| Astro2night <- nightgrid |> | |
| mutate(attime = ymd_hms("2025-11-11 08:25:00"), | |
| difference = abs(as.numeric(difftime(night,attime, units="sec")))) |> | |
| arrange(lat,difference) |> | |
| group_by(lat) |> | |
| slice(1) |> | |
| ungroup() |> | |
| filter(difference < 10) |> | |
| select(lat,lon) |> | |
| mutate(boundry="Astronomical Twilight to full night") | |
| boundries <- bind_rows(Naut2Astro, Astro2night) | |
| nzoutline <- map_data("nzHires") | |
| # this whole map is just to help align | |
| # the metservice screenshot in Inkscape | |
| ggplot() + | |
| geom_polygon(data=nzoutline, aes(x=long, y=lat, group = group), | |
| colour="yellow", fill="black", linewidth=0.2)+ | |
| geom_line(data=boundries, aes(x=lon,y=lat, linetype=boundry), | |
| colour="yellow", linewidth=2)+ | |
| scale_colour_viridis_d(begin = 0.8) + | |
| coord_quickmap(xlim=c(150,180), ylim=c(-49,-34.5)) + | |
| annotate("text", x=151,y=-34.6, colour="white", | |
| hjust=0, size=6, vjust=1, | |
| label="#30DayMapChallenge | |
| Day 12 A map from 2125. | |
| Aurora viewing status\nas at 21:25 local time | |
| Too early or too cloudy")+ | |
| annotate("text", x=151,y=-43, colour="white", | |
| hjust=0, size=4, vjust=1, | |
| label="Night boundaries calculated in R | |
| Cloud: Metservice, Aurora: SWPC 30 minute")+ | |
| theme_void(paper="black")+ | |
| theme_void(paper="black")+ | |
| theme(legend.position = c(0.2, 0.2), | |
| legend.text = element_text(colour="white")) | |
| ggsave(filename="~/Desktop/full.pdf", | |
| height=4.5, width = 8, units = "in", bg = "black") | |
| ggplot() + | |
| geom_line(data=boundries, aes(x=lon,y=lat, linetype=boundry), | |
| colour="yellow", linewidth=2)+ | |
| scale_colour_viridis_d(begin = 0.8) + | |
| coord_quickmap(xlim=c(150,180), ylim=c(-49,-34.5)) + | |
| annotate("text", x=151,y=-34.6, colour="white", | |
| hjust=0, size=6, vjust=1, | |
| label="#30DayMapChallenge | |
| Day 12 A map from 2125. | |
| Aurora viewing status\nas at 21:25 local time | |
| Too early or too cloudy")+ | |
| annotate("text", x=151,y=-43, colour="white", | |
| hjust=0, size=4, vjust=1, | |
| label="Night boundaries calculated in R | |
| Cloud: Metservice, Aurora: SWPC 30 minute")+ | |
| theme_void(paper="black")+ | |
| theme(legend.position = c(0.2, 0.2), | |
| legend.text = element_text(colour="white")) | |
| ggsave(filename="~/Desktop/lines.pdf", | |
| height=4.5, width = 8, units = "in", bg = "black") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment