Exemple #1
0
def distanceAreaIntegrand(dist, cosb, Gsamples, rmcenter, onlygreen):
    # Calculate the density
    densmap = densprofiles.healpixelate(dist,
                                        densprofiles.expdisk,
                                        [1. / 3., 1. / 0.3],
                                        nside=_NSIDE,
                                        nest=False)
    # Load the dust map
    if onlygreen:
        combinedmap = dust.load_green15(dist, nest=False, nside_out=_NSIDE)
        combinedmap[combinedmap == healpy.UNSEEN] = 0.
    else:
        combinedmap = dust.load_combined(dist, nest=False, nside_out=_NSIDE)
    # Sample over the distribution of MG
    combinedmask = numpy.zeros_like(combinedmap)
    G0 = 0.68 + dust.dist2distmod(dist)
    if dust.dist2distmod(dist) == 9.5 or dust.dist2distmod(dist) == 10.5:
        print numpy.sum(numpy.isnan(combinedmap))
    for jj in range(_NGSAMPLES):
        combinedmask+= ((combinedmap > (_GMIN-G0-Gsamples[jj]+0.68))\
                            *(combinedmap < (_GMAX-G0-Gsamples[jj]+0.68))).astype('float')
    combinedmask /= _NGSAMPLES
    if dust.dist2distmod(dist) == 9.5 or dust.dist2distmod(dist) == 10.5:
        print numpy.sum(combinedmask)
        print dust.dist2distmod(dist), numpy.sum(cosb * densmap * combinedmask)
    # If rmcenter, rm the center of the MW
    if rmcenter:
        theta, phi = healpy.pixelfunc.pix2ang(
            _NSIDE,
            numpy.arange(healpy.pixelfunc.nside2npix(_NSIDE)),
            nest=False)
        combinedmask[((phi < 25.*_DEGTORAD)+(phi > (360.-25.)*_DEGTORAD))\
                         *(numpy.fabs(numpy.pi/2.-theta) < 25.*_DEGTORAD)]= 0.
    # Compute cross correlation
    return (cosb * densmap * combinedmask)
def distanceAreaIntegrand(dist,cosb,Gsamples,rmcenter,onlygreen):
    # Calculate the density
    densmap= densprofiles.healpixelate(dist,densprofiles.expdisk,
                                       [1./3.,1./0.3],nside=_NSIDE,
                                       nest=False)
    # Load the dust map
    if onlygreen:
        combinedmap= dust.load_green15(dist,nest=False,nside_out=_NSIDE)
        combinedmap[combinedmap == healpy.UNSEEN]= 0.
    else:
        combinedmap= dust.load_combined(dist,nest=False,nside_out=_NSIDE)
    # Sample over the distribution of MG
    combinedmask= numpy.zeros_like(combinedmap)
    G0= 0.68+dust.dist2distmod(dist)
    if dust.dist2distmod(dist) == 9.5 or dust.dist2distmod(dist) == 10.5:
        print numpy.sum(numpy.isnan(combinedmap))
    for jj in range(_NGSAMPLES):
        combinedmask+= ((combinedmap > (_GMIN-G0-Gsamples[jj]+0.68))\
                            *(combinedmap < (_GMAX-G0-Gsamples[jj]+0.68))).astype('float')
    combinedmask/= _NGSAMPLES
    if dust.dist2distmod(dist) == 9.5 or dust.dist2distmod(dist) == 10.5:
        print numpy.sum(combinedmask)
        print dust.dist2distmod(dist), numpy.sum(cosb*densmap*combinedmask)
    # If rmcenter, rm the center of the MW
    if rmcenter:
        theta, phi= healpy.pixelfunc.pix2ang(_NSIDE,
                                             numpy.arange(healpy.pixelfunc.nside2npix(_NSIDE)),
                                             nest=False)
        combinedmask[((phi < 25.*_DEGTORAD)+(phi > (360.-25.)*_DEGTORAD))\
                         *(numpy.fabs(numpy.pi/2.-theta) < 25.*_DEGTORAD)]= 0.
    # Compute cross correlation
    return (cosb*densmap*combinedmask)
