Surface NMR processing and inversion GUI
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

plotKernel.py 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import matplotlib.pyplot as plt
  2. import sys,os
  3. from pylab import meshgrid
  4. from matplotlib.colors import LightSource
  5. from matplotlib.ticker import ScalarFormatter
  6. from matplotlib.ticker import MaxNLocator
  7. from matplotlib.ticker import AutoMinorLocator
  8. from matplotlib.ticker import LogLocator
  9. from matplotlib.ticker import FormatStrFormatter
  10. import numpy as np
  11. import yaml
  12. from akvo.tressel.lemma_yaml import *
  13. from akvo.tressel.SlidesPlot import *
  14. import cmocean
  15. def catLayers(K0):
  16. K = np.zeros( (len(K0.keys()), len(K0["layer-0"].data)) , dtype=complex )
  17. for lay in range(len(K0.keys())):
  18. #print(K0["layer-"+str(lay)].data) # print (lay)
  19. K[lay] = K0["layer-"+str(lay)].data # print (lay)
  20. return K
  21. if __name__ == "__main__":
  22. with open(sys.argv[1]) as f:
  23. # use safe_load instead load
  24. K0 = yaml.load(f, Loader=yaml.Loader)
  25. K = 1e9*catLayers(K0.K0)
  26. q = np.array(K0.PulseI.data)* (float)(K0.Taup)
  27. centres = (np.array(K0.Interfaces.data[0:-1]) + np.array(K0.Interfaces.data[1::])) / 2
  28. fig = plt.figure( figsize=(pc2in(20),pc2in(20)) )
  29. fig.add_axes((.2,.2,.65,.7))
  30. #plt.pcolor(K0.Interfaces.data, K0.PulseI.data, np.abs(K))
  31. #plt.pcolor(q, K0.Interfaces.data, np.abs(K), cmap=cmocean.cm.gray_r)
  32. #plt.contourf(q, K0.Interfaces.data[0:-1], np.abs(K), cmap=cmocean.cm.tempo)
  33. #plt.pcolormesh(q, K0.Interfaces.data, np.abs(K), cmap=cmocean.cm.tempo, shading='nearest')
  34. plt.pcolormesh(q, centres, np.abs(K), cmap=cmocean.cm.tempo, shading='nearest')
  35. plt.colorbar(label=r"$\left| \overline{\mathcal{V}_N}(0) \right|$ (nV)")
  36. ax1 = plt.gca()
  37. ax1.set_ylim( ax1.get_ylim()[1], ax1.get_ylim()[0] )
  38. #ax1.set_xscale('log')
  39. #ax1.set_yscale('log')
  40. #ax1.xaxis.set_major_formatter(ScalarFormatter())
  41. ax1.set_xticks([ax1.get_xlim()[0], 1, ax1.get_xlim()[1],])
  42. ax1.xaxis.set_major_formatter(FormatStrFormatter('%.1f'))
  43. #print(yaml.dump(K0.K0))
  44. #print( K0.K0["layer-0"].data )
  45. #print( type( np.array(K0.K0["layer-0"].data) ) )
  46. #plt.plot( np.real( K0.K0["layer-0"].data ) )
  47. #plt.plot( K0.K0["layer-0"].data )
  48. plt.gca().set_xlabel("q (A $\cdot$ s)")
  49. plt.gca().set_ylabel("depth (m)")
  50. plt.savefig("kernel.pdf")
  51. #sound = np.sum(K, axis=0)
  52. #plt.figure()
  53. #plt.plot(q, np.abs(sound))
  54. #plt.savefig("sound.pdf")
  55. plt.show()
  56. #print(yaml.dump(K0))