def isoDensityMap(isoroot):
    isoDensity, isoDensityStd = loadIsotropicResults(isoroot)

    # Calculate the average of the average density from the isotropic 
    # simulations. 
    avgIsoDensity = isoDensity.mean(axis=0)
    stdIsoDensity = isoDensity.std(axis=0)

    # Plot the maps
    healpix.plot(avgIsoDensity, showdisks=True, 
                 unit='Avg. Density [stars/deg^2]')
    py.savefig(isoroot + '_avg.png')

    healpix.plot(stdIsoDensity, showdisks=True, 
                 unit='Std. Density [stars/deg^2]')
    py.savefig(isoroot + '_std.png')
Exemple #2
0
def isoDensityMap(isoroot):
    isoDensity, isoDensityStd = loadIsotropicResults(isoroot)

    # Calculate the average of the average density from the isotropic
    # simulations.
    avgIsoDensity = isoDensity.mean(axis=0)
    stdIsoDensity = isoDensity.std(axis=0)

    # Plot the maps
    healpix.plot(avgIsoDensity,
                 showdisks=True,
                 unit='Avg. Density [stars/deg^2]')
    py.savefig(isoroot + '_avg.png')

    healpix.plot(stdIsoDensity,
                 showdisks=True,
                 unit='Std. Density [stars/deg^2]')
    py.savefig(isoroot + '_std.png')
Exemple #3
0
def distNormalVector(N, outdir):
    incl = np.arccos(2.0 * scipy.rand(N) - 1.0)
    omeg = scipy.rand(N) * 2.0 * math.pi

    # Double check for random orientation
    nside = 4
    npix = healpy.nside2npix(nside)
    hidx = healpy.ang2pix(nside, incl, omeg)

    pdf = np.zeros(npix)
    for hh in hidx:
        pdf[hh] += 1

    healpix.plot(pdf, unit='N stars')
    py.savefig(outdir + 'heal_io_sim.png')
    py.close()

    incl = np.degrees(incl)
    omeg = np.degrees(omeg)

    return (incl, omeg)
def distNormalVector(N, outdir):
    incl = np.arccos( 2.0 * scipy.rand(N) - 1.0 )
    omeg = scipy.rand(N) * 2.0 * math.pi
    
    # Double check for random orientation
    nside = 4
    npix = healpy.nside2npix(nside)
    hidx = healpy.ang2pix(nside, incl, omeg)

    pdf = np.zeros(npix)
    for hh in hidx:
        pdf[hh] += 1

    healpix.plot(pdf, unit='N stars')
    py.savefig(outdir + 'heal_io_sim.png')
    py.close()
    
    incl = np.degrees(incl)
    omeg = np.degrees(omeg)

    return (incl, omeg)
Exemple #5
0
def probabilityMap(obsdir, isoroot):
    """
    Read a healpix map of our observed density of normal vectors.
    For each pixel in the map, calculate the probability distribution
    for the corresponding pixel from isotropic simulations. This yields
    a "probability map" indicating the probability that the observed
    density of normal vectors could be the result of an isotropic 
    distribution of stars.

    Parameters:
    obsdir -- the directory to search for the disk.neighbor.dat file
    isoroot -- the directory and root file name for the isotropic simulations.
               an example would be 'iso_test/iso_d_avg_0.8_13.5_73_200_1000'
               and all files with this root name will be included in the
               isotropic simulations.
    """
    Nside = 32
    Npix = healpy.nside2npix(Nside)

    # Load the observations
    from papers import lu06yng as lu
    obsDensity, obsDensityStd = lu.loadDiskDensity(Npix, orbDir=obsdir)

    # Load results from the Isotropic Simulations
    isoDensity, isoDensityStd = loadIsotropicResults(isoroot)

    # Get the inclination and omegas for each pixel
    pixIdx = np.arange(0, Npix)
    (ipix, opix) = healpy.pix2ang(Nside, pixIdx)
    ipix = np.degrees(ipix)
    opix = np.degrees(opix)

    # Construct a probability map and a gaussian significance map
    probMap = np.zeros(Npix, dtype=float)
    gsigMap = np.zeros(Npix, dtype=float)

    # Calculate the values for each pixel.
    for jj in range(Npix):
        i = ipix[jj]
        o = opix[jj]
        density = obsDensity[jj]

        probMap[jj] = probabilityFromMap(i,
                                         o,
                                         density,
                                         isoDensity,
                                         verbose=False)

        # Calculate the average of the average density from the isotropic
        # simulations.
        avgIsoDensity = isoDensity[:, jj].mean()
        stdIsoDensity = isoDensity[:, jj].std()

        # Use the same definition as Bartko et al.
        gsigMap[jj] = (density - avgIsoDensity) / stdIsoDensity

    # Find the peak in the observations
    peakIdx = obsDensity.argmax()
    peakIncl = ipix[peakIdx]
    peakOmeg = opix[peakIdx]
    peakDens = obsDensity[peakIdx]
    print 'Disk candidate: '
    print '    inclination = %6.2f deg' % (peakIncl)
    print '    Omega       = %6.2f deg' % (peakOmeg)
    print '    density     = %9.5f stars/deg^2' % (peakDens)
    print 'Probability of measuring this density or higher'
    print 'from an isotropic distribution is:'
    print '    Prob        = %.2e' % (probMap[peakIdx])

    probMapLog = np.ma.masked_where(probMap == 0, np.log10(probMap))
    healpix.plot(probMapLog, showdisks=True, unit='Log Probabilty')
    py.savefig(obsdir + 'iso_probability_map.png')

    healpix.plot(gsigMap, showdisks=True, unit='normal sigma')
    py.savefig(obsdir + 'iso_significance_map.png')
