Skip to main content

SSPTools

MIT license Tests

Simple Stellar Population Tools

Provides access to the EvolvedMF class (and similar subclasses), which evolves an arbitrary N-component power law initial mass function (IMF) to a binned present-day mass function (PDMF) at any given set of ages, and computes the numbers and masses of stars and remnants in each mass bin.

To be used for populating mass models and other such simulations based on an IMF and various other initial population parameters.

Can optionally account for all of the evolution of stars off the main-sequence, the loss of low-mass stars to a host tidal field, the ejection of black holes due to both dynamical ejections and natal kicks.

Note

This is a fork of SSPTools which has been updated to use an N-component mass function, updated remnant initial-final mass relations and implements further black hole retention calculations, among other changes.

Quickstart

SSPTools can be installed from PyPI using:

pip install astro-ssptools

An evolved mass function can be computed using the EvolvedMF class:

import ssptools

m_break, a_slopes, nbins = [0.08, 0.5, 150.], [+1.3, -2.3], [5, 30]
pdmf = ssptools.EvolvedMF.from_powerlaw(m_break, a_slopes, nbins,
                                        FeH=-1.5, tout=13000, esc_rate=0, N0=1e6)

Alternatively, an IMF class can be instantiated and used directly:

imf = ssptools.masses.PowerLawIMF(m_break, a_slopes, N0=1e6)
pdmf = ssptools.EvolvedMF(imf, nbins, FeH=-1.5, tout=[0, 1000, 13000], esc_rate=0)

See the documentation of each class for more details on all possible parameters.

The final element of tout (in Myr) defines the age to which the mass function is evolved to, where the masses and numbers of stars and remnants (together) can then be accessed easily:

pdmf.N  # Total number of stars in each bin
pdmf.M  # Total mass of stars in each bin
pdmf.m  # Mean mass of stars in each bin

pdmf.M[pdmf.types == 'MS']  # Star bins only
pdmf.M[pdmf.types == 'BH']  # Black hole bins only

All other outputted times can also be seen in the underlying attributes, which generally have shape (len(tout), sum(nbins)). Note that these arrays will also contain bins with basically no objects in them (i.e. N<0.1), which are not valid and are typically filtered out in the output arrays above.

pdmf.Ns[0]  # Initial star bin amounts
pdmf.Ns[-1]  # Final star bin amounts

pdmf.Mr  # Named tuple with fields ('WD', 'NS', 'BH')
pdmf.Mr.BH[-1]  # Final BH bin masses
import matplotlib.pyplot as plt

for i in range(pdmf.nout):
    mes = pdmf.massbins.turned_off_bins(pdmf.tout[i])  # mass bins at t_i
    plt.step(pdmf.ms[i], pdmf.Ns[i] / (mes.upper - mes.lower),
             ls='-', label=f"Stars @ t={pdmf.tout[i]} Myr")
#
    mebh = pdmf.massbins.bins.BH  # BH mass bins
    plt.step(pdmf.mr.BH[i], pdmf.Nr.BH[i] / (mebh.upper - mebh.lower),
             ls='--', c=str(0.8 * 1 - (i / pdmf.nout)),
             label=f" BHs  @ t={pdmf.tout[i]} Myr")

plt.ylabel(r"$\frac{\mathrm{d}N}{\mathrm{d}m}$", rotation=0)
plt.xlabel(r"$m\ [M_\odot]$")
plt.yscale('log'); plt.xscale('log')
plt.ylim(bottom=1)

plt.legend(); plt.show()

evolve_mf_example1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astro_ssptools-3.1.1.tar.gz (44.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astro_ssptools-3.1.1-py3-none-any.whl (43.1 MB view details)

Uploaded Python 3

File details

Details for the file astro_ssptools-3.1.1.tar.gz.

File metadata

  • Download URL: astro_ssptools-3.1.1.tar.gz
  • Upload date:
  • Size: 44.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.1 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for astro_ssptools-3.1.1.tar.gz
Algorithm Hash digest
SHA256 a5be4639107a54f32b0314d9c62bcc8ab4c7871f6cdf5ae6b454181b5fd24b91
MD5 faa07ad56d3c6adb96d1bc816648d9b6
BLAKE2b-256 8d9830f3236e6e256f816144aeba26b313054c0bed9d7a350239448172f0f49e

See more details on using hashes here.

File details

Details for the file astro_ssptools-3.1.1-py3-none-any.whl.

File metadata

  • Download URL: astro_ssptools-3.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.1 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for astro_ssptools-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 737a84dd16599d8fe236c4adae058dd6886666ac653c7668cf693433dc73a7bb
MD5 d5203ca1637039f1c55dc1102b114ed7
BLAKE2b-256 c08e357dee6504bca738ee83be4f899b424650327c5da195e04f9eb18105cf03

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.1.1 This release

2 files

3.1.0

2 files

2.1.3

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page