import numpy as np
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
from astropy.time import Time
import astropy.units as u
from saltshaker import get_track_length

# Define your target and the night of interest
target = SkyCoord.from_name('Sirius')
obs_date = '2026-01-15'
start_time = Time(f"{obs_date} 12:00:00")

# Sample the tracking zone over 24 hours
times = start_time + np.linspace(0, 24, 1000) * u.hour
track_lengths = [get_track_length(target, t).to(u.second).value for t in times]

plt.figure(figsize=(10, 5))
plt.fill_between(times.plot_date, track_lengths, color='red', alpha=0.1)
plt.plot(times.plot_date, track_lengths, color='red', lw=2)

# Reference line for an intended 30-minute exposure
plt.axhline(1800, color='black', linestyle='--', label='Intended 30 min Exposure')

plt.title(f"Estimated Tracking Time for {target.name}")
plt.ylabel("Available Track Length (seconds)")
plt.xlabel("Time (UTC)")
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()