Пример #1
0
print("ybins : {0:5.3f}".format(bsy))

H, xe, ye = np.histogram2d(lcolor_x, lcolor_y, bins = (nx, ny), normed = True)
H         = gaussian_filter(H, sigma = 2)

# plot contour and residual of sample model galaxies -----------------------------------------------

my_cm = mpl.colors.ListedColormap(np.loadtxt("colormap.dat") / 255)
for i, ax in enumerate(np.ravel(axs)) :
	ax.set_xlim(0.5, 2.5)
	ax.set_ylim(0.0, 1.25)

	ax.contour(xe[:- 1], ye[:- 1], H.T, levels = [0.1], colors = ["#1A1A1A"], lw = 2.5)

	sizes  = std[:, i] * 100
	if i == 0 or i == 3 : colors = err(phy_sam[:, i], med[:, i])
	else                : colors = err(phy_sam[:, i], med[:, i], relative = False)

	xg = np.linspace(0.5, 2.5, 100)
	yg = np.linspace(0.0, 1.25, 100)
	zg = griddata(scolor_x, scolor_y, std[:, i], xg, yg, interp = "linear")

	#cont = ax.contourf(xg, yg, zg, vmin = -1.0, vmax = +1.0, levels = np.linspace(-1., +1., 9), cmap = my_cm)
	cont = ax.contour(xg, yg, zg, 3)
	plt.colorbar(cont)

	#if i == 0 :
		#sc = ax.scatter(scolor_x, scolor_y, lw = 0, c = colors, s = sizes, vmin = -1.0, vmax = +1.0, cmap = my_cm)
		#cb = plt.colorbar(sc)
		#cb.set_label("residual")
		#cb.set_ticks(np.linspace(-1., +1., 9))
Пример #2
0
print("ybins : {0:5.3f}".format(bsy))

H, xe, ye = np.histogram2d(lcolor_x, lcolor_y, bins=(nx, ny), normed=True)
H = gaussian_filter(H, sigma=2)

# plot contour and residual of sample model galaxies -----------------------------------------------

my_cm = mpl.colors.ListedColormap(np.loadtxt("colormap.dat") / 255)
for i, ax in enumerate(np.ravel(axs)):
    ax.set_xlim(0.5, 2.5)
    ax.set_ylim(0.0, 1.25)

    ax.contour(xe[:-1], ye[:-1], H.T, levels=[0.1], colors=["#1A1A1A"], lw=2.5)

    sizes = std[:, i] * 100
    if i == 0 or i == 3: colors = err(phy_sam[:, i], med[:, i])
    else: colors = err(phy_sam[:, i], med[:, i], relative=False)

    xg = np.linspace(0.5, 2.5, 100)
    yg = np.linspace(0.0, 1.25, 100)
    zg = griddata(scolor_x, scolor_y, std[:, i], xg, yg, interp="linear")

    #cont = ax.contourf(xg, yg, zg, vmin = -1.0, vmax = +1.0, levels = np.linspace(-1., +1., 9), cmap = my_cm)
    cont = ax.contour(xg, yg, zg, 3)
    plt.colorbar(cont)

    #if i == 0 :
    #sc = ax.scatter(scolor_x, scolor_y, lw = 0, c = colors, s = sizes, vmin = -1.0, vmax = +1.0, cmap = my_cm)
    #cb = plt.colorbar(sc)
    #cb.set_label("residual")
    #cb.set_ticks(np.linspace(-1., +1., 9))
Пример #3
0
import thesis_redux_tools as rt

from operator import __getslice__

#table = np.loadtxt("../../outputs/photometric_fit/remote_set3/phot_fit_SDSS.physical")
#table = np.loadtxt("../../outputs/photometric_fit/phot_fit_SDSS_dust_fitting_monoZ_dust_fitting_off.physical")
table = np.loadtxt(
    "../../outputs/photometric_fit/remote_set3/photofit_SDSS.physical")
names = np.loadtxt("../../inputs/SFHs_set3/set3_list.log", dtype=np.str)
names = map(__getslice__, names, [0] * names.size, [12] * names.size)

table[:, 6:8] = np.log10(table[:, 6:8])

res = [
    rt.err(table[:,
                 i], table[:, i +
                           1]) if i == 0 else rt.err(table[:,
                                                           i], table[:, i +
                                                                     1], False)
    for i in xrange(0, 10, 2)
]
lab = [
    "mass residuals", "mass weighted age residuals",
    "flux weighted age residuals", "metallicity residuals",
    "dust extinction residuals"
]

for j in xrange(len(res)):
    fig, axs = plt.subplots(5, 13, sharex=True, sharey=True, figsize=(20, 15))

    plt.xlim(-1.5, +1.5)
