Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion src/onepower/utils/poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Poisson(Component, metaclass=ABCMeta):
"""
Class to calculate the Poisson parameter for use in Pgg integrals.

Can be either a scalar (P = poisson) or a power law (P = poisson x (M/M_0)^slope),
Can be either a scalar (P = poisson), a power law (P = poisson x (M/M_0)^slope),
or a logistic function (P = poisson x L / (1 + exp(-k * (log10(M) - log10(M_0))))),
by using the appropriate child class. Parent class is just an instance of an abstract class
Further models can be added if necessary.

Expand Down Expand Up @@ -61,4 +62,22 @@ def poisson_func(self):
return poisson * (self.mass / (10.0**M_0)) ** slope


class logistic_function(Poisson):
"""Logistic function mass dependent Poisson parameter."""

_defaults = {'poisson': 1.0, 'L': None, 'k': None, 'log10_M0': None}

@property
def poisson_func(self):
poisson = self.params['poisson']
L = self.params['L']
k = self.params['k']
log10_M0 = self.params['log10_M0']
if L is None or k is None or log10_M0 is None:
raise ValueError(
"L, k, and log10_M0 must be provided for 'logistic_function' poisson type."
)
return poisson * L / (1 + np.exp(-k * (np.log10(self.mass) - log10_M0)))


# Add more if needed!
Loading