Example #1
0
def get_indices(pointing, basedir = '/d/monk/eigenbrot/WIYN/14B-0456/anal/indecies/D4000/tau_grid'):

    DIfile = '{}/NGC_891_P{}_bin30.msoz.Dn4000.dat'.format(basedir,pointing)
    tifile = '{}/NGC_891_P{}_bin30.msoz.bands.dat'.format(basedir,pointing)

    DIres = DI.quick_eat(DIfile)
    tires = ti.quick_eat(tifile)

    #Output will be numap X 5 and 2nd dim will be:
    # Hda, Dn4000, [MgFe], <Fe>, Mgb

    return np.hstack((DIres[:,[0,2]],tires[:,[6,5,7]]))
Example #2
0
def get_mab_data(prefix=None,
                 DIfile = '/d/monk/eigenbrot/WIYN/14B-0456/anal/indecies/D4000/tau_grid/zmod.const.norm_hr.ospec.prep.Dn4000.dat',
                 tifile = '/d/monk/eigenbrot/WIYN/14B-0456/anal/indecies/D4000/tau_grid/zmod.const.norm_hr.ospec.prep.bands.dat'):

    if prefix is not None:
        DIfile = prefix+'.Dn4000.dat'
        tifile = prefix+'.bands.dat'

    import tau_indecies as ti

    Dres = quick_eat(DIfile)
    Tres = ti.quick_eat(tifile)
    
    z = np.arange(Dres.shape[0])*0.01

    return z, Dres, Tres
