Skip to content

Commit

Permalink
fix append by deriving time from fn
Browse files Browse the repository at this point in the history
  • Loading branch information
joergbuchwald committed Feb 29, 2024
1 parent 048616a commit 1a374ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions VTUinterface/vtuIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
Expand Down

0 comments on commit 1a374ca

Please sign in to comment.