Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NA returned for night with some coordinates via getSunlightTimes #13

Open
mfidino opened this issue Sep 1, 2022 · 4 comments
Open

NA returned for night with some coordinates via getSunlightTimes #13

mfidino opened this issue Sep 1, 2022 · 4 comments

Comments

@mfidino
Copy link

mfidino commented Sep 1, 2022

Using suncalc 0.5.0

Some code that recreates the issue:

suncalc::getSunlightTimes(
  date = as.Date("2018-05-24"),
  lat = 53.53043,
  lon = -113.51,
  keep = c("dusk", "night", "dawn","nightEnd"),
  tz = "US/Mountain"
)

which returns

        date      lat     lon                dusk night                dawn nightEnd
1 2018-05-24 53.53043 -113.51 2018-05-24 22:30:49  <NA> 2018-05-24 04:33:53     <NA>

Working through the time calculations it looks as if it is tied to the .hourAngle() function. Essentially, the value that gets evaluated within acos() is < -1 and therefore returns NA. Warnings are suppressed here and does not return any type of recognition to the user that this is something that there is trouble to calculate.

@VirginiaMorera
Copy link

I have found the same issue, only for calculating the night and endNight variables. Attached 100 observations sampled from the data that were causing problems. In the same dataset, with observations in similar dates and locations, the night and endNight times can be calculated, and no error or warning is produced, so I can't see what the problem is!

example_suncalc.csv

@natpac
Copy link

natpac commented Feb 9, 2024

Hey,
Any news on this issue?

@Sofya2024
Copy link

Yeah I have encountered the same issue but only for night and nightEnd values at specific dates irrespective of the location points I use. the dates range from 25/05/2023 to 22/07/2023. I don't have this issue for later dates or for other time calculations like nauticalDawn. I would have hoped someone has found a solution by now

@natpac
Copy link

natpac commented Mar 29, 2024

Up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants