<commit_before>"""
Functions to calculation production rates
"""

from __future__ import division, print_function, unicode_literals

import numpy as np
import numexpr as ne

from scipy.interpolate import InterpolatedUnivariateSpline
from scipy.interpolate import dfitpack

from cosmogenic import muon
from cosmogenic import scaling as scal
from cosmogenic import util

LAMBDA_h = 160.0 # attenuation length of hadronic component in atm, g / cm2

DEFAULT_ALT = 0.0  # sea level
DEFAULT_LAT = 75.0 # high latitude


def P_sp(z, n, scaling=None, alt=None, lat=None, t=None, pressure=None):
    """
    Returns production rate due to spallation reactions (atoms/g/yr)

    ::math P_{sp} = f_{scaling} * P_0 * exp(-z / \Lambda)

    where f_scaling is a scaling factor. It currently scales for altitude
    and latitude after Stone (2000).

    Parameters
    ----------
    z : array_like
       depth in g/cm**2 (vector or scalar)
    n : nuclide object from cosmogenic.nuclide
        The nuclide to you want a production rate for. Can be a user-defined
        object as long as it satisfies the same interfaces as the objects
        in cosmogenic.nuclide.
    scaling : string, optional
              If "stone" applies Stone 2000 scaling factor
    alt : array_like
          site altitude in meters
    lat : array_like,
          site latitude (in degrees North)
    
    Returns
    -------
    p_sp : array_like
           production rate from spallation in atoms/g/year
    """

    if scaling is None:
        f_scaling = 1.0
        # we are not scaling, default to the LSD (Sato "Sa") prod. rate
        scaling = "Sa"
    elif scaling in ("stone", "St"):
        f_scaling = scal.stone2000_sp(lat=lat, alt=alt, pressure=pressure)
        scaling = "St"
    elif scaling == "Sa":
        raise NotImplementedError("No Sa scaling yet.")
   
    p_sp_ref = n.scaling_p_sp_ref[scaling]
    return f_scaling * p_sp_ref * np.exp(-z / LAMBDA_h)


def P_tot(z, n, scaling=None, alt=None, lat=None, pressure=None):<commit_msg>Default to Sato production rates<commit_after>"""
Functions to calculation production rates
"""

from __future__ import division, print_function, unicode_literals

import numpy as np
import numexpr as ne

from scipy.interpolate import InterpolatedUnivariateSpline
from scipy.interpolate import dfitpack

from cosmogenic import muon
from cosmogenic import scaling as scal
from cosmogenic import util

LAMBDA_h = 160.0 # attenuation length of hadronic component in atm, g / cm2

DEFAULT_ALT = 0.0  # sea level
DEFAULT_LAT = 75.0 # high latitude


def P_sp(z, n, scaling=None, alt=None, lat=None, t=None, pressure=None):
    """
    Returns production rate due to spallation reactions (atoms/g/yr)

    ::math P_{sp} = f_{scaling} * P_0 * exp(-z / \Lambda)

    where f_scaling is a scaling factor. It currently scales for altitude
    and latitude after Stone (2000).

    Parameters
    ----------
    z : array_like
       depth in g/cm**2 (vector or scalar)
    n : nuclide object from cosmogenic.nuclide
        The nuclide to you want a production rate for. Can be a user-defined
        object as long as it satisfies the same interfaces as the objects
        in cosmogenic.nuclide.
    scaling : string, optional
              If "stone" applies Stone 2000 scaling factor
    alt : array_like
          site altitude in meters
    lat : array_like,
          site latitude (in degrees North)
    
    Returns
    -------
    p_sp : array_like
           production rate from spallation in atoms/g/year
    """

    if scaling is None and alt is None and lat is None and pressure is None:
        f_scaling = 1.0
        # we are not scaling, default to the LSD (Sato "Sa") prod. rate
        scaling = "Sa"
    elif scaling in ("stone", "St", None):
        # scale with Stone by default for now until LSD scaling is done
        f_scaling = scal.stone2000_sp(lat=lat, alt=alt, pressure=pressure)
        scaling = "St"
    elif scaling == "Sa":
        raise NotImplementedError("No Sa scaling yet.")
   
    p_sp_ref = n.scaling_p_sp_ref[scaling]
    return f_scaling * p_sp_ref * np.exp(-z / LAMBDA_h)


def P_tot(z, n, scaling=None, alt=None, lat=None, pressure=None):
{'fraction_non_alphanumeric': 0.08273894436519258, 'fraction_numerical': 0.012363290537327628, 'mean_word_length': 2.8003613369467026, 'pattern_counts': {'":': 2, '<': 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': '204611', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1243, 'n_words': 478}