pyp-beagle


Namepyp-beagle JSON
Version 0.10.17 PyPI version JSON
download
home_pagehttps://github.com/jacopo-chevallard/PyP-BEAGLE
SummaryPackage for post-processing of results obtained with the Beagle SED fitting tool
upload_time2024-03-26 11:48:08
maintainerNone
docs_urlNone
authorJacopo Chevallard
requires_pythonNone
licenseMIT
keywords astronomy galaxies statistics visualization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Upload Python Package](https://github.com/jacopo-chevallard/PyP-BEAGLE/actions/workflows/python-publish.yml/badge.svg)](https://github.com/jacopo-chevallard/PyP-BEAGLE/actions/workflows/python-publish.yml)

# PyP-BEAGLE

PyP-BEAGLE (**Py**thon **P**ostprocessing of **BEAGLE**) is a Python package to postprocess the analyses performed with the galaxy SED modelling tool [Beagle](http://www.jacopochevallard.org/beagle/) (**B**ay**E**sian **A**nalysis of **G**a**L**axy s**E**ds). PyP-BEAGLE allows one to create different types of publication-quality plots, LaTeX tables, as well as several higher level "summary" catalogues.  

# Installing PyP-BEAGLE

* Make sure that you have a (science-ready!) installation of Python 3.x (starting from PyP-BEAGLE version 0.7.0), for instance [Anaconda](https://www.continuum.io/downloads)

* To install PyP-BEAGLE simply run
  ```
  pip install pyp_beagle
  ```

# Known issues

* On a Mac OS, multiprocessing only works with the ``Agg`` backend. Make sure that your ``~/.matplotlib/matplotlibrc`` file contains the line
  ```
  backend      : Agg
  ```

* If you encounter errors related to LaTeX, or if the visual appearance of the plots is not satisfying, you can copy the matplotlib configuration file ``script/matplotlibrc`` into your ``$HOME/.matplotlib/`` folder (if the folder does not exist, create it). If you already have a customized  ``matplotlibrc`` file, then you can use the GNU ``diff`` command to update it.

* PyP-BEAGLE assumes that the Beagle environment variables are correctly set on your machine. Note that while these are the same environment variables used by Docker-Beagle (see [here](https://github.com/jacopo-chevallard/BEAGLE-general/wiki#running-beagle)), they have to point to the actual folders on your machine, not to the "virtual" folder that Docker-Beagle uses. To correctly set the environment variables, you can use the ``scripts/BEAGLE_env_variable.bash`` or ``scripts/BEAGLE_env_variable.csh`` files. In practice, after modifying the file to reflect your Beagle folder tree, you can simply add at the end of your ``.bashrc`` (or ``.tcshrc``, or equivalent) the line
 ```bash
 source <full path to the file>/BEAGLE_env_variable.bash
 ```

# Using PyP-BEAGLE

The post-processing of Beagle results is performed by means of the command ``pyp_beagle``. Since PyP-BEAGLE is often updated, you can visualize the (entire) possible options via the PyP-BEAGLE ``help``, with the command
```csh
pyp_beagle --help
```

Below we report a few of some common PyP-BEAGLE use cases and related commands.

* [triangle plots](#plotting-the-posterior-probability-distributions-aka-triangle-plots)
* [marginal plots](#plotting-the-comparison-of-data-and-model-observables-aka-marginal-plots)
* [summary catalogue](#computing-a-summary-catalogue)
* [true vs retrieved parameters](#plotting-the-comparison-of-input-and-retrieved-parameters-when-fitting-mock-observations)

### Plotting the posterior probability distributions (aka "triangle plots")

#### Command

```csh
pyp_beagle -r <your Beagle results folder> \
--plot-triangle \
[-np <number of processors>] \
[--json-triangle <JSON triangle file>] \
[--mock-catalogue <input mock catalogue>] \
[--json-mock <JSON mock file>]
```

where
* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;
* ``<number of processors>`` is an integer indicating how many processors can be used for the parallel execution of the script. This is particularly important when producing plots for large (> 1000) samples, as the creation of each individual plot can take several tens of seconds.
* ``<JSON triangle file>`` is a JSON file used for the configuration of the triangle plot (which parameters should be plotted, log scale, plot limits, ...), an example can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/params_names.json);
* ``<input mock catalogue>`` indicates a Beagle FITS file containing the input (i.e. "true") physical parameters used to construct the noiseless SEDs which have then been fitted with Beagle (after the noise addition, which must be performed **outside** Beagle). Note that in this case, a ``<JSON mock file>`` must be passed, since we must instruct PyP-BEAGLE where (in which FITS extension and column) to find the "true" parameters. An example of the ``<JSON mock file>`` to be used in this case can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/params_names_mock.json).


#### Output

The successful execution of the script will create a set of ``*_triangle.pdf`` files (one per object) in the ``<your Beagle results folder>/pyp-beagle/plot`` folder.


### Plotting the comparison of data and model observables (aka "marginal plots")

#### Command

```csh
pyp_beagle -r <your Beagle results folder> \
--plot-marginal \
[-np <number of processors>] \
[--log-wavelength] \
[--plot-line-labels] \
[--spectral-resolution <resolution>] \
```

where
* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;
* ``<number of processors>`` is an integer indicating how many processors can be used for the parallel execution of the script. This is particularly important when producing plots for large (> 1000) samples, as the creation of each individual plot can take several tens of seconds;
* ``<resolution>`` is a float indicating the resolution of the spectra, and it is used to determine which emission line labels are printed on the plot.

#### Output

The successful execution of the script will create a set of ``*_marginal_SED_spec.pdf`` files (one per object) in the ``<your Beagle results folder>/pyp-beagle/plot`` folder.


### Computing a summary catalogue

#### Command

```csh
pyp_beagle -r <your Beagle results folder> 
--compute-summary
[--json-summary <JSON summary file>]
```

where
* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;
* ``<JSON summary file>`` is a JSON file used for the configuration of the summary catalogue, specifying for which parameters the summary statistics (posterior mean and median, 68 and 95 % credible regions) should be computed. An example can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/summary_config.json).

#### Output

The successful execution of the script will create the file ``<your Beagle results folder>/pyp-beagle/data/BEAGLE_summary_catalogue.fits``.

#### Description

In the ``POSTERIOR PDF`` extension we have added some quantities related to the MAP = Maximum-a-Posteriori solution, namely the probability (``MAP_probability``), log-likelihood (``MAP_ln_likelihood``), chi-square (``MAP_chi_square``), and number of data points used in the fitting (``MAP_n_data``). These quantities enable a quick "frequentist-like" check of the goodness-of-the-fit of the MAP solution.

The physical parameters corresponding to the MAP solution are indicated as ``<parameter_name>_MAP`` (e.g. ``mass_MAP``).

### Plotting the comparison of input and retrieved parameters when fitting mock observations

#### Command

```csh
pyp_beagle -r <your Beagle results folder> 
--mock-catalogue <input mock catalogue> \
--json-mock <JSON mock file>
```

where
* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;
* ``<input mock catalogue>`` indicates a Beagle FITS file containing the input (i.e. "true") physical parameters used to construct the noiseless SEDs which have then been fitted with Beagle (after the noise addition, which must be performed **outside** Beagle). Note that in this case, a ``<JSON mock file>`` must be passed, since we must instruct PyP-BEAGLE where (in which FITS extension and column) to find the "true" parameters. An example of the ``<JSON mock file>`` to be used in this case can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/params_names_mock.json).

#### Output

The successful execution of the script will create the files ``<your Beagle results folder>/pyp-beagle/plot/BEAGLE_mock_retrieved_params_hist.pdf`` and ``<your Beagle results folder>/pyp-beagle/plot/BEAGLE_mock_retrieved_params.pdf``.




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jacopo-chevallard/PyP-BEAGLE",
    "name": "pyp-beagle",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "astronomy galaxies statistics visualization",
    "author": "Jacopo Chevallard",
    "author_email": "jacopo.chevallard@mailfence.com",
    "download_url": "https://files.pythonhosted.org/packages/d5/6d/e74239880babf58677e4dca080a2e423b971fdae7dc8e6391755a4d1b738/pyp_beagle-0.10.17.tar.gz",
    "platform": null,
    "description": "[![Upload Python Package](https://github.com/jacopo-chevallard/PyP-BEAGLE/actions/workflows/python-publish.yml/badge.svg)](https://github.com/jacopo-chevallard/PyP-BEAGLE/actions/workflows/python-publish.yml)\n\n# PyP-BEAGLE\n\nPyP-BEAGLE (**Py**thon **P**ostprocessing of **BEAGLE**) is a Python package to postprocess the analyses performed with the galaxy SED modelling tool [Beagle](http://www.jacopochevallard.org/beagle/) (**B**ay**E**sian **A**nalysis of **G**a**L**axy s**E**ds). PyP-BEAGLE allows one to create different types of publication-quality plots, LaTeX tables, as well as several higher level \"summary\" catalogues.  \n\n# Installing PyP-BEAGLE\n\n* Make sure that you have a (science-ready!) installation of Python 3.x (starting from PyP-BEAGLE version 0.7.0), for instance [Anaconda](https://www.continuum.io/downloads)\n\n* To install PyP-BEAGLE simply run\n  ```\n  pip install pyp_beagle\n  ```\n\n# Known issues\n\n* On a Mac OS, multiprocessing only works with the ``Agg`` backend. Make sure that your ``~/.matplotlib/matplotlibrc`` file contains the line\n  ```\n  backend      : Agg\n  ```\n\n* If you encounter errors related to LaTeX, or if the visual appearance of the plots is not satisfying, you can copy the matplotlib configuration file ``script/matplotlibrc`` into your ``$HOME/.matplotlib/`` folder (if the folder does not exist, create it). If you already have a customized  ``matplotlibrc`` file, then you can use the GNU ``diff`` command to update it.\n\n* PyP-BEAGLE assumes that the Beagle environment variables are correctly set on your machine. Note that while these are the same environment variables used by Docker-Beagle (see [here](https://github.com/jacopo-chevallard/BEAGLE-general/wiki#running-beagle)), they have to point to the actual folders on your machine, not to the \"virtual\" folder that Docker-Beagle uses. To correctly set the environment variables, you can use the ``scripts/BEAGLE_env_variable.bash`` or ``scripts/BEAGLE_env_variable.csh`` files. In practice, after modifying the file to reflect your Beagle folder tree, you can simply add at the end of your ``.bashrc`` (or ``.tcshrc``, or equivalent) the line\n ```bash\n source <full path to the file>/BEAGLE_env_variable.bash\n ```\n\n# Using PyP-BEAGLE\n\nThe post-processing of Beagle results is performed by means of the command ``pyp_beagle``. Since PyP-BEAGLE is often updated, you can visualize the (entire) possible options via the PyP-BEAGLE ``help``, with the command\n```csh\npyp_beagle --help\n```\n\nBelow we report a few of some common PyP-BEAGLE use cases and related commands.\n\n* [triangle plots](#plotting-the-posterior-probability-distributions-aka-triangle-plots)\n* [marginal plots](#plotting-the-comparison-of-data-and-model-observables-aka-marginal-plots)\n* [summary catalogue](#computing-a-summary-catalogue)\n* [true vs retrieved parameters](#plotting-the-comparison-of-input-and-retrieved-parameters-when-fitting-mock-observations)\n\n### Plotting the posterior probability distributions (aka \"triangle plots\")\n\n#### Command\n\n```csh\npyp_beagle -r <your Beagle results folder> \\\n--plot-triangle \\\n[-np <number of processors>] \\\n[--json-triangle <JSON triangle file>] \\\n[--mock-catalogue <input mock catalogue>] \\\n[--json-mock <JSON mock file>]\n```\n\nwhere\n* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;\n* ``<number of processors>`` is an integer indicating how many processors can be used for the parallel execution of the script. This is particularly important when producing plots for large (> 1000) samples, as the creation of each individual plot can take several tens of seconds.\n* ``<JSON triangle file>`` is a JSON file used for the configuration of the triangle plot (which parameters should be plotted, log scale, plot limits, ...), an example can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/params_names.json);\n* ``<input mock catalogue>`` indicates a Beagle FITS file containing the input (i.e. \"true\") physical parameters used to construct the noiseless SEDs which have then been fitted with Beagle (after the noise addition, which must be performed **outside** Beagle). Note that in this case, a ``<JSON mock file>`` must be passed, since we must instruct PyP-BEAGLE where (in which FITS extension and column) to find the \"true\" parameters. An example of the ``<JSON mock file>`` to be used in this case can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/params_names_mock.json).\n\n\n#### Output\n\nThe successful execution of the script will create a set of ``*_triangle.pdf`` files (one per object) in the ``<your Beagle results folder>/pyp-beagle/plot`` folder.\n\n\n### Plotting the comparison of data and model observables (aka \"marginal plots\")\n\n#### Command\n\n```csh\npyp_beagle -r <your Beagle results folder> \\\n--plot-marginal \\\n[-np <number of processors>] \\\n[--log-wavelength] \\\n[--plot-line-labels] \\\n[--spectral-resolution <resolution>] \\\n```\n\nwhere\n* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;\n* ``<number of processors>`` is an integer indicating how many processors can be used for the parallel execution of the script. This is particularly important when producing plots for large (> 1000) samples, as the creation of each individual plot can take several tens of seconds;\n* ``<resolution>`` is a float indicating the resolution of the spectra, and it is used to determine which emission line labels are printed on the plot.\n\n#### Output\n\nThe successful execution of the script will create a set of ``*_marginal_SED_spec.pdf`` files (one per object) in the ``<your Beagle results folder>/pyp-beagle/plot`` folder.\n\n\n### Computing a summary catalogue\n\n#### Command\n\n```csh\npyp_beagle -r <your Beagle results folder> \n--compute-summary\n[--json-summary <JSON summary file>]\n```\n\nwhere\n* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;\n* ``<JSON summary file>`` is a JSON file used for the configuration of the summary catalogue, specifying for which parameters the summary statistics (posterior mean and median, 68 and 95 % credible regions) should be computed. An example can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/summary_config.json).\n\n#### Output\n\nThe successful execution of the script will create the file ``<your Beagle results folder>/pyp-beagle/data/BEAGLE_summary_catalogue.fits``.\n\n#### Description\n\nIn the ``POSTERIOR PDF`` extension we have added some quantities related to the MAP = Maximum-a-Posteriori solution, namely the probability (``MAP_probability``), log-likelihood (``MAP_ln_likelihood``), chi-square (``MAP_chi_square``), and number of data points used in the fitting (``MAP_n_data``). These quantities enable a quick \"frequentist-like\" check of the goodness-of-the-fit of the MAP solution.\n\nThe physical parameters corresponding to the MAP solution are indicated as ``<parameter_name>_MAP`` (e.g. ``mass_MAP``).\n\n### Plotting the comparison of input and retrieved parameters when fitting mock observations\n\n#### Command\n\n```csh\npyp_beagle -r <your Beagle results folder> \n--mock-catalogue <input mock catalogue> \\\n--json-mock <JSON mock file>\n```\n\nwhere\n* ``<your Beagle results folder>`` must be replaced by the full path to the Beagle output directory;\n* ``<input mock catalogue>`` indicates a Beagle FITS file containing the input (i.e. \"true\") physical parameters used to construct the noiseless SEDs which have then been fitted with Beagle (after the noise addition, which must be performed **outside** Beagle). Note that in this case, a ``<JSON mock file>`` must be passed, since we must instruct PyP-BEAGLE where (in which FITS extension and column) to find the \"true\" parameters. An example of the ``<JSON mock file>`` to be used in this case can be found [here](https://github.com/jacopo-chevallard/PyP-BEAGLE/blob/0996fd3c6b271e15452b7edee6627bc7fbc68675/PyP-BEAGLE/files/params_names_mock.json).\n\n#### Output\n\nThe successful execution of the script will create the files ``<your Beagle results folder>/pyp-beagle/plot/BEAGLE_mock_retrieved_params_hist.pdf`` and ``<your Beagle results folder>/pyp-beagle/plot/BEAGLE_mock_retrieved_params.pdf``.\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Package for post-processing of results obtained with the Beagle SED fitting tool",
    "version": "0.10.17",
    "project_urls": {
        "Homepage": "https://github.com/jacopo-chevallard/PyP-BEAGLE"
    },
    "split_keywords": [
        "astronomy",
        "galaxies",
        "statistics",
        "visualization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d15812e3cdaa2b12f0d027140d47f3e97aec2ecec7521ff0ac214327b5169949",
                "md5": "95af5445a358bc24545d5b0c225776e3",
                "sha256": "6980d120b653531acfe69f39e6fde7ba9bc44dd58932872871f0a7624b1b0a23"
            },
            "downloads": -1,
            "filename": "pyp_beagle-0.10.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "95af5445a358bc24545d5b0c225776e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 81211,
            "upload_time": "2024-03-26T11:48:06",
            "upload_time_iso_8601": "2024-03-26T11:48:06.505497Z",
            "url": "https://files.pythonhosted.org/packages/d1/58/12e3cdaa2b12f0d027140d47f3e97aec2ecec7521ff0ac214327b5169949/pyp_beagle-0.10.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d56de74239880babf58677e4dca080a2e423b971fdae7dc8e6391755a4d1b738",
                "md5": "9a02b0b093c6d01cf2a07e2696579b13",
                "sha256": "61625ec8f89a69bf63f2566d1fc67337578e1fe25acf9809cb3d10557d3ed683"
            },
            "downloads": -1,
            "filename": "pyp_beagle-0.10.17.tar.gz",
            "has_sig": false,
            "md5_digest": "9a02b0b093c6d01cf2a07e2696579b13",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 72744,
            "upload_time": "2024-03-26T11:48:08",
            "upload_time_iso_8601": "2024-03-26T11:48:08.798769Z",
            "url": "https://files.pythonhosted.org/packages/d5/6d/e74239880babf58677e4dca080a2e423b971fdae7dc8e6391755a4d1b738/pyp_beagle-0.10.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-26 11:48:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jacopo-chevallard",
    "github_project": "PyP-BEAGLE",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyp-beagle"
}
        
Elapsed time: 0.22311s