import numpy as np
import matplotlib.pyplot as plt

import astropy.units as u
from astropy.time import Time
from sbpy.dynamics import State, SynGenerator

# define the dust source
r = [2, 0, 0] * u.au
v = [0, 30, 0] * u.km / u.s
t = Time("2023-12-08")
frame = "heliocentriceclipticiau76"
comet = State(r, v, t, frame=frame)

# define particle parameters
betas = [1, 0.1, 0.01, 0]
ages = np.linspace(0, 100, 25) * u.day

# observe it from a fixed location in the Solar System
observer = State(
    r=[0, 2, 2] * u.au,
    v=[0, 0, 0] * u.km / u.s,
    t=comet.t,
    frame="icrs",
)

# define the dust generator
dust = SynGenerator(comet, betas, ages, observer=observer)

# plot syndynes
fig, ax = plt.subplots()

ls = ["-", "--", "-."]
syndynes = dust.syndynes()
for i in range(3):
   syndynes[i].plot(ax, color="k", ls=ls[i])
   ax.invert_xaxis()

ax.set(
   xlim=[100, -10],
   ylim=[-10, 100],
   xlabel="$\\Delta$RA (arcsec)",
   ylabel="$\\Delta$Dec (arcsec)",
)
fig.tight_layout()