Strong improvements to sws_npz conversion times
This commit is contained in:
parent
6ae1ea9899
commit
14cf8c4efe
1 changed files with 8 additions and 4 deletions
|
@ -16,10 +16,14 @@ class ReadSwash:
|
|||
|
||||
@classmethod
|
||||
def read_nohead(cls, path):
|
||||
with tempfile.TemporaryFile(mode="w+t") as tmpfile:
|
||||
log.info(f"Replacing \\s with \\n in '{path}'")
|
||||
subprocess.run(("sed", "-i", r"s/\s\+/\n/g", path))
|
||||
subprocess.run(("sed", r"s/\s\+/\n/g;/^$/d", path), stdout=tmpfile, text=True)
|
||||
log.info(f"Loading '{path}'")
|
||||
return np.loadtxt(path)
|
||||
tmpfile.seek(0)
|
||||
a = np.asarray(tmpfile.readlines(), dtype=float)
|
||||
log.debug(f"path={a}")
|
||||
return a
|
||||
|
||||
def read_time(self, path):
|
||||
self._t = np.unique(self.read_nohead(path))
|
||||
|
|
Loading…
Reference in a new issue