Skip to content

Commit deb33c6

Browse files
Merge pull request #27 from joergbuchwald/fix_append
fix append by deriving time from fn
2 parents 048616a + 1a374ca commit deb33c6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

VTUinterface/vtuIO.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ def rename(self, newname):
11991199
xml_declaration=True,
12001200
pretty_print=True)
12011201

1202-
def append(self, filename, vtu_rename=False):
1202+
def append(self, filename, vtu_rename=False, timestep_from_filename=False):
12031203
"""
12041204
appends entries from another PVD file
12051205
@@ -1220,7 +1220,13 @@ def append(self, filename, vtu_rename=False):
12201220
self.timesteps = self.timesteps[:-1]
12211221
self.vtufilenames = self.vtufilenames[:-1]
12221222
for tag in find_xpath:
1223-
self.timesteps = np.append(self.timesteps, [float(tag.attrib['timestep'])+offset])
1223+
if timestep_from_filename is False:
1224+
self.timesteps = np.append(self.timesteps, [float(tag.attrib['timestep'])+offset])
1225+
else:
1226+
fn = tag.attrib['file']
1227+
fn_cut = fn.split("_t_")[1]
1228+
time_fromfile = float(fn_cut(".")[0]+"."+fn_cut(".")[1])
1229+
self.timesteps = np.append(self.timesteps, [time_fromfile])
12241230
newvtuname = tag.attrib['file']
12251231
if vtu_rename is True:
12261232
newvtuname = tag.attrib['file'].replace(filename_dirstripped.split(".pvd")[0],

0 commit comments

Comments
 (0)