77"""
88
99import os
10- import numpy as np
10+
1111import matplotlib .pyplot as pl
1212from matplotlib .backends .backend_pdf import PdfPages
1313
@@ -18,19 +18,19 @@ def makefig(sps, tage=13.7, oldspec=None, **plotkwargs):
1818 w , spec = sps .get_spectrum (tage = tage )
1919 fig , ax = pl .subplots ()
2020 if oldspec is not None :
21- ax .plot (w , oldspec / w * 1e19 , color = ' gray' , linewidth = 2 , alpha = 0.5 )
22- ax .plot (w , spec / w * 1e19 , 'C2' , linewidth = 2 )
21+ ax .plot (w , oldspec / w * 1e19 , color = " gray" , linewidth = 2 , alpha = 0.5 )
22+ ax .plot (w , spec / w * 1e19 , "C2" , linewidth = 2 )
2323 return fig , ax , spec
2424
2525
2626def prettify (fig , ax , label = None ):
2727 ax .set_xlim (0.9e3 , 1e6 )
28- ax .set_xscale (' log' )
28+ ax .set_xscale (" log" )
2929 ax .set_ylim (0.01 , 2 )
30- #ax.set_yscale('log')
31- ax .set_xlabel (r' rest-frame $\lambda$ ($\AA$)' , fontsize = 20 )
32- ax .set_ylabel (r' $\lambda \, f_\lambda$' , fontsize = 20 )
33- ax .tick_params (axis = ' both' , which = ' major' , labelsize = 16 )
30+ # ax.set_yscale('log')
31+ ax .set_xlabel (r" rest-frame $\lambda$ ($\AA$)" , fontsize = 20 )
32+ ax .set_ylabel (r" $\lambda \, f_\lambda$" , fontsize = 20 )
33+ ax .tick_params (axis = " both" , which = " major" , labelsize = 16 )
3434 if label is not None :
3535 ax .text (0.63 , 0.85 , label , transform = ax .transAxes , fontsize = 16 )
3636
@@ -39,94 +39,93 @@ def prettify(fig, ax, label=None):
3939
4040
4141if __name__ == "__main__" :
42-
43- pl .rc ('text' , usetex = True )
44- pl .rc ('font' , family = 'serif' )
45- pl .rc ('axes' , grid = False )
46- pl .rc ('xtick' , direction = 'in' )
47- pl .rc ('ytick' , direction = 'in' )
48- pl .rc ('xtick' , top = True )
49- pl .rc ('ytick' , right = True )
42+ pl .rc ("text" , usetex = True )
43+ pl .rc ("font" , family = "serif" )
44+ pl .rc ("axes" , grid = False )
45+ pl .rc ("xtick" , direction = "in" )
46+ pl .rc ("ytick" , direction = "in" )
47+ pl .rc ("xtick" , top = True )
48+ pl .rc ("ytick" , right = True )
5049
5150 sps = fsps .StellarPopulation (zcontinuous = 1 )
5251 ilib , slib , dlib = sps .libraries
5352 print (ilib , slib )
5453 os .makedirs ("./figures" , exist_ok = True )
55- pdf = PdfPages (' ./figures/features.pdf' )
54+ pdf = PdfPages (" ./figures/features.pdf" )
5655
5756 # Basic spectrum
58- sps .params [' sfh' ] = 4
59- sps .params [' tau' ] = 5.0
60- sps .params [' logzsol' ] = 0.0
61- sps .params [' dust_type' ] = 4 # kriek and Conroy
62- sps .params [' imf_type' ] = 2 # kroupa
63- sps .params [' imf3' ] = 2.3
57+ sps .params [" sfh" ] = 4
58+ sps .params [" tau" ] = 5.0
59+ sps .params [" logzsol" ] = 0.0
60+ sps .params [" dust_type" ] = 4 # kriek and Conroy
61+ sps .params [" imf_type" ] = 2 # kroupa
62+ sps .params [" imf3" ] = 2.3
6463 fig , ax , spec = makefig (sps )
6564 fig , ax = prettify (fig , ax , label = r"$\tau=5$, Age$=13.7$,\\n$\log Z/Z_\odot=0.0$" )
6665 pdf .savefig (fig )
6766 pl .close (fig )
6867
6968 # change IMF
70- sps .params [' imf3' ] = 2.5
69+ sps .params [" imf3" ] = 2.5
7170 fig , ax , spec = makefig (sps , oldspec = spec )
7271 fig , ax = prettify (fig , ax , label = r"IMF slope" )
7372 pdf .savefig (fig )
7473
7574 # Attenuate
76- sps .params [' add_dust_emission' ] = False
77- sps .params [' dust2' ] = 0.2
75+ sps .params [" add_dust_emission" ] = False
76+ sps .params [" dust2" ] = 0.2
7877 fig , ax , spec = makefig (sps , oldspec = spec )
7978 fig , ax = prettify (fig , ax , label = r"Dust Attenuation" )
8079 pdf .savefig (fig )
8180 pl .close (fig )
8281
8382 # Dust emission
84- sps .params [' add_dust_emission' ] = True
83+ sps .params [" add_dust_emission" ] = True
8584 fig , ax , spec = makefig (sps , oldspec = spec )
8685 fig , ax = prettify (fig , ax , label = r"Dust Emission" )
8786 pdf .savefig (fig )
8887 pl .close (fig )
8988
9089 # Dust temperature
91- sps .params [' duste_umin' ] = 10
90+ sps .params [" duste_umin" ] = 10
9291 fig , ax , spec = makefig (sps , oldspec = spec )
9392 fig , ax = prettify (fig , ax , label = r"Dust SED\\n({})" .format (dlib ))
9493 pdf .savefig (fig )
9594 pl .close (fig )
9695
9796 # AGN emission
98- sps .params [' fagn' ] = 0.3
97+ sps .params [" fagn" ] = 0.3
9998 fig , ax , spec = makefig (sps , oldspec = spec )
10099 fig , ax = prettify (fig , ax , label = r"AGN dust\\n(Nenkova)" )
101100 pdf .savefig (fig )
102101 pl .close (fig )
103102
104103 # Nebular emission
105- sps .params [' add_neb_emission' ] = True
106- sps .params [' gas_logu' ] = - 3.5
104+ sps .params [" add_neb_emission" ] = True
105+ sps .params [" gas_logu" ] = - 3.5
107106 fig , ax , spec = makefig (sps , oldspec = spec )
108107 fig , ax = prettify (fig , ax , label = r"Neb. emission\\n(Byler)" )
109108 pdf .savefig (fig )
110109 pl .close (fig )
111110
112111 # change logu
113- sps .params [' gas_logu' ] = - 1.0
112+ sps .params [" gas_logu" ] = - 1.0
114113 fig , ax , spec = makefig (sps , oldspec = spec )
115114 fig , ax = prettify (fig , ax , label = r"Change U$_{neb}$" )
116115 pdf .savefig (fig )
117116 pl .close (fig )
118117
119118 # change logz
120- sps .params [' logzsol' ] = - 0.5
121- sps .params [' gas_logz' ] = - 0.5
119+ sps .params [" logzsol" ] = - 0.5
120+ sps .params [" gas_logz" ] = - 0.5
122121 fig , ax , spec = makefig (sps , oldspec = spec )
123122 fig , ax = prettify (fig , ax , label = r"$\log Z/Z_\odot=-0.5$" )
124123 pdf .savefig (fig )
125124 pl .close (fig )
126125
127126 # IGM absorption
128- sps .params [' zred' ] = 6.0
129- sps .params [' add_igm_absorption' ] = True
127+ sps .params [" zred" ] = 6.0
128+ sps .params [" add_igm_absorption" ] = True
130129 fig , ax , spec = makefig (sps , oldspec = spec )
131130 fig , ax = prettify (fig , ax , label = r"IGM attenuation\\n(Madau, $z=6$)" )
132131 pdf .savefig (fig )
0 commit comments