PyCosmoMMF


NamePyCosmoMMF JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://github.com/James11222/PyCosmoMMF/
SummaryA package for detecting structures in the Cosmic Web.
upload_time2024-04-15 21:33:59
maintainerNone
docs_urlNone
authorJames Sunseri
requires_python<4,>=3.6
licenseMIT
keywords cosmology
VCS
bugtrack_url
requirements numpy numba scikit-image matplotlib pytest
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyCosmoMMF

A python version of the CosmoMMF package originally written in Julia.

<p align="center">

<img src="Images/CosmoMMF_Dark.png#gh-dark-mode-only" width="60%">

<img src="Images/CosmoMMF_light.png#gh-light-mode-only" width="60%">

</p>

# PyCosmoMMF

<!-- [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://James11222.github.io/PyCosmoMMF/stable)

[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://James11222.github.io/CosmoMMF.jl/dev)

[![codecov](https://codecov.io/gh/James11222/CosmoMMF/branch/main/graph/badge.svg?token=cSdBAqnqya)](https://codecov.io/gh/James11222/CosmoMMF)

[![DOI](https://zenodo.org/badge/347520773.svg)](https://zenodo.org/badge/latestdoi/347520773) -->

[![codecov](https://codecov.io/gh/James11222/PyCosmoMMF/graph/badge.svg?token=UCHHHXEV2D)](https://codecov.io/gh/James11222/PyCosmoMMF)

Nexus Pipeline for analyzing the effects of baryonic matter on cosmological structures in IllustrisTNG simulations

The `PyCosmoMMF` package contains the algorithms necessary for a Multiscale Morphological Analysis (MMF) of cosmological simulations. The purpose of this package is to streamline our modified version of the NEXUS+ algorithm. We used the `julia` version of this package in our work ([Sunseri et al. 2022](https://ui.adsabs.harvard.edu/abs/2023PhRvD.107b3514S/abstract)) to analyze the effects of baryonic matter on the Cosmic Web.

The NEXUS+ algorithm contains several steps as described in our paper ([Sunseri et al. 2022](https://ui.adsabs.harvard.edu/abs/2023PhRvD.107b3514S/abstract)). In general, we start with a density field (note: we more specifically mean a 1 + δ field), smooth it with a logarithmic Gaussian smoothing filter, then compute the hessian of the smoothed density field, use the eigenvalues of the hessian matrix to calculate the structure type signatures, find the maximum signatures over a range of smoothing scales, and apply physically based threshold criterion to categorize structures within the Cosmic Web. The entire package is implemented in `python` and all of these steps are summarized inside of two functions. The first function `maximum_signature()` does the first several steps of the NEXUS+ algorithm to compute the maximum structure signatures, the second function is `calc_structure_bools()` which uses physical criteria to tag structures into 4 categories: clusters, filaments, walls, and voids.

We also make the data products from our paper ([Sunseri et al. 2022](https://ui.adsabs.harvard.edu/abs/2023PhRvD.107b3514S/abstract)) available for download at [This Link](http://idark.ipmu.jp/~jia.liu/data/Baryon_Analysis_Data/)

## General Code Usage

The general usage of the package would look like:

### Step I

We first calculate the maximum structure signatures across multiple smoothing scales with the NEXUS+/NEXUS algorithm

```python

import PyCosmoMMF

density_field = np.load("path/to/density_field.npy")

Rs = [sqrt(2)**n for n in range(10)] #smoothing scales

max_signatures = PyCosmoMMF.maximum_signature(Rs, density_field, alg="NEXUSPLUS") #compute maximum signatures

```

The output of `maximum_signature()` is a 4D Float Array where the 4th index denotes the signature type: 0 = clusters, 1 = filaments, 2 = walls. An example output of this can be seen below

<p align="center">

<img src="Images/final_NEXUSPLUS_Signatures_hydro_dark.png#gh-dark-mode-only" width="100%">

<img src="Images/final_NEXUSPLUS_Signatures_hydro.png#gh-light-mode-only" width="100%">

</p>

### Step II

We then have the option of running the tagging scheme a few different ways. The first important argument in `calc_structure_bools()` besides the `density_field` and the `max_signatures` arrays is the `verbose_flag`. When

set to `True` the code gives a lot more information and provides a few plots. This is best turned on when

debugging the code. When `verbose_flag` is turned on there are 4 additional outputs to the `calc_structure_bools()`

function: `S_fil, dM2_fil, S_wall, dM2_wall` which can be used to make the mass change curves for filaments and

walls.

***Verbose Flag On:***

```python

verbose_flag = True #or False


clusbool, filbool, wallbool, voidbool, S_fil, dM2_fil, S_wall, dM2_wall = PyCosmoMMF.calc_structure_bools(

                                                       density_field, max_signatures, verbose_flag) #tag structures

```

***Verbose Flag Off:***

```python

verbose_flag = False


clusbool, filbool, wallbool, voidbool = PyCosmoMMF.calc_structure_bools(

                                        density_field, max_signatures, verbose_flag) #tag structures

```

We also note in the `calc_structure_bools()` function, one can use their own cluster boolean filter instead of the one generated by the NEXUS+ formalism (using virialization of clusters as a tool for determining spurious detections). This is helpful if you want to use a more trusted cluster/halo finder algorithm (FoF, Rockstar, etc...). For more information on the NEXUS+ method, see [Cautun et al. 2013](https://academic.oup.com/mnras/article/429/2/1286/1038906).

***External Cluster Boolean Filter:***

```python

clusbool_ext = np.load("path/to/cluster_boolean_filter.npy")#load in externally computed boolean filter for clusters

verbose_flag = False


clusbool, filbool, wallbool, voidbool = PyCosmoMMF.calc_structure_bools(
                                        density_field, max_signatures, verbose_flag, clusbool_ext) #tag structures

```

Another important optional argument in the `calc_structure_bools()` function is `Δ`. The default value is `Δ = 370` as used in [Cautun et al. 2013](https://academic.oup.com/mnras/article/429/2/1286/1038906) but other values can be 200 or 500 corresponding to `R_200` or `R_500`. `Δ` is the overdensity parameter, when clusters achieve a density greater than this value, they are thought to be virialized/collapsed.

The boolean filters for each structure type produced by `calc_structure_bools()` can be used to tag structures within a density field, the results of this can be seen below

<p align="center">

<img src="Images/final_tagging_figure_dark.png#gh-dark-mode-only" width="100%">

<img src="Images/final_tagging_figure.png#gh-light-mode-only" width="100%">

</p>

### Additional Code Information

* Note: The NEXUS+ implementation of tagging clusters is highly dependent on the the grid resolution being used. The cluster boolean filter will only be physically motivated if the resolution of each voxel is roughly < 1 Mpc/h so clusters can be resolved.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/James11222/PyCosmoMMF/",
    "name": "PyCosmoMMF",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.6",
    "maintainer_email": null,
    "keywords": "cosmology",
    "author": "James Sunseri",
    "author_email": "js7501@princeton.edu",
    "download_url": "https://files.pythonhosted.org/packages/87/93/ea71b762a8fe69022bb37b17d18dbc12a6ebc831d6e9e5f88ed674a1f6b2/PyCosmoMMF-0.0.8.tar.gz",
    "platform": "any",
    "description": "# PyCosmoMMF\n\nA python version of the CosmoMMF package originally written in Julia.\n\n<p align=\"center\">\n\n<img src=\"Images/CosmoMMF_Dark.png#gh-dark-mode-only\" width=\"60%\">\n\n<img src=\"Images/CosmoMMF_light.png#gh-light-mode-only\" width=\"60%\">\n\n</p>\n\n# PyCosmoMMF\n\n<!-- [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://James11222.github.io/PyCosmoMMF/stable)\n\n[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://James11222.github.io/CosmoMMF.jl/dev)\n\n[![codecov](https://codecov.io/gh/James11222/CosmoMMF/branch/main/graph/badge.svg?token=cSdBAqnqya)](https://codecov.io/gh/James11222/CosmoMMF)\n\n[![DOI](https://zenodo.org/badge/347520773.svg)](https://zenodo.org/badge/latestdoi/347520773) -->\n\n[![codecov](https://codecov.io/gh/James11222/PyCosmoMMF/graph/badge.svg?token=UCHHHXEV2D)](https://codecov.io/gh/James11222/PyCosmoMMF)\n\nNexus Pipeline for analyzing the effects of baryonic matter on cosmological structures in IllustrisTNG simulations\n\nThe `PyCosmoMMF` package contains the algorithms necessary for a Multiscale Morphological Analysis (MMF) of cosmological simulations. The purpose of this package is to streamline our modified version of the NEXUS+ algorithm. We used the `julia` version of this package in our work ([Sunseri et al. 2022](https://ui.adsabs.harvard.edu/abs/2023PhRvD.107b3514S/abstract)) to analyze the effects of baryonic matter on the Cosmic Web.\n\nThe NEXUS+ algorithm contains several steps as described in our paper ([Sunseri et al. 2022](https://ui.adsabs.harvard.edu/abs/2023PhRvD.107b3514S/abstract)). In general, we start with a density field (note: we more specifically mean a 1 + \u03b4 field), smooth it with a logarithmic Gaussian smoothing filter, then compute the hessian of the smoothed density field, use the eigenvalues of the hessian matrix to calculate the structure type signatures, find the maximum signatures over a range of smoothing scales, and apply physically based threshold criterion to categorize structures within the Cosmic Web. The entire package is implemented in `python` and all of these steps are summarized inside of two functions. The first function `maximum_signature()` does the first several steps of the NEXUS+ algorithm to compute the maximum structure signatures, the second function is `calc_structure_bools()` which uses physical criteria to tag structures into 4 categories: clusters, filaments, walls, and voids.\n\nWe also make the data products from our paper ([Sunseri et al. 2022](https://ui.adsabs.harvard.edu/abs/2023PhRvD.107b3514S/abstract)) available for download at [This Link](http://idark.ipmu.jp/~jia.liu/data/Baryon_Analysis_Data/)\n\n## General Code Usage\n\nThe general usage of the package would look like:\n\n### Step I\n\nWe first calculate the maximum structure signatures across multiple smoothing scales with the NEXUS+/NEXUS algorithm\n\n```python\n\nimport PyCosmoMMF\n\ndensity_field = np.load(\"path/to/density_field.npy\")\n\nRs = [sqrt(2)**n for n in range(10)] #smoothing scales\n\nmax_signatures = PyCosmoMMF.maximum_signature(Rs, density_field, alg=\"NEXUSPLUS\") #compute maximum signatures\n\n```\n\nThe output of `maximum_signature()` is a 4D Float Array where the 4th index denotes the signature type: 0 = clusters, 1 = filaments, 2 = walls. An example output of this can be seen below\n\n<p align=\"center\">\n\n<img src=\"Images/final_NEXUSPLUS_Signatures_hydro_dark.png#gh-dark-mode-only\" width=\"100%\">\n\n<img src=\"Images/final_NEXUSPLUS_Signatures_hydro.png#gh-light-mode-only\" width=\"100%\">\n\n</p>\n\n### Step II\n\nWe then have the option of running the tagging scheme a few different ways. The first important argument in `calc_structure_bools()` besides the `density_field` and the `max_signatures` arrays is the `verbose_flag`. When\n\nset to `True` the code gives a lot more information and provides a few plots. This is best turned on when\n\ndebugging the code. When `verbose_flag` is turned on there are 4 additional outputs to the `calc_structure_bools()`\n\nfunction: `S_fil, dM2_fil, S_wall, dM2_wall` which can be used to make the mass change curves for filaments and\n\nwalls.\n\n***Verbose Flag On:***\n\n```python\n\nverbose_flag = True #or False\n\n\nclusbool, filbool, wallbool, voidbool, S_fil, dM2_fil, S_wall, dM2_wall = PyCosmoMMF.calc_structure_bools(\n\n                                                       density_field, max_signatures, verbose_flag) #tag structures\n\n```\n\n***Verbose Flag Off:***\n\n```python\n\nverbose_flag = False\n\n\nclusbool, filbool, wallbool, voidbool = PyCosmoMMF.calc_structure_bools(\n\n                                        density_field, max_signatures, verbose_flag) #tag structures\n\n```\n\nWe also note in the `calc_structure_bools()` function, one can use their own cluster boolean filter instead of the one generated by the NEXUS+ formalism (using virialization of clusters as a tool for determining spurious detections). This is helpful if you want to use a more trusted cluster/halo finder algorithm (FoF, Rockstar, etc...). For more information on the NEXUS+ method, see [Cautun et al. 2013](https://academic.oup.com/mnras/article/429/2/1286/1038906).\n\n***External Cluster Boolean Filter:***\n\n```python\n\nclusbool_ext = np.load(\"path/to/cluster_boolean_filter.npy\")#load in externally computed boolean filter for clusters\n\nverbose_flag = False\n\n\nclusbool, filbool, wallbool, voidbool = PyCosmoMMF.calc_structure_bools(\n                                        density_field, max_signatures, verbose_flag, clusbool_ext) #tag structures\n\n```\n\nAnother important optional argument in the `calc_structure_bools()` function is `\u0394`. The default value is `\u0394 = 370` as used in [Cautun et al. 2013](https://academic.oup.com/mnras/article/429/2/1286/1038906) but other values can be 200 or 500 corresponding to `R_200` or `R_500`. `\u0394` is the overdensity parameter, when clusters achieve a density greater than this value, they are thought to be virialized/collapsed.\n\nThe boolean filters for each structure type produced by `calc_structure_bools()` can be used to tag structures within a density field, the results of this can be seen below\n\n<p align=\"center\">\n\n<img src=\"Images/final_tagging_figure_dark.png#gh-dark-mode-only\" width=\"100%\">\n\n<img src=\"Images/final_tagging_figure.png#gh-light-mode-only\" width=\"100%\">\n\n</p>\n\n### Additional Code Information\n\n* Note: The NEXUS+ implementation of tagging clusters is highly dependent on the the grid resolution being used. The cluster boolean filter will only be physically motivated if the resolution of each voxel is roughly < 1 Mpc/h so clusters can be resolved.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package for detecting structures in the Cosmic Web.",
    "version": "0.0.8",
    "project_urls": {
        "Bug Reports": "https://github.com/James11222/PyCosmoMMF/issues",
        "Check out my Website!": "http://www.james-sunseri.com",
        "Funding": "https://donate.pypi.org",
        "Homepage": "https://github.com/James11222/PyCosmoMMF/",
        "Source": "https://github.com/James11222/PyCosmoMMF/"
    },
    "split_keywords": [
        "cosmology"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cf8902011ea78ba266e26823c80e8085ea6a649fcb621166e1eed5d7f3fa7346",
                "md5": "33a93fffcac7e6c31fc093cb40edb34a",
                "sha256": "bfb2df0fe093666a3c4fb45936e34978d742d8287ac6b29b93ba1d73e2f7b326"
            },
            "downloads": -1,
            "filename": "PyCosmoMMF-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "33a93fffcac7e6c31fc093cb40edb34a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.6",
            "size": 125996,
            "upload_time": "2024-04-15T21:33:56",
            "upload_time_iso_8601": "2024-04-15T21:33:56.088827Z",
            "url": "https://files.pythonhosted.org/packages/cf/89/02011ea78ba266e26823c80e8085ea6a649fcb621166e1eed5d7f3fa7346/PyCosmoMMF-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8793ea71b762a8fe69022bb37b17d18dbc12a6ebc831d6e9e5f88ed674a1f6b2",
                "md5": "cf74d512e0aa8a61b20ccdd42bd102e2",
                "sha256": "3b17303e1c4874ca7261b30b98d138f6cc3b80a64c8b679463f48d5233b09c71"
            },
            "downloads": -1,
            "filename": "PyCosmoMMF-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "cf74d512e0aa8a61b20ccdd42bd102e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.6",
            "size": 129422,
            "upload_time": "2024-04-15T21:33:59",
            "upload_time_iso_8601": "2024-04-15T21:33:59.639067Z",
            "url": "https://files.pythonhosted.org/packages/87/93/ea71b762a8fe69022bb37b17d18dbc12a6ebc831d6e9e5f88ed674a1f6b2/PyCosmoMMF-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 21:33:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "James11222",
    "github_project": "PyCosmoMMF",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "numba",
            "specs": []
        },
        {
            "name": "scikit-image",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        }
    ],
    "lcname": "pycosmommf"
}
        
Elapsed time: 0.21694s