-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpub_optical_residual.py
executable file
·65 lines (50 loc) · 1.59 KB
/
pub_optical_residual.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
"""
Plot residuals of optical magnitude fits in the SFR-Mstar plane.
"""
import numpy as np
import pylab as P
import galaxy_model as g
from bestfit import *
BAND = 'u'
# Best-fit parameters
params = params_bf
# Load Guo (2010) simulations data (z=0)
mh, mstar, sfr, mag_u, mag_g, mag_r, mag_i, mag_z = \
np.genfromtxt('../delucia_mass/guo_colours_z0.dat',
delimiter=',', skip_header=1).T
mags = [mag_u, mag_g, mag_r, mag_i, mag_z]
names = ['u', 'g', 'r', 'i', 'z']
# Convert units
mh *= 1e10 / 0.73
mstar *= 1e10 / 0.73
# Plot 2D scatter plot of residuals
# Apply selection
band = names.index(BAND)
mag = mags[band]
idxs = np.where(sfr > -1.)
# Calculate residuals
mag_est = mag[idxs] - g.optical_mag(sfr[idxs], mstar[idxs],
band=BAND, z=0., params=params)
# Plot residuals
P.subplot(111)
P.scatter(mstar[idxs], sfr[idxs], c=mag_est, cmap='Spectral', lw=0., s=5.,
vmin=-1., vmax=1., rasterized=True)
P.xscale('log')
P.yscale('log')
P.xlim((5e5, 3e12))
P.ylim((1e-7, 5e1))
cbar = P.colorbar()
cbar.set_label("$\Delta m$", fontsize=18)
# Cuts
#P.axhline(1e-7, ls='dashed', color='k', lw=1.8)
#P.axvline(1e7, ls='dashed', color='k', lw=2.)
P.xlabel('$M_\star$ $[M_\odot]$', fontsize=18)
P.ylabel(r'$\psi_{\rm SFR}$ $[M_\odot/{\rm yr}]$', fontsize=18)
P.tick_params(axis='both', which='major', labelsize=18, size=8.,
width=1.5, pad=8.)
P.tick_params(axis='both', which='minor', labelsize=18, size=5.,
width=1.5, pad=8.)
P.tight_layout()
P.savefig('../draft/residual_%sband.pdf' % BAND)
P.show()