Пример #4
0
table = np.loadtxt("../../outputs/photometric_fit/remote_set3/photofit_SDSS.physical")

ave_sed = rt.binned_stat(np.loadtxt("../../outputs/spectroscopic_fit/table_din.v4.log")[order_sed], bin_size = 1)
chis    = ave_sed[:, 5:]
ave_sed = ave_sed[:, :5]

sfhs_cat = "../../inputs/run09_sfh_catalog.txt"
u_lib, g_lib, r_lib, i_lib, z_lib, tm, tf, tform, Z, V, pV, mass, mass1gyr, A, mu = np.genfromtxt(sfhs_cat,
missing = '""', usecols = range(39, 44) + [33, 35, 5, 12, 38, 25, 16, 18, 19, 14], unpack = True)

u, g, r, i, z = np.genfromtxt("../../inputs/set3_catalog.txt", usecols = range(39, 39 + 5), unpack = True, missing = '""')

table[:, 6:8] = np.log10(table[:, 6:8])

res_sed = [rt.err(table[:, ::2][:, i], ave_sed[:, i]) if i in [0] else rt.err(table[:, ::2][:, i], ave_sed[:, i], False) for i in xrange(5)]

res_sed.pop(2)

lcolor_x = (u_lib - g_lib)[((V - pV) < 1.2) & (mu < 1.)]
lcolor_y = (g_lib - r_lib)[((V - pV) < 1.2) & (mu < 1.)]

zmask = redshift < 0.03
ocolor_x = (u_obs - g_obs)[zmask]
ocolor_y = (g_obs - r_obs)[zmask]

ug = np.repeat(u - g, 100)
gr = np.repeat(g - r, 100)

nx, xi, xf, bsx = rt.nbins(ocolor_x)
ny, yi, yf, bsy = rt.nbins(ocolor_y)
Пример #5
0
from matplotlib import cm
import thesis_redux_tools as rt

name_pho  = np.loadtxt("../../inputs/SFHs_set3/set3_list.log", usecols = (0,), dtype = "|S")
name_sed  = np.loadtxt("../../outputs/spectroscopic_fit/names.log", dtype = "|S")
order_sed = [j for i in xrange(120) for j in xrange(12000) if name_pho[i] == name_sed[j][:12] + ".fits.gz"]

osed = np.loadtxt("../../outputs/spectroscopic_fit/table_din.v3.log")[order_sed]

sdss = dl.load_data("SDSS")
jpas = dl.load_data("JPAS")

nams = ["M_lib", "M_mod", "log_t_M_lib", "log_t_M_mod", "log_t_L_lib", "log_t_L_mod", "Z_M_lib", "Z_M_mod", "Av_lib", "Av_mod"]

sdss.physical[nams[6]] = np.log10(sdss.physical[nams[6]])
res_sed = [rt.err(sdss.physical[n], osed[:, i]) if i == 0 else rt.err(sdss.physical[n], osed[:, i], False) for i, n in enumerate(nams[::2])]
sdss.physical[nams[6]] = 10 ** sdss.physical[nams[6]]

fig, axs = plt.subplots(2, 3, sharex = True, figsize = (10, 6))
axins    = inset_axes(axs[0, 0], width = "50%", height = "4%", loc = 2)

for i, j in product(xrange(axs.shape[0]), xrange(axs.shape[1])) :

  if j == 0 :
    if i == 0 :
      axs[i, j].set_title("SDSS")
      axs[i, j].set_ylim(-1.5, 3.5)
      axs[i, j].set_ylabel(r"$\Delta\,M/M_\textrm{SSAG}$", fontsize = 15)
      sc = axs[i, j].scatter(sdss.residuals["log_t_M"], sdss.residuals["M"], lw = 0, s = 7, c = sdss.residuals["Av"], vmin = sdss.residuals["Av"].min(), vmax = sdss.residuals["Av"].max())
      x, y = rt.binner(sdss.residuals["log_t_M"], sdss.residuals["M"], "mean", 10)
      axs[i, j].plot(x, y, "--k")
Пример #6
0
#!/usr/bin/python

import numpy as np
import matplotlib.pyplot as plt
import scipy.stats.mstats as st
import thesis_redux_tools as rt

table = np.loadtxt(
    "../../outputs/photometric_fit/photoz/photofit_JPASz3p00.physical")
table = rt.binned_stat(table, 50)

table[:, 2:6] = 10**table[:, 2:6]

res_pho = [
    rt.err(table[:, i], table[:, i + 1]) if i in [0] else rt.err(
        table[:, i], table[:, i + 1], False) for i in xrange(0, 10, 2)
]