Example #3
0
def plot_z_all(output, basedir='.', exclude=excl, window=55, plotmab=False):

    import tau_indecies as ti

    fig = plt.figure()
    Hax = fig.add_subplot(232)
    Hax.set_ylabel(r'H$\delta_A$')
    Hax.set_xticklabels([])
    # Hax.yaxis.tick_right()
    # Hax.yaxis.set_label_position('right')
    # Hax.yaxis.set_ticks_position('both')
    Dax = fig.add_subplot(233)
    Dax.set_xticklabels([])
    # Dax.set_xlabel('|$z$| [kpc]')
    Dax.set_ylabel('Dn4000')
    # Dax.yaxis.tick_right()
    # Dax.yaxis.set_label_position('right')
    # Dax.yaxis.set_ticks_position('both')

    MgFeax = fig.add_subplot(234)
    MgFeax.set_ylabel('[MgFe]')
    MgFeax.set_xlabel('|$z$| [kpc]')
    # MgFeax.set_xticklabels([])
    Feax = fig.add_subplot(235)
    Feax.set_ylabel(r'<Fe>')
    Feax.set_xlabel('|$z$| [kpc]')
    # Feax.set_xticklabels([])
    Mgbax = fig.add_subplot(236)
    Mgbax.set_xlabel('|$z$| [kpc]')
    Mgbax.set_ylabel('Mg$b$')

    z1 = np.array([])
    z2 = np.array([])
    z3 = np.array([])

    D41 = np.array([])
    HdA1 = np.array([])
    MgFe1 = np.array([])
    Mgb1 = np.array([])
    Fe1 = np.array([])

    D42 = np.array([])
    HdA2 = np.array([])
    MgFe2 = np.array([])
    Mgb2 = np.array([])
    Fe2 = np.array([])

    D43 = np.array([])
    HdA3 = np.array([])
    MgFe3 = np.array([])
    Mgb3 = np.array([])
    Fe3 = np.array([])

    for p in range(6):
        datafile = glob('{}/NGC_891_P{}_bin30.*Dn4000.dat'.format(basedir,p+1))[0]
        tidatfile = glob('{}/NGC_891_P{}_bin30.*bands.dat'.format(basedir,p+1))[0]
        loc = '{}/NGC_891_P{}_bin30_locations.dat'.format(basedir,p+1)
        res = quick_eat(datafile)
        tires = ti.quick_eat(tidatfile)
        r, z = np.loadtxt(loc,usecols=(4,5),unpack=True)
        r = np.abs(r)
        z = np.abs(z)
        
        exar = np.array(exclude[p]) - 1
        res = np.delete(res,exar,axis=0)
        tires = np.delete(tires,exar,axis=0)
        z = np.delete(z,exar)
        r = np.delete(r,exar)
        rid1 = np.where(r < 3)[0]
        rid2 = np.where((r >= 3) & (r < 8))[0]
        rid3 = np.where(r >= 8)[0]
        
        z1 = np.r_[z1,z[rid1]]
        z2 = np.r_[z2,z[rid2]]
        z3 = np.r_[z3,z[rid3]]

        D41 = np.r_[D41,res[rid1,2]]
        HdA1 = np.r_[HdA1,res[rid1,0]]
        MgFe1 = np.r_[MgFe1,tires[rid1,6]]
        Mgb1 = np.r_[Mgb1,tires[rid1,7]]
        Fe1 = np.r_[Fe1,tires[rid1,5]]

        D42 = np.r_[D42,res[rid2,2]]
        HdA2 = np.r_[HdA2,res[rid2,0]]
        MgFe2 = np.r_[MgFe2,tires[rid2,6]]
        Mgb2 = np.r_[Mgb2,tires[rid2,7]]
        Fe2 = np.r_[Fe2,tires[rid2,5]]

        D43 = np.r_[D43,res[rid3,2]]
        HdA3 = np.r_[HdA3,res[rid3,0]]
        MgFe3 = np.r_[MgFe3,tires[rid3,6]]
        Mgb3 = np.r_[Mgb3,tires[rid3,7]]
        Fe3 = np.r_[Fe3,tires[rid3,5]]

        colors = ['#1b9e77','#d95f02','#7570b3']
        colors = ['r','g','b']
        
        Dax.plot(z[rid1], res[rid1,2], '.', color=colors[0])
        Hax.plot(z[rid1], res[rid1,0], '.', color=colors[0])
        Feax.plot(z[rid1], tires[rid1,5], '.', color=colors[0])
        MgFeax.plot(z[rid1], tires[rid1,6], '.', color=colors[0])
        Mgbax.plot(z[rid1], tires[rid1,7], '.', color=colors[0])

        Dax.plot(z[rid2], res[rid2,2], '.', color=colors[1])
        Hax.plot(z[rid2], res[rid2,0], '.', color=colors[1])
        Feax.plot(z[rid2], tires[rid2,5], '.', color=colors[1])
        MgFeax.plot(z[rid2], tires[rid2,6], '.', color=colors[1])
        Mgbax.plot(z[rid2], tires[rid2,7], '.', color=colors[1])

        Dax.plot(z[rid3], res[rid3,2], '.', color=colors[2])
        Hax.plot(z[rid3], res[rid3,0], '.', color=colors[2])
        Feax.plot(z[rid3], tires[rid3,5], '.', color=colors[2])
        MgFeax.plot(z[rid3], tires[rid3,6], '.', color=colors[2])
        Mgbax.plot(z[rid3], tires[rid3,7], '.', color=colors[2])

    sidx1 = np.argsort(z1)
    sidx2 = np.argsort(z2)
    sidx3 = np.argsort(z3)

    mz = np.linspace(0,z.max(),100)
    intD41 = np.interp(mz,z1[sidx1],D41[sidx1])
    intHdA1 = np.interp(mz,z1[sidx1],HdA1[sidx1])
    intMgFe1 = np.interp(mz,z1[sidx1],MgFe1[sidx1])
    intFe1 = np.interp(mz,z1[sidx1],Fe1[sidx1])
    intMgb1 = np.interp(mz,z1[sidx1],Mgb1[sidx1])

    intD42 = np.interp(mz,z2[sidx2],D42[sidx2])
    intHdA2 = np.interp(mz,z2[sidx2],HdA2[sidx2])
    intMgFe2 = np.interp(mz,z2[sidx2],MgFe2[sidx2])
    intFe2 = np.interp(mz,z2[sidx2],Fe2[sidx2])
    intMgb2 = np.interp(mz,z2[sidx2],Mgb2[sidx2])

    intD43 = np.interp(mz,z3[sidx3],D43[sidx3])
    intHdA3 = np.interp(mz,z3[sidx3],HdA3[sidx3])
    intMgFe3 = np.interp(mz,z3[sidx3],MgFe3[sidx3])
    intFe3 = np.interp(mz,z3[sidx3],Fe3[sidx3])
    intMgb3 = np.interp(mz,z3[sidx3],Mgb3[sidx3])
    
    # spD41 = spi.UnivariateSpline(z1[sidx1],D41[sidx1],k=3)
    # spHdA1 = spi.UnivariateSpline(z1[sidx1],HdA1[sidx1],k=3)
    # spMgFe1 = spi.UnivariateSpline(z1[sidx1],MgFe1[sidx1],k=3)
    # spFe1 = spi.UnivariateSpline(z1[sidx1],Fe1[sidx1],k=3)
    # spMgb1 = spi.UnivariateSpline(z1[sidx1],Mgb1[sidx1],k=3)

    # spD42 = spi.UnivariateSpline(z2[sidx2],D42[sidx2],k=3)
    # spHdA2 = spi.UnivariateSpline(z2[sidx2],HdA2[sidx2],k=3,s=150)
    # spMgFe2 = spi.UnivariateSpline(z2[sidx2],MgFe2[sidx2],k=3)
    # spFe2 = spi.UnivariateSpline(z2[sidx2],Fe2[sidx2],k=3)
    # spMgb2 = spi.UnivariateSpline(z2[sidx2],Mgb2[sidx2],k=3)

    # spD43 = spi.UnivariateSpline(z3[sidx3],D43[sidx3],k=3)
    # spHdA3 = spi.UnivariateSpline(z3[sidx3],HdA3[sidx3],k=3,s=90)
    # spMgFe3 = spi.UnivariateSpline(z3[sidx3],MgFe3[sidx3],k=3)
    # spFe3 = spi.UnivariateSpline(z3[sidx3],Fe3[sidx3],k=3)
    # spMgb3 = spi.UnivariateSpline(z3[sidx3],Mgb3[sidx3],k=3)

    Dax.plot(mz,ssig.savgol_filter(intD41,window,3),color=colors[0],lw=1.2)
    Hax.plot(mz,ssig.savgol_filter(intHdA1,window,3),color=colors[0],lw=1.2)
    Feax.plot(mz,ssig.savgol_filter(intFe1,window,3),color=colors[0],lw=1.2)
    MgFeax.plot(mz,ssig.savgol_filter(intMgFe1,window,3),color=colors[0],lw=1.2)
    Mgbax.plot(mz,ssig.savgol_filter(intMgb1,window,3),color=colors[0],lw=1.2)

    Dax.plot(mz,ssig.savgol_filter(intD42,window,3),color=colors[1],lw=1.2)
    Hax.plot(mz,ssig.savgol_filter(intHdA2,window,3),color=colors[1],lw=1.2)
    Feax.plot(mz,ssig.savgol_filter(intFe2,window,3),color=colors[1],lw=1.2)
    MgFeax.plot(mz,ssig.savgol_filter(intMgFe2,window,3),color=colors[1],lw=1.2)
    Mgbax.plot(mz,ssig.savgol_filter(intMgb2,window,3),color=colors[1],lw=1.2)

    Dax.plot(mz,ssig.savgol_filter(intD43,window,3),color=colors[2],lw=1.2)
    Hax.plot(mz,ssig.savgol_filter(intHdA3,window,3),color=colors[2],lw=1.2)
    Feax.plot(mz,ssig.savgol_filter(intFe3,window,3),color=colors[2],lw=1.2)
    MgFeax.plot(mz,ssig.savgol_filter(intMgFe3,window,3),color=colors[2],lw=1.2)
    Mgbax.plot(mz,ssig.savgol_filter(intMgb3,window,3),color=colors[2],lw=1.2)

    if plotmab:
        mabz, mabD, mabT = get_mab_data()
        Dax.plot(mabz,mabD[:,2],color='k',lw=1.2)
        Hax.plot(mabz,mabD[:,0],color='k',lw=1.2)
        Feax.plot(mabz,mabT[:,5],color='k',lw=1.2)
        MgFeax.plot(mabz,mabT[:,6],color='k',lw=1.2,label='m62')
        Mgbax.plot(mabz,mabT[:,7],color='k',lw=1.2)
        
        mabz32, mabD32, mabT32 = get_mab_data('zmod.const.hr.m32.ospec.prep')
        Dax.plot(mabz32,mabD32[:,2],color='k',lw=1.2,ls=':')
        Hax.plot(mabz32,mabD32[:,0],color='k',lw=1.2,ls=':')
        Feax.plot(mabz32,mabT32[:,5],color='k',lw=1.2,ls=':')
        MgFeax.plot(mabz32,mabT32[:,6],color='k',lw=1.2,ls=':',label='m32')
        Mgbax.plot(mabz32,mabT32[:,7],color='k',lw=1.2,ls=':')
        
        mabz42, mabD42, mabT42 = get_mab_data('zmod.const.hr.m42.ospec.prep')
        Dax.plot(mabz42,mabD42[:,2],color='k',lw=1.2,ls='--')
        Hax.plot(mabz42,mabD42[:,0],color='k',lw=1.2,ls='--')
        Feax.plot(mabz42,mabT42[:,5],color='k',lw=1.2,ls='--')
        MgFeax.plot(mabz42,mabT42[:,6],color='k',lw=1.2,ls='--',label='m42')
        Mgbax.plot(mabz42,mabT42[:,7],color='k',lw=1.2,ls='--')
        
        mabz52, mabD52, mabT52 = get_mab_data('zmod.const.hr.m52.ospec.prep')
        Dax.plot(mabz52,mabD52[:,2],color='k',lw=1.2,ls='-.')
        Hax.plot(mabz52,mabD52[:,0],color='k',lw=1.2,ls='-.')
        Feax.plot(mabz52,mabT52[:,5],color='k',lw=1.2,ls='-.')
        MgFeax.plot(mabz52,mabT52[:,6],color='k',lw=1.2,ls='-.',label='m52')
        Mgbax.plot(mabz52,mabT52[:,7],color='k',lw=1.2,ls='-.')
        
        MgFeax.legend(loc='center',bbox_to_anchor=(0.5,1.3))

    Dax.axvline(0.4,ls=':',alpha=0.6,color='k')
    Dax.axvline(1,ls=':',alpha=0.6,color='k')
    Hax.axvline(0.4,ls=':',alpha=0.6,color='k')
    Hax.axvline(1,ls=':',alpha=0.6,color='k')

    Dax.set_xlim(-0.3,2.7)
    Dax.set_ylim(1,2.3)
    Hax.set_ylim(-2.5,8)
    Hax.set_xlim(*Dax.get_xlim())

    Feax.set_ylim(-0.2,3.4)
    MgFeax.set_ylim(-0.2,3.7)
    Mgbax.set_ylim(0.5,5.4)
    Feax.set_xlim(*Dax.get_xlim())
    MgFeax.set_xlim(*Dax.get_xlim())
    Mgbax.set_xlim(*Dax.get_xlim())

    Feax.axvline(0.4,ls=':',alpha=0.6,color='k')
    Feax.axvline(1,ls=':',alpha=0.6,color='k')
    MgFeax.axvline(0.4,ls=':',alpha=0.6,color='k')
    MgFeax.axvline(1,ls=':',alpha=0.6,color='k')
    Mgbax.axvline(0.4,ls=':',alpha=0.6,color='k')
    Mgbax.axvline(1,ls=':',alpha=0.6,color='k')

    MgFeax.text(0.25,1.65,r'$|r| < 3$ kpc',color=colors[0], fontsize=25, transform=MgFeax.transAxes)
    MgFeax.text(0.25,1.5,r'$3 \leq |r| < 8$ kpc',color=colors[1], fontsize=25, transform=MgFeax.transAxes)
    MgFeax.text(0.25,1.35,r'$|r| \geq 8$ kpc',color=colors[2], fontsize=25, transform=MgFeax.transAxes)

    fig.subplots_adjust(hspace=0.1)
    pp = PDF(output)
    pp.savefig(fig)
    pp.close()

    return
