-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathData_Loader.py
More file actions
175 lines (154 loc) · 7.58 KB
/
Copy pathData_Loader.py
File metadata and controls
175 lines (154 loc) · 7.58 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 3 11:01:51 2020
@author: Ahmed
"""
import pandas
import numpy as np
def xmtrLoader(pathname, filename="/data/xmtr.lis"):
df = pandas.read_table(pathname+filename, skiprows=1,
delim_whitespace=True, names=('xmtr_id','freq', 'lat','lon', 'pwr','incl', 'headng', 'alt', 'location'))
endIdx = df[df["xmtr_id"]== "end"].index
df.drop(endIdx, inplace=True)
return df
def areaLoader(pathname, filename="/data/area.lis"):
df = pandas.read_table(pathname+filename, skiprows=1,
delim_whitespace=True, names=('area_id', 'lat1', 'lon1', 'lat2','lon2'))
endIdx = df[df["area_id"]== "end"].index
df.drop(endIdx, inplace=True)
return df
def rxLoader(pathname, filename = "/data/rx.lis"):
try:
df = pandas.read_table(pathname+filename, skiprows=1,
delim_whitespace=True, names=('rx_id', 'lat','lon'))
except:
with open(pathname+filename, "w+") as f:
f.write("rx_id lat lon\n")
f.writelines("Tunisia \t 36.8 \t -10.22\n")
f.writelines("Algeria \t 36.76 \t -3.47\n")
f.close()
finally:
df = pandas.read_table(pathname+filename, skiprows=1,
delim_whitespace=True, names=('rx_id', 'lat','lon'))
return df
def gcpathLoader(pathname, filename="/gcpath.log"):
df_gcpath = pandas.read_table(pathname+filename, skiprows=14, delim_whitespace=True,
names=('xmtr_id', 'tlat', 'tlon', 'bearing', 'range',
'rlat', 'rlon', 'rrho'))
df_gcpathAmb = pandas.read_table(pathname+filename, skiprows=16, delim_whitespace=True,
names=('rho', 'lat', 'lon', 'azim', 'dip', 'bfield', 'sigma',
'epsr', 'ncd', 'chi', 'beta', 'hprime', 'npr'))
endIdx = df_gcpathAmb[df_gcpathAmb['rho']== 'quit'].index
df_gcpathAmb.drop(endIdx, inplace=True)
df_gcpathAmb.drop(endIdx+1, inplace=True)
return df_gcpath[0:1], df_gcpathAmb
def bearingsLoader(pathname, filename="/bearings.log"):
"""
Load bearings data from bearings.log
"""
df_bearings_path_info = pandas.read_table(pathname+filename, skiprows=21, delim_whitespace=True,
names=("nr", "rho", "lat", "lon", "azim",
"dip", "sigma", "chi", "beta", "h'"))
endIdx = df_bearings_path_info[df_bearings_path_info["nr"]== 'PRFL_HGTS:'].index
#print(endIdx)
df_bearings_path_info = df_bearings_path_info[0:endIdx[0]]
# Find signal prop: dist, Amp, Phase
with open(pathname+filename) as f:
content = f.readlines()
# Pointeur = 'z component'
index = [x for x in range(len(content)) if 'z component' in content[x].lower()]
indexrows =index[0] + 2
df_bearings_ambient = pandas.read_table(pathname+filename, skiprows= indexrows, delim_whitespace=True,
names=("dist1", "amplitude1", "phase1", "dist2", "amplitude2", "phase2",
"dist3", "amplitude3", "phase3"))
endIdx = df_bearings_ambient[df_bearings_ambient["dist1"]== 'nc'].index
df_bearings_ambient = df_bearings_ambient[0:endIdx[0]].dropna()
df1 = df_bearings_ambient[["dist1", "amplitude1", "phase1"]]
df2 = df_bearings_ambient[["dist2", "amplitude2", "phase2"]]
df3 = df_bearings_ambient[["dist3", "amplitude3", "phase3"]]
df_ambient = np.vstack((np.array(df1, dtype = np.float64),
np.array(df2, dtype = np.float64),
np.array(df3, dtype = np.float64)))
return df_bearings_path_info , df_ambient
def rexpLoader(pathname, filename="/rexp.log"):
"""
Load rexp data from rexp.log
"""
df_rexp_path_info = pandas.read_table(pathname+filename, skiprows=23, delim_whitespace=True,
names=("nr", "rho", "lat", "lon", "azim",
"dip", "sigma", "chi", "beta", "h'"))
endIdx = df_rexp_path_info[df_rexp_path_info["nr"]== 'PRFL_HGTS:'].index
df_rexp_path_info = df_rexp_path_info[0:endIdx[0]]
#print(df_rexp_path_info["rho"])
# Find signal prop: dist, Amp, Phase
with open(pathname+filename) as f:
content = f.readlines()
# Pointeur = 'z component'
index = [x for x in range(len(content)) if 'z component' in content[x].lower()]
indexrows =index[0] + 2
df_rexp_disturb = pandas.read_table(pathname+filename, skiprows= indexrows, delim_whitespace=True,
names=("dist1", "amplitude1", "phase1", "dist2", "amplitude2", "phase2",
"dist3", "amplitude3", "phase3"))
endIdx = df_rexp_disturb[df_rexp_disturb["dist1"]== 'nc'].index
df_rexp_disturb = df_rexp_disturb[0:endIdx[0]].dropna()
df1 = df_rexp_disturb[["dist1", "amplitude1", "phase1"]]
df2 = df_rexp_disturb[["dist2", "amplitude2", "phase2"]]
df3 = df_rexp_disturb[["dist3", "amplitude3", "phase3"]]
df_disturb = np.vstack((np.array(df1, dtype = np.float64),
np.array(df2, dtype = np.float64),
np.array(df3, dtype = np.float64)))
return df_rexp_path_info, df_disturb
if __name__ == "__main__":
import matplotlib.pyplot as plt
from scipy import interpolate
df_gcpath, df_gcpathAmb = gcpathLoader(pathname= "lwpcv21_linux")
bearing, range_max = df_gcpath["bearing"], df_gcpath["rrho"]
print("bearing = ", float(bearing), "range max = ", float(range_max))
## FIGURE
df_rexp_path_info, df_disturb = rexpLoader(pathname= "lwpcv21_linux")
rho = df_rexp_path_info['rho']
rho = np.array(rho, dtype = np.float64)
hprime = df_rexp_path_info["h'"]
hprime =np.array(hprime, dtype = np.float64)
beta = df_rexp_path_info['beta']
beta =np.array(beta, dtype = np.float64)
print("beta amb = ", hprime[0])
print("hprime amb = ",beta[0])
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True,figsize=(8,5))
ax1.plot(rho/1000, hprime, "r-o")
ax1.set_title("H' new stratified maillor")
ax1.set_xlabel("rho (Mm)")
ax1.set_ylabel("h' (km)")
ax2.plot(rho/1000, beta, "r-o")
ax2.set_title("Beta new stratified maillor")
ax2.set_xlabel("rho (Mm)")
ax2.set_ylabel("Beta' (km^-1)")
# perturbation grid
hmodel = np.ones(len(hprime))
for k in np.arange(0,10,1):
for i in range(len(hprime)):
if 50<= hprime[i] <= 76:
hmodel[i]= hprime[i]-k
else:
hmodel[i]= hprime[i]
ax1.plot(rho/1000, hmodel, "bo-", ms=2, alpha = 0.5)
betamodel = np.ones(len(beta))
for k in np.arange(0,0.2,0.02):
for i in range(len(beta)):
if 0.29 <= beta[i] <= 0.32:
betamodel[i]= beta[i]-k
else:
betamodel[i]= beta[i]
ax2.plot(rho/1000, betamodel, "bo-",ms=2, alpha = 0.5)
plt.tight_layout()
# df_bearings_path_info , df_ambient = bearingsLoader(pathname= "lwpcv21_linux")
# fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True,figsize=(8,5))
# ax1.plot(df_ambient[:,0], df_ambient[:,1], "b-")
# ax1.plot(df_disturb[:-1,0], df_disturb[:-1,1], "r-")
# ax1.set_ylabel("Amplitude")
# ax2.plot(df_ambient[:,0], df_ambient[:,2], "b-")
# ax2.plot(df_disturb[:-1,0], df_disturb[:-1,2], "r-")
# ax2.set_xlabel("rho [km]")
# ax2.set_ylabel("Phase")
# plt.suptitle("Hello!", fontsize = 14, color = "r", fontweight = "bold")
# plt.show()