pysersic
pysersic: A Python package for determining galaxy structural properties via Bayesian inference, accelerated with jax - Published in JOSS (2023)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
✓Committers with academic emails
2 of 2 committers (100.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Scientific Fields
Repository
Bayesian fitting of Sersic profiles to galaxy images accelerated with jax
Basic Info
Statistics
- Stars: 30
- Watchers: 1
- Forks: 1
- Open Issues: 5
- Releases: 5
Metadata Files
README.md
pysersic is a code for fitting sersic profiles to galaxy images using Bayesian Inference. It is written in python using jax with inference performed using numpyro. You can read more about the motivation for this software via the JOSS Paper.
Installation
pysersic now requies at least python version 3.9. To start you should have jax installed. The easiest way to do this is to use pip install 'jax[cpu]', however if you are on windows or planning on running it on a GPU, the installation can be a little more complicated, please see the guide here. The other package dependencies for pysersic are:
- arviz
- asdf
- astropy
- corner
- matplotlib
- numpy
- numpyro
- pandas
- photutils
- scipy
- equinox
- interpax
- tqdm
Optional - jaxopt (only when using the pure minimization option).
There is a provided minimal environment.yml capturing the above in the base repo, as well as an environment-lock.yml which has a full set of versions specified for every dependency --- if you are having trouble with the installation, creating an environment using this file should ensure you have a single set of package versions that pysersic is known to work with. (We don't recommend using the lock yml in general, as pysersic should be kept up to date with new versions of its dependencies.)
Next you can install pysersic! To install the latest stable release, you can simply pip install via
pip install pysersic
If you would like the bleeding edge, development build (or would like to modify, add to, or otherwise access pysersic source files), you can also install from the github:
git clone https://github.com/pysersic/pysersic.git
cd pysersic
pip install -e .
Basic usage
All you need to run pysersic is a cutout of you galaxy of interest, and cutout of the error map, pixelized version of the PSF, and optionally a mask specifying bad pixels or nearby sources. The most basic setup is shown below for many many more details and in depth examples please see the documentation. First we set up a prior.
``` from pysersic.priors import SourceProperties
props = SourceProperties(imgcutout,mask=mask) # Optional mask prior = props.generateprior('sersic', # Other profiles inclues 'exp', 'dev' and 'pointsource' sky_type='none') # Can also use 'flat' or 'tilted-plane' to simultaneously fit a background ``` Then we initialize the fitting object:
``` from pysersic import FitSingle from pysersic.loss import gaussian_loss
fitter = FitSingle(data=imgcutout, # Cutout of galaxy rms=sigcutout, # Cutout of pixel errors psf=psf, #Point spread function prior=prior, # Prior that we initialized above mask=mask, #Optional mask lossfunc=gaussianloss) # Can specify loss function! See loss.py for many options or write your own! ```
Now we can fit!
``` mapdict = fitter.findMAP() # Find the 'best-fit' parameters as the maximum-a-posteriori. Returns a dictionary containing the MAP parameters and model image
svires = fitter.estimateposterior('svi-flow') #Train a normalizing flow to estimate the posterior, retruns a PysersicResults object containing the posterior and other helper methods nuts_res = fitter.sample() #Sample the posterior using the No U-turn sampler (NUTS), retruns a PysersicResults object ```
Test Suite
There is a growing set of tests that can be used to confirm the behavior of pysersic and its features is as expected. These tests run automatically on each pull request and merge. If you would like to run the tests yourself on your local machine, you can do so with the pytest package. Once installed, you can simply navigate to the tests directory and run:
pytest
Citation
If you use pysersic and find it useful, please do cite it. You can use the following BibTex.
@article{Pasha2023,
doi = {10.21105/joss.05703},
url = {https://doi.org/10.21105/joss.05703},
year = {2023},
publisher = {The Open Journal},
volume = {8},
number = {89},
pages = {5703},
author = {Imad Pasha and Tim B. Miller},
title = {pysersic: A Python package for determining galaxy structural properties via Bayesian inference, accelerated with jax},
journal = {Journal of Open Source Software} }
Owner
- Name: pysersic
- Login: pysersic
- Kind: organization
- Repositories: 1
- Profile: https://github.com/pysersic
JOSS Publication
pysersic: A Python package for determining galaxy structural properties via Bayesian inference, accelerated with jax
Authors
Tags
Python astronomy galaxies model fittingGitHub Events
Total
- Issues event: 6
- Watch event: 4
- Delete event: 1
- Issue comment event: 8
- Push event: 29
- Pull request event: 10
- Create event: 9
Last Year
- Issues event: 6
- Watch event: 4
- Delete event: 1
- Issue comment event: 8
- Push event: 29
- Pull request event: 10
- Create event: 9
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| prappleizer | i****a@y****u | 183 |
| tbmiller-astro | t****r@y****u | 126 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 40
- Total pull requests: 33
- Average time to close issues: about 1 month
- Average time to close pull requests: 4 days
- Total issue authors: 10
- Total pull request authors: 4
- Average comments per issue: 2.33
- Average comments per pull request: 0.24
- Merged pull requests: 30
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 5
- Pull requests: 8
- Average time to close issues: 2 months
- Average time to close pull requests: 3 days
- Issue authors: 4
- Pull request authors: 2
- Average comments per issue: 2.2
- Average comments per pull request: 0.13
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- tbmiller-astro (18)
- ke27whal (7)
- prappleizer (4)
- JBorrow (4)
- aruba19th (2)
- fdeugenio (1)
- AstroBarker (1)
- nehirozden (1)
- WeichenStars (1)
- Firestar-Reimu (1)
Pull Request Authors
- prappleizer (22)
- tbmiller-astro (15)
- eloisabentivegna (1)
- dfm (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v3 composite
- actions/setup-python v3 composite
- ipython *
- nbsphinx *
- nbsphinx_link *
- sphinx *
- sphinx-autoapi *
- sphinx-rtd-theme *
- sphinxcontrib-napoleon *
- pysersic *
- arviz *
- asdf *
- astropy *
- corner *
- jax *
- matplotlib *
- numpy *
- numpyro *
- pandas *
- photutils >=0.16
- scipy *
- tqdm *
- arviz *
- asdf *
- astropy *
- corner *
- jax *
- matplotlib *
- numpy *
- numpyro *
- pandas *
- photutils >=0.16
- scipy *
- tqdm *
