Пример #1
0
    def upper_rad_cut(lum, rad,
                      den):  #this should get rid of galaxies outside 4r1/2
        from def_mymath import halflight
        nlum = []
        nrad = []
        nden = []
        mult = 6
        for x in range(len(rad)):
            lums = lum[x]
            rads = rad[x]
            dens = den[x]
            half = math.log10(10**np.max(lums) / 2.0)
            hhx = halflight(rads, lums)

            hhx10 = 10**hhx
            hhx2s = mult * hhx10
            hhx2 = math.log10(hhx2s)
            if np.max(rads) >= hhx2:
                mx = rads[(rads >= hhx) & (rads <= hhx2)]
                if len(mx) >= 4:
                    nlum.append(lums)
                    nrad.append(rads)
                    nden.append(dens)
                else:
                    print('not enough data points')
            else:
                print('Upper limit out of range')
        nlum = np.array(nlum)
        nrad = np.array(nrad)
        nden = np.array(nden)
        return nlum, nrad, nden
Пример #2
0
def get_halflight(bigLIs, bigrads):
    print('Getting Halfs')
    N = np.ndim(bigrads)
    if N == 2:
        print('Array is 2D')
        halfrad = []
        for x in range(len(bigrads)):
            #print('Galaxy #', str(x))
            #print('Luminosity= ', bigLIs[x])
            #print('Radii= ', bigrads[x])
            rad = bigrads[x]
            lum = bigLIs[x]
            half = math.log10(10**np.max(lum) / 2.0)
            fhalf = halflight(rad, lum)
            halfrad.append(fhalf)
        halfrads = np.array(halfrad)
    else:
        halfrads = halflight(bigrads, bigLIs)
    return halfrads
Пример #3
0
def get_mean_halflight(newdata, bands, aperture, scale=''):
    import numpy as np
    from def_get_mags import get_zdistmod, get_kcorrect2, aper_and_comov, abs2lum, lumdensity, abs_mag
    import math
    from defclump import meanlum2, get_error
    import matplotlib.pyplot as plt
    from def_mymath import halflight

    Naps = len(aperture)
    Ndat = len(newdata)
    redshifts = newdata['Z']

    DM = get_zdistmod(newdata, 'Z')

    kcorrect = get_kcorrect2(newdata, 'mag_forced_cmodel', '_err', bands, '',
                             'hsc_filters.dat', redshifts)

    bigLI = []
    bigrad = []
    bigden = []
    for n in range(0, Ndat):
        #this goes through every galaxy

        LI = []
        LI2 = []
        lumdi = []

        string = str(n)
        radkpc = aper_and_comov(aperture, redshifts[n])
        #print('redshifts are ', redshifts[n])

        for a in range(0, Naps):  #this goes through every aperture
            ns = str(a)
            #print('aperture0',ns)

            absg, absr, absi, absz, absy = abs_mag(newdata[n], 'mag_aperture0',
                                                   kcorrect, DM[n], bands, ns,
                                                   n)

            Lumg, Lumr, Lumi, Lumz, Lumy = abs2lum(absg, absr, absi, absz,
                                                   absy)

            Lg, Lr, Li, Lz, Ly = lumdensity(Lumg, Lumr, Lumi, Lumz, Lumy,
                                            radkpc[a])

            #LG.append(Lg)
            #LR.append(Lr)
            #LI.append(Logli)
            if scale == 'log':
                #print('getting logs')
                logLumi = math.log10(Lumi)
                logLi = math.log10(Li)
                LI.append(logLumi)
                lumdi.append(logLi)
            else:
                LI.append(Lumi)
                lumdi.append(Li)
            #LZ.append(Lz)
            #LY.append(Ly)
        #print('Luminosity(i) for ',n,' galaxy is ', LI)
        bigLI.append(LI)
        bigden.append(lumdi)
        if scale == 'log':
            lograd = [math.log10(radkpc[n]) for n in range(len(radkpc))]
            bigrad.append(lograd)
        else:
            bigrad.append(radkpc)

    bigLIs = np.array(bigLI)
    bigrads = np.array(bigrad)
    lumdensi = np.array(bigden)
    bigLIs.flatten()  #luminosity
    bigrads.flatten()  #radii
    lumdensi.flatten()  #luminosity density
    #print('Check: ', bigLIs[0], lumdensi[0])

    meanlum, radavg, bb = meanlum2(bigLIs, bigrads, Naps, scale='log')
    meandens, radavg, bb = meanlum2(lumdensi, bigrads, Naps, scale='log')

    err = 'bootstrap_stdv'
    lumdenerr = get_error(lumdensi, bigrads, bb, error=err)

    print('Mean Luminosity= ', meanlum)
    print('Mean LumDensity=', meandens)
    print('Mean Radii= ', radavg)
    print('Standard Deviation= ', lumdenerr)

    halfrad = halflight(radavg, meanlum)

    print('Half Radius is ', halfrad)

    return meandens, radavg, lumdenerr, halfrad