#print table[np.argmax(res_pho[0]), 0], np.max(res_pho[0])
#print table[np.argmax(res_pho[1]), 2], np.max(res_pho[1])

mask = table[:, 6] > 0.4

# --------------------------------------------------------------------------------------------------
lm = np.array([0, 1])

plt.figure(figsize=(8, 7))
plt.plot(lm, lm, "--k")

tks, tls = [], []
for per in [10, 30, 50]:
Пример #7
0
import numpy as np
import scipy.stats.mstats as st
import pyfits as pyf
import thesis_redux_tools as rt

from operator import __getslice__

#table = np.loadtxt("../../outputs/photometric_fit/remote_set3/phot_fit_SDSS.physical")
#table = np.loadtxt("../../outputs/photometric_fit/phot_fit_SDSS_dust_fitting_monoZ_dust_fitting_off.physical")
table = np.loadtxt("../../outputs/photometric_fit/remote_set3/photofit_SDSS.physical")
names = np.loadtxt("../../inputs/SFHs_set3/set3_list.log", dtype = np.str)
names = map(__getslice__, names, [0] * names.size, [12] * names.size)

table[:, 6:8] = np.log10(table[:, 6:8])

res = [rt.err(table[:, i], table[:, i + 1]) if i == 0 else rt.err(table[:, i], table[:, i + 1], False) for i in xrange(0, 10, 2)]
lab = ["mass residuals", "mass weighted age residuals", "flux weighted age residuals", "metallicity residuals", "dust extinction residuals"]

for j in xrange(len(res)) :
  fig, axs = plt.subplots(5, 13, sharex = True, sharey = True, figsize = (20, 15))

  plt.xlim(-1.5, +1.5)
  plt.ylim(0, 40)

  axs = np.ravel(axs)

  for i in xrange(65) :
    data   = res[j][i * 100:(i + 1) * 100]
    median = np.median(data)
    p16    = st.scoreatpercentile(data, 16.0)
    p84    = st.scoreatpercentile(data, 84.0)
Пример #8
0
]

osed = np.loadtxt(
    "../../outputs/spectroscopic_fit/table_din.v3.log")[order_sed]

sdss = dl.load_data("SDSS")
jpas = dl.load_data("JPAS")

nams = [
    "M_lib", "M_mod", "log_t_M_lib", "log_t_M_mod", "log_t_L_lib",
    "log_t_L_mod", "Z_M_lib", "Z_M_mod", "Av_lib", "Av_mod"
]

sdss.physical[nams[6]] = np.log10(sdss.physical[nams[6]])
res_sed = [
    rt.err(sdss.physical[n], osed[:, i]) if i == 0 else rt.err(
        sdss.physical[n], osed[:, i], False) for i, n in enumerate(nams[::2])
]
sdss.physical[nams[6]] = 10**sdss.physical[nams[6]]

fig, axs = plt.subplots(2, 3, sharex=True, figsize=(10, 6))
axins = inset_axes(axs[0, 0], width="50%", height="4%", loc=2)

for i, j in product(xrange(axs.shape[0]), xrange(axs.shape[1])):

    if j == 0:
        if i == 0:
            axs[i, j].set_title("SDSS")
            axs[i, j].set_ylim(-1.5, 3.5)
            axs[i, j].set_ylabel(r"$\Delta\,M/M_\textrm{SSAG}$", fontsize=15)
            sc = axs[i, j].scatter(sdss.residuals["log_t_M"],
Пример #9
0
#!/usr/bin/python

import numpy as np
import matplotlib.pyplot as plt
import scipy.stats.mstats as st
import thesis_redux_tools as rt

table = np.loadtxt("../../outputs/photometric_fit/photoz/photofit_JPASz3p00.physical")
table = rt.binned_stat(table, 50)

table[:, 2:6] = 10 ** table[:, 2:6]

res_pho = [rt.err(table[:, i], table[:, i + 1]) if i in [0] else rt.err(table[:, i], table[:, i + 1], False) for i in xrange(0, 10, 2)]

#print table[np.argmax(res_pho[0]), 0], np.max(res_pho[0])
#print table[np.argmax(res_pho[1]), 2], np.max(res_pho[1])

mask = table[:, 6] > 0.4

# --------------------------------------------------------------------------------------------------
lm = np.array([0, 1])

plt.figure(figsize = (8, 7))
plt.plot(lm, lm, "--k")

tks, tls = [], []
for per in [10, 30, 50] :
  m1, m2 = rt.err_slope(per)

  tks.append(m2 * lm[1])
  tls.append((str(per) + r"\%"))