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):
|
2022-03-03 10:38:32 +01:00
|
|
|
return read_reshape(path, (-1, 2, n))
|
2022-03-02 14:25:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
def read_nohead_vect_k(path, n):
|
2022-03-03 10:38:32 +01:00
|
|
|
return read_reshape(path, (-1, 2, n, k))
|