Example #4
0
def plot_MgFe_D4000(output, basedir='.', exclude=excl,zcuts=[],rcuts=[]):
    
    import tau_indecies as ti

    tmpMgFe = []
    tmpD4000 = []
    r = []
    z = []
    for p in range(6):
        bandfile = '{}/NGC_891_P{}_bin30.msoz.bands.dat'.format(basedir,p+1)
        D4000file = '{}/NGC_891_P{}_bin30.msoz.Dn4000.dat'.format(basedir,p+1)
        loc = '{}/NGC_891_P{}_bin30_locations.dat'.format(basedir,p+1)
        tmpr, tmpz = np.loadtxt(loc, usecols=(4,5), unpack=True)
        tmpr = np.abs(tmpr)
        tmpz = np.abs(tmpz)

        D4000 = quick_eat(D4000file)[:,1]
        MgFe = ti.quick_eat(bandfile)[:,6]

        exar = np.array(exclude[p]) - 1
        D4000 = np.delete(D4000, exar)
        MgFe = np.delete(MgFe, exar)
        tmpr = np.delete(tmpr, exar)
        tmpz = np.delete(tmpz, exar)
        
        tmpMgFe.append(MgFe)
        tmpD4000.append(D4000)
        r.append(tmpr)
        z.append(tmpz)

    bigD4000 = np.hstack(tmpD4000)
    bigMgFe = np.hstack(tmpMgFe)
    r = np.hstack(r)
    z = np.hstack(z)

    fig = plt.figure()
    lax = fig.add_subplot(111, label='biglabel') #label is necessary if len(zcuts) == len(rcuts) == 0
    lax.spines['top'].set_visible(False)
    lax.spines['right'].set_visible(False)
    lax.spines['bottom'].set_visible(False)
    lax.spines['left'].set_visible(False)   
    lax.set_xticklabels([])
    lax.set_yticklabels([])
    lax.set_xlabel('<MgFe>')
    lax.set_ylabel('Dn4000')
    lax.tick_params(axis='both',pad=20,length=0)

    bigz = [0] + zcuts + [2.6]
    bigr = [0] + rcuts + [11]
    
    i = 1
    for zz in range(len(zcuts) + 1):
        zc = [bigz[-zz-2], bigz[-zz-1]]
        for rr in range(len(rcuts) + 1):
            rc = [bigr[rr], bigr[rr+1]]
            print zc, rc
            ax = fig.add_subplot(len(zcuts)+1,len(rcuts)+1,i)
            idx = np.where((z >= zc[0]) & (z < zc[1])
                           & (r >= rc[0]) & (r < rc[1]))[0]
            ax.scatter(bigMgFe[idx],bigD4000[idx],s=40,linewidths=0,marker='o',alpha=0.7,c='k')
            ax.set_xlim(0,3.9)
            ax.set_ylim(0.82,2.66)
            ax.text(3.5,2.4,'${}\leq |z| <{}$ kpc\n${}\leq |r| <{}$ kpc'.format(*(zc+rc)),ha='right',va='center')
            if i <= (len(zcuts)) * (len(rcuts) + 1):
                ax.set_xticklabels([])
            if len(rcuts) > 0 and i % (len(rcuts)+1) != 1:
                ax.set_yticklabels([])
            i += 1
            
    fig.subplots_adjust(hspace=0.00001,wspace=0.0001)

    pp = PDF(output)
    pp.savefig(ax.figure)
    pp.close()
    plt.close(ax.figure)
    return