title: How would you find the roots of a linear interpolation in Python?
body: <p>I'm working on calculating the full width at half maximum for light curves with irregular shapes. My approach right now is to</p>
  <ul>
  <li>fit a spline (<code>scipy.interpolate.UnivariateSpline</code>) to the data (minus half maximum, so that y = 0 <em>is</em> the half max)</li>
  <li>find the roots of the spline (<code>UnivariateSpline.roots()</code>)</li>
  <li>find the difference between the first and last roots to determine the width of the curve at half max</li>
  </ul>
  <p>The <code>roots</code> method is only available for cubic splines, but I need the spline to be linear, or else I get results like the image below (due to the spacing of the data points). I should note that I'm working with hundreds of datasets, so manually selecting these &quot;roots&quot; is not quite feasible.</p>
  <p>Does anyone have any tricks to find the roots of a <em>linear</em> spline (or all of the x-values for a given y value)? Many thanks!</p>
  <p><a href="https://i.stack.imgur.com/X5n2M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X5n2M.png" alt="A plot showing the discrepancy between the true flux and the cubic spline." /></a></p>