From 1a374cac842dd9c2f8bda7dcb9e361398166df61 Mon Sep 17 00:00:00 2001 From: joergbuchwald Date: Thu, 29 Feb 2024 18:10:46 +0100 Subject: [PATCH] fix append by deriving time from fn --- VTUinterface/vtuIO.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/VTUinterface/vtuIO.py b/VTUinterface/vtuIO.py index 72b8dd8..80693a5 100644 --- a/VTUinterface/vtuIO.py +++ b/VTUinterface/vtuIO.py @@ -1199,7 +1199,7 @@ def rename(self, newname): xml_declaration=True, pretty_print=True) - def append(self, filename, vtu_rename=False): + def append(self, filename, vtu_rename=False, timestep_from_filename=False): """ appends entries from another PVD file @@ -1220,7 +1220,13 @@ def append(self, filename, vtu_rename=False): self.timesteps = self.timesteps[:-1] self.vtufilenames = self.vtufilenames[:-1] for tag in find_xpath: - self.timesteps = np.append(self.timesteps, [float(tag.attrib['timestep'])+offset]) + if timestep_from_filename is False: + self.timesteps = np.append(self.timesteps, [float(tag.attrib['timestep'])+offset]) + else: + fn = tag.attrib['file'] + fn_cut = fn.split("_t_")[1] + time_fromfile = float(fn_cut(".")[0]+"."+fn_cut(".")[1]) + self.timesteps = np.append(self.timesteps, [time_fromfile]) newvtuname = tag.attrib['file'] if vtu_rename is True: newvtuname = tag.attrib['file'].replace(filename_dirstripped.split(".pvd")[0],