petrofit

Python package for calculating Petrosian properties and fitting galaxy light profiles

https://github.com/petrofit/petrofit

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 4 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

fitting galfit petrofit petrosian python sersic
Last synced: 6 months ago · JSON representation ·

Repository

Python package for calculating Petrosian properties and fitting galaxy light profiles

Basic Info
Statistics
  • Stars: 30
  • Watchers: 2
  • Forks: 7
  • Open Issues: 30
  • Releases: 11
Topics
fitting galfit petrofit petrosian python sersic
Created almost 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.rst

.. image:: https://github.com/PetroFit/petrofit/raw/main/docs/images/petrofit_full_logo.png
    :width: 100%

PetroFit
--------
|repostatus tag| |CI tag| |rtd tag| |pyOpenSci| |PyPI tag| |AJ tag| |zonodo tag| |python version tag| |CodeCov| |astropy tag| |photutils tag| 

PetroFit is a package for calculating Petrosian properties, such as radii and concentration indices, as well as fitting
galaxy light profiles. In particular, PetroFit includes tools for performing accurate photometry, segmentations,
Petrosian profiling, and Sérsic fitting. Please see the `petrofit documentation `_
for installation instructions and a guide to the ``petrofit`` module.

.. image:: https://github.com/PetroFit/petrofit/raw/main/docs/images/multi_fit.png
    :width: 100%

Installation
------------

You can install PetroFit using pip or build a `jupyter lab `_ environment using `hatch `_ . Please see
the `petrofit documentation `_ for detailed installation instructions.

**pip Install**: 

.. code-block:: bash

    pip install petrofit

**hatch  Jupyter Lab**:

cd into the dir you want to launch jupyter lab in, and then run:

.. code-block:: bash
    
    hatch run jupyter:lab

Examples
--------

Please see the `petrofit documentation `_
for detailed examples, a quick stat guide, and instructions.

**Image Fitting**: 

PetroFit can be used with ``astropy`` models to fit psf convolved galaxy light profiles. Given a 2D image (``image``) and a psf (``PSF``), the following code snippet demonstrates how to fit a Sérsic model to the image:

.. code-block:: python

    import petrofit as pf
    from astropy.modeling import models

    sersic_model = models.Sersic2D(
            amplitude=1,
            r_eff=10,
            n=4,
            x_0=0, y_0=0,
            ellip=0.2,
            theta=25,
            bounds=pf.get_default_sersic_bounds(),
    )

    psf_sersic_model = pf.PSFConvolvedModel2D(
        sersic_model, psf=PSF, oversample=4, psf_oversample=1
    )

    fitted_model, fit_info = pf.fit_model(
        image, psf_sersic_model,
    )

**Photometry and Petrosian**: 

Given a 2D image (``image``) the following code snippet demonstrates how to create a Petrosian profile:

.. code-block:: python

    import petrofit as pf
    
    # Make a segmentation map and 
    # catalog using Photutils wrapper
    cat, segm, segm_deblend = pf.make_catalog(
        image,
        threshold=image.std()*3,
        wcs=None, deblend=True,
        npixels=4**2, nlevels=30, contrast=0.001,
    )

    # Photomerty on first source in catalog
    r_list = pf.make_radius_list(max_pix=50, n=50)
    flux_arr, area_arr, error_arr = pf.source_photometry(
        cat[0], # Source (`photutils.segmentation.catalog.SourceCatalog`)
        image, # Image as 2D array
        segm_deblend, # Deblended segmentation map of image
        r_list, # list of aperture radii
        cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius
    )

    # Make a Petrosian profile 
    p = pf.Petrosian(r_list, area_arr, flux_arr)
    print("{:0.4f} pix".format(p.r_half_light))


Citation
--------

Please see the `PetroFit citation documentation `_
for citation instructions. This information is also available in the ``CITATION.rst`` 
file in the PetroFit repo.

License
-------

This project is Copyright (c) The PetroFit Team and licensed under
the terms of the BSD 3-Clause license. This package is based upon
the `Astropy package template `_
which is licensed under the BSD 3-clause license. See the licenses folder for
more information.

Generative AI Policy
--------------------

To maintain scientific rigor and reproducibility, no generative AI-produced code 
is permitted within this repository. All code contributions must be manually authored 
or closely supervised to ensure our standards. Generative AI can be used, however, for 
documentation, issues, and PR descriptions (i.e ``git`` and GitHub workflow).

