Пример #1
0
def optical_lumfn(obsmag, band, params, z=0.):
    """
    Calculate optical luminosity function in some band, for a given set of 
    model parameters.
    """
    # Include dust attenuation correction in the optical
    dndmag_sfms, dndmag_pass = g.optical_mag_fn_atten(hm,
                                                      obsmag,
                                                      band,
                                                      z=z,
                                                      params=params)
    phi = dndmag_sfms + dndmag_pass
    return phi
Пример #2
0
def optical_lumfn(obsmag, band, params, z=0., atten=True):
    """
    Calculate optical luminosity function in some band, for a given set of 
    model parameters.
    """
    # Decide whether dust-attenuated optical luminosity fn. should be used
    if atten and band != 'z': # FIXME: Temporary hack to ignore atten. for z-band
        # Include dust attenuation correction in the optical
        dndmag_sfms, dndmag_pass = g.optical_mag_fn_atten( hm, obsmag, band, 
                                                           z=z, params=params )
    else:
        # No dust attenuation in the optical
        dndmag_sfms, dndmag_pass = g.optical_mag_fn( hm, obsmag, band, z=z, 
                                                     params=params )
    phi = dndmag_sfms + dndmag_pass
    return phi
Пример #3
0
def optical_lumfn(obsmag, band, params, z=0., atten=True):
    """
    Calculate optical luminosity function in some band, for a given set of 
    model parameters.
    """
    # Decide whether dust-attenuated optical luminosity fn. should be used
    if atten and band != 'z':  # FIXME: Temporary hack to ignore atten. for z-band
        # Include dust attenuation correction in the optical
        dndmag_sfms, dndmag_pass = g.optical_mag_fn_atten(hm,
                                                          obsmag,
                                                          band,
                                                          z=z,
                                                          params=params)
    else:
        # No dust attenuation in the optical
        dndmag_sfms, dndmag_pass = g.optical_mag_fn(hm,
                                                    obsmag,
                                                    band,
                                                    z=z,
                                                    params=params)
    phi = dndmag_sfms + dndmag_pass
    return phi
Пример #4
0
P.xlabel(pname2)
"""

pname = 'extinction_amp'
p0 = params[pname]
#vals = params['extinction_amp'] * np.linspace(0.3, 1.5, 10)
vals = params['extinction_amp'] * np.logspace(-5., -2., 10)

P.errorbar(mag_gama, Phi_gama, yerr=err_gama, marker='.', color='r', 
           ls='none', capsize=4., elinewidth=1.5, mew=1.5)

#params['extinction_amp'] = 1e-5
for v in vals:
    print v / p0
    params[pname] = v
    magfn_sfms, magfn_pass = g.optical_mag_fn_atten(hm, mag_gama, band=BAND, 
                                                    z=0., params=params)
    logL = loglike_optical_lf(mag_gama, Phi_gama, err_gama, BAND, params, 0.,
                                  magfn_sfms + magfn_pass)
    
    P.plot(mag_gama, magfn_sfms + magfn_pass, lw=1.8, 
           label="%s = %3.3e, $\log \mathcal{L} = %2.1f$" % (pname, v/p0, -logL))

P.title(BAND)
P.legend(loc='lower left', frameon=False)
P.yscale('log')
P.gca().invert_xaxis()
P.tight_layout()


P.show()
Пример #5
0
    ax1 = P.subplot(gs[i])
    ax2 = P.subplot(gs[i+5])
    
    # Load GAMA band binned luminosity fun. for this band
    hh = 0.67
    gama_mag, gama_n, gama_err, gama_ngal = \
                             np.genfromtxt("../lumfns/lf%s_z0_driver12.data" % b).T
    gama_mag += 5.*np.log10(hh)
    gama_n *= hh**3. # Convert (Mpc/h)^-3 -> (Mpc)^-3
    gama_err *= hh**3.
    ax1.errorbar(gama_mag, gama_n, yerr=gama_err, marker='.', color=col, 
                 ls='none', capsize=4., elinewidth=1.5, mew=1.5)
    
    # Calculate number density as a function of magnitude
    dndmag_sfms, dndmag_pass = \
        g.optical_mag_fn_atten(hm, mag, band=b, z=0., params=params)
        #g.optical_mag_fn_dust( hm, gama_mag, mag, band=b, z=0.,
        #                       params=params, include_intrinsic=True)

    # Results from my calculation
    ax1.plot(mag, dndmag_sfms + dndmag_pass, color=col, lw=1.8) 
    #       label="%s-band" % b)
    ax1.plot(mag, dndmag_sfms, color=col, lw=1.8, ls='dashed')
    ax1.plot(mag, dndmag_pass, color=col, lw=1.8, dashes=[2,2])
    
    # Add band label to each upper subplot
    ax1.annotate("%s" % b, xy=(0.75, 0.82), xycoords='axes fraction', fontsize=24.)
    
    # Residuals (obtained by interpolating in (y-)log space)
    logdndmag_interp = scipy.interpolate.interp1d(mag, 
                               np.log(dndmag_sfms + dndmag_pass), kind='linear',
    hh = 0.67
    gama_mag, gama_n, gama_err, gama_ngal = \
                             np.genfromtxt("../lumfns/lf%s_z0_driver12.data" % b).T
    gama_mag += 5. * np.log10(hh)
    gama_n *= hh**3.  # Convert (Mpc/h)^-3 -> (Mpc)^-3
    gama_err *= hh**3.
    P.errorbar(gama_mag,
               gama_n,
               yerr=gama_err,
               marker='.',
               color=col,
               ls='none')

    # Calculate number density as a function of magnitude
    dndmag_sfms, dndmag_pass = \
        g.optical_mag_fn_atten(hm, gama_mag, band=b, z=0., params=params)
    #g.optical_mag_fn_dust( hm, gama_mag, mag, band=b, z=0.,
    #                       params=params, include_intrinsic=True)

    # Results from my calculation
    P.plot(gama_mag,
           dndmag_sfms + dndmag_pass,
           color=col,
           lw=1.8,
           label="%s-band" % b)
    P.plot(gama_mag, dndmag_sfms, color=col, lw=1.8, ls='dashed')
    P.plot(gama_mag, dndmag_pass, color=col, lw=1.8, ls='dotted')

    # Save data to file
    #np.savetxt("model_lumfn_%s.dat" % b,
    #           np.column_stack((mag, dndmag_sfms + dndmag_pass)))