#TODO: compute the distance from mainshock to each event using: seis_utils.haversine (or a basemap equal-distance projection) aR = seis_utils.haversine(mData[7][MS_ID], mData[6][MS_ID], mData[7], mData[6]) #TODO: select events within rmax, i.e. dPar['rmax'] selR = dPar['rmax'] >= aR print('maximum radius', dPar['rmax'], 'N events within r_max: ', selR.sum(), 'N events outside of Rmax', (1 - selR).sum()) mData = mData.T[selR].T #B# update mainshock ID for smaller data-set MS_ID = np.arange(mData[0].shape[0])[mData[9] == dPar['MSmag']][0] #C# TODO: create time vector in units of days at_days = mData[0] * 365.25 + mData[1] * (365.25 / 12) + mData[ 2] + mData[3] / 24 + mData[4] / (60 * 24) + mData[5] / (60 * 24 * 60) #D# TODO: temporal decay rates, dN/dt see eq. page 3 of the assignment at_bin, aN_bin = seis_utils.eqRate(at_days, dPar['k']) if dPar['testPlot'] == True: # it is a good idea to create a test plot here for debugging purposes # if everything is done correctly you should see the events before the M5.7 Prague earthquake in balck # and all aftershocks in red # this plot is for debugging purposes and does not have to be handed in plt.figure() ax = plt.subplot(111) ax.semilogy(at_bin / 365.25, aN_bin, 'ko', label='all events') at_bin_tmp, aN_bin_tmp = seis_utils.eqRate(at_days[MS_ID::], dPar['k']) ax.semilogy(at_bin_tmp / 365.25, aN_bin_tmp, 'ro', mec='r', mew=1.5,
#------------------------------------------------------------------------ # load seismicity and well data using loadtxt mSeis = np.loadtxt(file_eq).T aTime = seis_utils.dateTime2decYr(mSeis[1], mSeis[2], mSeis[3], mSeis[4], mSeis[5], mSeis[6]) mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt(file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot(211) at_den, a_rate = seis_utils.eqRate(aTime, dPar['k']) ax.plot(at_den, a_rate / 12, 'b-', lw=2, alpha=.5) ax.set_ylabel('Earthquake Rate [ev/mo]') ax2 = plt.subplot(212) ax2.plot(sorted(mSeis[0]), np.cumsum(np.ones(mSeis[0].shape[0])), 'r--') ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax.get_xlim()) plt.show() #--------------------------3--------------------------------------------- # map view of well and event locations #------------------------------------------------------------------------ # create time vector with dt_map spacing at_bin = np.arange(dPar['tmin'], 2018, dPar['dt_map']) for i in range(at_bin.shape[0] - 1):
aWell = mWells[1] x = sorted(mWells[1]) t0 = aWell[0] at = mSeis[0] #at -= t0 aV = np.array([]) aV = mWells[4] if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot(211) # compute seismicity rates using seis_utils.eqRate aBin, aRate = seis_utils.eqRate(at, k_win) #TODO: plot seismicity rates fig1 = plt.figure(1) ax = plt.subplot(211) ax.plot(aBin, aRate, 'b-', ms = 2) ax.set_ylabel( 'Earthquake Rate [ev/mo]') ax2 = plt.subplot( 212) #TODO: plot cumulative number of earthquakes ax2.plot(aWell, aV, 'ro', ms = 2) ax2.set_xlabel( 'Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim( ax.get_xlim()) plt.show()
mSeis = np.loadtxt( file_eq).T #TODO: convert date-time to decimal year use seis_utils.dateTime2decYr aTime = seis_utils.dateTime2decYr( file_eq).T mSeis = np.array( [aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt( file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot( 211) # compute seismicity rates using seis_utils.eqRate seis_rates = seis_utils.eqRate( dPar['tmin'] , dPar['k'] ) #TODO: plot seismicity rates plt.title('Seismicity Rates') plot_sr = plt.scatter( seis_rates) ax.set_ylabel( 'Earthquake Rate [ev/mo]') ax2 = plt.subplot( 212) plt.show() #TODO: plot cumulative number of earthquakes plot_cum_eq = Basemap.plot( aTime, file_eq[0].sum() ) ax2.set_xlabel( 'Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim( ax.get_xlim()) plt.show()
#TODO: convert date-time to decimal year use seis_utils.dateTime2decYr aTime = seis_utils.dateTime2decYr(mSeis[1], mSeis[2], mSeis[3], mSeis[4], mSeis[5], mSeis[6]) #print aTime mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt(file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax1 = plt.subplot(211) # compute seismicity rates using seis_utils.eqRate at_bin, at_rate = seis_utils.eqRate(aTime, dPar['k']) #TODO: plot seismicity rates ax1.plot(at_bin, at_rate, 'r-', lw=1.5) ax1.set_ylabel('Earthquake Rate [ev/mo]') ax2 = plt.subplot(212) #TODO: plot cumulative number of earthquakes eq_cum = np.cumsum(np.ones(at_bin.shape[0])) ax2.plot(at_bin, eq_cum, 'b-', lw=1.5) ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax1.get_xlim()) plt.show() #--------------------------3---------------------------------------------
seis_utils.dateTime2decYr(mSeis[1][n], mSeis[2][n], mSeis[3][n], mSeis[4][n], mSeis[5][n], mSeis[6][n])) mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt(file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot(211) seisDataNorm = seis_utils.eqRate(mSeis, 6) # print( seis_utils.eqRate(mSeis, aTime)) #plot seismicity rates plt.figure(1) ax.plot(seisDataNorm[1], seisDataNorm[0], 'b-') ax.set_xlabel('Time [dec. yr]') ax.set_ylabel('Earthquake Rate [ev/mo]') ax2 = plt.subplot(212) #plot cumulative number of earthquakes ax2.plot(0, len(mSeis[1]), 'ko') ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax.get_xlim()) plt.show()
aTime = seis_utils.dateTime2decYr(YR, MO, DAY, HR, MIN, SEC) mLoc_seis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt(file_well).T mLoc_wells = np.array([mWells[1], mWells[3], mWells[2]]) #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax1 = plt.subplot(211) # compute seismicity rates using seis_utils.eqRate aBin, aRates = seis_utils.eqRate(aTime, dPar.get('k')) #TODO: plot seismicity rates ax1.plot(aBin, aRates, 'b-') ax1.set_ylabel('Earthquake Rate [ev/mo]') ax2 = plt.subplot(212) #TODO: plot cumulative number of earthquakes ax2.plot(aTime, mSeis[:, 0], 'ko') ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax1.get_xlim()) plt.show() #--------------------------3---------------------------------------------
#TODO: convert date-time to decimal year use seis_utils.dateTime2decYr DONE aTime = funcs.dateTime2decYr(mSeis[1], mSeis[2], mSeis[3], mSeis[4], mSeis[5], mSeis[6]) mSeis = np.array( [aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt( file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax1 = plt.subplot( 211) # compute seismicity rates using seis_utils.eqRate aBin, aRate = funcs.eqRate(aTime, dPar['k']) #TODO: plot seismicity rates ax1.plot(aBin, aRate, 'b-') ax1.set_ylabel( 'Earthquake Rate [ev/mo]') ax2 = plt.subplot( 212) #TODO: plot cumulative number of earthquakes cumulative = np.cumsum ( np.ones(len(aBin.T))) ax2.plot( aBin, cumulative) ax2.set_xlabel( 'Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim( ax1.get_xlim()) plt.show()
mWells = np.loadtxt(file_well).T #TODO: convert date-time to decimal year use seis_utils.dateTime2decYr aTime = seis_utils.dateTime2decYr(mSeis[1], mSeis[2], mSeis[3], mSeis[4], mSeis[5], mSeis[6]) mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) #---------------------EQ Rates, Cumulative #------------------- #plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot(211) #compute seismocity rates using seis_utils.eqRate seisRate = seis_utils.eqRate(aTime, dPar['k']) totalEQ = np.cumsum(np.ones(len(aTime))) #TODO: plot seismocity rates ax.hist(aTime, dPar['k']) ax.set_ylabel('Earthquake Rate [ev/mo]') ax2 = plt.subplot(212) #TODO: plot cumulative number of earthquakes ax2.hist(aTime, totalEQ) ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax.get_xlim()) plt.show() #---------------------MAP VIEW---------------------------------
mSeis = np.loadtxt(file_eq).T aTime = seis_utils.dateTime2decYr(seism_OK_Data[1], seism_OK_Data[2], seism_OK_Data[3], seism_OK_Data[4], seism_OK_Data[5], seism_OK_Data[6]) mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt(file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ if dPar['showRate'] == True: plt.figure(1, figsize=(12, 5)) ax = plt.subplot(211) # compute seismicity rates aBin, aRate = seis_utils.eqRate(aTime, 200) plot1 = plt.plot(aBin, aRate) ax.set_ylabel('Earthquake Rate [ev/mo]') ax2 = plt.subplot(212) plot2 = plt.plot(aTime, np.cumsum(np.ones(7200))) ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax.get_xlim()) plt.show() #--------------------------3--------------------------------------------- # map view of well and event locations #------------------------------------------------------------------------
aTime = DecYear(mSeis[1], mSeis[2], mSeis[3], mSeis[4], mSeis[5], mSeis[6]) mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events #---------------------------------------------------------------------rate # compute seismicity rates using seis_utils.eqRate eq_bins, eq_rate = seis_utils.eqRate(aTime, dPar['k']) #--------------------------------------------------------------------- L = np.cumsum(np.ones(len(aTime))) #---------------------------------------------------------------------plot 1 #TODO: plot seismicity rates if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot(211) ax.hist(aTime, dPar['k']) ax.set_ylabel('Earthquake Rate [ev/mo]') #---------------------------------------------------------------------
aTime = seis_utils.dateTime2decYr(YR, MO, DY, HR, MN, SC) mSeis = np.array([aTime, mSeis[7], mSeis[8], mSeis[-1]]) mWells = np.loadtxt(file_well).T #--------------------------2--------------------------------------------- # earthquake rates, cumulative number #------------------------------------------------------------------------ # plot rate and cumulative number of events if dPar['showRate'] == True: plt.figure(1) ax = plt.subplot(211) # compute seismicity rates using seis_utils.eqRate rates = seis_utils.eqRate() #TODO: plot seismicity rates ax.plot(aTime, rates, 'b-') ax.set_ylabel('Earthquake Rate [eq/mo]') ax2 = plt.subplot(212) #TODO: plot cumulative number of earthquakes y = np.cumsum(np.ones(rates)) ax2.plot(aTime, y, 'ko') ax2.set_xlabel('Time [dec. yr]') ax2.set_ylabel('Cumulative Number') ax2.set_xlim(ax.get_xlim()) plt.show()