IMF
Installation
Either use the dev version:
pip install https://github.com/keflavich/imf/archive/refs/heads/main.zip
or use pypi:
pip install initial_mass_function
Note that the project name (initial_mass_function) is different from the
packagename you import (imf) because the latter was taken.
Usage
Simple tools to work with the Initial Mass Function
Some basic examples below.
-
Make a simple 1000 Msun cluster sampled from the default Kroupa IMF:
cluster = imf.make_cluster(1000)or from a Salpeter IMF:
cluster = imf.make_cluster(1000, massfunc='salpeter') -
Create a sample of clusters to do some analysis of later. This will make clusters with masses Gaussian-distributed around a given mean mass in the list of cluster_masses, so that you could then do things like estimate the typical luminosity of a cluster for a given mass:
from imf import imf from tqdm.auto import tqdm cluster_masses = [100, 1000, 10000] nclusters_per_bin = 30 clusters = np.array([[imf.make_cluster(mass*(np.random.randn()/20.+1.), silent=True) for ii in range(nclusters_per_bin)] for mass in tqdm(cluster_masses)])
-
Calculate the mass fraction represented by M>8 Msun stars in a Kroupa IMF when the maximum mass is 200 Msun:
kroupa = imf.Kroupa() mmax = 200 cutoff1 = 8 over8fraction = (kroupa.m_integrate(cutoff1, mmax)[0] / kroupa.m_integrate(kroupa.mmin, mmax)[0])
-
This figure was made with examples/imf_figure.py
Contributing
To avoid committing notebook cell outputs (plots/images), install the repository hooks:
pip install pre-commit
pre-commit install
The nbstripout hook will clear output from .ipynb files before commit, and CI enforces the same check.
Credits
- Adam Ginsburg (@keflavich, wrote some of this)
- Sergey Koposov (@segasai, majorly refactored the distribution functions)
- Theo Richardson (@richardson-t, refactored pre-IMF submodules and wrote/revised some functions, especially the PMF and CMF, and wrote all of the documentation)
- Tiffany Christian (@teachristian, made some small corrections)
A companion paper describing the package is in prep.
Metadata
Release files for initial-mass-function 2026.7.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| initial_mass_function-2026.7.11.tar.gz | 1.7 MB | Without provenance | Details for initial_mass_function-2026.7.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| initial_mass_function-2026.7.11-py3-none-any.whl | Python 3 | none | any | Details for initial_mass_function-2026.7.11-py3-none-any.whl |
Total release size: 3.4 MB
Release files / initial_mass_function-2026.7.11.tar.gz
| Download URL | initial_mass_function-2026.7.11.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4cf26634dceab9e77f5c20a34e7b066f3fffadde4bdf175236609daac847870
|
|
BLAKE2b-256 checksum How to use checksums |
137cf2b207fcbbe37c77b4b87bdf6656e40e1b71906263daa372e8b8082ba0f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.9
|
Release files / initial_mass_function-2026.7.11-py3-none-any.whl
| Download URL | initial_mass_function-2026.7.11-py3-none-any.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9da8f5e38ae83e6576ecff7279674f030b75592ec624c4b0314e70b899f2ad26
|
|
BLAKE2b-256 checksum How to use checksums |
834487105bcba1ae9874d4cf306884c9778fab773278d5efad10046af3b73455
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.9
|
Security for initial-mass-function 2026.7.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.