add astrophysix support, fix labels
This commit is contained in:
+54
-17
@@ -149,7 +149,15 @@ class PostProcessor(HDF5Container):
|
||||
|
||||
cells_loaded = False
|
||||
|
||||
def __init__(self, path=None, num=None, path_out=None, pp_params=None, tag=None):
|
||||
def __init__(
|
||||
self,
|
||||
path=None,
|
||||
num=None,
|
||||
path_out=None,
|
||||
pp_params=None,
|
||||
tag=None,
|
||||
unit_time=cst.year,
|
||||
):
|
||||
"""
|
||||
Creates the basic structures needed for the outputs
|
||||
"""
|
||||
@@ -170,6 +178,14 @@ class PostProcessor(HDF5Container):
|
||||
self.path_out + "/cells_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.pspec_filename = (
|
||||
self.path_out + "/pspec_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.filaments_filename = (
|
||||
self.path_out + "/filaments_" + tag_name + format(num, "05") + ".pickle"
|
||||
)
|
||||
|
||||
if not os.path.exists(self.path_out):
|
||||
os.makedirs(self.path_out)
|
||||
|
||||
@@ -213,7 +229,7 @@ class PostProcessor(HDF5Container):
|
||||
if not self.pp_params.pymses.multiprocessing:
|
||||
self._rt.disable_multiprocessing()
|
||||
|
||||
# Set the extend of the image
|
||||
# Set the extent of the image
|
||||
self._radius = 0.5 / self.pp_params.pymses.zoom
|
||||
self.lbox = self.info["boxlen"]
|
||||
|
||||
@@ -273,12 +289,23 @@ class PostProcessor(HDF5Container):
|
||||
|
||||
self.log_id = "[{}, {}] ".format(self.run, self.num)
|
||||
|
||||
if os.path.exists(self.path_out + "/filaments.pickle"):
|
||||
with open(self.path_out + "/filaments.pickle", "rb") as f:
|
||||
if os.path.exists(self.filaments_filename):
|
||||
with open(self.filaments_filename, "rb") as f:
|
||||
self.fil = pickle.load(f)
|
||||
else:
|
||||
self.fil = None
|
||||
|
||||
self.snapshot = Snapshot(
|
||||
name=str(self.num),
|
||||
description="",
|
||||
time=(
|
||||
self.info["time"] * self.info["unit_time"].express(unit_time),
|
||||
unit_time,
|
||||
),
|
||||
directory_path=self.path,
|
||||
data_reference="OUTPUT_{}".format(self.num),
|
||||
)
|
||||
|
||||
self.def_rules()
|
||||
|
||||
def load_cells(self):
|
||||
@@ -964,12 +991,22 @@ class PostProcessor(HDF5Container):
|
||||
)
|
||||
|
||||
bins = np.zeros(r.shape, dtype=int)
|
||||
for r0 in radial_bins[1:]:
|
||||
for r0 in radial_bins[1:-1]:
|
||||
bins = bins + (r >= r0).astype(int)
|
||||
|
||||
vr_mean = mean_bin_vr[bins]
|
||||
vphi_mean = mean_bin_vphi[bins]
|
||||
|
||||
# use linear interpolation
|
||||
# v = ((r[i+1] - r)v[i] + (r - r[i])v[i + 1]) / (r[i+1] - r[i])
|
||||
vr_mean = (radial_bins[bins + 1] - r) * vr_mean
|
||||
vr_mean = vr_mean + (r - radial_bins[bins]) * mean_bin_vr[bins + 1]
|
||||
vr_mean = vr_mean / (radial_bins[bins + 1] - radial_bins[bins])
|
||||
|
||||
vphi_mean = (radial_bins[bins + 1] - r) * vphi_mean
|
||||
vphi_mean = vphi_mean + (r - radial_bins[bins]) * mean_bin_vphi[bins + 1]
|
||||
vphi_mean = vphi_mean / (radial_bins[bins + 1] - radial_bins[bins])
|
||||
|
||||
vr = self.oct_getter_vr(dset)
|
||||
vphi = self.oct_getter_vphi(dset)
|
||||
alpha = (vphi - vphi_mean) * (vr - vr_mean)
|
||||
@@ -1055,7 +1092,7 @@ class PostProcessor(HDF5Container):
|
||||
return sinks_dict
|
||||
|
||||
def _pspec(self):
|
||||
outfile = self.path_out + "/pspec.h5"
|
||||
outfile = self.pspec_filename
|
||||
pspec_new.pspec(repo=self.path, iouts=[self.num], outfile=outfile)
|
||||
return True
|
||||
|
||||
@@ -1086,9 +1123,10 @@ class PostProcessor(HDF5Container):
|
||||
self.fil.create_mask(
|
||||
verbose=verbose,
|
||||
smooth_size=1 * u.pix,
|
||||
adapt_thresh=2 * u.pix,
|
||||
adapt_thresh=4 * u.pix,
|
||||
size_thresh=size_thresh * u.pix ** 2,
|
||||
glob_thresh=glob_thresh,
|
||||
fill_hole_size=0.1 * u.pix ** 2,
|
||||
)
|
||||
self.fil.medskel(verbose=verbose)
|
||||
self.fil.analyze_skeletons(
|
||||
@@ -1099,8 +1137,7 @@ class PostProcessor(HDF5Container):
|
||||
self.fil.exec_rht()
|
||||
self.fil.find_widths()
|
||||
|
||||
outfile = self.path_out + "/filaments.pickle"
|
||||
with open(outfile, "wb") as f:
|
||||
with open(self.filaments_filename, "wb") as f:
|
||||
pickle.dump(self.fil, f, pickle.HIGHEST_PROTOCOL)
|
||||
return True
|
||||
|
||||
@@ -1121,7 +1158,7 @@ class PostProcessor(HDF5Container):
|
||||
|
||||
def _filaments_forces(self):
|
||||
"""
|
||||
Compute forces within a filament (for disks)
|
||||
Compute forces within a filament (for disks), within the slice at z=0
|
||||
"""
|
||||
|
||||
GM = self.G * self.pp_params.disk.mass_star # Mass parameter
|
||||
@@ -1134,11 +1171,11 @@ class PostProcessor(HDF5Container):
|
||||
i_center, j_center = self._filaments_center()
|
||||
|
||||
# Get slices and projections at z = 0
|
||||
vphi = self.save.get_node("/maps/slice_velphi_z").read()
|
||||
gr = self.save.get_node("/maps/slice_gr_z").read()
|
||||
Pz = self.save.get_node("/maps/slice_P_z").read()
|
||||
coldens = self.save.get_node("/maps/coldens_z").read()
|
||||
vr = self.save.get_node("/maps/slice_velr_z").read()
|
||||
vphi = self.get_value("/maps/slice_velphi_z")
|
||||
gr = self.get_value("/maps/slice_gr_z")
|
||||
Pz = self.get_value("/maps/slice_P_z")
|
||||
rho = self.get_value("/maps/slice_rho_z")
|
||||
vr = self.get_value("/maps/slice_velr_z")
|
||||
|
||||
# Get coordinates
|
||||
im_extent = np.array(self.save.root.maps._v_attrs.im_extent) * self.lbox
|
||||
@@ -1167,7 +1204,7 @@ class PostProcessor(HDF5Container):
|
||||
# Thermal support
|
||||
GPx, GPy = np.gradient(Pz)
|
||||
gradPr = (xx * GPx + yy * GPy) / rr
|
||||
fP = gradPr / coldens
|
||||
fP = gradPr / rho
|
||||
|
||||
# Gravitational field
|
||||
e2 = (1.0 / 512) ** 2
|
||||
@@ -1371,7 +1408,7 @@ class PostProcessor(HDF5Container):
|
||||
"slice_velphi": "z",
|
||||
"slice_gr": "z",
|
||||
"slice_P": "z",
|
||||
"coldens": "z",
|
||||
"slice_rho": "z",
|
||||
"slice_velr": "z",
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user