-
How to make an averaged radial profile of a disk? |
Beta Was this translation helpful? Give feedback.
Answered by
nvaytet
Feb 9, 2022
Replies: 1 comment
-
This example shows how to make a 1D profile of the mean gas density as a function of radius. import osyris
import numpy as np
import matplotlib.pyplot as plt
path = "osyrisdata/starformation"
data8 = osyris.Dataset(8, scale="au", path=path).load()
# Find center
ind = np.argmax(data8["hydro"]["density"])
center = data8["amr"]["xyz"][ind.values]
# Re-center cell coordinates according to origin
data8['amr']['xyz_new'] = data8['amr']['xyz'] - center
# Create figure
fig, ax = plt.subplots()
# Make scatter plot as radial profile
step = 100
osyris.scatter(data8['amr']['xyz_new'][::step],
data8['hydro']['density'][::step],
c='grey', edgecolors='None', loglog=True, ax=ax)
# Define range and number of bins
rmin = 1.5
rmax = 3.5
nr = 100
# Radial bin edges and centers
edges = np.linspace(rmin, rmax, nr+1)
midpoints = 0.5 * (edges[1:] + edges[:-1])
# Bin the data in radial bins
z0, _ = np.histogram(np.log10(data8['amr']['xyz_new'].norm.values), bins=edges)
z1, _ = np.histogram(np.log10(data8['amr']['xyz_new'].norm.values), bins=edges,
weights=data8['hydro']['density'].values)
rho_mean = z1/z0
#Overlay profile
ax.plot(10.0**midpoints, rho_mean, color='r', lw=3, label="Mean profile")
ax.legend() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nvaytet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example shows how to make a 1D profile of the mean gas density as a function of radius.