astropy / astroplan

Observation planning package for astronomers – maintainer @bmorris3
https://astroplan.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
198 stars 109 forks source link

Amount of time #571

Closed HealthyPear closed 11 months ago

HealthyPear commented 11 months ago

Hello,

Is it possible to compute from this project API the amount of time a source takes to transit in the FoV given a set of constraints?

For example, I want to observe a source between 0 and 50° zenith from a location during 24h, how much (total) time do I get to observe my source?

Apologies if this is already possible or easier to do from pure astropy!

bmorris3 commented 11 months ago

You could do that like this:

from astroplan import FixedTarget, Observer
from astropy.time import Time
import astropy.units as u

# pick a target:
target = FixedTarget.from_name('Vega')

# pick the date you're observing:
time = Time('2024-06-01')

# pick your observatory:
obs = Observer.at_site("APO")

# compute the time when the target rises above altitude 0 deg and 50 deg:
rise_0deg = obs.target_rise_time(time, target, which='next', horizon=0*u.deg)
rise_50deg = obs.target_rise_time(time, target, which='next', horizon=50*u.deg)

# the difference is the elapsed time
print((rise_50deg - rise_0deg).to(u.hour))

which returns 4.7756809 hours.

For more, see the tutorials in the docs.