Пример #1
0
    def plot_cpd(self):
        vmag = np.array([d['vmag'] for d in self.data])
        bmag = np.array([d['bmag'] for d in self.data])
        period = np.array([d['period'] for d in self.data])
        good = np.array([d['good'] for d in self.data])
        member = np.array([d['member'] for d in self.data])
        vmag = 1.0001722499859311*vmag + 0.5402413960734754
        bmag = 1.0108861546902421*bmag + 0.9271685986891227
        bv = bmag-vmag
        
        i = np.where(period>0.0)
        plt.scatter(bv[i]-0.56, period[i], facecolor='none', edgecolor='k',label='WiFSIP')
        j = np.where((period>0.0) & (good==True))
        plt.scatter(bv[j]-0.56, period[j], facecolor='r', edgecolor='none',label='rotators')
        k = np.where(member==True)
        plt.scatter(bv[k]-0.56, period[k], marker='s', s=50, facecolor='none', edgecolor='g',label='members')
        plt.ylim(0.0,15.0)
        plt.xlim(-0.5, 2.0)
        plt.xlabel('(B - V)$_0$')
        plt.ylabel('P [days]')

        import gyroage
        
        bvgyro = np.linspace(0.4, 1.5, num=50)
        #bv = np.linspace(0.473, 1.631, num=100)
        
        P500 = gyroage.gyroperiod(bvgyro, 500)
        plt.plot(bvgyro, P500, color='r')
        
        P800 = gyroage.gyroperiod(bvgyro, 800)
        plt.plot(bvgyro, P800, 'b--')
        
        plt.savefig(config.plotpath+'NGC2236cpd.eps')
        plt.show()
Пример #2
0
    def make_cpd(self):
        import pylab as plt
        import numpy as np
        from datasource import DataSource

        wifsip = DataSource(database='wifsip', user='******', host='pina.aip.de')
        query = """SELECT bv, period, theta 
                    FROM ngc1647stars 
                    WHERE vmag>4.762*bv + 10.4762 and theta>0.5;"""
        data = wifsip.query(query)

        bv = np.array([d[0] for d in data])
        period = np.array([d[1] for d in data])
        theta = np.array([d[2] for d in data])

        query = """SELECT bv, period, theta 
                    FROM ngc1647stars 
                    WHERE vmag<4.762*bv + 10.4762 
                    AND theta>0.5;"""
        data = wifsip.query(query)
        wifsip.close()
        bv_ms = np.array([d[0] for d in data])
        period_ms = np.array([d[1] for d in data])
        theta_ms = np.array([d[2] for d in data])

        import gyroage

        bv170 = np.linspace(0.5, 1.6, num=20)
        P = gyroage.gyroperiod(bv170, 170.0)
        P01 = gyroage.gyroperiod(bv170, 170.0, P0=0.1)
        P33 = gyroage.gyroperiod(bv170, 170.0, P0=3.3)

        plt.plot(bv170, P, color='r')
        plt.plot(bv170, P01, color='r', linestyle='dashed')
        plt.plot(bv170, P33, color='r', linestyle='dashed')

        plt.scatter(bv - self.ebv,
                    period,
                    s=(1.0 - theta) * 40.,
                    edgecolor='none',
                    alpha=0.5)
        plt.scatter(bv_ms - self.ebv,
                    period_ms,
                    s=(1.0 - theta_ms) * 40.,
                    edgecolor='none',
                    alpha=0.75,
                    facecolor='green')
        plt.xlabel('(B - V)$_0$')
        plt.ylabel('period [days]')
        plt.ylim(0.0, 10.0)
        plt.xlim(0.0, 2.2)
        plt.grid()
        plt.savefig('/work1/jwe/Dropbox/NGC1647/plots/ngc1647cpd.pdf')
        plt.show()
        plt.close()
