<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Read in the pickle file
Step1:  Get statistics of binned quantities
Step2:  Create a sample of sn with z, mu, mu_err
Step3:  These show
<ASSISTANT_TASK:>
Python Code:
mockDataFile = os.path.join(isotropy.example_data_dir, 'snFits.p.gz')
sampleData, totalSN = isotropy.read_mockDataPickle(mockDataFile)
sampleData.head()
# Total number of SN in the simulation (before we threw away bad points)
totalSN
sampleData['mu_err'] = sampleData.mu_var.apply(np.sqrt)
sampleData.head()
# mu_err > 5.0 is pretty useless, throw them 
sampleData = sampleData.query('mu_err < 5.0')
Explanation: Read in the pickle file
End of explanation
df = isotropy.binnedDescStat(sampleData)
# removes the nans
df = df.dropna()
df
# Now create samples of size numSN = 50000
Explanation: Get statistics of binned quantities
End of explanation
numSN = 50000
dfmu = isotropy.drawSamples(df, numSN, totalSN, np.random.RandomState(0))
dfmu.head()
fig, ax = plt.subplots(1,3)
_ = ax[0].hist(dfmu.z, bins=np.arange(0., 1.4, 0.1), histtype='step')
_ = ax[1].hist(dfmu.mu_err, bins=20, histtype='step')
_ = ax[2].errorbar(dfmu.z, dfmu.mu, yerr=dfmu.mu_err.values, fmt='o')
_ = ax[2].plot(dfmu.z, cosmo.distmod(dfmu.z), 'k-', lw=2.)
ax[0].set_xlabel('x')
ax[0].set_ylabel('Num')
ax[1].set_xlabel('mu_err')
ax[2].set_xlabel('z')
ax[2].set_ylabel('mu')
Explanation: Create a sample of sn with z, mu, mu_err
End of explanation
from utils import plotutils as pl
fig, ax0, ax1 = pl.settwopanel(setdifflimits=None)
ax0.errorbar(dfmu.z, dfmu.mu, yerr=dfmu.mu_err.values, fmt='.')
ax0.plot(dfmu.z, cosmo.distmod(dfmu.z), 'k-', lw=2.)
ax0.set_xscale('log')
ax1.errorbar(dfmu.z, dfmu.mu - cosmo.distmod(dfmu.z).value, yerr=dfmu.mu_err.values, fmt='o')
ax1.set_xscale('log')
ax0.set_xlim(0., 1.5)
ax1.set_xlim(0., 1.5)
Explanation: These show:
    - z histogram in the first panel
    - mu_err histogram in the second plot
    - hubble diagram in the 3rd plot, with the line showing the true cosmology values
The distribution of mu_err in the 2nd panel is a problem because it is going below 0. Surely not a good repesentation!
End of explanation
<END_TASK>