-
Notifications
You must be signed in to change notification settings - Fork 1
/
Import_ZfilestoPython.py
72 lines (60 loc) · 1.69 KB
/
Import_ZfilestoPython.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 27 11:31:48 2020
@author: Paul Goyes
This Script imports you Z_file from Stratagem HS4 used for MT sounding
E-mail: goyes.yesid@gmail.com
E-mail: yesid.goyes@correo.uis.edu.co
Universidad Industrial de Santander
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
filepath = 'ZFILE.001'
data = []
headers = ['frequency',
'ExHy_coherency',
'ExHy_scalar_apparent_resistivity',
'ExHy_scalar_phase',
'EyHz_coherency',
'EyHx_scalar_apparent_resistivity',
'EyHx_scalar_phase',
're_Zxx/sqrt(µo)',
'im_Zxx/√(µo)',
're_Zxy/√(µo)',
'im_Zxy/√(µo)',
're_Zyx/√(µo)',
'im_Zyx/√(µo)',
're_Zyy/√(µo)',
'im_Zyy/√(µo)',
]
with open(filepath) as fp:
while True:
line = fp.readline()
if not len(line):
break
fp.readline()
line2 = fp.readline()
fp.readline()
combined = line.strip().split() + line2.strip().split()
data.append(combined)
df = pd.DataFrame(data, columns=headers).astype('float')
array = np.array(data).astype(np.float)
# Check if dtype=float
#print(type(df['frequency'][0]))
# to-do: remove the zeros values from freqs.
xx = df.frequency.values
yy = df.ExHy_scalar_apparent_resistivity.values
phase = df.ExHy_scalar_phase.values
plt.subplot(211)
plt.loglog(xx[1:40],yy[1:40],'b-o')
plt.xlabel('Frequency [Hz]')
plt.ylabel('ExHy_scalar_apparent_resistivity')
plt.grid(True)
plt.subplot(212)
plt.semilogx(xx[1:40],phase[1:40],'b-o')
plt.xlabel('Frequency [Hz]')
plt.ylabel('ExHy_scalar_phase')
plt.grid(True)
plt.show()