Processing update: fix empty file issue
This commit is contained in:
parent
68e8d16f7c
commit
009e500d7a
2 changed files with 13 additions and 19 deletions
|
@ -13,8 +13,10 @@ class ReadSwash:
|
|||
|
||||
@classmethod
|
||||
def read_nohead(cls, path):
|
||||
with open(path) as file, tempfile.TemporaryFile() as tmpfile:
|
||||
subprocess.run(("tr", "-d", "\n"), stdin=file, stdout=tmpfile)
|
||||
with tempfile.TemporaryFile() as tmpfile:
|
||||
with open(path) as file:
|
||||
subprocess.run(("tr", "-d", "\n"), stdin=file, stdout=tmpfile)
|
||||
tmpfile.seek(0)
|
||||
return np.loadtxt(tmpfile)
|
||||
|
||||
def read_time(self, path):
|
||||
|
@ -29,27 +31,17 @@ class ReadSwash:
|
|||
|
||||
def read_scalar(self, path, const=False):
|
||||
if const:
|
||||
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)
|
||||
)
|
||||
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):
|
||||
return 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):
|
||||
return 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):
|
||||
return 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):
|
||||
|
|
|
@ -32,8 +32,10 @@ log.info(f"Wrinting output in '{inp}'")
|
|||
log.info("Reading 'dep'")
|
||||
np.save(inp.joinpath("dep"), rsws.read_scalar(sws_out.joinpath("dep.dat")))
|
||||
log.info("Reading 'botl'")
|
||||
np.save(inp.joinpath("botl"), rsws.read_scalar(sws_out.joinpath("botl.dat"),
|
||||
const=True))
|
||||
np.save(
|
||||
inp.joinpath("botl"),
|
||||
rsws.read_scalar(sws_out.joinpath("botl.dat"), const=True),
|
||||
)
|
||||
log.info("Reading 'watl'")
|
||||
np.save(inp.joinpath("watl"), rsws.read_scalar(sws_out.joinpath("watl.dat")))
|
||||
log.info("Reading 'vel'")
|
||||
|
|
Loading…
Reference in a new issue