def probabilityMap(obsdir, isoroot):
    """
    Read a healpix map of our observed density of normal vectors.
    For each pixel in the map, calculate the probability distribution
    for the corresponding pixel from isotropic simulations. This yields
    a "probability map" indicating the probability that the observed
    density of normal vectors could be the result of an isotropic 
    distribution of stars.

    Parameters:
    obsdir -- the directory to search for the disk.neighbor.dat file
    isoroot -- the directory and root file name for the isotropic simulations.
               an example would be 'iso_test/iso_d_avg_0.8_13.5_73_200_1000'
               and all files with this root name will be included in the
               isotropic simulations.
    """
    Nside = 32
    Npix = healpy.nside2npix(Nside)

    # Load the observations
    from papers import lu06yng as lu
    obsDensity, obsDensityStd = lu.loadDiskDensity(Npix, orbDir=obsdir)

    # Load results from the Isotropic Simulations
    isoDensity, isoDensityStd = loadIsotropicResults(isoroot)

    # Get the inclination and omegas for each pixel
    pixIdx = np.arange(0, Npix)
    (ipix, opix) = healpy.pix2ang(Nside, pixIdx)
    ipix = np.degrees(ipix)
    opix = np.degrees(opix)

    # Construct a probability map and a gaussian significance map
    probMap = np.zeros(Npix, dtype=float)
    gsigMap = np.zeros(Npix, dtype=float)

    # Calculate the values for each pixel.
    for jj in range(Npix):
        i = ipix[jj]
        o = opix[jj]
        density = obsDensity[jj]
        
        probMap[jj] = probabilityFromMap(i, o, density, isoDensity, 
                                         verbose=False)

        # Calculate the average of the average density from the isotropic 
        # simulations. 
        avgIsoDensity = isoDensity[:,jj].mean()
        stdIsoDensity = isoDensity[:,jj].std()

        # Use the same definition as Bartko et al.
        gsigMap[jj] = (density - avgIsoDensity) / stdIsoDensity
    
    # Find the peak in the observations
    peakIdx = obsDensity.argmax()
    peakIncl = ipix[peakIdx]
    peakOmeg = opix[peakIdx]
    peakDens = obsDensity[peakIdx]
    print 'Disk candidate: '
    print '    inclination = %6.2f deg' % (peakIncl)
    print '    Omega       = %6.2f deg' % (peakOmeg)
    print '    density     = %9.5f stars/deg^2' % (peakDens)
    print 'Probability of measuring this density or higher'
    print 'from an isotropic distribution is:'
    print '    Prob        = %.2e' % (probMap[peakIdx])

    probMapLog = np.ma.masked_where(probMap == 0, np.log10(probMap))
    healpix.plot(probMapLog, showdisks=True, unit='Log Probabilty')
    py.savefig(obsdir + 'iso_probability_map.png')

    healpix.plot(gsigMap, showdisks=True, unit='normal sigma')
    py.savefig(obsdir + 'iso_significance_map.png')