<commit_before><commit_msg>add new module to find the cosmic star formation rate and cosmic stellar mass.<commit_after>"""
Galaxy-evolution related utilities

"""
import astropy.units as u
import numpy as np
from scipy.integrate import quad

def cosmic_sfr(z):
    """ Cosmic star formation rate in Msun / yr / cubic Mpc.

    Equation 16 from Madau and Dickinson 2014.

    """
    zp1 = 1 + z
    return 0.015 * zp1**2.7 / (1 + (zp1 / 2.9)**5.6)

def cosmic_mstel(z, hubble_par, R=0.27):
    """ The cosmic stellar mass at redshift z in Msun / cubic Mpc

    (see figure 11 in Madau and Dickinson 2014).
    """
    def integrand(z):
        return cosmic_sfr(z) / (hubble_par(z).to(u.yr**-1).value * (z+1))

    result = quad(integrand, z, np.inf)[0]
    return (1 - R) * result
{'fraction_non_alphanumeric': 0.12548015364916773, 'fraction_numerical': 0.04353393085787452, 'mean_word_length': 3.01025641025641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2075213', 'n_tokens_mistral': 308, 'n_tokens_neox': 269, 'n_words': 93}