""".format( kappa=kappa, k=k, Qm=Qm, nrow=nrow, dz=dz, ) ) # Create an instance of the Heat model, initialize it from the file. h = Heat() h.initialize(file_like) # set the initial temperature based on our linear fit. model_z = np.arange(0, nrow * dz, dz) T_init = fit.intercept_[0] + fit.coef_[0][0] * model_z h.set_value("temperature", T_init) # override the default timestep to use 1 day. h.timestep = seconds_per_day # run the model forward in time forced by the surface temperature. while h.get_current_time() < duration_years * seconds_per_year: # calculate the time to run until. run_until = min([h.get_current_time() + seconds_per_year, duration_years*seconds_per_year]) # determine the current surface temperature current_time = h.get_current_time()/seconds_per_year current_temperature_change = surface_temperature_change(current_time) # set the surface temperature in the model. h.set_value_at_indices("temperature", [0], T_init[0] + current_temperature_change) # run forward in time. h.update_until(run_until)