Add possibility to launch an external rule
+ some plotter improvements + some namelist improvements + add datacube extraction
This commit is contained in:
+32
-25
@@ -63,10 +63,13 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
self.runs = selector.runs
|
||||
self.nums = selector.nums
|
||||
|
||||
|
||||
run0 = self.runs[0]
|
||||
self.info = selector.info[run0][self.nums[run0][0]]
|
||||
self.namelist = selector.namelist
|
||||
|
||||
# Get postprocesor objets for each run and infos on them
|
||||
self.snaps = {}
|
||||
self.info = {}
|
||||
|
||||
for run in self.runs:
|
||||
path_run = path + "/" + run
|
||||
path_out_run = self.path_out + "/" + run
|
||||
@@ -82,9 +85,7 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
unit_time=unit_time,
|
||||
)
|
||||
|
||||
run0 = self.runs[0]
|
||||
self.info = selector.info[run0][self.nums[run0][0]]
|
||||
self.namelist = selector.namelist
|
||||
|
||||
|
||||
# Save namelist and logs
|
||||
if self.params.out.copy_info:
|
||||
@@ -234,8 +235,19 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
value = snap.get_value(node_name)
|
||||
return value
|
||||
|
||||
def get_nml(self, nml_key, run):
|
||||
return self.namelist[run][nml_key]
|
||||
def get_nml(self, nml_key=None, run=None):
|
||||
if run is not None:
|
||||
if nml_key is not None:
|
||||
return self.namelist[run][nml_key]
|
||||
else:
|
||||
return self.namelist[run]
|
||||
else:
|
||||
if nml_key is not None:
|
||||
return {run : self.namelist[run][nml_key] for run in self.runs}
|
||||
else:
|
||||
return self.namelist
|
||||
|
||||
|
||||
|
||||
def get_pdf_slope(self, name, run, num):
|
||||
snap = self.snaps[run][num]
|
||||
@@ -464,15 +476,19 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
time_gas = self.get_value("/series/coarse_step_from_log/time")
|
||||
mass_gas = self.get_value("/series/coarse_step_from_log/mcons")
|
||||
mass_sink = self.get_value("/series/sinks_from_log/mass_sink")
|
||||
time_sink = self.get_value("/series/sinks_from_log/time")
|
||||
|
||||
total_mass = dict()
|
||||
for run in self.runs:
|
||||
|
||||
if time_sink[run][-1] > time_gas[run][-1]:
|
||||
time_sink[run] = time_sink[run][:-1]
|
||||
mass_sink[run] = mass_sink[run][:-1]
|
||||
# A bit specific ... needs to be generalized (TODO)
|
||||
info = self.snaps[run][self.nums[run][0]].info
|
||||
surface = (info["unit_length"].express(U.pc)) ** 2
|
||||
m0 = self.get_coldens0(run) * surface # Initial mass in Msun
|
||||
offset = time_gas[run].size - mass_sink[run].size
|
||||
offset = time_gas[run].size - time_sink[run].size
|
||||
mass_gas[run] = m0 + m0*mass_gas[run] # convert in Msun
|
||||
total_mass[run] = mass_gas[run].copy()
|
||||
total_mass[run][offset:] = mass_gas[run][offset:] + mass_sink[run] # re add sink_mass
|
||||
@@ -574,7 +590,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
name = "time_" + glob_name
|
||||
|
||||
self.rules[name] = Rule(
|
||||
self,
|
||||
partial(
|
||||
self._time_series,
|
||||
partial(
|
||||
@@ -627,7 +642,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
)
|
||||
|
||||
self.rules[name] = Rule(
|
||||
self,
|
||||
fn,
|
||||
group="/comp",
|
||||
unit=units,
|
||||
@@ -640,7 +654,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
self.rules = {
|
||||
# Read from log
|
||||
"sinks_from_log": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._from_log,
|
||||
["time", "mass_sink", "nb_sink"],
|
||||
@@ -655,7 +668,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
},
|
||||
),
|
||||
"issfr": Rule(
|
||||
self,
|
||||
self._ssfr_from_mass_sink,
|
||||
group="/series/sinks_from_log",
|
||||
unit=U.ssfr,
|
||||
@@ -663,7 +675,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
dependencies=["sinks_from_log"],
|
||||
),
|
||||
"ssm": Rule(
|
||||
self,
|
||||
self._surfacic_sink_mass,
|
||||
group="/series/sinks_from_log",
|
||||
unit=U.Msun / U.pc ** 2,
|
||||
@@ -671,7 +682,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
dependencies=["sinks_from_log"],
|
||||
),
|
||||
"sfr_from_log": Rule(
|
||||
self,
|
||||
partial(self._from_log, ["time", "sfr"], self._extract_sfr_from_log),
|
||||
group="/series",
|
||||
unit={"time": U.year, "sfr": U.ssfr},
|
||||
@@ -681,7 +691,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
},
|
||||
),
|
||||
"rms_from_log": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._from_log,
|
||||
["time", "dt", "turb_rms", "turb_energy"],
|
||||
@@ -706,7 +715,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
},
|
||||
),
|
||||
"coarse_step_from_log": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._from_log,
|
||||
[
|
||||
@@ -738,7 +746,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
},
|
||||
),
|
||||
"fine_step_from_log": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._from_log,
|
||||
["time", "fine_step", "dt", "a", "mem_cells", "mem_parts"],
|
||||
@@ -755,7 +762,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
},
|
||||
),
|
||||
"stellar_from_log": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._from_log,
|
||||
["time", "mass", "lifetime", "id"],
|
||||
@@ -770,7 +776,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
},
|
||||
),
|
||||
"turb_power": Rule(
|
||||
self,
|
||||
self._turb_power,
|
||||
group="/series/rms_from_log",
|
||||
unit={
|
||||
@@ -784,7 +789,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
),
|
||||
# Read from outputs
|
||||
"time": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._time_series, partial(self.get_global, "/globals/time_num")
|
||||
),
|
||||
@@ -793,7 +797,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
dependencies=["time_num"],
|
||||
),
|
||||
"time_rho_prof": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._time_series, partial(self.get_snap_value, "/profile/rho_prof")
|
||||
),
|
||||
@@ -801,15 +804,20 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
dependencies={"time": None, "rho_prof": "__parent__"},
|
||||
),
|
||||
"time_coldens_pdf": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._time_series, partial(self.get_snap_value, "/hist/pdf_coldens")
|
||||
),
|
||||
group="/series",
|
||||
dependencies={"time": None, "pdf_coldens": "__parent__"},
|
||||
),
|
||||
"time_rho_pdf": Rule(
|
||||
partial(
|
||||
self._time_series, partial(self.get_snap_value, "/hist/rho_pdf")
|
||||
),
|
||||
group="/series",
|
||||
dependencies={"time": None},
|
||||
),
|
||||
"time_pdf_slope_coldens": Rule(
|
||||
self,
|
||||
partial(
|
||||
self._time_series,
|
||||
partial(
|
||||
@@ -822,7 +830,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
dependencies={"time": None, "fit_pdf_coldens": "z"},
|
||||
),
|
||||
"sbeta_onavg": Rule(
|
||||
self,
|
||||
partial(self._sbeta_onavg),
|
||||
group="/comp",
|
||||
dependencies={
|
||||
@@ -832,7 +839,6 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
),
|
||||
# namelist
|
||||
"nml": Rule(
|
||||
self,
|
||||
lambda nml_key: self._compare(
|
||||
partial(self.get_nml, nml_key), use_num=False
|
||||
),
|
||||
@@ -854,6 +860,7 @@ class StudyProcessor(Aggregator, HDF5Container):
|
||||
"turb_power",
|
||||
"time_rho_prof",
|
||||
"time_coldens_pdf",
|
||||
"time_rho_pdf"
|
||||
]:
|
||||
self._gen_rule_avg(name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user