Last active
August 21, 2017 12:44
-
-
Save philippslang/845141802581bbad8117ade85b490883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_exponential_decline(p0, exp, time): | |
return p0 * np.exp(-exp * time) | |
def calc_two_stage_decline(p0, exp_stage_zero, exp_stage_one, time_max, time_next_stage, time_min=0., | |
production_jumpfactor=4., num=50, noise=0.1, noise_mean=1.): | |
time = np.linspace(time_min, time_max, num) | |
stage_one = np.where(time > time_next_stage) | |
production = calc_exponential_decline(p0, exp_stage_zero, time) * np.random.normal(noise_mean, noise, time.shape) | |
time_stage_one_relative = np.linspace(time_min, time_max-time_next_stage, len(time[stage_one])) | |
production[stage_one] = calc_exponential_decline(production[stage_one][0] + p0/production_jumpfactor, exp_stage_one, | |
time_stage_one_relative) * np.random.normal(noise_mean, noise*2., time_stage_one_relative.shape) | |
stage = np.zeros_like(time) | |
stage[stage_one] = 1. | |
production[production < 0.] = 0. | |
return time, production, stage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment