예제 #1
0
# Clip out crab, which has way too large TS_var
xmin = 0
xmax = np.max(ts_var[ts_var<200]) + 10

#nbins = 30
nbins = 20
bins = np.linspace(xmin, xmax, nbins + 1)

TS_CUTOFF=4
print 'num significiant',sum(ts_point>=TS_CUTOFF)
print 'num not significiant',sum(ts_point<TS_CUTOFF)
axes.hist(ts_var[ts_point>=TS_CUTOFF], bins=bins, histtype='step', color='black')
axes.hist(ts_var[ts_point<TS_CUTOFF], bins=bins, histtype='step', color='blue')



lower,upper=list(axes.xaxis.get_view_interval())
x=np.linspace(lower,upper,10000)
months=36
chidist = stats.chi2(months-1)
y=chidist.pdf(x)
# Normalize the distribution
y*=sum(ts_point>=TS_CUTOFF)*(bins[1]-bins[0])
axes.plot(x,y, dashes=[5,2], color='red' if not bw else 'black')

axes.set_xlabel(r'$\mathrm{TS}_\mathrm{var}$')
axes.set_ylabel(r'Number')

pubplot.save(join(outdir,'variability'))
plot_stat(((classification=='M')|(classification=='M*'))&(luminosity_significant==False), color=blue, marker='s', markerfacecolor='none', markersize=5, markeredgecolor=blue, zorder=6, elinewidth=1.5, capsize=0)

assert np.all(luminosity_significant[classification=='U']==True)
plot_sys(classification=='W', color=black, marker='None', zorder=7-0.1, capsize=capsize, elinewidth=0.25)
plot_stat(classification=='W', color=red, marker='*', markersize=8, 
          markerfacecolor=red, markeredgecolor=red, zorder=7, capsize=capsize, elinewidth=1.5)

for psr_name,print_name,kwargs in [
    ['J0534+2200', 'Crab Nebula', dict(horizontalalignment='right', verticalalignment='bottom', xytext=(10,20), textcoords='offset points')],
    ['J0835-4510', 'Vela X', dict(horizontalalignment='middle', verticalalignment='top', xytext=(-25,-10), textcoords='offset points')],
    ['J1513-5908', 'MSH 15-52', dict(horizontalalignment='left', verticalalignment='bottom', xytext=(10,0), textcoords='offset points')],
    ['J0205+6449', 'J0205', dict(horizontalalignment='left', verticalalignment='bottom', xytext=(8,-5), textcoords='offset points')],
]:
    cut=np.where(psrlist==psr_name)[0][0]
    axes.annotate(print_name,
                  xy=[Edot[cut], luminosity[cut]], xycoords='data',
                  color=red, 
                  zorder=8,
                  **kwargs)


axes.set_xlim(1e33,1e39)
axes.set_ylim(1e31,1e37)

axes.set_xlabel('$\dot E$ [erg s$^{-1}$]')
axes.set_ylabel(r'$L_\mathrm{off\,peak}$ [erg s$^{-1}$]')

fig.tight_layout()

pubplot.save('off_peak_luminosity_vs_edot')
예제 #3
0
histogram(axes, 
          data=[2*(ll_gaussian-ll_point),
                2*(ll_disk-ll_point)],
          color=['red' if not bw else '0.6','black'])
axes.set_xlabel(r'$\mathrm{TS}_\mathrm{ext}$')
prop = matplotlib.font_manager.FontProperties(size=10)
axes.set_ylim(0,100)
axes.legend([Line2D([0],[0],color='black'),Line2D([0],[0],color='red' if not bw else '0.6')],
            ['disk','Gaussian'],
            prop=prop)


axes=fig.add_subplot(223)
histogram(axes, 
          2*(ll_elliptical_disk-ll_disk), 
          color='black')
axes.set_xlabel(r'$\mathrm{TS}_\mathrm{elliptical\ disk}-\mathrm{TS}_\mathrm{disk}$')

