Removed PA readswash
This commit is contained in:
parent
4ab8973bec
commit
4ec58f4fa8
1 changed files with 0 additions and 111 deletions
|
@ -1,111 +0,0 @@
|
|||
import numpy as np
|
||||
|
||||
|
||||
def readswash(filename, nx, nlay):
|
||||
with open(filename, "r") as f:
|
||||
content = f.readlines()
|
||||
fsurf = []
|
||||
klay = np.zeros((7203, nlay+1, nx))
|
||||
brkp = []
|
||||
Vxfield = np.zeros((7203, nlay+1, nx))
|
||||
Vyfield = np.zeros((7203, nlay+1, nx))
|
||||
Vzfield = np.zeros((7203, nlay+1, nx))
|
||||
ts = []
|
||||
t = 0
|
||||
for i in range(len(content)):
|
||||
if (
|
||||
content[i][33:93]
|
||||
== "Layer interface k=00"
|
||||
):
|
||||
layint0 = content[i + 7].split(".")
|
||||
layint1 = content[i + 12].split(".")
|
||||
surftemp = (
|
||||
[float(layint0[0].split()[1])]
|
||||
+ layint0[1:-1]
|
||||
+ [float(layint1[0].split()[1])]
|
||||
+ layint1[1:-1]
|
||||
)
|
||||
j = 0
|
||||
while j < len(surftemp):
|
||||
surftemp[j] = float(surftemp[j])
|
||||
j += 1
|
||||
fsurf.append(np.asarray(surftemp) / 10)
|
||||
if content[i][33:56] == "Flow velocity per layer":
|
||||
k = int(content[i][83:85])
|
||||
layint0 = content[i + 7].split(".")
|
||||
layint1 = content[i + 12].split(".")
|
||||
vktemp = (
|
||||
[float(layint0[0].split()[1])]
|
||||
+ layint0[1:-1]
|
||||
+ [float(layint1[0].split()[1])]
|
||||
+ layint1[1:-1]
|
||||
)
|
||||
j = 0
|
||||
while j < len(vktemp):
|
||||
try:
|
||||
vktemp[j] = float(vktemp[j])
|
||||
except:
|
||||
# vktemp[j] = float(vktemp[j][-5:])
|
||||
vktemp[j] = 0
|
||||
j += 1
|
||||
if content[i][87:88] == "X":
|
||||
Vxfield[t, k, :] = np.asarray(vktemp) / 1000
|
||||
else:
|
||||
Vyfield[t, k, :] = np.asarray(vktemp) / 1000
|
||||
if content[i][33:56] == "Velocity in z-direction":
|
||||
k = int(content[i][91:93])
|
||||
layint0 = content[i + 7].split(".")
|
||||
layint1 = content[i + 12].split(".")
|
||||
vktemp = (
|
||||
[float(layint0[0].split()[1])]
|
||||
+ layint0[1:-1]
|
||||
+ [float(layint1[0].split()[1])]
|
||||
+ layint1[1:-1]
|
||||
)
|
||||
j = 0
|
||||
while j < len(vktemp):
|
||||
try:
|
||||
vktemp[j] = float(vktemp[j])
|
||||
except:
|
||||
vktemp[j] = 0.0
|
||||
j += 1
|
||||
Vzfield[t, k, : len(vktemp)] = np.asarray(vktemp) / 1000
|
||||
Vzfield[t, k, len(vktemp) :] = np.zeros(nx - len(vktemp))
|
||||
if content[i][33:48] == "Layer interface":
|
||||
k = int(content[i][91:93])
|
||||
layint0 = content[i + 7].split(".")
|
||||
layint1 = content[i + 12].split(".")
|
||||
layktemp = (
|
||||
[float(layint0[0].split()[1])]
|
||||
+ layint0[1:-1]
|
||||
+ [float(layint1[0].split()[1])]
|
||||
+ layint1[1:-1]
|
||||
)
|
||||
j = 0
|
||||
while j < len(layktemp):
|
||||
layktemp[j] = float(layktemp[j])
|
||||
j += 1
|
||||
klay[t, k, :] = np.asarray(layktemp) / 10
|
||||
if content[i][33:52] == "wave breaking point":
|
||||
br0 = content[i + 7].split(".")
|
||||
br1 = content[i + 12].split(".")
|
||||
brtemp = (
|
||||
[float(br0[0].split()[1])]
|
||||
+ br0[1:-1]
|
||||
+ [float(br1[0].split()[1])]
|
||||
+ br1[1:-1]
|
||||
)
|
||||
j = 0
|
||||
while j < len(brtemp):
|
||||
brtemp[j] = float(brtemp[j])
|
||||
j += 1
|
||||
brkp.append(np.asarray(brtemp))
|
||||
if content[i][33:68] == "Time in seconds from reference time":
|
||||
ts.append(float(content[i + 1][7:16]))
|
||||
t += 1
|
||||
|
||||
return fsurf, Vxfield, Vyfield, Vzfield, brkp, klay
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(readswash("test.txt", 1250, 10))
|
Loading…
Reference in a new issue