Contributing
------------

We love contributions! petrofit is open source,
built on open source, and we'd love to have you hang out in our community.

**Imposter syndrome disclaimer**: We want your help. No, really.

There may be a little voice inside your head that is telling you that you're not
ready to be an open source contributor; that your skills aren't nearly good
enough to contribute. What could you possibly offer a project like this one?

We assure you - the little voice in your head is wrong. If you can write code at
all, you can contribute code to open source. Contributing to open source
projects is a fantastic way to advance one's coding skills. Writing perfect code
isn't the measure of a good developer (that would disqualify all of us!); it's
trying to create something, making mistakes, and learning from those
mistakes. That's how we all improve, and we are happy to help others learn.

Being an open source contributor doesn't just mean writing code, either. You can
help out by writing documentation, tests, or even giving feedback about the
project (and yes - that includes giving feedback about the contribution
process). Some of these contributions may be the most valuable to the project as
a whole, because you're coming to the project with fresh eyes, so you can see
the errors and assumptions that seasoned contributors have glossed over.

Note: This disclaimer was originally written by
`Adrienne Lowe `_ for a
`PyCon talk `_, and was adapted by
petrofit based on its use in the README file for the
`MetPy project `_.


Acknowledgments
---------------
We thank Dr. Gregory D. Wirth, Dr. D. J. Pisano, and Dr. Alan Kahn for their guidance and support throughout this project. 
We would also like to thank the developers of Photutils, as much of this work is built on top of the tools they provid. 
This work was made possible by NASA grant AR 15058. Lastly, we give thanks to the Space Telescope Science Institute and 
the Technical Staff Research Committee (TSRC), a group that facilitates matching research projects with interested technical staff.

|nasa_logo|  |stsci_logo|

.. |nasa_logo| image:: https://github.com/PetroFit/petrofit/raw/main/docs/images/nasa_logo.png
    :width: 120px
    :height: 100px


.. |stsci_logo| image:: https://github.com/PetroFit/petrofit/raw/main/docs/images/stsci_logo.svg
    :width: 100px
    :height: 100px

.. |CI tag| image:: https://github.com/PetroFit/petrofit/actions/workflows/main.yml/badge.svg?branch=main
    :target: https://github.com/PetroFit/petrofit/actions/workflows/main.yml
    :alt: PetroFit CI status

.. |rtd tag| image:: https://readthedocs.org/projects/petrofit/badge/?version=latest
    :target: https://petrofit.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

.. |PyPI tag| image:: https://img.shields.io/pypi/v/petrofit?color=blue
    :target: https://pypi.org/project/petrofit/
    :alt: PetroFit's PyPI Status

.. |AJ tag| image:: http://img.shields.io/badge/paper-AJ-blue.svg?style=flat
    :target: https://doi.org/10.3847/1538-3881/ac5908
    :alt: PetroFit AJ

.. |astropy tag| image:: http://img.shields.io/badge/powered%20by-Astropy-orange.svg?style=flat&colorB=D93F0B
    :target: https://pypi.org/project/astropy
    :alt: Powered by Astropy
    
.. |photutils tag| image:: http://img.shields.io/badge/powered%20by-Photutils-blue.svg?style=flat&colorB=084680
    :target: https://pypi.org/project/photutils/
    :alt: Powered by photutils

.. |zonodo tag| image:: http://img.shields.io/badge/zenodo-10.5281/zenodo.6386991-blue.svg?style=flat
    :target: https://zenodo.org/badge/latestdoi/348478663
    :alt: PetroFit Zenodo DOI

.. |repostatus tag| image:: https://www.repostatus.org/badges/latest/active.svg
    :alt: Project Status: Active – The project has reached a stable, usable state and is being actively developed.
    :target: https://www.repostatus.org/#active

.. |python version tag| image:: https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fpetrofit%2Fpetrofit%2Fmain%2Fpyproject.toml
    :alt: Python Version from PEP 621 TOML
    :target: https://www.python.org/downloads/

.. |CodeCov| image:: https://codecov.io/gh/petrofit/petrofit/graph/badge.svg
   :alt: Tests code coverage
   :target: https://codecov.io/gh/petrofit/petrofit

.. |pyOpenSci| image:: https://tinyurl.com/y22nb8up
   :alt: pyOpenSci
   :target: https://github.com/pyOpenSci/software-review/issues/159


Owner

  • Name: PetroFit
  • Login: PetroFit
  • Kind: organization

