Looking at the magnitude of variable stars - the dataset is from here:
https://dogwood.physics.mcmaster.ca/Cepheid/URL/MW/BD-10d4669.html
The magnitude plot:
import pandas as pd
from matplotlib import pyplot as plt
from scipy import signal
import numpy as np
plt.rcParams["figure.figsize"] = (16, 9)
df = pd.read_table('BD-10d4669.p.1',
sep=' ',
engine='python',
names=['time', 'mag'])
df.plot(x='time', y='mag');
Clearly there are gaps in the timeline.
But how do I tell signal.spectrogram()
that the gaps exist? It seems to me like that function assumes the timeseries could never have any data gaps.
This is the naive spectrogram plot that does not take into account the gaps:
sig = np.array(df['mag'].tolist())
nseg = 20
f, t, Sxx = signal.spectrogram(sig, 1, nperseg=nseg, noverlap=nseg-1)
plt.pcolormesh(t, f, np.log10(Sxx), shading='auto');
I would like the timeline of the spectrogram to match at least partially the timeline of the plot.
I am aware there might be issues due to the bucket size (nperseg), and I am not sure how to handle that either.