Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supernova volumetric redshift rate #140

Closed
wants to merge 8 commits into from
Closed
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions skypy/supernova/Ia_redshift_rate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
r"""Creates the volumetric SNe Ia rate for an array of redshifts
=================
.. autosummary::
:nosignatures:
:toctree: ../api/
SNeIa_redshifts

Models
======
.. autosummary::
:nosignatures:
:toctree: ../api/
Ia_redshift_rate
"""

from astropy import units


def Ia_redshift_rate(redshift, r0=2.27e-5, a=1.7):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what are these default values? Are they "standard" values? I would generally prefer them to not have defaults in most cases. They should also be documented under 'Parameters' even if it just says 'free parameters of the model'

"""Creates a redshift distribution of Type Ia Supernovae
This function computes the redshift distribution of Type Ia Supernovae
using the rate parameters as given in [1].
Parameters
----------
redshift : numpy.array
Redshift at which to evaluate the Type Ia supernovae rate.
Returns
-------
rate : astropy.Quantity
Volumetric rate of Type Ia's the redshifts given in units of
[SNe Ia yr−1 Mpc−3]

Examples
--------
>>> import numpy as np
>>> z = np.array([0.0,0.1,0.2])
>>> Ia_redshift_rate(z,r0=2.27e-5,a=1.7)
<Quantity [2.27000000e-05, 2.66927563e-05, 3.09480989e-05] yr / Mpc3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will probably have to update the units here as well

References
----------
.. [1] Frohmaier, C. et al. (2019), https://arxiv.org/pdf/1903.08580.pdf .
"""

rate = r0*(1+redshift)**a * units.year *(units.Mpc)**-3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whitespace will fix your PEP8 error. Also I think it should be units.year ** -1 is that correct?

Suggested change
rate = r0*(1+redshift)**a * units.year *(units.Mpc)**-3
rate = r0 * (1+redshift) ** a * units.year ** -1 * (units.Mpc) ** -3

return rate