calculation of the two signal cross spectral density

results show:

 import complete code: 

numpy as NP import matplotlib.pyplot as PLT fig (ax1, AX2) = plt.subplots (2, 1) make little extra space # a between the subplots fig.subplots_adjust (hspace=0.5) DT = 0.01 t = np.arange (0, 30, DT Fixing random state for reproducibility #) np.random.seed (19680801) nse1 = np.random.randn (len (T) white #) noise 1 nse2 = np.random.randn (len (T)) # white noise 2 r = np.exp (-t / 0.05) cnse1 = n P.convolve (nse1, R, mode='same') * DT colored noise # 1 cnse2 = np.convolve (nse2, R, mode='same') * DT colored noise 2 two # # signals with a coherent part and a random part np.sin (S1 = 0.01 * 2 * np.pi * 10 * t) + cnse1 (S2 = 0.01 * np.sin 2 * np.pi * 10 * t) cnse2 + ax1.plot (T, S1, t, S2) ax1.set_xlim (0, 5) ax1.set_xlabel ('time') ax1.set_ylabel ('s1 and s2') ax1.grid (True) cxy, f = ax2.csd (S1, S2, 256, 1. ('CSD / DT) ax2.set_ylabel (db ')) plt.show (

)

above is the article on Python+matplotlib calculation of the two signal cross spectral density examples of all of the content, we hope to help. Interested friends can continue to refer to other relevant topics of the station, if there are shortcomings, welcome the message. Thank you for the support of our friends!


This concludes the body part