extension subfolders

This commit is contained in:
Noe Brucy
2021-07-24 20:53:21 +02:00
parent 35e5a767cb
commit 35cf8ff401
4 changed files with 37 additions and 34 deletions
+14 -7
View File
@@ -377,8 +377,7 @@ class Plotter(Aggregator, BaseProcessor):
if movie:
for run in runs:
clip = ImageSequenceClip(filenames[run], fps=movie_fps)
movie_filename = self._find_filename(name_full, run=run)
movie_filename = os.path.splitext(movie_filename)[0] + ".mp4"
movie_filename = self._find_filename(name_full, run=run, ext=".mp4")
clip.write_videofile(movie_filename)
return datafiles
@@ -408,22 +407,26 @@ class Plotter(Aggregator, BaseProcessor):
else:
self._log("Plot {} is already done, skipping...".format(plot_filename))
def _find_filename(self, name_full, run=None, num=None, fmt=None):
def _find_filename(self, name_full, run=None, num=None, fmt=None, ext=None):
"""
Determine a filename based on rule name, run, output and parameters
"""
tag_name = self.params.out.tag
if self.params.out.ext_subfolder:
subfolder = "/{ext[1:]}/"
else:
subfolder = ""
if fmt is None and self.params.out.fmt == "":
if not self.params.out.tag == "":
tag_name = "_" + tag_name
if run is not None and num is not None:
fmt = "{out}/{run}/{name}{tag}_{run}_{num:05}{ext}"
fmt = "{out}/{run}/{subfolder}{name}{tag}_{run}_{num:05}{ext}"
elif run is not None:
fmt = "{out}/{run}/{name}{tag}_{run}{ext}"
fmt = "{out}/{run}/{subfolder}{name}{tag}_{run}{ext}"
else:
fmt = "{out}/{name}{tag}{ext}"
fmt = "{out}/{name}{subfolder}{tag}{ext}"
elif fmt is None:
fmt = self.params.out.fmt
@@ -431,6 +434,9 @@ class Plotter(Aggregator, BaseProcessor):
if run is not None:
nml = self.study.namelist[run]
if ext is None:
ext = self.params.out.ext
return fmt.format(
run=run,
name=name_full,
@@ -438,7 +444,8 @@ class Plotter(Aggregator, BaseProcessor):
num=num,
nml=nml,
out=self.path_out,
ext=self.params.out.ext,
ext=ext,
subfolder=subfolder,
)
def get_label_run(self, run, label=None, nml_key=None, time=None):