Looking ofr dusks/dawns along a year : TargetNeverUpWarning lead to crash
- Dominant language
- Python
- Stars
- 225
- Forks
- 121
- Avg merge
- 28m
- Merged PRs (30d)
- 1
Description
Hello,
Astroplan v0.8
I am making the list of dusks and dawns along the year 2021 with the code below.
It returns `Nan ` (and crashes because of year -4713) on June the 14th because of a too-short night it seems, which is likely to happen every year :-)
I realize this can happen at Pole, i.e. a day without night, but the search within 24 hours is a strange limitation (although it is mentioned in the doc).
I guess that I have to check that dusk or dawn is not Nan and rewind to continue, but that's a bit tricky...
Any known workaround to suggest?
Thanks !!!
```
from astropy.time import Time
import astropy.units as u
from astropy.coordinates import EarthLocation
from astroplan import Observer
```
```
twindow = [Time("2021-06-01 00:00:00.0",scale="utc"),
Time("2021-12-31 23:59:59.0",scale="utc")]
tstart = twindow[0]
tstop = twindow[1]
location = EarthLocation.of_address("Paris")
obs = Observer(location = location, name = location, timezone ="utc")
night = obs.is_night(tstart, horizon = -18*u.deg)
if (night): search = "previous" # Will search start of that night
else: search = "next" # Will search next night
t_night=[]
t_dawn = tstart # First dawwn cannot be before start
while(t_dawn < tstop):
t_dusk = obs.twilight_evening_astronomical(t_dawn, which = search)
print(" dusk :",t_dusk.datetime)
search="next"
t_dawn = obs.twilight_morning_astronomical(t_dusk, which="next")
print(" dawn :",t_dawn.datetime)
t_night.append([t_dusk, t_dawn])
```
Here is the sequence:
```
dusk : 2021-06-12 23:35:46.674107
dawn : 2021-06-13 00:07:07.888164
dusk : 2021-06-13 23:42:10.162592
dawn : 2021-06-14 00:02:01.176933
WARNING: TargetNeverUpWarning: Target with index 0 does not cross horizon=-18.0 deg within 24 hours [astroplan.observer]
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the supplied Python reproducer and reading the Observer twilight_evening_astronomical and twilight_morning_astronomical behavior around the documented 24-hour search limit. Trace how TargetNeverUpWarning results are handled after the June 14 short night; done means the year-long dusk/dawn loop no longer crashes and handles that case consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100