Example #1
0
def gim2d_catalog(cat, band):
    '''
    http://irsa.ipac.caltech.edu/data/COSMOS/tables/morphology/cosmos_morph_zurich_colDescriptions.html
    '''
    '''
    ACS_MU_CLASS 	float 	  	Type of object.
    1 = galaxy
    2 = star
    3 = spurious
    '''
    '''
    ACS_CLEAN 	float 	  	Object useable flag.
    0 = do not use this object
    1 = use this object
    '''
    '''
    FLUX_GIM2D 	float 	counts 	GIM2D total flux
    R_GIM2D 	float 	arcseconds 	GIM2D psf-convolved half-light radius of object
    ELL_GIM2D 	float 	  	GIM2D ellipticity = 1-b/a of object
    PA_GIM2D 	float 	degrees 	GIM2D position angle of object - cw from +y-axis
    DX_GIM2D 	float 	arcseconds 	x-offset of GIM2D-model center from ACS-coordinate center
    DY_GIM2D 	float 	arcseconds 	y-offset of GIM2D-model center from ACS-coordinate center
    SERSIC_N_GIM2D 	float 	  	GIM2D Sersic index
    R_0P5_GIM2D 	float 	arcseconds 	GIM2D half-light radius of object without PSF convolution

    TYPE 	float 	  	ZEST Type CLASS
    1 = Early type
    2 = Disk
    3 = Irregular Galaxy
    9 = no classification
    '''
    '''
    BULG 	float 	  	ZEST "Bulgeness" CLASS - only for Type 2 (disk) galaxies.
    0 = bulge dominated galaxy
    1,2 = intermediate-bulge galaxies
    3 = pure disk galaxy
    9 = no classification
    '''
    '''
    STELLARITY 	float 	  	Visual Stellarity flag.

    0 if ACS_CLASS_STAR<0.6 (object is ASSUMED to be a galaxy; no visual inspection)
    0 if ACS_CLASS_STAR>=0.6 AND object visually identified as a galaxy.
    1 if ACS_CLASS_STAR>=0.6 AND visually identified as a star.
    2 if ACS_CLASS_STAR>=0.8 (object is assumed to be a star and was not visually inspected)
    3 if ACS_CLASS_STAR<0.6 but object is visually identified as a star (e.g. saturated star, etc)

    JUNKFLAG 	float 	  	
    0 = good object
    1 = spurious
    '''

    print('Classifications:', Counter(cat.type).most_common())

    cat.is_galaxy = (cat.stellarity == 0)
    srcs = []
    for t in cat:
        pos = RaDecPos(t.ra, t.dec)
        bright = NanoMaggies(
            **{band: NanoMaggies.magToNanomaggies(t.acs_mag_auto)})
        shape = GalaxyShape(t.r_0p5_gim2d, 1. - t.ell_gim2d, 90. + t.pa_gim2d)

        is_galaxy = (t.is_galaxy * (shape.re >= 0) * (shape.ab <= 1.) *
                     (shape.phi > -999))

        if is_galaxy and t.type == 1:
            # deV
            src = DevGalaxy(pos, bright, shape)
        elif is_galaxy and t.type == 2:
            # exp
            src = ExpGalaxy(pos, bright, shape)
        else:
            src = PointSource(pos, bright)
        srcs.append(src)
    return srcs
Example #2
0
def gim2d_catalog(cat, band):
    '''
    http://irsa.ipac.caltech.edu/data/COSMOS/tables/morphology/cosmos_morph_zurich_colDescriptions.html
    '''
    '''
    ACS_MU_CLASS 	float 	  	Type of object.
    1 = galaxy
    2 = star
    3 = spurious
    '''
    '''
    ACS_CLEAN 	float 	  	Object useable flag.
    0 = do not use this object
    1 = use this object
    '''
    '''
    FLUX_GIM2D 	float 	counts 	GIM2D total flux
    R_GIM2D 	float 	arcseconds 	GIM2D psf-convolved half-light radius of object
    ELL_GIM2D 	float 	  	GIM2D ellipticity = 1-b/a of object
    PA_GIM2D 	float 	degrees 	GIM2D position angle of object - cw from +y-axis
    DX_GIM2D 	float 	arcseconds 	x-offset of GIM2D-model center from ACS-coordinate center
    DY_GIM2D 	float 	arcseconds 	y-offset of GIM2D-model center from ACS-coordinate center
    SERSIC_N_GIM2D 	float 	  	GIM2D Sersic index
    R_0P5_GIM2D 	float 	arcseconds 	GIM2D half-light radius of object without PSF convolution

    TYPE 	float 	  	ZEST Type CLASS
    1 = Early type
    2 = Disk
    3 = Irregular Galaxy
    9 = no classification
    '''

    '''
    BULG 	float 	  	ZEST "Bulgeness" CLASS - only for Type 2 (disk) galaxies.
    0 = bulge dominated galaxy
    1,2 = intermediate-bulge galaxies
    3 = pure disk galaxy
    9 = no classification
    '''

    '''
    STELLARITY 	float 	  	Visual Stellarity flag.

    0 if ACS_CLASS_STAR<0.6 (object is ASSUMED to be a galaxy; no visual inspection)
    0 if ACS_CLASS_STAR>=0.6 AND object visually identified as a galaxy.
    1 if ACS_CLASS_STAR>=0.6 AND visually identified as a star.
    2 if ACS_CLASS_STAR>=0.8 (object is assumed to be a star and was not visually inspected)
    3 if ACS_CLASS_STAR<0.6 but object is visually identified as a star (e.g. saturated star, etc)

    JUNKFLAG 	float 	  	
    0 = good object
    1 = spurious
    '''
    
    print('Classifications:', Counter(cat.type).most_common())
    
    cat.is_galaxy = (cat.stellarity == 0)
    srcs = []
    for t in cat:
        pos = RaDecPos(t.ra, t.dec)
        bright = NanoMaggies(**{band:NanoMaggies.magToNanomaggies(t.acs_mag_auto)})
        shape = GalaxyShape(t.r_0p5_gim2d, 1. - t.ell_gim2d, 90. + t.pa_gim2d)

        is_galaxy = (t.is_galaxy * (shape.re >= 0 ) * (shape.ab <= 1.) *
                     (shape.phi > -999))
        
        if is_galaxy and t.type == 1:
            # deV
            src = DevGalaxy(pos, bright, shape)
        elif is_galaxy and t.type == 2:
            # exp
            src = ExpGalaxy(pos, bright, shape)
        else:
            src = PointSource(pos, bright)
        srcs.append(src)
    return srcs
