Surface NMR processing and inversion GUI
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

calcAkvoKernel--save.py 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import os, sys
  2. import numpy as np
  3. from ruamel import yaml
  4. import pyLemma.LemmaCore as lc
  5. import pyLemma.Merlin as mrln
  6. import pyLemma.FDEM1D as em1d
  7. import numpy as np
  8. #import matplotlib.pyplot as plt
  9. #import seaborn as sns
  10. #sns.set(style="ticks")
  11. #import cmocean
  12. #from SEGPlot import *
  13. #from matplotlib.ticker import FormatStrFormatter
  14. #import matplotlib.ticker as plticker
  15. # Converts Lemma/Merlin/Akvo serialized Eigen arrays into numpy ones for use by Python
  16. class VectorXr(yaml.YAMLObject):
  17. """
  18. Converts Lemma/Merlin/Akvo serialized Eigen arrays into numpy ones for use by Python
  19. """
  20. yaml_tag = u'VectorXr'
  21. def __init__(self, array):
  22. self.size = np.shape(array)[0]
  23. self.data = array.tolist()
  24. def __repr__(self):
  25. # Converts to numpy array on import
  26. return "np.array(%r)" % (self.data)
  27. class AkvoData(yaml.YAMLObject):
  28. """
  29. Reads an Akvo serialized dataset into a standard python dictionary
  30. """
  31. yaml_tag = u'AkvoData'
  32. def __init__(self, array):
  33. pass
  34. #self.size = np.shape(array)[0]
  35. #self.Imp = array.tolist()
  36. def __repr__(self):
  37. # Converts to a dictionary with Eigen vectors represented as Numpy arrays
  38. return self
  39. def loadAkvoData(fnamein):
  40. """ Loads data from an Akvo YAML file. The 0.02 is hard coded as the pulse length. This needs to be
  41. corrected in future kernel calculations. The current was reported but not the pulse length.
  42. """
  43. fname = (os.path.splitext(fnamein)[0])
  44. with open(fnamein, 'r') as stream:
  45. try:
  46. AKVO = (yaml.load(stream, Loader=yaml.Loader))
  47. except yaml.YAMLError as exc:
  48. print(exc)
  49. return AKVO
  50. def main():
  51. if len(sys.argv) < 3:
  52. print ("usage python calcAkvoKernel.py AkvoDataset.yaml Coil1.yaml " )
  53. exit()
  54. AKVO = loadAkvoData(sys.argv[1])
  55. B_inc = AKVO.META["B_0"]["inc"]
  56. B_dec = AKVO.META["B_0"]["dec"]
  57. B0 = AKVO.META["B_0"]["intensity"]
  58. gamma = 2.67518e8
  59. fT = AKVO.transFreq
  60. #B0 = (fL*2.*np.pi) /gamma * 1e9
  61. Coil1 = em1d.PolygonalWireAntenna.DeSerialize( sys.argv[2] )
  62. Coil1.SetNumberOfFrequencies(1)
  63. Coil1.SetFrequency(0, fT)
  64. Coil1.SetCurrent(1.)
  65. lmod = em1d.LayeredEarthEM()
  66. lmod.SetNumberOfLayers(4)
  67. lmod.SetLayerThickness([15.49, 28.18])
  68. lmod.SetLayerConductivity([0.0, 1./16.91, 1./24.06, 1./33.23])
  69. lmod.SetMagneticFieldIncDecMag( B_inc, B_dec, B0, lc.NANOTESLA )
  70. exit()
  71. Kern = mrln.KernelV0()
  72. Kern.PushCoil( "Coil 1", Coil1 )
  73. Kern.SetLayeredEarthEM( lmod );
  74. Kern.SetIntegrationSize( (200,200,200) )
  75. Kern.SetIntegrationOrigin( (0,0,0) )
  76. Kern.SetTolerance( 1e-9 )
  77. Kern.SetMinLevel( 3 )
  78. Kern.SetHankelTransformType( lc.FHTKEY201 )
  79. Kern.AlignWithAkvoDataset( sys.argv[1] )
  80. thick = np.geomspace(.5, 10,num=40)
  81. iface = np.cumsum(thick)
  82. Kern.SetDepthLayerInterfaces(iface)
  83. #Kern.SetDepthLayerInterfaces(np.geomspace(1, 110, num=40))
  84. #Kern.SetDepthLayerInterfaces(np.linspace(1, 110, num=50))
  85. #Kern.SetDepthLayerInterfaces(np.geomspace(1, 110, num=40))
  86. # autAkvoDataNode = YAML::LoadFile(argv[4]);
  87. # Kern->AlignWithAkvoDataset( AkvoDataNode );
  88. #Kern.SetPulseDuration(0.040)
  89. #Kern.SetPulseCurrent( [1.6108818092452406, 1.7549935078885168, 1.7666319459646016, 1.9270787752430283,
  90. # 1.9455431806179229, 2.111931346726564, 2.1466747256211747, 2.3218217392379588,
  91. # 2.358359967649008, 2.5495654202189058, 2.5957289164577992, 2.8168532605800802,
  92. # 2.85505242699187, 3.1599429539069774, 3.2263673040205068, 3.6334182368296544,
  93. # 3.827985200119751, 4.265671313014058, 4.582237014873297, 5.116839616183394,
  94. # 5.515173073160611, 6.143620383280934, 6.647972282096122, 7.392577402979211,
  95. # 8.020737177449933, 8.904435233295793, 9.701975105606063, 10.74508217792577,
  96. # 11.743887525923592, 12.995985956061467, 14.23723766879807, 15.733870137824457,
  97. # 17.290155933625808, 19.07016662950366, 21.013341340455703, 23.134181634845618,
  98. # 25.570925414182238, 28.100862178905476, 31.13848909847073, 34.16791099558486,
  99. # 37.95775984680512, 41.589619321873165, 46.327607251605286, 50.667786337299205,
  100. # 56.60102493062895, 61.81174065797068, 69.23049946198458, 75.47409803238031,
  101. # 84.71658869065816, 92.1855007134236, 103.77129947551164, 112.84577430578537,
  102. # 127.55127257092909, 138.70199812969176, 157.7443764728878, 171.39653462998626]
  103. #)
  104. Kern.CalculateK0( ["Coil 1"], ["Coil 1"], False )
  105. yml = open('akvoK3-' + str(Kern.GetTolerance()) + '.yaml', 'w')
  106. print(Kern, file=yml)
  107. K0 = Kern.GetKernel()
  108. #plt.matshow(np.abs(K0))
  109. #plt.show()
  110. if __name__ == "__main__":
  111. main()