Пример #1
0
def sgr():
    """ Top-down plot of Sgr particles, with selected stars and then 
        re-observed
    """
    
    cached_data_file = os.path.join(plot_path, 'sgr_kde.pickle')
    
    fig,axes = plt.subplots(1, 2, figsize=(14,6.5), sharex=True, sharey=True)
    
    # read in all particles as a table
    pdata = particle_table(N=0, expr="(Pcol<7) & (abs(Lmflag)==1)")
    extent = {'x':(-90,55), 
              'y':(-58,68)}
    
    if not os.path.exists(cached_data_file):    
        Z = sgr_kde(pdata, extent=extent)
        
        with open(cached_data_file, 'w') as f:
            pickle.dump(Z, f)
    
    with open(cached_data_file, 'r') as f:
        Z = pickle.load(f)
    
    axes[1].imshow(Z**0.5, interpolation="nearest", 
              extent=extent['x']+extent['y'],
              cmap=cm.Blues, aspect=1)
    
    np.random.seed(42)
    particles = particles_today(N=100, expr="(Pcol<7) & (Pcol>0) & (abs(Lmflag)==1)")   
    
    # read in Stripe 82 RR Lyrae
    s82 = ascii.read(stripe82_catalog)
    stripe82_xyz = ra_dec_dist_to_xyz(s82['ra']*u.deg, s82['dec']*u.deg, 
                                      s82['dist']*u.kpc)
    
    catalina = ascii.read(os.path.join(project_root, "data/spitzer_sgr_sample.txt"))
    catalina = catalina[catalina['dist'] < 35.]
    catalina_xyz = ra_dec_dist_to_xyz(catalina['ra']*u.deg, 
                                      catalina['dec']*u.deg, 
                                      catalina['dist']*u.kpc)
    
    '''
    quest = ascii.read(quest_catalog)
    quest = quest[quest['dist'] < 35]
    quest = quest[quest['dist'] > 10]
    quest_xyz = ra_dec_dist_to_xyz(quest['ra']*u.deg, 
                                   quest['dec']*u.deg, 
                                   quest['dist']*u.kpc)
    '''
    
    rcparams = {'lines.linestyle' : 'none', 
                'lines.color' : 'k',
                'lines.marker' : 'o'}
    
    with rc_context(rc=rcparams): 
        axes[0].plot(pdata['x'], pdata['z'],
                     marker='.', alpha=0.1, ms=5)
        
        axes[1].plot(stripe82_xyz[:,0], stripe82_xyz[:,2], marker='.', 
                     color='#111111', alpha=0.85, markersize=12, 
                     label="Stripe 82", markeredgewidth=0)
        
        axes[1].plot(catalina_xyz[:,0], catalina_xyz[:,2], marker='^', 
                     color='#111111', alpha=0.85, markersize=7, 
                     label="Catalina", markeredgewidth=0)
        
        #axes[1].plot(quest_xyz[:,0], quest_xyz[:,2], marker='s', 
        #             color='#111111', alpha=0.85, markersize=6, 
        #             label="QUEST", markeredgewidth=0)
        
        # add solar symbol
        axes[0].text(-8., 0., s=r"$\odot$")
        axes[1].text(-8., 0., s=r"$\odot$")

        axes[0].set_xlabel("$X_{GC}$ [kpc]")
        axes[1].set_xlabel("$X_{GC}$ [kpc]")
        axes[0].set_ylabel("$Z_{GC}$ [kpc]")
    
    axes[1].legend(loc='upper left')
    plt.tight_layout()
    
    axes[0].set_xlim(extent['x'])
    axes[0].set_ylim(extent['y'])
    
    # turn off right, left ticks respectively
    axes[0].yaxis.tick_left()
    axes[1].yaxis.tick_right()
    
    # turn off top ticks
    axes[0].xaxis.tick_bottom()
    axes[1].xaxis.tick_bottom()
    
    fig.subplots_adjust(wspace=0.)
    fig.savefig(os.path.join(plot_path, "lm10.png"))