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