extension subfolders
This commit is contained in:
+8
-6
@@ -74,17 +74,19 @@ input: # Parameters on how to look for input files (= output from Ramses)
|
||||
ramses_ism : True # If ramses-ism is used
|
||||
|
||||
out: # Parameters for post processing
|
||||
tag : "" # Tag for the image
|
||||
interactive : False # Interactive mode (keep figures open)
|
||||
save : True # Save the plots on the disk
|
||||
ext : '.jpeg' # extension for plots
|
||||
fmt : "" # Format of the output filename for plots
|
||||
tag : "" # Tag for the image
|
||||
interactive : False # Interactive mode (keep figures open)
|
||||
save : True # Save the plots on the disk
|
||||
ext : '.jpeg' # extension for plots
|
||||
ext_subfolder : True # Separate production by extension in subfolders
|
||||
fmt : "" # Format of the output filename for plots
|
||||
# The following keys are accepted
|
||||
# {out} : The output directory (where hdf5 files are also stored)
|
||||
# {run} : Name of the relevant run
|
||||
# {num} : Name of the input file (from Ramses)
|
||||
# {ext} : Extension defined above
|
||||
# {ext} : Extension defined above (with the dot)
|
||||
# {name} : Name of the rule
|
||||
# {subfolder} : replaced by /{ext[1:]}/ if ext_subfolder is true
|
||||
# {tag} : Tag defined above
|
||||
# {nml[nml_key]} : The value of nml_key in the namelist (ex: {nml[amr_params/levelmin]})
|
||||
|
||||
|
||||
+14
-7
@@ -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):
|
||||
|
||||
+10
-18
@@ -312,24 +312,17 @@ class SnapshotProcessor(HDF5Container):
|
||||
else:
|
||||
tag_name = ""
|
||||
|
||||
self.filename = (
|
||||
self.path_out + "/postproc_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.cells_filename = (
|
||||
self.path_out + "/cells_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.parts_filename = (
|
||||
self.path_out + "/parts_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.pspec_filename = (
|
||||
self.path_out + "/pspec_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
if self.params.out.subfolder_ext:
|
||||
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.filaments_filename = (
|
||||
self.path_out + "/filaments_" + tag_name + format(num, "05") + ".pickle"
|
||||
f"{self.path_out}/{subfolder}filaments_{tag_name}{num:05}.h5"
|
||||
)
|
||||
|
||||
if not os.path.exists(self.path_out):
|
||||
@@ -507,7 +500,7 @@ class SnapshotProcessor(HDF5Container):
|
||||
if len(data[key] > 0):
|
||||
hdf5.create_array(
|
||||
"/data", key, data[key], "", createparents=True
|
||||
)
|
||||
)
|
||||
finally:
|
||||
hdf5.close()
|
||||
return data
|
||||
@@ -1374,7 +1367,6 @@ class SnapshotProcessor(HDF5Container):
|
||||
df = pd.read_csv(csv_name, header=None, names=header)
|
||||
return {key: df[key].values for key in df}
|
||||
|
||||
|
||||
def _pspec(self, **kwargs):
|
||||
outfile = self.pspec_filename
|
||||
pspec_new.pspec(repo=self.path, iouts=[self.num], outfile=outfile, **kwargs)
|
||||
|
||||
+5
-3
@@ -29,7 +29,7 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
selector=None,
|
||||
tag=None,
|
||||
unit_time=U.year,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Creates the basic structures needed for the outputs
|
||||
@@ -43,8 +43,10 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
else:
|
||||
tag_name = ""
|
||||
|
||||
self.filename = self.path_out + "/comp" + tag_name + ".h5"
|
||||
|
||||
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"
|
||||
# Select runs
|
||||
if selector is None:
|
||||
selector = RunSelector(
|
||||
|
||||
Reference in New Issue
Block a user