1
Fork 0
internship/swash/processing/read_swash.py

29 lines
533 B
Python
Raw Normal View History

2022-03-02 14:25:53 +01:00
import numpy as np
def read_nohead(path):
with open(path) as file:
return file.read()
2022-03-02 14:45:13 +01:00
def read_reshape(path, shape):
2022-03-02 14:25:53 +01:00
return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape(
2022-03-02 14:45:13 +01:00
shape
2022-03-02 14:25:53 +01:00
)
2022-03-02 14:45:13 +01:00
def read_nohead_scalar(path, n):
return read_reshape(path, (-1, n))
2022-03-02 14:25:53 +01:00
def read_nohead_k(path, n, k):
2022-03-02 14:45:13 +01:00
return read_reshape(path, (-1, n, k))
2022-03-02 14:25:53 +01:00
def read_nohead_vect(path, n):
return read_reshape(path, (-1, 2, n))
2022-03-02 14:25:53 +01:00
def read_nohead_vect_k(path, n):
return read_reshape(path, (-1, 2, n, k))