Skip to content

Commit fa9925d

Browse files
authored
Merge pull request #159 from bd-j/dustelib
dust emission libraries
2 parents bab6a11 + 4a0aa0d commit fa9925d

6 files changed

Lines changed: 38 additions & 17 deletions

File tree

demos/feature_demo.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def prettify(fig, ax, label=None):
3434
if label is not None:
3535
ax.text(0.63, 0.85, label, transform=ax.transAxes, fontsize=16)
3636

37+
fig.tight_layout()
3738
return fig, ax
3839

3940

@@ -48,6 +49,8 @@ def prettify(fig, ax, label=None):
4849
pl.rc('ytick', right=True)
4950

5051
sps = fsps.StellarPopulation(zcontinuous=1)
52+
ilib, slib, dlib = sps.libraries
53+
print(ilib, slib)
5154
os.makedirs("./figures", exist_ok=True)
5255
pdf = PdfPages('./figures/features.pdf')
5356

@@ -59,7 +62,7 @@ def prettify(fig, ax, label=None):
5962
sps.params['imf_type'] = 2 # kroupa
6063
sps.params['imf3'] = 2.3
6164
fig, ax, spec = makefig(sps)
62-
fig, ax = prettify(fig, ax, label=r"$\tau=5$, Age$=13.7$,\n$\log Z/Z_\odot=0.0$")
65+
fig, ax = prettify(fig, ax, label=r"$\tau=5$, Age$=13.7$,\\n$\log Z/Z_\odot=0.0$")
6366
pdf.savefig(fig)
6467
pl.close(fig)
6568

@@ -87,22 +90,22 @@ def prettify(fig, ax, label=None):
8790
# Dust temperature
8891
sps.params['duste_umin'] = 10
8992
fig, ax, spec = makefig(sps, oldspec=spec)
90-
fig, ax = prettify(fig, ax, label=r"Dust SED\n(Draine)")
93+
fig, ax = prettify(fig, ax, label=r"Dust SED\\n({})".format(dlib))
9194
pdf.savefig(fig)
9295
pl.close(fig)
9396

9497
# AGN emission
9598
sps.params['fagn'] = 0.3
9699
fig, ax, spec = makefig(sps, oldspec=spec)
97-
fig, ax = prettify(fig, ax, label=r"AGN dust\n(Nenkova)")
100+
fig, ax = prettify(fig, ax, label=r"AGN dust\\n(Nenkova)")
98101
pdf.savefig(fig)
99102
pl.close(fig)
100103

101104
# Nebular emission
102105
sps.params['add_neb_emission'] = True
103106
sps.params['gas_logu'] = -3.5
104107
fig, ax, spec = makefig(sps, oldspec=spec)
105-
fig, ax = prettify(fig, ax, label=r"Neb. emission\n(Byler)")
108+
fig, ax = prettify(fig, ax, label=r"Neb. emission\\n(Byler)")
106109
pdf.savefig(fig)
107110
pl.close(fig)
108111

@@ -125,7 +128,7 @@ def prettify(fig, ax, label=None):
125128
sps.params['zred'] = 6.0
126129
sps.params['add_igm_absorption'] = True
127130
fig, ax, spec = makefig(sps, oldspec=spec)
128-
fig, ax = prettify(fig, ax, label=r"IGM attenuation\n(Madau, $z=6$)")
131+
fig, ax = prettify(fig, ax, label=r"IGM attenuation\\n(Madau, $z=6$)")
129132
pdf.savefig(fig)
130133
pl.close(fig)
131134

docs/installation.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Where, on different systems, you might have to specify the `SPS_HOME`
1919
environment variable. Python-FSPS requires that variable to be set and it will
2020
fail to import if it is set incorrectly.
2121

22-
Python-FSPS is built against specific versions of the FSPS Fortran API, so it is
23-
important that you have a recent version of FSPS through git. Currently
24-
Python-FSPS is built against FSPS v3.0.
22+
Python-FSPS is built against specific versions of the FSPS Fortran API and data
23+
files, so it is important that you have a recent version of FSPS through git.
24+
Currently Python-FSPS is built against FSPS v3.2.
2525