def plot_dustwapogee(plotname):
    # Load the dust map
    green15map= dust.load_green15(5.,nest=True,nside_out=_NSIDE)
    green15map[green15map == healpy.UNSEEN]= -1.
    # plot it
    healpy.visufunc.mollview(green15map,
                             nest=True,
                             xsize=4000,min=0.,max=.8,
                             format=r'$%g$',
                             title='',
                             cmap='gist_yarg',
                             unit='$A_H\,(\mathrm{mag})$')
    # Load the RC data to get the fields
    data= define_rcsample.get_rcsample()
    loc_ids= numpy.array(list(set(data['LOCATION_ID'])))
    # Load the selection function, just to get the field centers
    apo= apogee.select.apogeeSelect(_justprocessobslog=True)
    theta= numpy.empty(len(loc_ids))
    phi= numpy.empty(len(loc_ids))
    for ii,loc_id in enumerate(loc_ids):
        tl, tb= apo.glonGlat(loc_id)
        theta[ii]= (90.-tb)/180.*numpy.pi
        phi[ii]= tl/180.*numpy.pi
    hib= numpy.fabs((numpy.pi/2.-theta)) > (8./180.*numpy.pi)
    healpy.visufunc.projplot(theta[hib],phi[hib],'o',ms=5.,mfc='none',mew=0.8,
                             mec='k')
    lowb= True-hib
    healpy.visufunc.projplot(theta[lowb],phi[lowb],'o',ms=5.,mfc='none',
                             mec='w',mew=0.8)
    bovy_plot.bovy_end_print(plotname)
Exemple #4
0
def plot_dust(dist,plotname):
    # Load the dust map
    green15map= dust.load_green15(dist,nest=True,nside_out=_NSIDE)
    dm= dust.dist2distmod(dist)
    green15map[green15map == healpy.UNSEEN]= -1.
    # plot it
    healpy.visufunc.mollview(green15map,
                             nest=True,
                             xsize=4000,min=0.,
                             max=round(10.*(12.8-dm+1.49))/10.,
                             format=r'$%g$',
                             title=r'$\mathrm{Extinction\ to\ %.1f\,kpc}$' % dist,
                             cmap='gist_yarg',
                             unit='$A_H\,(\mathrm{mag})$')
    bovy_plot.bovy_end_print(plotname)
def plot_dustwapogee(plotname):
    # Load the dust map
    green15map = dust.load_green15(5., nest=True, nside_out=_NSIDE)
    green15map[green15map == healpy.UNSEEN] = -1.
    # plot it
    healpy.visufunc.mollview(green15map,
                             nest=True,
                             xsize=4000,
                             min=0.,
                             max=.8,
                             format=r'$%g$',
                             title='',
                             cmap='gist_yarg',
                             unit='$A_H\,(\mathrm{mag})$')
    # Load the RC data to get the fields
    data = define_rcsample.get_rcsample()
    loc_ids = numpy.array(list(set(data['LOCATION_ID'])))
    # Load the selection function, just to get the field centers
    apo = apogee.select.apogeeSelect(_justprocessobslog=True)
    theta = numpy.empty(len(loc_ids))
    phi = numpy.empty(len(loc_ids))
    for ii, loc_id in enumerate(loc_ids):
        tl, tb = apo.glonGlat(loc_id)
        theta[ii] = (90. - tb) / 180. * numpy.pi
        phi[ii] = tl / 180. * numpy.pi
    hib = numpy.fabs((numpy.pi / 2. - theta)) > (8. / 180. * numpy.pi)
    healpy.visufunc.projplot(theta[hib],
                             phi[hib],
                             'o',
                             ms=5.,
                             mfc='none',
                             mew=0.8,
                             mec='k')
    lowb = True - hib
    healpy.visufunc.projplot(theta[lowb],
                             phi[lowb],
                             'o',
                             ms=5.,
                             mfc='none',
                             mec='w',
                             mew=0.8)
    bovy_plot.bovy_end_print(plotname)