Пример #3
0
    def plot_cpd(self):
        '''
        create plot for Heraeus Talk
        '''
        from datasource import DataSource
        wifsip = DataSource(database='wifsip', user='******', host='oldpina.aip.de')
        query = """SELECT bv, period 
                    FROM m48stars 
                    WHERE good;"""

        data = wifsip.query(query)
        
        bv = np.array([d[0] for d in data])
        period = np.array([d[1] for d in data])
        
        import gyroage
        from functions import logspace
        
        bv360 = logspace(0.5, 2.0, num=100)
        #P = gyroage.gyroperiod(bv360, 360.0, version=2007)
        P, pc = gyroage.gyroperiod(bv360, 360.0, version=2003)
        plt.plot(bv360, pc, color='b', linestyle='--')
        plt.plot(bv360, P, color='r')
        
        plt.scatter(bv-self.ebv, period, s=1, 
                    edgecolor='none', c='k')
         
        plt.xlabel('(B - V)$_0$')
        plt.ylabel('period [days]')
        plt.ylim(0.0, 20.0)
        plt.xlim(0.0, 2.0)
        plt.grid()
        plt.savefig('/home/jwe/Documents/Talks/Heraeus2015/m48cpd.eps')
        plt.savefig('/home/jwe/Documents/Talks/Heraeus2015/m48cpd.pdf')
        plt.close()
Пример #4
0
def plot():
    from gyroage import gyroperiod
    data = np.loadtxt(config.datapath + 'periods.txt')
    bv = data[:, 1]
    p = data[:, 5]
    bv400 = np.linspace(0.515, 1.6, num=100)
    P11 = gyroperiod(bv400, clusterage)
    P34 = gyroperiod(bv400, clusterage, P0=3.4)
    P01 = gyroperiod(bv400, clusterage, P0=0.1)

    plt.scatter(bv - 0.03,
                p,
                edgecolor='none',
                c='k',
                label='STELLA rotation periods')
    plt.axvline(0.653, color='y', linewidth=3.0)

    plt.plot(bv400, P34, 'b--', label='P$_0$=3.4 d')
    plt.plot(bv400, P01, 'g--', label='P$_0$=0.1 d')
    plt.plot(bv400, P11, 'r', linewidth=3.0, label='P$_0$=1.1 d')
    plt.legend()

    plt.show()
Пример #5
0
    def make_cpd(self):
        import pylab as plt
        import numpy as np
        from datasource import DataSource

        wifsip = DataSource(database='wifsip', user='******', host='pina.aip.de')
        query = """SELECT bv, period, theta 
                    FROM ngc2281stars
                    WHERE bv >-1.0 AND period>0
                    and vmag < 5.8333*(bv-0.09)+10.5;"""
        data = wifsip.query(query)

        bv = np.array([d[0] for d in data])
        period = np.array([d[1] for d in data])
        theta = np.array([d[2] for d in data])

        wifsip.close()

        import gyroage

        bv358 = np.linspace(0.5, 1.6, num=40)
        #P = gyroage.gyroperiod(bv358, 358.1)
        #P01 = gyroage.gyroperiod(bv358, 358.1, P0=0.1)
        #P33 = gyroage.gyroperiod(bv358, 358.1, P0=3.3)

        PI, PC = gyroage.gyroperiod(bv358, 358.1)

        plt.plot(bv358, PI, color='r')
        plt.plot(bv358, PC, color='r', linestyle='dashed')

        plt.scatter(bv - self.ebv,
                    period,
                    s=40. * (1.0 - theta)**2,
                    edgecolor='none',
                    alpha=0.75)
        plt.title('NGC 2281')
        plt.xlabel('(B - V)$_0$')
        plt.ylabel('period [days]')
        plt.ylim(0.0, 20.0)
        plt.xlim(0.0, 2.2)
        plt.grid()
        plt.savefig('/work1/jwe/Dropbox/NGC2281/plots/ngc2281cpd.pdf')
        #plt.show()
        plt.close()
Пример #6
0
 def plot_cpd(self, show=False, gyrochrone=False):
     from dbtable import DBTable
     
     members = DBTable(self.wifsip, 'ngc6633', condition='member')
     good = DBTable(self.wifsip, 'ngc6633', condition='good and period>0')
     nonmembers = DBTable(self.wifsip, 'ngc6633', condition='NOT member')
     
     
     import gyroage
     from functions import logspace
     
     bvgyro = logspace(0.5, 1.5, num=100)
     age = 550
     P = gyroage.gyroperiod(bvgyro, age, version=2010)
     
     plt.style.use('aanda.mplstyle')
     
     if gyrochrone:
         plt.plot(bvgyro, P, color='b', label='%d Myr'% age)
     
     plt.scatter(good['bv']-self.ebv, good['period'], marker='o',edgecolor='r', facecolor='r', s=20, label='rotators')
     plt.scatter(members['bv']-self.ebv, members['period'], marker='o',edgecolor='k', facecolor='r', s=20, label='members')
     plt.scatter(nonmembers['bv']-self.ebv, nonmembers['period'], marker='x',edgecolor='k', facecolor='k', s=20, label='nonmembers')
     
     
     plt.xlabel('(B - V)$_0$')
     plt.ylabel('period [days]')
     plt.ylim(0.0, 15.0)
     plt.xlim(0.4, 1.6)
     plt.legend()
     plt.title('NGC 6633 Color Period Diagram')
     #plt.grid()
     if show:
         plt.show()
     else:
         if gyrochrone:
             plt.savefig(config.plotpath+'ngc6633cpd_gyro.pdf')
         else:
             plt.savefig(config.plotpath+'ngc6633cpd.pdf')
     plt.close()
