[params] fix subfolder

This commit is contained in:
Noe Brucy
2021-07-25 11:23:03 +02:00
parent 4f2bd29057
commit 3d10c7a78f
3 changed files with 22 additions and 17 deletions
+10 -7
View File
@@ -374,6 +374,7 @@ class Plotter(Aggregator, BaseProcessor):
for run in runs:
clip = ImageSequenceClip(filenames[run], fps=movie_fps)
movie_filename = self._find_filename(name_full, run=run, ext=".mp4")
os.makedirs(os.path.dirname(movie_filename), exist_ok=True)
clip.write_videofile(movie_filename)
return datafiles
@@ -390,6 +391,7 @@ class Plotter(Aggregator, BaseProcessor):
plt.tight_layout(pad=1)
if self.params.out.save:
os.makedirs(os.path.dirname(plot_filename), exist_ok=True)
plt.savefig(plot_filename)
self._log("{} plotted".format(plot_filename), "SUCCESS")
else:
@@ -408,8 +410,12 @@ class Plotter(Aggregator, BaseProcessor):
Determine a filename based on rule name, run, output and parameters
"""
tag_name = self.params.out.tag
if ext is None:
ext = self.params.out.ext
if self.params.out.ext_subfolder:
subfolder = "/{ext[1:]}/"
subfolder = f"/{ext[1:]}"
else:
subfolder = ""
@@ -418,11 +424,11 @@ class Plotter(Aggregator, BaseProcessor):
tag_name = "_" + tag_name
if run is not None and num is not None:
fmt = "{out}/{run}/{subfolder}{name}{tag}_{run}_{num:05}{ext}"
fmt = "{out}/{run}{subfolder}/{name}{tag}_{run}_{num:05}{ext}"
elif run is not None:
fmt = "{out}/{run}/{subfolder}{name}{tag}_{run}{ext}"
fmt = "{out}/{run}{subfolder}/{name}{tag}_{run}{ext}"
else:
fmt = "{out}/{name}{subfolder}{tag}{ext}"
fmt = "{out}{subfolder}/{name}{tag}{ext}"
elif fmt is None:
fmt = self.params.out.fmt
@@ -430,9 +436,6 @@ 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,
+8 -8
View File
@@ -312,21 +312,21 @@ class SnapshotProcessor(HDF5Container):
else:
tag_name = ""
if self.params.out.subfolder_ext:
subfolder = "/h5/"
if self.params.out.ext_subfolder:
subfolder = "/h5"
else:
subfolder = ""
self.filename = f"{self.path_out}/{subfolder}postproc_{tag_name}{num:05}.h5"
self.cells_filename = f"{self.path_out}/{subfolder}cells_{tag_name}{num:05}.h5"
self.parts_filename = f"{self.path_out}/{subfolder}parts_{tag_name}{num:05}.h5"
self.pspec_filename = f"{self.path_out}/{subfolder}pspec_{tag_name}{num:05}.h5"
self.filename = f"{self.path_out}{subfolder}/postproc_{tag_name}{num:05}.h5"
self.cells_filename = f"{self.path_out}{subfolder}/cells_{tag_name}{num:05}.h5"
self.parts_filename = f"{self.path_out}{subfolder}/parts_{tag_name}{num:05}.h5"
self.pspec_filename = f"{self.path_out}{subfolder}/pspec_{tag_name}{num:05}.h5"
self.filaments_filename = (
f"{self.path_out}/{subfolder}filaments_{tag_name}{num:05}.h5"
)
if not os.path.exists(self.path_out):
os.makedirs(self.path_out)
if not os.path.exists(f"{self.path_out}{subfolder}"):
os.makedirs(f"{self.path_out}{subfolder}")
self.path = path
self.run = os.path.basename(path)
+4 -2
View File
@@ -44,9 +44,11 @@ class StudyProcessor(Aggregator, HDF5Container):
tag_name = ""
if self.params.out.ext_subfolder:
self.filename = f"{self.path_out}/study{tag_name}.h5"
else:
self.filename = f"{self.path_out}/h5/study{tag_name}.h5"
else:
self.filename = f"{self.path_out}/study{tag_name}.h5"
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
# Select runs
if selector is None:
selector = RunSelector(