Surface NMR processing and inversion GUI
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

lemma_yaml.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import yaml
  2. def Complex_ctor(loader, node):
  3. re = eval(node.value[0][1].value)
  4. im = eval(node.value[1][1].value)
  5. return re + 1j*im
  6. yaml.add_constructor(r'Complex', Complex_ctor)
  7. class MatrixXr(yaml.YAMLObject):
  8. yaml_tag = u'MatrixXr'
  9. def __init__(self, rows, cols, data):
  10. self.rows = rows
  11. self.cols = cols
  12. self.data = np.zeros((rows,cols))
  13. def __repr__(self):
  14. return "%s(rows=%r, cols=%r, data=%r)" % (self.__class__.__name__, self.rows, self.cols, self.data)
  15. class VectorXr(yaml.YAMLObject):
  16. yaml_tag = r'VectorXr'
  17. def __init__(self, array):
  18. self.size = np.shape(array)[0]
  19. self.data = array.tolist()
  20. def __repr__(self):
  21. # Converts to numpy array on import
  22. return "np.array(%r)" % (self.data)
  23. class VectorXcr(yaml.YAMLObject):
  24. yaml_tag = r'VectorXcr'
  25. def __init__(self, array):
  26. self.size = np.shape(array)[0]
  27. self.datar = array.tolist()
  28. def __repr__(self):
  29. # Converts to numpy array on import
  30. #return "np.array(%r)" % (self.data)
  31. return "np.array(%r)" % (3)
  32. class Vector3r(yaml.YAMLObject):
  33. yaml_tag = r'Vector3r'
  34. def __init__(self, array):
  35. self.size = 3 #np.shape(array)[0]
  36. self.data = array.tolist()
  37. def __repr__(self):
  38. # Converts to numpy array on import
  39. return "np.array(%r)" % (self.data)
  40. class Vector3Xcr(yaml.YAMLObject):
  41. yaml_tag = r'Vector3Xcr'
  42. def __init__(self, array):
  43. self.size = 3 #np.shape(array)[0]
  44. self.data = array.tolist()
  45. def __repr__(self):
  46. # Converts to numpy array on import
  47. return "np.array(%r)" % (self.data)
  48. class Vector3Xr(yaml.YAMLObject):
  49. yaml_tag = r'Vector3Xr'
  50. def __init__(self, array):
  51. self.size = 3 #np.shape(array)[0]
  52. self.data = array.tolist()
  53. def __repr__(self):
  54. # Converts to numpy array on import
  55. return "np.array(%r)" % (self.data)
  56. #class KernelV0( ):
  57. #yaml_tag = r'KernelV0'
  58. # def __init__(self):
  59. # self.name = "hello"
  60. #def KernelV0_constructor(loader, node):
  61. #... value = loader.construct_scalar(node)
  62. #... a, b = map(int, value.split('d'))
  63. # return KernelV0( )
  64. # class KervnelV0(yaml.YAMLObject):
  65. # yaml_loader = yaml.Loader
  66. # yaml_dumper = yaml.Dumper
  67. #
  68. # yaml_tag = u'!KernelV0'
  69. # #yaml_flow_style = ...
  70. #
  71. # def __init__(self):
  72. # self.val = 7
  73. #
  74. # @classmethod
  75. # def from_yaml(cls, loader, node):
  76. # # ...
  77. # data = 0
  78. # return data
  79. #
  80. # @classmethod
  81. # def to_yaml(cls, dumper, data):
  82. # # ...
  83. # return node
  84. class KervnelV0(yaml.YAMLObject):
  85. yaml_tag = u'KernelV0'
  86. def __init__(self, val):
  87. self.val = val
  88. class LayeredEarthEM(yaml.YAMLObject):
  89. yaml_tag = u'LayeredEarthEM'
  90. def __init__(self, val):
  91. self.val = val
  92. class PolygonalWireAntenna(yaml.YAMLObject):
  93. yaml_tag = u'PolygonalWireAntenna'
  94. def __init__(self, val):
  95. self.val = val
  96. class AkvoData(yaml.YAMLObject):
  97. yaml_tag = u'AkvoData'
  98. def __init__(self, obj): #nPulseMoments, pulseLength):
  99. #def __init__(self, rows, cols, data):
  100. #self.nPulseMoments = nPulseMoments
  101. #self.pulseLength = pulseLength
  102. #for key in obj.keys:
  103. # self[key] = obj.key
  104. pass