コード例 #1
0
def read_meert_catalog(phot_type=None):
    """Loader for the Meert et al. 2015 catalog of improved photometric measurements
    for galaxies in the SDSS DR7 main galaxy catalog 
    input: phot_type - integer corresponding to the photometry model fit type from the catalog
        1=best fit, 2=deVaucouleurs, 3=Sersic, 4=DeVExp, 5=SerExp
    returns combined structured array with all the data
    """
    import pyfits
    from setup import data_home_dir

    if (phot_type < 1) or (phot_type > 5):
        raise Exception(
            'unsupported type of Meert et al. photometry: %d, choose number between 1 and 5'
        )

    datadir = data_home_dir()
    datameertnonpar = datadir + '\\Meert2015_v2\UPenn_PhotDec_nonParam_rband.fits'
    datameertnonparg = datadir + '\\Meert2015_v2\UPenn_PhotDec_nonParam_gband.fits'
    datameert = datadir + '\\Meert2015_v2\UPenn_PhotDec_Models_rband.fits'
    datasdss = datadir + '\\Meert2015_v2\UPenn_PhotDec_CAST.fits'
    datasdssmodels = datadir + '\\Meert2015_v2\UPenn_PhotDec_CASTmodels.fits'
    datameertg = datadir + '\\Meert2015_v2\UPenn_PhotDec_Models_gband.fits'
    datamorph = datadir + '\\Meert2015_v2\UPenn_PhotDec_H2011.fits'  # morphology probabilities from Huertas-Company et al. 2011

    # mdata tables: 1=best fit, 2=deVaucouleurs, 3=Sersic, 4=DeVExp, 5=SerExp
    mdata = pyfits.open(datameert)[phot_type].data
    mdatag = pyfits.open(datameertg)[phot_type].data
    mnpdata = pyfits.open(datameertnonpar)[1].data
    mnpdatag = pyfits.open(datameertnonparg)[1].data
    sdata = pyfits.open(datasdss)[1].data
    phot_r = pyfits.open(datasdssmodels)[1].data
    morph = pyfits.open(datamorph)[1].data

    # eliminate galaxies with bad photometry
    fflag = mdata['finalflag']
    print(np.size(fflag), "galaxies in Meert et al. sample initially")

    def isset(flag, bit):
        """Return True if the specified bit is set in the given bit mask"""
        return (flag & (1 << bit)) != 0

    # use minimal quality cuts and flags recommended by Alan Meert
    igood = [(phot_r['petroMag'] > 0.) & (phot_r['petroMag'] < 100.) &
             (mnpdata['kcorr'] > 0) & (mdata['m_tot'] > 0) &
             (mdata['m_tot'] < 100) & (isset(fflag, 1) | isset(fflag, 4)
                                       | isset(fflag, 10) | isset(fflag, 14))]

    sdata = sdata[igood]
    phot_r = phot_r[igood]
    mdata = mdata[igood]
    mnpdata = mnpdata[igood]
    mdatag = mdatag[igood]
    mnpdatag = mnpdatag[igood]
    morph = morph[igood]

    return sdata, mdata, mnpdata, phot_r, mdatag, mnpdatag, morph