axes=fig.add_subplot(224)
ts_inc = 2*(ll_elliptical_ring-ll_elliptical_disk)
ts_inc = np.where(ts_inc > 0, ts_inc, 0)
histogram(axes, ts_inc,
         color='black')
axes.set_xlabel(r'$\mathrm{TS}_\mathrm{elliptical\ ring}-\mathrm{TS}_\mathrm{elliptical\ disk}$')

fig.tight_layout()

label_axes(fig)

save('ts_comparison_w44sim')
red = 'red' if not bw else 'grey'

def plot(cut, **kwargs):
    axes.plot(age[cut],Edot[cut]/distance[cut]**2,'.', **kwargs)

plot(has_distance & (classification=='Non_Detected'),color='lightgrey', markersize=10)
plot(has_distance & (classification=='Upper_Limit')|(classification=='Confused'), color='black', markersize=10)
plot(has_distance & (classification=='Pulsar'), color=blue, markersize=5, marker='s', markeredgecolor=blue)
plot(has_distance & (classification=='PWN'), color=red, markersize=10, marker='*', markeredgecolor=red)

axes.set_xlabel('Age [yr]')
axes.set_ylabel('$\dot E/d^2$ [erg s$^{-1}$ kpc$^{-2}$]')


axes.set_xlim(1e2, 1e11)

for psr_name,print_name,kwargs in [
    ['J0534+2200', 'Crab Nebula', dict(horizontalalignment='center', verticalalignment='bottom', xytext=(0,10), textcoords='offset points')],
    ['J0835-4510', 'Vela X', dict(horizontalalignment='left', verticalalignment='middle', xytext=(5,0), textcoords='offset points')],
    ['J1513-5908', 'MSH 15-52', dict(horizontalalignment='right', verticalalignment='middle', xytext=(15,10), textcoords='offset points')],
    ['J0205+6449', 'J0205', dict(horizontalalignment='center', verticalalignment='bottom', xytext=(5,15), textcoords='offset points')],
    ['J1357-6429', 'HESS J1356', dict(horizontalalignment='right', verticalalignment='top', xytext=(5,-10), textcoords='offset points')],
]:
    cut=np.where(psrlist==psr_name)[0][0]
    axes.annotate(print_name,
                  xy=[age[cut],Edot[cut]/distance[cut]**2], xycoords='data',
                  color=red, **kwargs)

fig.tight_layout()
pubplot.save('off_peak_edot_d2_vs_age')
예제 #5
0
#axes=fig.add_subplot(323)
axes=fig.add_subplot(223)
plot(axes,'r68')
axes.set_xlabel('r68 (deg)')

#axes=fig.add_subplot(324)
#plot(axes,'eccentricity')
#axes.set_xlabel('Eccentricity')


#axes=fig.add_subplot(325)
#plot(axes,'angle')
#axes.set_xlabel('Ellipse Angle (deg)')


#axes=fig.add_subplot(326)
#plot(axes,'fraction')
#axes.set_xlabel('Ring Fraction')


prop = matplotlib.font_manager.FontProperties(size=6)
plots=[Line2D([0],[0],color=i) for i in all_colors]
axes.legend(reversed(plots),reversed(print_names), prop=prop, loc=1,
            borderaxespad=1)

fig.tight_layout()

label_axes(fig, borderpad=0.2)

save('bias_w44sim')
예제 #6
0
                           nbins=nbins,
                           repeat_phase=False,
                           data_kwargs=dict(color='black', linewidth=0.5),
                           offset=offset,
                           axes=axes)


    axes.set_ylim(ymax=axes.get_ylim()[1]*1.2)

    # from http://matplotlib.sourceforge.net/faq/howto_faq.html#align-my-ylabels-across-multiple-subplots
    axes.yaxis.set_label_coords(-0.25,0.5)

    y,x = np.unravel_index(i, (nrows,ncols))
    if x != 0:
        axes.set_ylabel('')
    if y != nrows-1:
        axes.set_xlabel('')

    label_axes(fig)

