I am working on capturing seasonality of time series using periodogram plot, I want to use the top ten frequency components to create the seasonality time series, so far, I plotted the periodogram:
data=elec_price[:48*365]
from scipy.signal import periodogram
f, Pxx_den = periodogram(data)
data is a one year subset of prices with 30 minutes intervals , and captured the top ten frequency components from the fourier_coefficients list after sorting it by the amplitude
fourier_coefficients=Pxx_den.tolist()
fourier_coefficients=pd.DataFrame(fourier_coefficients,columns=['amplitude'])
top frequencies with highest amplitudes are : 365,2,730,22,52,5,729,8 , what I need to do next is to use these top frequency components to get the seasonality of time series, I generated the sinusoidal waves of each frequency component, and added them together to plot the time series, thought I am not sure if this is the right way, because I remember that there should be an imaginary part of the frequency component but I cant find it from the periodogram data, secondly I am only assuming that each of these components is a sin wave.
sin_waves=fourier_coefficients.drop(columns=['frequency coneficient','amplitude']).copy()
sin_waves[' sin_wave_1']=0
sin_waves[' sin_wave_2']=0
sin_waves[' sin_wave_3']=0
sin_waves[' sin_wave_4']=0
sin_waves[' sin_wave_5']=0
sin_waves[' sin_wave_6']=0
sin_waves[' sin_wave_7']=0
sin_waves[' sin_wave_8']=0
for i in range(8761):
sin_waves[' sin_wave_1'][i]= fourier_coefficients['amplitude'][365]*math.sin(math.pi*i*365/8761)
sin_waves[' sin_wave_2'][i]= fourier_coefficients['amplitude'][2]*math.sin(math.pi*i*2/8761)
sin_waves[' sin_wave_3'][i]= fourier_coefficients['amplitude'][730]*math.sin(math.pi*i*730/8761)
sin_waves[' sin_wave_4'][i]= fourier_coefficients['amplitude'][22]*math.sin(math.pi*i*22/8761)
sin_waves[' sin_wave_5'][i]= fourier_coefficients['amplitude'][52]*math.sin(math.pi*i*52/8761)
sin_waves[' sin_wave_6'][i]= fourier_coefficients['amplitude'][5]*math.sin(math.pi*i*5/8761)
sin_waves[' sin_wave_7'][i]= fourier_coefficients['amplitude'][729]*math.sin(math.pi*i*729/8761)
sin_waves[' sin_wave_8'][i]= fourier_coefficients['amplitude'][8]*math.sin(math.pi*i*8/8761)
sin_waves['accumulated_sin_wave']=(sin_waves[' sin_wave_1']+sin_waves[' sin_wave_2']
+ sin_waves[' sin_wave_3']+sin_waves[' sin_wave_4']+sin_waves[' sin_wave_5']+
sin_waves[' sin_wave_6']+sin_waves[' sin_wave_7']+sin_waves[' sin_wave_8'])
the 8761 is the number of samples in the data.
I then plotted sinaves['accumulated_sin_wave']
here is a plot for the seasonal components in the first year:
So, I am wondering what should I do instead of just plotting these sin waves to capture the real components of the top frequencies.