コード例 #2
0
ファイル: read_data.py プロジェクト: qingyangtang/galaxies
def read_meert_catalog(phot_type=None):
    """Loader for the Meert et al. 2015 catalog of improved photometric measurements
    for galaxies in the SDSS DR7 main galaxy catalog 
    input: phot_type - integer corresponding to the photometry model fit type from the catalog
        1=best fit, 2=deVaucouleurs, 3=Sersic, 4=DeVExp, 5=SerExp
    returns combined structured array with all the data
    """
    import pyfits
    from setup import data_home_dir

    if (phot_type < 1) or (phot_type > 5):
        raise Exception('unsupported type of Meert et al. photometry: %d, choose number between 1 and 5')

    datadir = data_home_dir()
    datameertnonpar = datadir+'/Meert2015_v2/UPenn_PhotDec_nonParam_rband.fits'
    datameertnonparg = datadir+'/Meert2015_v2/UPenn_PhotDec_nonParam_gband.fits'
    datameertnonpari = datadir+'/Meert2015_v2/UPenn_PhotDec_nonParam_iband.fits'
    datameert = datadir+'/Meert2015_v2/UPenn_PhotDec_Models_rband.fits'
    datasdss = datadir+'/Meert2015_v2/UPenn_PhotDec_CAST.fits'
    datasdssmodels = datadir+'/Meert2015_v2/UPenn_PhotDec_CASTmodels.fits'
    datameertg = datadir+'/Meert2015_v2/UPenn_PhotDec_Models_gband.fits'
    datameerti = datadir+'/Meert2015_v2/UPenn_PhotDec_Models_iband.fits'
    datamorph = datadir+'/Meert2015_v2/UPenn_PhotDec_H2011.fits' # morphology probabilities from Huertas-Company et al. 2011

    # mdata tables: 1=best fit, 2=deVaucouleurs, 3=Sersic, 4=DeVExp, 5=SerExp
    mdata = pyfits.open(datameert)[phot_type].data
    mdatag = pyfits.open(datameertg)[phot_type].data
    mdatai = pyfits.open(datameerti)[phot_type].data
    mnpdata = pyfits.open(datameertnonpar)[1].data
    mnpdatag = pyfits.open(datameertnonparg)[1].data
    mnpdatai = pyfits.open(datameertnonpari)[1].data
    sdata = pyfits.open(datasdss)[1].data
    phot_r = pyfits.open(datasdssmodels)[1].data
    morph = pyfits.open(datamorph)[1].data

    # eliminate galaxies with bad photometry
    fflag = mdata['finalflag']
    print np.size(fflag), "galaxies in Meert et al. sample initially"

    def isset(flag, bit):
        """Return True if the specified bit is set in the given bit mask"""
        return (flag & (1 << bit)) != 0
        
    # use minimal quality cuts and flags recommended by Alan Meert
    igood = [(phot_r['petroMag'] > 0.) & (phot_r['petroMag'] < 100.) & (mnpdata['kcorr'] > 0) &
             (mdata['m_tot'] > 0) & (mdata['m_tot'] < 100) &
             (isset(fflag, 1) | isset(fflag, 4) | isset(fflag, 10) | isset(fflag, 14))]

    sdata = sdata[igood]; phot_r = phot_r[igood]; mdata = mdata[igood]; mdatai = mdatai[igood] 
    mnpdata = mnpdata[igood]; mdatag = mdatag[igood]; mnpdatag = mnpdatag[igood]; morph = morph[igood]; mnpdatai = mnpdatai[igood]; 

    return sdata, mdata, mnpdata, phot_r, mdatag, mnpdatag, morph, mdatai, mnpdatai
コード例 #3
0
        
    ax.contour(H, linewidths=np.linspace(1,2,len(lvls))[::-1], 
                colors='whitesmoke', alpha=0.4, levels = lvls, norm = LogNorm(), 
                extent = [xbins[0], xbins[-1], ybins[0], ybins[-1]], interpolation='bicubic')

    if outfile != None:
        plt.savefig(outfile)
    plt.show()

    
if __name__ == '__main__':
    from read_sdss_fits import read_sdss_fits
    from setup import data_home_dir

    # read fits file with the SDSS DR8 main spectroscopic sample
    data = read_sdss_fits(data_home_dir()+'SDSSspecgalsDR8.fit')

    z_max = 0.04

    # redshift cut
    sdata = data[data['z'] < z_max]
    mr = sdata['modelMag_r']
    gr = sdata['modelMag_g'] - sdata['modelMag_r']
    r50 = sdata['petroR50_r']
    sb = mr - 2.5*np.log10(0.5) + 2.5*np.log10(np.pi*(r50)**2)

    from colossus.cosmology import cosmology

    # set cosmology to the best values from 9-year WMAP data
    cosmo = cosmology.setCosmology('WMAP9')