Petrosian Profiles and Model Fitting

Citation (CITATION.rst)

##################
Citing and Credits
##################

Publications
============

|AJ tag| |zonodo tag| |ads tag|  |ascl tag|

If you would like to cite PetroFit for a publication, please use the acknowledgments below.
Given the close relationship between PetroFit and Photutils, we ask that you also cite
Photutils:

.. code-block:: text

    This research made use of Photutils, an Astropy package for
    detection and photometry of astronomical sources (Bradley et al.
    20XX). This research made use of PetroFit (Geda et al. 2022), a
    package based on Photutils, for calculating Petrosian properties
    and fitting galaxy light profiles.

Where `(Bradley et al. 20XX)` is a citation to the `Zenodo record of the Photutils version
<https://doi.org/10.5281/zenodo.596036>`_
that was used. For more information on how to cite Photutils or get an example BibTeX entry, please visit
the `Photutils documentation <https://photutils.readthedocs.io/en/stable/citation.html>`_.
If you need to cite a specific version of PetroFit, please use
`PetroFit's Zonodo record <https://zenodo.org/badge/latestdoi/348478663>`_
in addition to the acknowledgments above.

*Geda et al. 2022* BibTeX (`download .bib file <https://iopscience.iop.org/export?type=article&doi=10.3847/1538-3881/ac5908&exportFormat=iopexport_bib&exportType=abs&navsubmit=Export+abstract>`_):