2626
Installing stable version
2727
-------------------------
@@ -55,7 +55,15 @@ in more detail in the FSPS documentation, but their names are:
5555
- `MILES` (default)
5656
- `BASEL`
5757

58-
Changing either library requires switching off the relevant default, which for isochrones is `MIST` and for spectra is `MILES`, and switching on the desired library. As an example, you can change to Padova isochrones and the BaSeL low resolution synthetic stellar library by re-installing:
58+
* Dust emission libraries
59+
60+
- `DL07` (default)
61+
- `THEMIS`
62+
63+
Changing any of these libraries requires switching off the relevant default,
64+
which for isochrones is `MIST` and for spectra is `MILES`, and switching on the
65+
desired library. As an example, you can change to Padova isochrones and the
66+
BaSeL low resolution synthetic stellar library by re-installing:
5967

6068
.. code-block:: bash
6169
@@ -77,9 +85,10 @@ repository <https://github.com/dfm/python-fsps>`_ and building:
7785
cd python-fsps
7886
python -m pip install .
7987
80-
Flags can be prepended to change the stellar libraries as described above. This repository includes FSPS as a submodule, so if you forget the `--recursive`
81-
flag above, you can get the submodule by running the following commands in the
82-
root directory of the Python-FSPS repository:
88+
Flags can be prepended to change the stellar libraries as described above. This
89+
repository includes FSPS as a submodule, so if you forget the `--recursive` flag
90+
above, you can get the submodule by running the following commands in the root
91+
directory of the Python-FSPS repository:
8392

8493
.. code-block:: bash
8594

docs/stellarpop_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ and some dust with a Calzetti et al (2000) extinction curve::
1515
>>> sp = fsps.StellarPopulation(compute_vega_mags=False, zcontinuous=1,
1616
sfh=0, logzsol=0.0, dust_type=2, dust2=0.2)
1717
>>> sp.libraries
18-
('mist', 'miles')
18+
('mist', 'miles', 'DL07')
1919

2020
The last line indicates that we are using the MIST isochrones and MILES spectral
2121
library. These can be changed only by reinstalling python-FSPS with appropriate

src/fsps/fsps.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,16 @@ subroutine get_lambda(ns,lambda)
514514

515515
end subroutine
516516

517-
subroutine get_libraries(isocname,specname)
517+
subroutine get_libraries(isocname,specname,dustname)
518518

519519
implicit none
520520

521521
character(4), intent(out) :: isocname
522522
character(5), intent(out) :: specname
523+
character(6), intent(out) :: dustname
523524
isocname = isoc_type
524525
specname = spec_type
526+
dustname = str_dustem
525527

526528
end subroutine
527529

src/fsps/fsps.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,14 +1159,20 @@ def sfr_avg(self, times=None, dt=0.1):
11591159

11601160
@property
11611161
def isoc_library(self):
1162-
r"""The name of the isochrone library being used in FSPS."""
1162+
r"""The name of the stellar isochrone library being used in FSPS."""
11631163
return self.libraries[0]
11641164

11651165
@property
11661166
def spec_library(self):
1167-
r"""The name of the spectral library being used in FSPS."""
1167+
r"""The name of the stellar spectral library being used in FSPS."""
11681168
return self.libraries[1]
11691169

1170+
@property
1171+
def duste_library(self):
1172+
r"""The name of the dust emission SED library being used in FSPS."""
1173+
return self.libraries[2]
1174+
1175+
11701176
@property
11711177
def libraries(self):
11721178
if self._libraries is None:

tests/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ def test_libraries(pop_and_params):
5555
"""This does not require or build clean SSPs"""
5656
pop, params = pop_and_params
5757
_reset_default_params(pop, params)
58-
ilib, splib = pop.libraries
58+
ilib, splib, dlib = pop.libraries
5959
assert ilib == pop.isoc_library
6060
assert splib == pop.spec_library
61+
assert dlib == pop.duste_library
6162

6263

6364
def test_filters():

0 commit comments

Comments
 (0)