Skip to content

Instantly share code, notes, and snippets.

@philippslang
Last active August 21, 2017 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippslang/845141802581bbad8117ade85b490883 to your computer and use it in GitHub Desktop.
Save philippslang/845141802581bbad8117ade85b490883 to your computer and use it in GitHub Desktop.
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