.. code-block:: text

    @article{Geda_2022,
        doi = {10.3847/1538-3881/ac5908},
        url = {https://doi.org/10.3847/1538-3881/ac5908},
        year = 2022,
        month = {apr},
        publisher = {American Astronomical Society},
        volume = {163},
        number = {5},
        pages = {202},
        author = {Robel Geda and Steven M. Crawford and Lucas Hunt and Matthew Bershady and Erik Tollerud and Solohery Randriamampandry},
        title = {{PetroFit}: A Python Package for Computing Petrosian Radii and Fitting Galaxy Light Profiles},
        journal = {The Astronomical Journal},
        abstract = {PetroFit is an open-source Python package based on Astropy and Photutils that can calculate Petrosian profiles and fit galaxy images. It offers end-to-end tools for making accurate photometric measurements, estimating morphological properties, and fitting 2D models to galaxy images. Petrosian metric radii can be used for model parameter estimation and aperture photometry to provide accurate total fluxes. Correction tools are provided for improving Petrosian radii estimates affected by galaxy morphology. PetroFit also provides tools for sampling Astropy-based models (including custom profiles and multicomponent models) onto image grids and enables point-spread function convolution to account for the effects of seeing. These capabilities provide a robust means of modeling and fitting galaxy light profiles. We have made the PetroFit package publicly available on GitHub ( PetroFit/petrofit ) and PyPi (pip install petrofit).}
    }

PetroFit Badges
===============

If a significant portion of your code uses PetroFit, please show support by adding the
following badge to your GitHub `README` file:

PetroFit Badge:

|petrofit tag|

reStructuredText (.rst):

.. code-block:: rst

    .. |petrofit tag| image:: https://img.shields.io/badge/powered%20by-PetroFit-blue.svg?style=flat&color=00B0F0
        :target: https://github.com/PetroFit/petrofit
        :alt: PetroFit

    |petrofit tag|

Markdown (.md):

.. code-block:: text

    [![PetroFit](https://img.shields.io/badge/powered%20by-PetroFit-blue.svg?style=flat&color=00B0F0)](https://github.com/PetroFit/petrofit)

HTML (.html):

.. code-block:: html

    <a href="https://github.com/PetroFit/petrofit"><img src="https://img.shields.io/badge/powered%20by-PetroFit-blue.svg?style=flat&color=00B0F0" alt="PetroFit"></a>

.. |AJ tag| image:: http://img.shields.io/badge/AJ-10.3847/1538-%2D3881/ac5908-blue.svg?style=flat
    :target: https://doi.org/10.3847/1538-3881/ac5908
    :alt: PetroFit AJ

.. |ads tag| image:: http://img.shields.io/badge/ADS-2022arXiv220213493G-blue.svg?style=flat
    :target: https://ui.adsabs.harvard.edu/abs/2022arXiv220213493G/abstract
    :alt: PetroFit ADS

.. |zonodo tag| image:: http://img.shields.io/badge/zenodo-10.5281/zenodo.6386991-blue.svg?style=flat
    :target: https://zenodo.org/badge/latestdoi/348478663
    :alt: PetroFit Zenodo DOI

.. |arxiv tag| image:: http://img.shields.io/badge/arxiv-2202.13493-blue.svg?style=flat&colorB=b31a1a
    :target: https://arxiv.org/abs/2202.13493
    :alt: PetroFit arxiv


.. |ads tag| image:: https://img.shields.io/badge/ADS-2022AJ....163..202G-blue.svg?style=flat&color=3484e0
    :target: https://ui.adsabs.harvard.edu/abs/2022AJ....163..202G/abstract
    :alt: ADS PetroFit

.. |ascl tag| image:: https://img.shields.io/badge/ascl-2203.013-black.svg?colorB=262255
    :target: https://ascl.net/2203.013
    :alt: ascl:2203.013

.. |petrofit tag| image:: https://img.shields.io/badge/powered%20by-PetroFit-blue.svg?style=flat&color=00B0F0
    :target: https://github.com/PetroFit/petrofit
    :alt: PetroFit

GitHub Events

Total
  • Issues event: 19
  • Watch event: 5
  • Delete event: 1
  • Issue comment event: 18
  • Push event: 15
  • Pull request review event: 1
  • Pull request event: 36
  • Fork event: 1
  • Create event: 1
Last Year
  • Issues event: 19
  • Watch event: 5
  • Delete event: 1
  • Issue comment event: 18
  • Push event: 15
  • Pull request review event: 1
  • Pull request event: 36
  • Fork event: 1
  • Create event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 154
  • Total Committers: 4
  • Avg Commits per committer: 38.5
  • Development Distribution Score (DDS): 0.045
Top Committers
Name Email Commits
robelgeda r****a@y****m 147
Robel Geda r****a@s****u 5
Liza Sazonova e****1@j****u 1
Dany Vohl m****e@u****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 91
  • Total pull requests: 78
  • Average time to close issues: 6 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 6
  • Total pull request authors: 5
  • Average comments per issue: 0.6
  • Average comments per pull request: 0.37
  • Merged pull requests: 75
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 12
  • Pull requests: 20
  • Average time to close issues: 14 days
  • Average time to close pull requests: about 13 hours
  • Issue authors: 2
  • Pull request authors: 2
  • Average comments per issue: 0.67
  • Average comments per pull request: 0.8
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • robelgeda (75)
  • kyleaoman (9)
  • SterlingYM (2)
  • danangsetyo5364 (1)
  • lucatelli (1)
  • crawfordsm (1)
Pull Request Authors
  • robelgeda (90)
  • kyleaoman (2)
  • macrocosme (1)
  • crawfordsm (1)
  • astro-nova (1)
Top Labels
Issue Labels
Enhancement (42) Bug (12) pyOpenSci (9) Documentation (8) Backwards Incompatible (7) Infrastructure (5) Installation (4) AstroPy (4) Good First Issue (4) Deprecated (4) Tracker (3) Visualization (3) Question (2) Photutils (2) Resolved ✓ (2) Release (2) Scrapped (1) Testing (1) Major (1)
Pull Request Labels
Documentation (37) Bug (14) pyOpenSci (12) Infrastructure (11) Testing (10) Enhancement (10) Backwards Incompatible (8) Installation (5) Major (5) Release (4) AstroPy (2) 🔥 Urgent! (2) Deprecated (2) Needs Review (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 71 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 12
  • Total maintainers: 1
pypi.org: petrofit

Python package for calculating Petrosian properties and fitting galaxy light profiles.

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 71 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 13.2%
Forks count: 14.3%
Average: 17.6%
Dependent repos count: 21.6%
Downloads: 28.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • Cython *
  • astropy >=5.0.3
  • astropy_helpers *
  • docutils *
  • extension_helpers *
  • ipywidgets *
  • jupyter *
  • matplotlib >=3.1.1
  • nbsphinx *
  • notebook *
  • numpy >=1.13
  • photutils >=1.1.0
  • regions *
  • scikit-image *
  • scipy *
  • sklearn *
  • sphinx *
  • sphinx-automodapi *
  • sphinx_astropy *
  • sphinx_rtd_theme *
  • tox *
Dockerfile docker
  • jupyter/scipy-notebook 4d9c9bd9ced0 build
.github/workflows/ci_tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
environment.yml pypi
pyproject.toml pypi
setup.py pypi