initial-mass-function


Nameinitial-mass-function JSON
Version 2025.1.20 PyPI version JSON
download
home_pagehttps://github.com/keflavich/imf
SummaryTools for sampling from and working with functional forms of the initial mass fuctino
upload_time2025-01-21 01:08:57
maintainerNone
docs_urlNone
authorAdam Ginsburg
requires_python>=3.6
licenseBSD 3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # IMF

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:

    ```python
   from imf import imf
   from astropy.utils.console import ProgressBar
   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 ProgressBar(cluster_masses)])
   ```

3. Calculate the mass fraction represented by M>8 Msun stars in a Kroupa IMF when
   the maximum mass is 200 Msun:

   ```python
     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.png](examples/plots/imf.png)



## 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/keflavich/imf",
    "name": "initial-mass-function",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Adam Ginsburg",
    "author_email": "adam.g.ginsburg@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/56/0d/e8eea43c92e837514474d1a74b7d8251c4eecf2ae26cc2d8888c76c161f1/initial_mass_function-2025.1.20.tar.gz",
    "platform": null,
    "description": "# IMF\n\nSimple tools to work with the Initial Mass Function\n\nSome basic examples below.\n\n1. Make a simple 1000 Msun cluster sampled from the default Kroupa IMF:\n\n    ```\n    cluster = imf.make_cluster(1000)\n    ```\n\n   or from a Salpeter IMF::\n\n    ```\n    cluster = imf.make_cluster(1000, massfunc='salpeter')\n    ```\n\n2. Create a sample of clusters to do some analysis of later.  This will make clusters\n   with masses Gaussian-distributed around a given mean mass in the list of\n   cluster_masses, so that you could then do things like estimate the typical\n   luminosity of a cluster for a given mass:\n\n    ```python\n   from imf import imf\n   from astropy.utils.console import ProgressBar\n   cluster_masses = [100, 1000, 10000]\n   nclusters_per_bin = 30\n   clusters = np.array([[imf.make_cluster(mass*(np.random.randn()/20.+1.), silent=True)\n                         for ii in range(nclusters_per_bin)]\n                         for mass in ProgressBar(cluster_masses)])\n   ```\n\n3. Calculate the mass fraction represented by M>8 Msun stars in a Kroupa IMF when\n   the maximum mass is 200 Msun:\n\n   ```python\n     kroupa = imf.Kroupa()\n\n     mmax = 200\n     cutoff1 = 8\n\n     over8fraction = (kroupa.m_integrate(cutoff1, mmax)[0] /\n                      kroupa.m_integrate(kroupa.mmin, mmax)[0])\n    ```\n\n4. This figure was made with examples/imf_figure.py\n\n    ![imf.png](examples/plots/imf.png)\n\n\n\n## Credits\n\n * Adam Ginsburg (@keflavich, wrote most of this)\n * Sergey Koposov (@segasai, majorly refactored the distribution functions)\n * Tiffany Christian (@teachristian, made some small corrections)\n * Theo Richardson (@richardson-t, refactored optimal sampling)\n\nNo formal citation is available yet; please just reference the repository\n(https://github.com/keflavich/imf) if you use this.\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause",
    "summary": "Tools for sampling from and working with functional forms of the initial mass fuctino",
    "version": "2025.1.20",
    "project_urls": {
        "Homepage": "https://github.com/keflavich/imf"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "560de8eea43c92e837514474d1a74b7d8251c4eecf2ae26cc2d8888c76c161f1",
                "md5": "6a2169c11ce18606f7c307c647855910",
                "sha256": "a1b27ae9dd60bb85be7781bf1a374296f110ffc4028261429cd08018493b337c"
            },
            "downloads": -1,
            "filename": "initial_mass_function-2025.1.20.tar.gz",
            "has_sig": false,
            "md5_digest": "6a2169c11ce18606f7c307c647855910",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 1883064,
            "upload_time": "2025-01-21T01:08:57",
            "upload_time_iso_8601": "2025-01-21T01:08:57.835183Z",
            "url": "https://files.pythonhosted.org/packages/56/0d/e8eea43c92e837514474d1a74b7d8251c4eecf2ae26cc2d8888c76c161f1/initial_mass_function-2025.1.20.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-21 01:08:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "keflavich",
    "github_project": "imf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "initial-mass-function"
}
        
Elapsed time: 0.37061s