[turbox] bug of unmached runs
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
from .turbox import (
|
||||
get_pspec,
|
||||
get_pspec_slope,
|
||||
build_suite,
|
||||
build_turbox_data,
|
||||
apply_rule_pdf,
|
||||
span_resolution,
|
||||
)
|
||||
|
||||
+22
-24
@@ -91,7 +91,7 @@ def get_pspec_slope(pp, field: str, resol: int, plotdebug: bool = False):
|
||||
return results.slope, results.intercept, results.rvalue**2
|
||||
|
||||
|
||||
def build_suite(pl, redo=False, cs0=0.28834810480560674):
|
||||
def build_turbox_data(pl, redo=False, cs0=0.28834810480560674):
|
||||
"""Compute an array of parameter for each run in the Plotter pl
|
||||
|
||||
Parameters
|
||||
@@ -131,36 +131,34 @@ def build_suite(pl, redo=False, cs0=0.28834810480560674):
|
||||
pl.study.avg_time_sigma("y", overwrite_dep=False)
|
||||
pl.study.avg_time_sigma("z", overwrite_dep=False)
|
||||
pl.study.time(overwrite=True)
|
||||
|
||||
df["time"] = np.empty(len(pl.runs), dtype=list)
|
||||
time = pl.study.get_value("/series/time", unit=U.Myr)
|
||||
for run in pl.runs:
|
||||
time[run] = list(time[run].T[0])
|
||||
df["time"][run] = time[run]
|
||||
print(run, time[run])
|
||||
|
||||
sigma1d = []
|
||||
for ax in ["x", "y", "z"]:
|
||||
df[f"sigma_{ax}"] = np.array(
|
||||
list(
|
||||
map(
|
||||
lambda x: x.T[0],
|
||||
[
|
||||
pl.study.get_value(f"/series/time_sigma_{ax}", unit=U.km_s)[run]
|
||||
for run in pl.runs
|
||||
],
|
||||
)
|
||||
)
|
||||
)
|
||||
sigma_ax = pl.study.get_value(f"/series/time_sigma_{ax}", unit=U.km_s)
|
||||
for run in sigma_ax:
|
||||
sigma_ax[run] = sigma_ax[run].T[0]
|
||||
sigma1d.append(sigma_ax)
|
||||
|
||||
sigma3d = {}
|
||||
for run in pl.runs:
|
||||
sigma3d[run] = np.sum([sigma1d_i[run]**2 for sigma1d_i in sigma1d], axis=0)
|
||||
sigma3d[run] = list(map(np.sqrt, sigma3d[run]))
|
||||
|
||||
df["sigma_all"] = df["sigma_x"] ** 2 + df["sigma_y"] ** 2 + df["sigma_z"] ** 2
|
||||
df["sigma_all"] = list(map(np.sqrt, df["sigma_all"].values))
|
||||
df["Mach_all"] = list(map(lambda v: v / cs0, df["sigma_all"].values))
|
||||
df["time"] = list(
|
||||
map(
|
||||
lambda x: x.T[0],
|
||||
[pl.study.get_value("/series/time", unit=U.Myr)[run] for run in pl.runs],
|
||||
)
|
||||
)
|
||||
|
||||
df["sigma"] = list(map(lambda sig_list: np.mean(sig_list), df["sigma_all"].values))
|
||||
df["sigma"] = np.zeros(len(pl.runs))
|
||||
for run in pl.runs:
|
||||
df["sigma"][run] = np.mean(sigma3d[run])
|
||||
df["Mach"] = df["sigma"] / cs0
|
||||
df["turnover"] = (df["L"] * U.pc.express(U.km) / (2 * df["sigma"])) * U.s.express(
|
||||
U.Myr
|
||||
)
|
||||
|
||||
pl.turbox = df
|
||||
return df
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user