Пример #4
0
def get_halflight(newdata, bands, aperture, scale=''):
    import numpy as np
    from def_get_mags import get_zdistmod, get_kcorrect2, aper_and_comov, abs2lum, lumdensity, abs_mag
    import math
    from defclump import meanlum2
    from my_def_plots import halflight_plot, scatter_fit
    from scipy import interpolate
    import matplotlib.pyplot as plt
    from def_mymath import halflight

    Naps = len(aperture)
    Ndat = len(newdata)
    redshifts = newdata['Z']

    DM = get_zdistmod(newdata, 'Z')
    kcorrect = get_kcorrect2(newdata, 'mag_forced_cmodel', '_err', bands, '',
                             'hsc_filters.dat', redshifts)
    fig = plt.figure()
    bigLI = []
    bigrad = []
    bigden = []
    for n in range(0, Ndat):
        #this goes through every galaxy
        #LG=[]
        #LR=[]
        LI = []
        LI2 = []
        lumdi = []
        #LZ=[]
        #LY=[]
        string = str(n)
        radkpc = aper_and_comov(aperture, redshifts[n])
        print('redshifts is ', redshifts[n])

        for a in range(0, Naps):  #this goes through every aperture
            ns = str(a)
            print('aperture0', ns)

            absg, absr, absi, absz, absy = abs_mag(newdata[n], 'mag_aperture0',
                                                   kcorrect, DM[n], bands, ns,
                                                   n)

            Lumg, Lumr, Lumi, Lumz, Lumy = abs2lum(absg, absr, absi, absz,
                                                   absy)

            Lg, Lr, Li, Lz, Ly = lumdensity(Lumg, Lumr, Lumi, Lumz, Lumy,
                                            radkpc[a])

            if scale == 'log':
                print('getting logs')
                logLumi = math.log10(Lumi)
                logLi = math.log10(Li)
                LI.append(logLumi)
                lumdi.append(logLi)
            else:
                LI.append(Lumi)
                lumdi.append(Li)
            #LZ.append(Lz)
            #LY.append(Ly)
        print('LI for ', n, ' galaxy is ', LI)
        bigLI.append(LI)
        bigden.append(lumdi)
        if scale == 'log':
            lograd = [math.log10(radkpc[n]) for n in range(len(radkpc))]
            bigrad.append(lograd)
        else:
            bigrad.append(radkpc)

    bigLIs = np.array(bigLI)

    bigrads = np.array(bigrad)

    lumdensi = np.array(bigden)

    halfrad = []
    halflum = []
    for x in range(len(bigrads)):
        #print('Galaxy #', str(x))
        #print('Luminosity= ', bigLIs[x])
        #print('Radii= ', bigrads[x])
        #f=interpolate.interp1d(bigLIs[x],bigrads[x], kind='linear', axis=-1)
        #half=(np.max(bigLIs[x])+np.min(bigLIs[x]))/2.0
        half = math.log10(10**np.max(bigLIs[x]) / 2.0)

        #print('Half Luminosity= ', half)
        #print('Half radius= ',f(half))
        fhalf = halflight(bigrads[x], bigLIs[x])

        halflum.append(half)
        halfrad.append(fhalf)

    halfrads = np.array(halfrad)
    halflums = np.array(halflum)

    print(len(bigrads), len(bigrads[0]))

    return halfrads, bigrads, lumdensi