# if there are not plots alow all of the bottom, overlay
# legend on higher up plots
i=len(cutoff_candidates)
while i < nrows*ncols:
    axes=fig.add_subplot(nrows,ncols,i+1 - ncols)
    axes.set_xlabel('Pulsar Phase')
    i+=1


pubplot.save(join(outdir,'off_peak_phase'))
예제 #7
0
    r = classifier.get_results(pwn)
    spectrum = r['spectrum']
    sed = r['sed_4bpd']

    s = SED(sed)
    s.plot_points(axes=axes, zorder=2.1)

    sp = SpectrumPlotter(axes=axes)
    sp.plot(spectrum, autoscale=False, color='red' if not bw else 'grey', zorder=1.9)

label_axes(grid)

grid[0].set_ylabel('')
grid[4].set_ylabel('')


for i in range(nrows*ncols):
    axes=grid[i]
    #axes.set_xlim_units(10**2*units.MeV,10**5.5*units.MeV)
    axes.set_xlim(0.1,10**2.5)
    #axes.set_ylim_units(1e-13*units.erg/units.cm**2/units.s,1e-9*units.erg/units.cm**2/units.s)
    if i in [0,1,2,3]:
        axes.set_ylim(1e-13,1e-9)
    elif i in [4,5]:
        axes.set_ylim(1e-13,1e-8)
    else:
        raise Exception("...")
fix_yaxesgrid(grid)

pubplot.save(join(base,'plots','off_peak_seds'))
예제 #8
0
    print '.. average ts_point (nocut)',np.average(ts_point_nocut), np.std(ts_point_nocut)
    print '.. average ts_ext',np.average(ts_ext), np.std(ts_ext)


    bins=np.linspace(0,max_ts_ext,1e3)
    data=np.histogram(ts_ext,bins=bins)[0]
    
    cdf=np.cumsum(data[::-1])[::-1]
    cdf=cdf.astype(float)/cdf[0] # normalize
    cdf = np.append(cdf, 0)

    cdf[cdf<ymin]=ymin

    axes.semilogy(bins,cdf,linewidth=1, **kwargs)


lower,upper=axes.get_xlim()
bins=np.linspace(lower,upper,10000)
y = chi2.sf(bins,1)/2
axes.semilogy(bins, y, color='red' if not bw else 'black', linewidth=1, label='$\chi^2_1/2$', zorder=0, dashes=(5,3))

axes.set_ylabel('Cumulative Density')
axes.set_xlabel(r'$\mathrm{TS}_\mathrm{ext}$')

axes.set_xlim(0,35)
axes.set_ylim(ymin,1)

P.legend()

save('plot_tsext_plane')
예제 #9
0
            n = a([np.sum(cut&(extension_mc==e)) for e in extlist])

            # Formula from http://arxiv.org/pdf/1012.0566v3.pdf
            p = coverage
            p_lower = dist.beta.ppf((1-c)/2.,k+1,n-k+1)
            p_higher = dist.beta.ppf(1-(1-c)/2.,k+1,n-k+1)

            grid[3].fill_between(extlist.tolist(), p_lower.tolist(), p_higher.tolist(), alpha=0.5, **plot_kwargs)

    grid[0].legend(numpoints=1, ncol=2, loc=3, prop=FontProperties(size=10))

    label_axes(grid)

    for g in grid: 
        g.xaxis.set_major_formatter(DegreesFormatter)
        g.set_xlabel('Extension')


    grid[3].set_ylim(ymax=1.1)

    grid[0].set_ylabel(r'Flux')
    grid[1].set_ylabel(r'$\langle\mathrm{TS}_\mathrm{point}\rangle$')
    grid[2].set_ylabel(r'$\langle\mathrm{TS}_\mathrm{ext}\rangle$')
    grid[3].set_ylabel(r'Coverage')

    grid[1].axhline(25, color='black', dashes=[5,2])
    grid[2].axhline(16, color='black', dashes=[5,2])
    grid[3].axhline(0.95, color='black', dashes=[5,2])

    pubplot.save('extul_%s' % type)