<jupyter_start><jupyter_text>Edot0=2B^2 Om0^2 R^6/3/c^3tau=3*I*c^3/c/B^2/R^6/Om0^2<jupyter_code>(1*u.G).to('g/(C*s)')
BB = 
coords.Gal
(1.4*u.M_sun).to('g')
RR = 1e6
II = 1e45
# BB = 0.17e12
# Mass = 2.7837738e33
omega = np.sqrt((2*finalb.tc*gp.yr_to_sec*finalb.l_f)/II)
BB = np.sqrt((3*gp.c_speed**3*II)/(4*RR**6*finalb.tc*gp.yr_to_sec*omega**2))
# omega = np.sqrt((3*gp.c_speed**3*II)/(2*RR**6*BB**2*(final.t0*gp.yr_to_sec)))
p0 = 2*np.pi/omega
pdot = p0/(2*finalb.tc*gp.yr_to_sec) 

final['p0'] = p0
final['pdot'] = pdot
fauch_p = np.loadtxt('../Computed_Population_20200410/faucher_p.txt').T
fauch_b = np.loadtxt('../Computed_Population_20200410/fauch_b.txt').T
plot_loghist(p0, 19, 'Periods Distribution of pulsars', 'Period [s]')
# plt.xlim(1e-3, 3)
plt.semilogx(fauch_p[0], fauch_p[1], drawstyle='steps-mid', lw=3, label='From Faucher-Giguere')
#plot_loghist(distr_p0, 15, '', '')
# plt.xlim(1e-3, 3)

plt.legend
# plt.savefig('PeriodDistr_comparison.png',dpi=100, bbox_inches='tight')
plot_loghist(pdot, 20, 'Period Derivatives Distribution of pulsars', '$\dotP$ [s s$^{-1}$]')
plt.savefig('PeriodDerivDistr.png',dpi=100, bbox_inches='tight')
plot_loghist(BB, 12, 'Surface Magnetic Field Distribution', '$B$ [G]')
plt.semilogx(fauch_b[0], fauch_b[1], drawstyle='steps-mid', lw=3, label='From Faucher-Giguere')

plt.savefig('SurfaceMagField_comparison.png',dpi=100, bbox_inches='tight')
len(fauch_b[0])
xxx = np.linspace(0.01, 20)
yyy = xxx/(200e3*gp.yr_to_sec)
yyy2 = xxx/(200e2*gp.yr_to_sec)
yyy1 = xxx/(200e1*gp.yr_to_sec)
yyy3 = xxx/(200e4*gp.yr_to_sec)

plt.loglog()
plt.scatter(final.p0, final.pdot, c=final.age, s=10)
plt.plot(xxx,yyy, '--k', alpha=0.5, zorder=-10, lw=1)
plt.plot(xxx,yyy2, '--k', alpha=0.5, zorder=-10, lw=1)
plt.plot(xxx,yyy1, '--k', alpha=0.5, zorder=-10, lw=1)
plt.plot(xxx,yyy3, '--k', alpha=0.5, zorder=-10, lw=1)
plt.text(0.02, 6e-13, '1 kyr', rotation=20, alpha=0.5,)
plt.text(0.02, 5e-14, '10 kyr', rotation=20, alpha=0.5,)
plt.text(0.02, 5e-15, '100 kyr', rotation=20, alpha=0.5,)
plt.text(0.02, 4.5e-16, '1 Myr', rotation=20, alpha=0.5,)

plt.grid()
plt.xlabel(r'Period [$s$]')
plt.ylabel(r'Period Derivative [$s\;\;s^{-1}$]')
plt.title('$P - \dotP$ diagram')
plt.xlim(0.01, 20)

plt.ylim(1e-17, 2e-11)
plt.tight_layout()
plt.savefig('PPdiagram.png',dpi=100, bbox_inches='tight')
plot_loghist(BB, 20, '', '')
(1*u.G).to('g/(C*s)')
final.t0<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup