コード例 #1
0
ファイル: fakeDFData.py プロジェクト: jobovy/segue-maps
def combine_abundance_singles(binned,options,savename,fehs,afes):
    for ii in range(len(fehs)):
        thisdata= binned(fehs[ii],afes[ii])
        thisdataIndx= binned.callIndx(fehs[ii],afes[ii])
        #Read from temporary file
        spl= savename.split('.')
        newname= ''
        for jj in range(len(spl)-1):
            newname+= spl[jj]
            if not jj == len(spl)-2: newname+= '.'
        newname+= '_%i.' % ii
        newname+= spl[-1]
        newdata= _load_fits(newname)
        #Load into binned
        binned.data.feh[thisdataIndx]= newdata.feh
        binned.data.dered_r[thisdataIndx]= newdata.dered_r
        binned.data.dered_g[thisdataIndx]= newdata.dered_g
        binned.data.plate[thisdataIndx]= newdata.plate
        binned.data.ra[thisdataIndx]= newdata.ra
        binned.data.dec[thisdataIndx]= newdata.dec
        binned.data.l[thisdataIndx]= newdata.l
        binned.data.b[thisdataIndx]= newdata.b
        binned.data.vr[thisdataIndx]= newdata.vr
        binned.data.pmra[thisdataIndx]= newdata.pmra
        binned.data.pmdec[thisdataIndx]= newdata.pmdec
        #Remove temporary file
        os.remove(newname)
    return binned
コード例 #2
0
def plotMetallicityColor(options,args):
    if options.png: ext= 'png'
    else: ext= 'ps'
    #Load data
    XYZ,vxvyvz,cov_vxvyvz,data= readData(metal=options.metal,
                                         sample=options.sample)
    #Load plates
    platestr= segueSelect._load_fits(os.path.join(segueSelect._SEGUESELECTDIR,
                                      'segueplates.fits'))
    #Set up ranges
    if options.sample.lower() == 'g':
        xrange=[0.46,0.57]
        rmin, rmax= 14.5, 20.2
        grmin, grmax= 0.48, 0.55
        rx= 0.47
        colorrange=[0.48,0.55]
    elif options.sample.lower() == 'k':
        xrange=[0.51,0.79]
        rmin, rmax= 14.5, 19.
        grmin, grmax= 0.55,0.75
        rx= 0.01/.11*(xrange[1]-xrange[0])+xrange[0]
        colorrange=[0.55,0.75]
    if options.metal.lower() == 'rich':
        yrange=[-0.55,0.5]
        ry= 0.275
        fehrange= _APOORFEHRANGE
    elif options.metal.lower() == 'poor':
        yrange=[-1.6,0.3]
        ry= yrange[1]-(.5-0.275)*(yrange[1]-yrange[0])
        fehrange= _ARICHFEHRANGE
    #First plot all data, faint, and bright
    bovy_plot.bovy_print()
    _plotMC_single(data,options,args,all=True,overplot=False,xrange=xrange,
                   yrange=yrange,fehrange=fehrange,colorrange=colorrange)
    _overplot_model(data,xrange=xrange,yrange=yrange,fehrange=fehrange,
                    colorrange=colorrange)
    bovy_plot.bovy_end_print(os.path.join(args[0],'FeH_gr_'+options.sample+'_'+options.metal+'.'+ext))
    #Then plot them pixel-by-pixel
    platelb= bovy_coords.radec_to_lb(platestr.ra,platestr.dec,
                                     degree=True)
    nside= 1
    for ii in range(12*nside**2):
        #First find all of the plates in this pixel
        indx= (platestr.healpix_level1 == ii)
        if numpy.sum(indx) == 0: continue #No match
        thisplatestr= platestr[indx]
        platels= platelb[indx,0]
        platebs= platelb[indx,1]
        indx= []
        for jj in range(len(data.ra)):
            if data[jj].plate in list(thisplatestr.plate):
                indx.append(True)
            else:
                indx.append(False)
        indx= numpy.array(indx,dtype='bool')
        if numpy.sum(indx) == 0: continue #No matches
        bovy_plot.bovy_print()
        _plotMC_single(data[indx],options,args,all=False,overplot=False,
                       xrange=xrange,yrange=yrange,platels=platels,
                       platebs=platebs,
                       ry=ry,rx=rx,
                       rmin=rmin,rmax=rmax,grmin=grmin,grmax=grmax)
        _overplot_model(data,xrange=xrange,yrange=yrange,fehrange=fehrange,
                        colorrange=colorrange)
        bovy_plot.bovy_end_print(os.path.join(args[0],'FeH_gr_'+options.sample+'_'+options.metal+'_%i.' % ii + ext))
    return None