Example #3
0
def compare_mags(TT, name, ps):
    for i,T in enumerate(TT):
        T.set('exp', np.zeros(len(T), np.uint8)+i)

    plt.clf()
    ap = 5    
    for i,T in enumerate(TT):
        cc = 'rgb'[i]
        plt.plot(T.flux, T.apflux[:, ap] / T.flux,
                 '.', color=cc, alpha=0.5)

        ff, frac = [],[]
        mags = np.arange(14, 24)
        for mlo,mhi in zip(mags, mags[1:]):
            flo = NanoMaggies.magToNanomaggies(mhi)
            fhi = NanoMaggies.magToNanomaggies(mlo)
            I = np.flatnonzero((T.flux > flo) * (T.flux <= fhi))
            ff.append(np.sqrt(flo * fhi))
            frac.append(np.median(T.apflux[I,ap] / T.flux[I]))
        plt.plot(ff, frac, 'o-', color=cc)
        
    plt.xscale('symlog')
    plt.xlim(1., 1e3)
    plt.ylim(0.9, 1.1)
    plt.xlabel('Forced-phot flux')
    plt.ylabel('Aperture / Forced-phot flux')
    plt.axhline(1, color='k', alpha=0.1)
    plt.title('%s region: Aperture %i fluxes' % (name, ap))
    ps.savefig()

    T = merge_tables(TT)

    T.bobjid = T.brickid.astype(int) * 10000 + T.objid
    bomap = {}
    for i,bo in enumerate(T.bobjid):
        try:
            bomap[bo].append(i)
        except KeyError:
            bomap[bo] = [i]

    II = []
    for bo,ii in bomap.items():
        if len(ii) != 3:
            continue
        II.append(ii)
    II = np.array(II)
    print 'II', II.shape

    exps = T.exp[II]
    print 'exposures:', exps
    assert(np.all(T.exp[II[:,0]] == 0))
    assert(np.all(T.exp[II[:,1]] == 1))
    assert(np.all(T.exp[II[:,2]] == 2))

    fluxes = T.flux[II]
    print 'fluxes', fluxes.shape
    meanflux = np.mean(fluxes, axis=1)
    print 'meanfluxes', meanflux.shape

    plt.clf()
    for i in range(3):
        plt.plot(meanflux, fluxes[:,i] / meanflux, '.',
                 color='rgb'[i], alpha=0.5)
    #plt.yscale('symlog')
    plt.xscale('symlog')
    plt.xlabel('Mean flux (nanomaggies)')
    plt.ylabel('Forced-phot flux / Mean')
    #plt.ylim(0, 2)
    plt.ylim(0.9, 1.1)
    plt.xlim(0, 1e3)
    plt.axhline(1, color='k', alpha=0.1)
    plt.title('%s region: Forced-phot fluxes' % name)
    ps.savefig()

    for ap in [4,5,6]:
        apfluxes = T.apflux[:,ap][II,]
        print 'ap fluxes', apfluxes.shape

        plt.clf()
        for i in range(3):
            plt.plot(meanflux, apfluxes[:,i] / meanflux, '.',
                     color='rgb'[i], alpha=0.5)
        plt.xscale('symlog')
        plt.xlabel('Mean flux (nanomaggies)')
        plt.ylabel('Aperture(%i) flux / Mean' % ap)
        plt.ylim(0.9, 1.1)
        plt.xlim(0, 1e3)
        plt.axhline(1, color='k', alpha=0.1)
        plt.title('%s region: Aperture %i fluxes' % (name, ap))
        ps.savefig()

        plt.clf()
        for i in range(3):
            plt.plot(fluxes[:,i], apfluxes[:,i] / fluxes[:,i], '.',
                     color='rgb'[i], alpha=0.5)
        plt.xscale('symlog')
        plt.xlim(0, 1e3)
        plt.ylim(0.9, 1.1)
        plt.xlabel('Forced-phot flux')
        plt.ylabel('Aperture / Forced-phot flux')
        plt.axhline(1, color='k', alpha=0.1)
        plt.title('%s region: Aperture %i fluxes' % (name, ap))
        ps.savefig()