dfm / python-fsps

Python bindings to Charlie Conroy's Flexible Stellar Population Synthesis (FSPS) Fortran code

Home Page:https://python-fsps.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

changing dust_type doesn't work?

dmyang42 opened this issue · comments

Hi! I am using prospector and have troubles utilizing different dust_type. It seems that dust_type doesn't work sometimes for me, like the following example. I guess this is probably not a python-fsps problem. So, I want to ask how to activate the "dust" correctly?

image

import fsps
import matplotlib.pyplot as plt


sp = fsps.StellarPopulation(compute_vega_mags=False, zcontinuous=1, dust1=0, 
                            sfh=1, logzsol=0.0, dust_type=3)

# dust_type:3, dust2:0.0, wgp1:1, wgp2:1
sp.params['wgp1'] = 1
sp.params['wgp2'] = 1
wave1, spec1 = sp.get_spectrum(tage=13.7)
info_str = "dust_type={},dust2={},wgp1={},wgp2={}".format(
        sp.params['dust_type'],sp.params['dust2'],sp.params['wgp1'],sp.params['wgp2'])

plt.clf()
plt.plot(wave1, spec1, '-', lw=2, label=info_str)


# dust_type:3, dust2:0.0, wgp1:6, wgp2:2
sp.params['wgp1'] = 6
sp.params['wgp2'] = 2
info_str = "dust_type={},dust2={},wgp1={},wgp2={}".format(
        sp.params['dust_type'],sp.params['dust2'],sp.params['wgp1'],sp.params['wgp2'])
wave2, spec2 = sp.get_spectrum(tage=13.7)
plt.plot(wave2, spec2, '--',lw=2,  label=info_str)

# dust_type:3, dust2:0.1, wgp1:6, wgp2:1
sp.params['dust2'] = 0.1
info_str = "dust_type={},dust2={},wgp1={},wgp2={}".format(
        sp.params['dust_type'],sp.params['dust2'],sp.params['wgp1'],sp.params['wgp2'])
wave3, spec3 = sp.get_spectrum(tage=13.7)
plt.plot(wave3, spec3, '-',lw=1,  label=info_str)

plt.xscale('log')
plt.yscale('log')
plt.legend()
plt.xlim(10**3, 3*10**5)
plt.ylim(5*10**(-21), 3*10**(-15))
plt.xlabel(r'Wavelength ($\AA$)')

# plt.show()
plt.savefig("test.pdf")

Hi, thanks for the clear and detailed info. The issue is that there is an if statement in the fortran that skips adding dust if both "dust1" and "dust2" are zero. This is incorrect behavior for dust_type=3. That said, if you set either "dust1", "dust2" greater than zero at the beginning it will have no effect except to trigger the addition of the correct WG curve as specified by "wgp1" and "wgp2".

oh! I see. Thanks for the prompt reply and clear explanation!

I made a pull request in the FSPS source to fix this, but that won't be propagated immediately to python-fsps, since the hash referenced by the python-fsps/src/libfsps submodule will have to be updated.