Пример #7
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on Oct 19, 2015

@author: Joerg Weingrill <*****@*****.**>
'''

if __name__ == '__main__':
    from gyroage import gyroperiod
    from numpy import linspace
    #bv = linspace(0.0, 1.6, num=50)
    bv = linspace(0.35, 1.6, num=100)

    age = 600

    P11 = gyroperiod(bv, age)
    P34 = gyroperiod(bv, age, P0=3.4)
    P01 = gyroperiod(bv, age, P0=0.1)

    for k in zip(bv, P01, P11, P34):
        print '%.3f\t%.3f\t%.3f\t%.3f' % k
Пример #8
0
    def plot_cmpd(self, show=False, gyrochrone=False):
        """
        make a 3d plot of the cmd and the cpd
        """
        from dbtable import DBTable
        from mpl_toolkits.mplot3d import Axes3D
        import numpy as np
        import matplotlib.pyplot as plt
        
        members = DBTable(self.wifsip, 'ngc6633', condition='member and period>0')
        good = DBTable(self.wifsip, 'ngc6633', condition='good and period>0')
        nonmembers = DBTable(self.wifsip, 'ngc6633', condition='NOT member and period>0')
        
        
        import gyroage
        from functions import logspace
        
        bvgyro = logspace(0.5, 1.5, num=100)
        age = 550
        P = gyroage.gyroperiod(bvgyro, age, version=2010)
        
        #plt.style.use('aanda.mplstyle')
        
#        if gyrochrone:
#            plt.plot(bvgyro, P, color='b', label='%d Myr'% age)
        
#        plt.scatter(good['bv']-self.ebv, good['period'], marker='o',edgecolor='r', facecolor='r', s=20, label='rotators')
#        plt.scatter(members['bv']-self.ebv, members['period'], marker='o',edgecolor='k', facecolor='r', s=20, label='members')
#        plt.scatter(nonmembers['bv']-self.ebv, nonmembers['period'], marker='x',edgecolor='k', facecolor='k', s=20, label='nonmembers')


        
        fig = plt.figure()
        ax = fig.gca(projection='3d')
        
        # Plot a sin curve using the x and y axes.
        #x = np.linspace(0, 1, 100)
        #y = np.sin(x * 2 * np.pi) / 2 + 0.5
        #ax.plot(x, y, zs=0, zdir='z', label='curve in (x,y)')
        iso_v, iso_bv = self.load_isochrone() 
        
        ax.plot(iso_bv+self.ebv, iso_v+self.dm+(3.1*self.ebv), zs=0, zdir='z', color='b', alpha=0.3, lw=5.0,label='600 Myr iso')     
        ax.plot(bvgyro-self.ebv, np.ones(100)*7, P, color='b', label='%d Myr'% age)   
        ax.scatter(good['bv']-self.ebv, good['vmag'], good['period'], marker='o',edgecolor='r', facecolor='r', s=20, label='rotators')
        ax.scatter(members['bv']-self.ebv, members['vmag'], members['period'], marker='o',edgecolor='k', facecolor='r', s=20, label='members')
        ax.scatter(nonmembers['bv']-self.ebv, nonmembers['vmag'],nonmembers['period'], marker='x',edgecolor='k', facecolor='k', s=20, label='nonmembers')
        
        for x,y,z in zip(good['bv']-self.ebv, good['vmag'], good['period']):
            ax.plot([x,x,],[y,y],[0,z],'0.5')
        
        # Make legend, set axes limits and labels
        #ax.legend()
        ax.set_xlim(0.2, 1.6)
        ax.set_ylim(20.0, 7.0)
        ax.set_zlim(0.0, 13.0)
        ax.set_xlabel('(B - V)$_0$')
        ax.set_ylabel('V [mag]')
        ax.set_zlabel('period [days]')
        
        # Customize the view angle so it's easier to see that the scatter points lie
        # on the plane y=0
        #ax.view_init(elev=20., azim=-35)
        
        #ax.set_title('NGC 6633 Color Period Diagram')
        
        if show:
            plt.show()
        else:
            if gyrochrone:
                plt.savefig(config.plotpath+'ngc6633cmpd_gyro.pdf')
            else:
                plt.savefig(config.plotpath+'ngc6633cmpd.pdf')
Пример #9
0
 def plot_cpd(self, show=False):
     query = """SELECT bv, period, amp 
                 FROM m48stars 
                 WHERE NOT good
                 AND NOT bv IS NULL
                 AND period>0;"""
     data = self.wifsip.query(query)
     
     bv = np.array([d[0] for d in data])
     period = np.array([d[1] for d in data])
     
     query = """SELECT bv, period, amp 
                 FROM m48stars 
                 WHERE vmag<4*bv + 13 
                 AND NOT bv IS NULL
                 AND period>0
                 AND good;"""
     data = self.wifsip.query(query)
     bv_ms = np.array([d[0] for d in data])
     period_ms = np.array([d[1] for d in data])
     amp_ms = np.array([d[2] for d in data])
     
     query = """SELECT bv, period, amp 
                 FROM m48stars 
                 WHERE NOT bv IS NULL
                 AND period>0
                 AND member;"""
     data = self.wifsip.query(query)
     bv_mem = np.array([d[0] for d in data])
     period_mem = np.array([d[1] for d in data])
     amp_mem = np.array([d[2] for d in data])
     
     
     import gyroage
     from functions import logspace
     
     bvgyro = logspace(0.5, 2.0, num=100)
     #P = gyroage.gyroperiod(bv360, 360.0, version=2007)
     P, pc = gyroage.gyroperiod(bvgyro, 360.0, version=2010)
     plt.plot(bvgyro, pc, color='b', linestyle='--')
     plt.plot(bvgyro, P, color='r')
     
     plt.scatter(bv-self.ebv, period, s=1, 
                 edgecolor='none', c='k')
     plt.scatter(bv_ms-self.ebv, period_ms, s=(1.0-amp_ms)*50., 
                 edgecolor='none', facecolor='green')
     
     plt.scatter(bv_mem-self.ebv, period_mem, s=(1.0-amp_mem)*50., 
                 edgecolor='blue',
                 facecolor='none')
     
     plt.xlabel('(B - V)$_0$')
     plt.ylabel('period [days]')
     plt.ylim(0.0, 20.0)
     plt.xlim(0.0, 2.0)
     plt.grid()
     if show:
         plt.show()
     else:
         plt.savefig(config.plotpath+'m48cpd.eps')
         plt.savefig(config.plotpath+'m48cpd.pdf')
     plt.close()
Пример #10
0
from datasource import DataSource

wifsip = DataSource(database='wifsip', user='******', host='oldpina.aip.de')
query = """SELECT bv, period 
            FROM m48stars 
            WHERE good;"""

data = wifsip.query(query)

bv = np.array([d[0] for d in data])
period = np.array([d[1] for d in data])

from gyroage import gyroperiod

bv400 = np.linspace(0.44, 1.6, num=100)
P11 = gyroperiod(bv400, 400)
P34 = gyroperiod(bv400, 400, P0=3.4)
P01 = gyroperiod(bv400, 400, P0=0.1)
P800 = gyroperiod(bv400, 800, P0=1.1)

plt.scatter(bv - 0.03,
            period,
            edgecolor='none',
            c='k',
            label='STELLA rotation periods')
plt.axvline(0.653, color='y', linewidth=3.0)

plt.plot(bv400, P34, 'b--', label='400 Myr model P$_0$=3.4 d')
#plt.plot(bv400, P01, 'g--', label='400 Myr model P$_0$=0.1 d')
plt.plot(bv400, P11, 'r', linewidth=3.0, label='400 Myr model P$_0$=1.1 d')
plt.plot(bv400, P800, 'g', label='800 Myr model P$_0$=1.1 d')