def _get_piecewise_val(knots, t):
	"""
	Based on the knots specified for a piecewise linear function
	and a point in the domain 't', return the value of the piecewise
	linear function.

	knots: dictionary where keys and values should all be numeric.
	t: numeric within the domain specified by the knots.

	returns: float
	"""
	knots = {i: knots[i] for i in sorted(knots.keys())}

	knot_times = list(knots.keys())
	knot_vals = list(knots.values())

	if t < knot_times[0] or t > knot_times[-1]:
		raise ValueError(f"Cannot determine piecewise value for t={t}")

	s = []

	for i in range(1, len(knot_times)):
		s.append((knot_vals[i] - knot_vals[i-1]) / 
			(knot_times[i] - knot_times[i-1]))

	j = 0
	while knot_times[j+1] < t:
		j += 1
	return knot_vals[j] + s[j]*(t - knot_times[j])