Python Lab 9 - Cart1233/PHYS250 GitHub Wiki

Goal

The goal of this lab is to observe the data taken from the Mexico City earthquake im 1985 using a Fourier transform. This is to find the frequency of the waves that were sent through the soil, and compare them to other natural disasters.

Overview

We are going to model earthquakes and more importantly the 1985 earthquake in Mexico City. This is to better understand how the frequency affected the buildings in the city, with some of them being up to 16 stories! Making figures of the frequency will help to observe the impact that the earthquake had on the buildings, and how the frequencies differ between natural frequencies and those from earthquakes.

Plotting Earthquakes from 1984-1986

To model these earthquakes we read in a table a data file containing all the data we need to make our plot. With the data we were able to make a plot of latitude vs. longitude:

image This image shows each earthquake from 1984-86 around the world, with each dot being the epicenter of the earthquake. The earthquake positions seem to follow a pattern that many tend to occur in the same area since there is such a high concentration of dots in areas, and there is still a lot of blank space around them.

We then create a histogram of the magnitudes of the earthquakes using an array for the bins.

mybins=np.arange(2,9,.5)
plt.hist(equakes['mag'],bins=mybins)
plt.yscale('log')
plt.xlabel("Scale of Earthquake")
plt.ylabel("Number of Earthquakes")

This code produces the following histogram: image This histogram shows the number of earthquakes for each richter scale value. From this we can see that the Mexico City earthquake with magnitude 8 would be very uncommon as there this was the lone one.

Analyzing the Seismic Waves

To analyze the seismic wave from the Mexico City earthquake we imported data from a table and established what each column represents. We first started with plots of acceleration, velocity, and displacement vs. time Using the following code:

plt.subplot(3,1,1)
plt.plot(seismic['time' ], seismic['accel'])
plt.xlabel("Time (s)")
plt.ylabel('Acceleration (cm/s^2)')

plt.subplot(3,1,2)
plt.plot(seismic['time' ], seismic['vel'])
plt.xlabel("Time (s)")
plt.ylabel('Velocity (cm/s)')

plt.subplot(3,1,3)
plt.plot(seismic['time' ], seismic['displ'])
plt.xlabel("Time (s)")
plt.ylabel('Displacement  (cm)')

This code gave us our plots, image This shows the intensity/ change in velocity, displacement, and acceleration over time. We can observe that the amplitude dramatically increases for each between the 40-70 second mark.

We then used the same data to plot the fourier spectrum of the seismic data. To do this we have to use the fft function on our previous data, the following code shows how to.

# your code to calculate fft here
acclfourier=np.fft.rfft(seismic['accel'])
velfourier=np.fft.rfft(seismic['vel'])
dis=np.fft.rfft(seismic['displ'])
n=len(seismic['time'])
f= np.arange(int(n/2)+1)*( 1/((seismic['time'][1]-seismic['time'][0])* (n-1)))

After setting up the fourier spectrum functions you can then plot the data using the following code,

plt.subplot(3,1,1)
plt.plot(f,acclfourier)
plt.ylabel("Acceleration (m/s^2)")

plt.subplot(3,1,2)
plt.plot(f,velfourier)
plt.ylabel("Velocity (m/s)")

plt.subplot(3,1,3)
plt.plot(f,dis)
plt.ylabel("Displacement (m)")
plt.xlabel('Frequency (Hz)')

This gives you the following plots, image This plot has its frequency extended to the Nyquist frequency and condenses what our previous plot showed us.

We then made a plot to show the more dominant frequencies ny shortening the x-axis limits. image

From this graph we are able to see that the highest amplitude occurs at a frequency of .5 Hz for each of the plots, and a range of about .3-.6 Hz.

Recommending Changes in Construction Practices

Using the scaling relation between frequency and period it is easy to see that the fewer the stories the more buildings that would be okay during another earthquake like the one in Mexico City. With this being known I would likely advice to not make too many multi-storied buildings as they are more susceptible to take serious damage rather than a smaller storied building.