[postprocessor] generalize use of get_value
This commit is contained in:
+25
-27
@@ -714,8 +714,8 @@ class PostProcessor(HDF5Container):
|
|||||||
bins : int, number of bins
|
bins : int, number of bins
|
||||||
logbins : bool, if true, the bins will be logaritmically distributed
|
logbins : bool, if true, the bins will be logaritmically distributed
|
||||||
"""
|
"""
|
||||||
x = self.save.get_node(group + name_x + "_" + ax_los).read()
|
x = self.get_value(group + name_x + "_" + ax_los)
|
||||||
y = self.save.get_node(group + name_y + "_" + ax_los).read()
|
y = self.get_value(group + name_y + "_" + ax_los)
|
||||||
|
|
||||||
centers, values = mean_by_bins(x, y, bins, logbins)
|
centers, values = mean_by_bins(x, y, bins, logbins)
|
||||||
# return ({os.path.basename(name_x) : centers, os.path.basename(name_y) : y_mean},
|
# return ({os.path.basename(name_x) : centers, os.path.basename(name_y) : y_mean},
|
||||||
@@ -727,7 +727,7 @@ class PostProcessor(HDF5Container):
|
|||||||
Mean of Ek/Eb in rho bins
|
Mean of Ek/Eb in rho bins
|
||||||
"""
|
"""
|
||||||
self.load_cells()
|
self.load_cells()
|
||||||
mean_speed = self.save.get_node("/globals/mwa_speed").read()
|
mean_speed = self.get_value("/globals/mwa_speed")
|
||||||
mean_speed = mean_speed * self.info["unit_velocity"].express(U.km_s)
|
mean_speed = mean_speed * self.info["unit_velocity"].express(U.km_s)
|
||||||
vel_fluct = (self.cells)["vel"] * self.info["unit_velocity"].express(
|
vel_fluct = (self.cells)["vel"] * self.info["unit_velocity"].express(
|
||||||
U.km_s
|
U.km_s
|
||||||
@@ -774,7 +774,7 @@ class PostProcessor(HDF5Container):
|
|||||||
|
|
||||||
def cos_vfluct_B(self):
|
def cos_vfluct_B(self):
|
||||||
"return the cos of the angle between the magnetic field and the velocity fluctuation field"
|
"return the cos of the angle between the magnetic field and the velocity fluctuation field"
|
||||||
mean_speed = self.save.get_node("/globals/mwa_speed").read()
|
mean_speed = self.get_value("/globals/mwa_speed")
|
||||||
|
|
||||||
def getter_cos_vfluct_B(dset):
|
def getter_cos_vfluct_B(dset):
|
||||||
vel_fluct = dset["vel"] - mean_speed
|
vel_fluct = dset["vel"] - mean_speed
|
||||||
@@ -787,7 +787,7 @@ class PostProcessor(HDF5Container):
|
|||||||
return self._vol_pdf(getter_cos_vfluct_B)
|
return self._vol_pdf(getter_cos_vfluct_B)
|
||||||
|
|
||||||
def _mwa_sigma(self, axes=["x", "y", "z"]):
|
def _mwa_sigma(self, axes=["x", "y", "z"]):
|
||||||
mw_speed = self.save.get_node("/globals/mwa_speed").read()
|
mw_speed = self.get_value("/globals/mwa_speed")
|
||||||
|
|
||||||
if axes == ["x", "y", "z"]:
|
if axes == ["x", "y", "z"]:
|
||||||
|
|
||||||
@@ -852,7 +852,7 @@ class PostProcessor(HDF5Container):
|
|||||||
def _temperature(self, ax_los, z=0.0):
|
def _temperature(self, ax_los, z=0.0):
|
||||||
P_op = ScalarOperator(lambda dset: dset["P"], self._ro.info["unit_pressure"])
|
P_op = ScalarOperator(lambda dset: dset["P"], self._ro.info["unit_pressure"])
|
||||||
dmap_P = (slicing.SliceMap(self._amr, self._cam[ax_los], P_op, z=z)).map.T
|
dmap_P = (slicing.SliceMap(self._amr, self._cam[ax_los], P_op, z=z)).map.T
|
||||||
dmap_rho = self.save.get_node("/maps/slice_rho_{}".format(ax_los)).read()
|
dmap_rho = self.get_value("/maps/slice_rho_{}".format(ax_los))
|
||||||
return dmap_P / dmap_rho
|
return dmap_P / dmap_rho
|
||||||
|
|
||||||
def _levels(self, ax_los):
|
def _levels(self, ax_los):
|
||||||
@@ -865,14 +865,14 @@ class PostProcessor(HDF5Container):
|
|||||||
return datamap.map.T
|
return datamap.map.T
|
||||||
|
|
||||||
def _jeans(self, ax_los):
|
def _jeans(self, ax_los):
|
||||||
dmap_T = self.save.get_node("/maps/T_" + ax_los).read()
|
dmap_T = self.get_value("/maps/T_" + ax_los)
|
||||||
dmap_rho = self.save.get_node("/maps/slice_rho_" + ax_los).read()
|
dmap_rho = self.get_value("/maps/slice_rho_" + ax_los)
|
||||||
dmap_jeans = np.sqrt(np.pi * dmap_T / dmap_rho)
|
dmap_jeans = np.sqrt(np.pi * dmap_T / dmap_rho)
|
||||||
return dmap_jeans
|
return dmap_jeans
|
||||||
|
|
||||||
def _jeans_ratio(self, ax_los):
|
def _jeans_ratio(self, ax_los):
|
||||||
dmap_jeans = self.save.get_node("/maps/jeans_" + ax_los).read()
|
dmap_jeans = self.get_value("/maps/jeans_" + ax_los)
|
||||||
dmap_levels = self.save.get_node("/maps/levels_" + ax_los).read()
|
dmap_levels = self.get_value("/maps/levels_" + ax_los)
|
||||||
dmap_jeans_ratio = dmap_jeans * 2 ** (dmap_levels)
|
dmap_jeans_ratio = dmap_jeans * 2 ** (dmap_levels)
|
||||||
return dmap_jeans_ratio
|
return dmap_jeans_ratio
|
||||||
|
|
||||||
@@ -989,7 +989,7 @@ class PostProcessor(HDF5Container):
|
|||||||
return rad_bins
|
return rad_bins
|
||||||
|
|
||||||
def _radial_centers(self, ax_los="z"):
|
def _radial_centers(self, ax_los="z"):
|
||||||
radial_bins = self.save.get_node("/radial/radial_bins_" + ax_los).read()
|
radial_bins = self.get_value("/radial/radial_bins_" + ax_los)
|
||||||
bin_centers = 0.5 * (radial_bins[1:] + radial_bins[:-1])
|
bin_centers = 0.5 * (radial_bins[1:] + radial_bins[:-1])
|
||||||
return bin_centers
|
return bin_centers
|
||||||
|
|
||||||
@@ -1016,8 +1016,8 @@ class PostProcessor(HDF5Container):
|
|||||||
return rr
|
return rr
|
||||||
|
|
||||||
def _bins_on_map(self, ax_los="z"):
|
def _bins_on_map(self, ax_los="z"):
|
||||||
rad_bins = self.save.get_node("/radial/radial_bins_" + ax_los).read()
|
rad_bins = self.get_value("/radial/radial_bins_" + ax_los)
|
||||||
rr = self.save.get_node("/maps/rr_" + ax_los).read()
|
rr = self.get_value("/maps/rr_" + ax_los)
|
||||||
|
|
||||||
# Find appropriate bin for each coordinate set
|
# Find appropriate bin for each coordinate set
|
||||||
bins = np.zeros(rr.shape, dtype=int)
|
bins = np.zeros(rr.shape, dtype=int)
|
||||||
@@ -1080,7 +1080,7 @@ class PostProcessor(HDF5Container):
|
|||||||
|
|
||||||
def _fluct_map(self, name, ax_los="z", mass_weighted=False):
|
def _fluct_map(self, name, ax_los="z", mass_weighted=False):
|
||||||
|
|
||||||
dmap = self.save.get_node("/maps/" + name + "_" + ax_los).read()
|
dmap = self.get_value("/maps/" + name + "_" + ax_los)
|
||||||
if mass_weighted:
|
if mass_weighted:
|
||||||
avg_map = self.get_value("/maps/mwavg_map_" + name + "_" + ax_los)
|
avg_map = self.get_value("/maps/mwavg_map_" + name + "_" + ax_los)
|
||||||
else:
|
else:
|
||||||
@@ -1147,8 +1147,8 @@ class PostProcessor(HDF5Container):
|
|||||||
return np.stack([values, centers])
|
return np.stack([values, centers])
|
||||||
|
|
||||||
def _fit_pdf(self, name, ax_los="z"):
|
def _fit_pdf(self, name, ax_los="z"):
|
||||||
pdf = self.save.get_node("/hist/pdf_" + name + "_" + ax_los)
|
pdf = self.get_value("/hist/pdf_" + name + "_" + ax_los)
|
||||||
values, centers = pdf.read()
|
values, centers = pdf
|
||||||
mask_fit = (
|
mask_fit = (
|
||||||
(centers > self.pp_params.pdf.xmin_fit)
|
(centers > self.pp_params.pdf.xmin_fit)
|
||||||
& (centers < self.pp_params.pdf.xmax_fit)
|
& (centers < self.pp_params.pdf.xmax_fit)
|
||||||
@@ -1171,15 +1171,13 @@ class PostProcessor(HDF5Container):
|
|||||||
|
|
||||||
# Mean part
|
# Mean part
|
||||||
|
|
||||||
T_avg = self.save.get_node("/maps/avg_map_T_mwavg_z").read()
|
T_avg = self.get_value("/maps/avg_map_T_mwavg_z")
|
||||||
|
|
||||||
radial_bins = self.save.get_node("/radial/radial_bins_" + ax_los).read()
|
radial_bins = self.get_value("/radial/radial_bins_" + ax_los)
|
||||||
mean_bin_vr = self.save.get_node(
|
mean_bin_vr = self.get_value("/radial/rad_avg_" + "slice_velr" + "_" + ax_los)
|
||||||
"/radial/rad_avg_" + "slice_velr" + "_" + ax_los
|
mean_bin_vphi = self.get_value(
|
||||||
).read()
|
|
||||||
mean_bin_vphi = self.save.get_node(
|
|
||||||
"/radial/rad_avg_" + "slice_velphi" + "_" + ax_los
|
"/radial/rad_avg_" + "slice_velphi" + "_" + ax_los
|
||||||
).read()
|
)
|
||||||
mean_bin_vr = np.concatenate((mean_bin_vr, [mean_bin_vr[-1]]))
|
mean_bin_vr = np.concatenate((mean_bin_vr, [mean_bin_vr[-1]]))
|
||||||
mean_bin_vphi = np.concatenate((mean_bin_vphi, [mean_bin_vr[-1]]))
|
mean_bin_vphi = np.concatenate((mean_bin_vphi, [mean_bin_vr[-1]]))
|
||||||
|
|
||||||
@@ -1223,8 +1221,8 @@ class PostProcessor(HDF5Container):
|
|||||||
"Map of the gravitational contribution to the Shakura&Sunaev alpha parameter for disks"
|
"Map of the gravitational contribution to the Shakura&Sunaev alpha parameter for disks"
|
||||||
assert ax_los == "z"
|
assert ax_los == "z"
|
||||||
|
|
||||||
T_avg = self.save.get_node("/maps/avg_map_T_mwavg_z").read()
|
T_avg = self.get_value("/maps/avg_map_T_mwavg_z")
|
||||||
coldens = self.save.get_node("/maps/avg_map_coldens_z").read()
|
coldens = self.get_value("/maps/avg_map_coldens_z")
|
||||||
|
|
||||||
def getter_alpha_grav(dset):
|
def getter_alpha_grav(dset):
|
||||||
r2 = np.sum((self.lbox * self.oct_getter_pos_disk(dset)) ** 2, axis=2)
|
r2 = np.sum((self.lbox * self.oct_getter_pos_disk(dset)) ** 2, axis=2)
|
||||||
@@ -1284,7 +1282,7 @@ class PostProcessor(HDF5Container):
|
|||||||
def _pspec(self, **kwargs):
|
def _pspec(self, **kwargs):
|
||||||
outfile = self.pspec_filename
|
outfile = self.pspec_filename
|
||||||
pspec_new.pspec(repo=self.path, iouts=[self.num], outfile=outfile, **kwargs)
|
pspec_new.pspec(repo=self.path, iouts=[self.num], outfile=outfile, **kwargs)
|
||||||
return True
|
return np.array([self.pspec_filename])
|
||||||
|
|
||||||
def _particles(self):
|
def _particles(self):
|
||||||
"""Ensure particles are written in the hdf5 file"""
|
"""Ensure particles are written in the hdf5 file"""
|
||||||
@@ -1303,7 +1301,7 @@ class PostProcessor(HDF5Container):
|
|||||||
branch_thresh = self.pp_params.filaments.branch_thresh
|
branch_thresh = self.pp_params.filaments.branch_thresh
|
||||||
glob_thresh = self.pp_params.filaments.glob_thresh
|
glob_thresh = self.pp_params.filaments.glob_thresh
|
||||||
|
|
||||||
datamap = self.save.get_node("/maps/" + datamap_name + "_z").read()
|
datamap = self.get_value("/maps/" + datamap_name + "_z")
|
||||||
shape = datamap.shape
|
shape = datamap.shape
|
||||||
x = np.arange(shape[0]) - shape[0] / 2
|
x = np.arange(shape[0]) - shape[0] / 2
|
||||||
y = np.arange(shape[1]) - shape[1] / 2
|
y = np.arange(shape[1]) - shape[1] / 2
|
||||||
|
|||||||
Reference in New Issue
Block a user