I would like to create Gaussians with random amplitude and variance, as a function of time. I would like to use a day as a time frame, but it gives me an error.
TypeError: 'Timedelta' object is not iterable
Could you help me please.
from astropy import modeling
import random
import numpy as np
import matplotlib.pyplot as plt
t =pd.to_timedelta(np.arange(3600),unit='s')
x=random.randrange(15)
for i in range(x):
y=random.uniform(-10, 10)
z=random.randrange(5)
p=random.choice(t)
m = modeling.models.Gaussian1D(amplitude=y, mean=p, stddev=z)
data = m(t)
plt.plot(t, data)
plt.xlabel('time')
plt.show()
Aucun commentaire:
Enregistrer un commentaire