6. Python data analysis and display ------ the drawing of gravitational waves

1. Concept

Gravitational waves: In physics, gravitational waves are energy that propagates in the form of radiation due to the curvature of space-time.
Einstein predicted the existence of gravitational waves based on general relativity.

On September 14, 2015, the LIGO collaboration announced the detection of the first gravitational wave signal. On June 16, 2016, the LIGO cooperation group announced that at 03:38:53 (UTC) on December 26, 2015, two gravitational wave detectors at different locations detected a gravitational wave signal at the same time.


import numpy as np
 import matplotlib.pyplot as plt
 from scipy.io import wavfile #Read
 time -related data from the configuration file
 rate_h , hstrain =wavfile.read( r'H1_Strain.wav' , 'rb' )
rate_l,lstrain=wavfile.read(r'L1_Strain.wav','rb')
reftime,ref_H1=np.genfromtxt('wf_template.txt').transpose()

#Read strain data
 htime_interval = 1 /rate_h
ltime_interval =1/rate_l
htime_len =hstrain.shape[0]/rate_h
htime = np.arange (-htime_len / 2 , htime_len / 2 , htime_interval)
ltime_len=lstrain.shape[0]/rate_l
ltime = np.arange (-ltime_len / 2 , ltime_len / 2 , ltime_interval)

#plot using the data from the "H1" detector
 #create a plot space of
 size 12*6 fig=plt.figure( figsize =( 12 , 6 ))
 #plot with time as X axis and strain data as Y Image of axes and set title and axis labels
 plth =fig.add_subplot( 221 )
plth.plot(htime,hstrain,'y')
plth.set_xlabel('Time (seconds)')
plth.set_ylabel('H1 Strain')
plth.set_title('H1 Strain')

pltl =fig.add_subplot(222)
pltl.plot(ltime,lstrain,'g')
pltl.set_xlabel('Time (seconds)')
pltl.set_ylabel('L1 Strain')
pltl.set_title('L1 Strain')

pltl =fig.add_subplot(222)
pltl.plot(ltime,lstrain,'g')
pltl.set_xlabel('Time (seconds)')
pltl.set_ylabel('H1 Strain')
pltl.set_title('H1 Strain')

pltlref =fig.add_subplot(212)
pltlref.plot(reftime,ref_H1)
pltlref.set_xlabel('Time (seconds)')
pltlref.set_ylabel('Template Strain')
pltlref.set_title( 'Template' )
 #Automatically adjust the outer edge of the image
 fig.tight_layout() #Save
 the image in PNG format
 plt.savefig( "Gravitational_Waves_Original.png" )
plt.show()
plt.close(fig)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325567322&siteId=291194637