Revert to separate npy outputs
This commit is contained in:
parent
b29d77a465
commit
8fb185dc06
2 changed files with 20 additions and 29 deletions
|
@ -10,11 +10,10 @@ class ReadSwash:
|
|||
self._n_t = None
|
||||
self._t = None
|
||||
self._x = None
|
||||
self._data = {}
|
||||
|
||||
@classmethod
|
||||
def read_nohead(cls, path):
|
||||
with tempfile.NamedTemporaryFile(dir=path.parent) as tmpfile:
|
||||
with tempfile.TemporaryFile() as tmpfile:
|
||||
with open(path) as file:
|
||||
subprocess.run(("tr", "-d", "\n"), stdin=file, stdout=tmpfile)
|
||||
tmpfile.seek(0)
|
||||
|
@ -32,28 +31,17 @@ class ReadSwash:
|
|||
|
||||
def read_scalar(self, path, const=False):
|
||||
if const:
|
||||
self._data[path.stem] = self.read_nohead(path).reshape(
|
||||
(self._n_t, self._n_x)
|
||||
)[0, :]
|
||||
return
|
||||
self._data[path.stem] = self.read_nohead(path).reshape(
|
||||
(self._n_t, self._n_x)
|
||||
)
|
||||
return self.read_nohead(path).reshape((self._n_t, self._n_x))[0, :]
|
||||
return self.read_nohead(path).reshape((self._n_t, self._n_x))
|
||||
|
||||
def read_vector(self, path):
|
||||
self._data[path.stem] = self.read_nohead(path).reshape(
|
||||
(self._n_t, 2, self._n_x)
|
||||
)
|
||||
return self.read_nohead(path).reshape((self._n_t, 2, self._n_x))
|
||||
|
||||
def read_scalar_lay(self, path):
|
||||
self._data[path.stem] = self.read_nohead(path).reshape(
|
||||
(self._n_t, -1, self._n_x)
|
||||
)
|
||||
return self.read_nohead(path).reshape((self._n_t, -1, self._n_x))
|
||||
|
||||
def read_vector_lay(self, path):
|
||||
self._data[path.stem] = self.read_nohead(path).reshape(
|
||||
(self._n_t, 2, -1, self._n_x)
|
||||
)
|
||||
return self.read_nohead(path).reshape((self._n_t, 2, -1, self._n_x))
|
||||
|
||||
@property
|
||||
def t(self):
|
||||
|
@ -62,7 +50,3 @@ class ReadSwash:
|
|||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
|
|
Reference in a new issue