Skip to main content

Tools for sampling from and working with functional forms of the initial mass fuctino

Project description

IMF

Installation

Either use the dev version:

pip install https://github.com/keflavich/imf/archive/refs/heads/master.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.

  1. 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')
    
  2. 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)])
    
  3. 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])
    
  4. This figure was made with examples/imf_figure.py

    IMF example figure

Credits

  • Adam Ginsburg (@keflavich, wrote most of this)
  • Sergey Koposov (@segasai, majorly refactored the distribution functions)
  • Tiffany Christian (@teachristian, made some small corrections)
  • Theo Richardson (@richardson-t, refactored optimal sampling)

No formal citation is available yet; please just reference the repository (https://github.com/keflavich/imf) if you use this.

Project details


Download files

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

Source Distribution

initial_mass_function-2025.1.20b0.tar.gz (1.9 MB view details)

Uploaded Source

File details

Details for the file initial_mass_function-2025.1.20b0.tar.gz.

File metadata

File hashes

Hashes for initial_mass_function-2025.1.20b0.tar.gz
Algorithm Hash digest
SHA256 ae6bf009349114d58d3d8f1528b03032f769cfb419b9f3427dc220ad7aa528da
MD5 178967951bc88af04fe4793fec1ebbbb
BLAKE2b-256 8f6b48b3159c39ae3d096735f7ff03ff38e0d78a0ae02efff89eca930beba8b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page