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

set the values in np.clip() from [-100,100] to [-10,10] to help with … #308

Merged
merged 1 commit into from
Dec 12, 2023
Merged
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
8 changes: 4 additions & 4 deletions prospect/models/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def logsfr_ratios_to_masses(logmass=None, logsfr_ratios=None, agebins=None,
time.
"""
nbins = agebins.shape[0]
sratios = 10**np.clip(logsfr_ratios, -100, 100) # numerical issues...
sratios = 10**np.clip(logsfr_ratios, -10, 10) # numerical issues...
dt = (10**agebins[:, 1] - 10**agebins[:, 0])
coeffs = np.array([ (1. / np.prod(sratios[:i])) * (np.prod(dt[1: i+1]) / np.prod(dt[: i]))
for i in range(nbins)])
Expand All @@ -209,8 +209,8 @@ def logsfr_ratios_to_sfrs(logmass=None, logsfr_ratios=None, agebins=None, **extr
def logsfr_ratios_to_masses_flex(logmass=None, logsfr_ratios=None,
logsfr_ratio_young=None, logsfr_ratio_old=None,
**extras):
logsfr_ratio_young = np.clip(logsfr_ratio_young, -100, 100)
logsfr_ratio_old = np.clip(logsfr_ratio_old, -100, 100)
logsfr_ratio_young = np.clip(logsfr_ratio_young, -10, 10)
logsfr_ratio_old = np.clip(logsfr_ratio_old, -10, 10)

abins = logsfr_ratios_to_agebins(logsfr_ratios=logsfr_ratios, **extras)

Expand All @@ -236,7 +236,7 @@ def logsfr_ratios_to_agebins(logsfr_ratios=None, agebins=None, **extras):
"""

# numerical stability
logsfr_ratios = np.clip(logsfr_ratios, -100, 100)
logsfr_ratios = np.clip(logsfr_ratios, -10, 10)

# calculate delta(t) for oldest, youngest bins (fixed)
lower_time = (10**agebins[0, 1] - 10**agebins[0, 0])
Expand Down
Loading