Пример #1
0
def filtertext(phot):
    filters = list(set([bmccom.band_name_nodigits_regex(b) for b in phot]))
    fw = [dld._eff_wavelength[fil] for fil in filters]
    fzip = sorted(list(zip(fw, filters)), key=lambda x: x[0])
    txt = "filters present\n(shortest to longest wavelength):\n"
    for fz in fzip:
        txt += f"{fz[1]} ({fz[0]:.2f} $\mu$m)\n"
    return txt
Пример #2
0
def _etglikelihood(jab, zin, zf, Jfilter, photom):
    predJ = 3631. * (10**(-0.4 * jab))
    lk = 1.
    for band in photom:
        if photom[band]['f'] is not None:
            colour = _model[zf][f'X-J_{Jfilter}'][
                bmccom.band_name_nodigits_regex(band)][f"{zin:.2f}"]
            predb = predJ * 10**(-0.4 * colour)
            lk *= bmccom.liketerm(predb, photom[band]['f'], photom[band]['e'])
    return lk
Пример #3
0
def _mltlikelihood(fj, t, Jfilter, photom):
    lk = 1.
    for band in photom:
        if photom[band]['f'] is not None:
            colour = _model[t][f'X-J_{Jfilter}'][
                bmccom.band_name_nodigits_regex(band)]
            predb = fj * 10**(
                -0.4 * colour
            ) if colour < 10 else 0.  #deals with blue filters which have been set to colour = 100 above
            lk *= bmccom.liketerm(predb, photom[band]['f'],
                                  photom[band]['e_mlt'])
    return lk
Пример #4
0
def _qsolikelihood(M, zin, qm, Jfilter, photom):
    #always start with a model J band flux based on the value of M passed in
    predJ = _Jflx_from_M1450(M, zin, qm, Jfilter)
    lk = 1.
    for band in photom:
        if photom[band]['f'] is not None:
            colour = _model[qm][f'X-J_{Jfilter}'][
                bmccom.band_name_nodigits_regex(band)][f"{zin:.2f}"]
            #the code will have already checked the redshift limits
            #so very blue H/K/W-J colours (z>10) are not an issue (where template fJ = 0).
            #we now deal with very red X-J colours in bluer X bands,
            #where template flux can be zero.
            predb = predJ * 10**(-0.4 * colour) if colour < 8 else 0.
            lk *= bmccom.liketerm(predb, photom[band]['f'], photom[band]['e'])
    return lk
Пример #5
0
def best_fit_sed_plot(d, phot, JF):
    bfq = hzq.best_fit_SED(phot, JF)
    qw, qf = zip(*make_plottable_sed(bfq))
    bfg = etg.best_fit_SED(phot, JF)
    gw, gf = zip(*make_plottable_sed(bfg))
    bfs = mlt.best_fit_SED(phot, JF)
    sw, sf = zip(*make_plottable_sed(bfs))
    #make plot
    fig = plt.figure(figsize=(8, 5), dpi=100)
    ax1 = fig.add_subplot(111)
    #xmin = round(min(bfq['wavelengths'])-0.2,2) ; xmax = round(max(bfq['wavelengths'])+0.25,2)
    #ymin = round((1.E6*min(bfq['f']))-0.2,1); ymax = round((1.E6*max(bfq['f']))+0.5,1)
    #ax1.set_xlim(xmin,xmax);
    ax1.set_xlabel(r'wavelength ($\mu$m)', fontsize=11)
    ax1.set_ylabel(r'flux ($\mu$Jy)', fontsize=11)
    ax1.plot(qw, qf, 'k-', lw=2, label='quasar')
    ax1.plot(gw, gf, 'r--', lw=2, label='galaxy')
    ax1.plot(sw, sf, 'y:', lw=2, label='MLT')  #plot templates
    #plot the source
    sourcew, sourcef, sourcee = [], [], []
    for i, e in enumerate(bfq['e']):
        if type(e) != str:
            sourcew.append(bfq['wavelengths'][i])
            sourcef.append(bfq['f'][i] * 1.E6)
            sourcee.append(e * 1.E6)
    ax1.errorbar(sourcew,
                 sourcef,
                 sourcee,
                 linestyle="None",
                 color='b',
                 capsize=4,
                 marker='o',
                 ms=4,
                 label='photometry')
    #check the photometry dictionary for any limits bands - these won't have been included in the chisq fitting
    xmin, xmax, xmajloc, xminloc, ymajloc, yminloc = plot_params(ax1)
    for b in phot:
        b_nodigits = bmccom.band_name_nodigits_regex(b)
        w = dld._eff_wavelength[b_nodigits]
        #ax1.text(w,-ymajloc*0.5,f"{b_nodigits}",fontsize=7)
        if type(phot[b]['e']) == str:
            #b_nodigits = bmccom.remove_digits(b);
            w = dld._eff_wavelength[b_nodigits]
            ax1.errorbar(w,
                         phot[b]['f'],
                         xerr=0.75 * xminloc,
                         yerr=yminloc,
                         linestyle="None",
                         color='b',
                         uplims=1)

    ax1.tick_params(axis='both', which='major', labelsize=10)
    ax1.xaxis.set_major_locator(tck.MultipleLocator(xmajloc))
    ax1.xaxis.set_minor_locator(tck.MultipleLocator(xminloc))
    ax1.yaxis.set_major_locator(tck.MultipleLocator(ymajloc))
    ax1.yaxis.set_minor_locator(tck.MultipleLocator(yminloc))
    ax1.set_ylim(bottom=-ymajloc)
    ax1.set_xlim(right=xmax)
    ax1.legend(frameon=0, fontsize=9)
    flttxt = filtertext(phot)
    ax1.text(0.66 * xmax, yminloc - ymajloc, flttxt, fontsize=8)
    plottxt = plottext(d, phot, bfq, bfg, bfs, JF)
    ax1.text(xmax + xminloc, ymajloc, plottxt, fontsize=6)
    plot_params(ax1)
    plt.subplots_adjust(left=0.1, right=0.75)
    return fig