Advertisement
Lawrenzz

Final

May 27th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.46 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Jan 30 13:10:14 2018
  4.  
  5. @author: Lawrence
  6. """
  7. import matplotlib
  8. import matplotlib.pyplot as plt
  9. matplotlib.use('Agg')
  10. from obspy import read, Trace
  11. from obspy.signal import PPSD
  12. from obspy.io.xseed import Parser
  13. from obspy.signal.invsim import corn_freq_2_paz
  14. import time
  15. from obspy.signal.invsim import corn_freq_2_paz
  16. from obspy.io.sac.sacpz import attach_resp
  17. from obspy.imaging.cm import pqlx
  18. import numpy as np
  19. import math
  20. import matplotlib.mlab as mlab
  21.  
  22. paz_sts2 = {
  23.     'poles': [-3.691000E-02 + 3.702000E-02j, -3.691000E-02 - 3.702000E-02j, -3.430000E+02 + 0j, -3.700000E+02 + 4.670000E+02j,
  24.               -3.700000E+02 - 4.670000E+02j, -8.360000E+02 + 1.522000E+03j, -8.360000E+02 - 1.522000E+03j, -4.900000E+03 + 4.700000E+03j, -4.900000E+03 - 4.700000E+03j,-6.900000E+03 + 0j, -1.500000E+04 + 0j],
  25.     'zeros': [0, 0, 0, -3.920000E+02 + 0j, -1.960000E+03 + 0j, -1.490000E+03 + 1.740000E+03j, -1.490000E+03 - -1.740000E+03j],
  26.     'gain':  4.344928E+17 * 800000,
  27.     'sensitivity': 7.543000E+02}
  28. paz_1hz=corn_freq_2_paz(1.0, damp=0.707)
  29. paz_1hz['sensitivity']= 1.0
  30. #Inputs:
  31. sta = 'GNGN'    #Station name
  32. input_fils_A= "C:/Users/lawre/Desktop/Thesis_Research/New_Data/Centaur-6_1270_20180429_190000.miniseed" #Make sure that "ls" will return files
  33. input_fils_B= "C:/Users/lawre/Desktop/Thesis_Research/New_Data/Centaur-6_1281_20180429_190000.miniseed" #Second Seismometer
  34. win_len = 3600. #Duration of each segment in seconds ppsd_length
  35. ovr_lap = 0.5  #Overlap is the overlap between consecutive segments
  36. sens_resp = "C:/Users/lawre/Desktop/Thesis_Research/S-ConfigurationSensitivityFilesforexistingTrilliumSensor/BHZ.TrilliumCompact.120.754.dataless" #Sensor Response
  37. digi_resp = "C:/Users/lawre/Desktop/Thesis_Research/S-ConfigurationSensitivityFilesforexistingTrilliumSensor/XX.NN443..HHZ.CENTAUR.2.250.OFF.dataless"#Digitizer Response
  38. #=======================================================================================
  39. sA = read(input_fils_A)
  40. for chn in ['HHZ']: #Loop through channels
  41.     scur = sA.select(channel=chn) #Select the channel
  42. print sA
  43. resample_rate=10
  44. sA.resample(resample_rate)
  45. print sA
  46. sA_orig = sA.copy() #Copy of original data
  47. sA.simulate(paz_remove=paz_sts2, paz_simulate=paz_1hz)
  48. #sA_orig.plot()
  49. sA[0].plot()
  50.  
  51. sB = read(input_fils_B)
  52. for chn in ['HHZ']: #Loop through channels
  53.     scur = sB.select(channel=chn) #Select the channel
  54. print sB
  55. sB.resample(resample_rate)
  56. print sB
  57. sB_orig = sB.copy() #Copy of original data
  58. sB.simulate(paz_remove=paz_sts2, paz_simulate=paz_1hz)
  59. #sB_orig.plot()
  60. sB[2].plot()
  61.  
  62. tr_A = np.array(sA[0])#number 2 is HHZ
  63. tr_B = np.array(sB[2])
  64. distance =np.array(3.0)
  65. tr_difference = np.subtract(tr_A, tr_B)
  66. tr_tilt = np.divide(tr_difference,distance)
  67. times=[]
  68. i=0
  69. while i < len(tr_tilt):
  70.     newval=float((i)*(1./resample_rate))
  71.     times.append(newval)
  72.     i+=1
  73. matplotlib.pyplot.plot(times,tr_tilt)
  74. matplotlib.pyplot.show()
  75.  
  76. fs = resample_rate
  77. n=tr_difference.size
  78. freqall = np.fft.rfftfreq(n, d=1./fs)
  79. freqplot=freqall
  80. power = np.fft.rfft(tr_tilt, norm="ortho")#the normalising fixed the amplitude to match Josh's result. Applying this changes normalisation from 1/n to 1/sqrt(n)
  81. powerplot =np.absolute(power)
  82. print(freqplot.size)
  83. print(powerplot.size)
  84. A = plt.plot([0.01, 0.2, 0.5], [3e-10, 6e-9, 1e-10],'r-', lw=2, zorder=2)
  85. plt.plot(freqplot,powerplot, zorder=1)
  86. plt.xscale('log')
  87. plt.yscale('log')
  88. plt.xlabel('Frequency (Hz)')
  89. plt.ylabel('rad/sqrt(Hz)')
  90. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement