Closed void4 closed 2 years ago
Hi @void4, thanks for the Issue.
You can (almost) just as easily capture warnings as you can exceptions so I don't see a strong need for this.
In [1]: from astroplan.observer import Observer
In [2]: from astroplan.exceptions import TargetAlwaysUpWarning
In [3]: from astropy.coordinates import SkyCoord, EarthLocation
In [4]: from astropy.time import Time
In [5]: import warnings
In [6]: warnings.filterwarnings('error', category=TargetAlwaysUpWarning)
In [7]: try:
...: Observer.at_site('Subaru').target_rise_time(Time.now(), SkyCoord.from_name('Polaris'))
...: except TargetAlwaysUpWarning as e:
...: print('always up!')
...:
always up!
I'm going to close the Issue but if you encounter problems feel free to open back up. Cheers!
It's not optimal (because it's a global setting), but it will suffice for now I think. It would be nice to have a separate is_target_always_up() function still
You can use a context manager to make a non global suppression:
https://docs.python.org/3/library/warnings.html#temporarily-suppressing-warnings
Thank you!
When calling target_rise_time() with a target that is always up from the observers' location, it sensibly returns no value and logs this warning:
Would it be possible to add a keyword argument to target_rise_time, e.g. throw=True that would throw TargetAlwaysUpWarning as an exception so this case can be caught and handled separately?
I didn't find a separate is_target_always_up() function on the observer class...