Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_bin_array_unweighted():
data = np.array([0,1,2, 3,3,3, 3,3,4])
binsize = 3
bindata = ms.bin_array(data, binsize)
np.testing.assert_allclose(bindata,
np.array([1.0, 3.0, np.mean([3,3,4])]))
def test_bin_array_weighted():
data = np.array([0,1,2, 3,3,3, 3,3,4])
unc = np.array([3,1,1, 1,2,3, 2,2,4])
binsize = 3
bindata, binstd = ms.bin_array(data, binsize, unc)
np.testing.assert_allclose(bindata,
np.array([1.42105263, 3.0, 3.11111111]))
np.testing.assert_allclose(binstd,
np.array([0.68824720, 0.85714286, 1.33333333]))
fignum: Integer
The figure number.
savefile: Boolean
If not None, name of file to save the plot.
fmt: String
Format of the plotted markers.
Returns
-------
ax: matplotlib.axes.Axes
Axes instance containing the marginal posterior distributions.
"""
# Bin down array:
binsize = int((np.size(data)-1)/nbins + 1)
binindp = ms.bin_array(indparams, binsize)
binmodel = ms.bin_array(model, binsize)
bindata, binuncert = ms.bin_array(data, binsize, uncert)
fs = 12 # Font-size
plt.figure(fignum, figsize=(8,6))
plt.clf()
# Residuals:
rax = plt.axes([0.15, 0.1, 0.8, 0.2])
rax.errorbar(binindp, bindata-binmodel, binuncert, fmt='ko', ms=4)
rax.plot([indparams[0], indparams[-1]], [0,0],'k:',lw=1.5)
rax.tick_params(labelsize=fs-1)
rax.set_xlabel("x", fontsize=fs)
rax.set_ylabel('Residuals', fontsize=fs)
# Data and Model:
ax = plt.axes([0.15, 0.35, 0.8, 0.55])
The figure number.
savefile: Boolean
If not None, name of file to save the plot.
fmt: String
Format of the plotted markers.
Returns
-------
ax: matplotlib.axes.Axes
Axes instance containing the marginal posterior distributions.
"""
# Bin down array:
binsize = int((np.size(data)-1)/nbins + 1)
binindp = ms.bin_array(indparams, binsize)
binmodel = ms.bin_array(model, binsize)
bindata, binuncert = ms.bin_array(data, binsize, uncert)
fs = 12 # Font-size
plt.figure(fignum, figsize=(8,6))
plt.clf()
# Residuals:
rax = plt.axes([0.15, 0.1, 0.8, 0.2])
rax.errorbar(binindp, bindata-binmodel, binuncert, fmt='ko', ms=4)
rax.plot([indparams[0], indparams[-1]], [0,0],'k:',lw=1.5)
rax.tick_params(labelsize=fs-1)
rax.set_xlabel("x", fontsize=fs)
rax.set_ylabel('Residuals', fontsize=fs)
# Data and Model:
ax = plt.axes([0.15, 0.35, 0.8, 0.55])
ax.errorbar(binindp, bindata, binuncert, fmt='ko', ms=4, label='Binned Data')
Number of bins in the output plot.
fignum: Integer
The figure number.
savefile: Boolean
If not None, name of file to save the plot.
fmt: String
Format of the plotted markers.
Returns
-------
ax: matplotlib.axes.Axes
Axes instance containing the marginal posterior distributions.
"""
# Bin down array:
binsize = int((np.size(data)-1)/nbins + 1)
binindp = ms.bin_array(indparams, binsize)
binmodel = ms.bin_array(model, binsize)
bindata, binuncert = ms.bin_array(data, binsize, uncert)
fs = 12 # Font-size
plt.figure(fignum, figsize=(8,6))
plt.clf()
# Residuals:
rax = plt.axes([0.15, 0.1, 0.8, 0.2])
rax.errorbar(binindp, bindata-binmodel, binuncert, fmt='ko', ms=4)
rax.plot([indparams[0], indparams[-1]], [0,0],'k:',lw=1.5)
rax.tick_params(labelsize=fs-1)
rax.set_xlabel("x", fontsize=fs)
rax.set_ylabel('Residuals', fontsize=fs)
# Data and Model: