Cropping Python lists by value instead of by index
<p>Good evening, StackOverflow. 
Lately, I've been wrestling with a Python program which I'll try to outline as briefly as possible. </p>

<p>In essence, my program plots (and then fits a function to) graphs. Consider <a href="https://i.stack.imgur.com/axth1.png" rel="nofollow">this graph.</a>
The graph plots just fine, but I'd like it to do a little more than that: since the data is periodic over an interval <strong>OrbitalPeriod</strong> (1.76358757), I'd like it to start with our <em>first x value</em> and then iteratively plot all of the points  <strong>OrbitalPeriod</strong> away from it, and then do the same exact thing over the next region of length <strong>OrbitalPeriod</strong>. </p>

<p>I know that there is a way to slice lists in Python of the form</p>

<pre><code>croppedList = List[a:b]
</code></pre>

<p>where <em>a</em> and <em>b</em> are the indices of the first and last elements you'd like to include in the new list, respectively. However, I have no idea what the indices are going to be for each of the values, or how many values fall between each <strong>OrbitalPeriod</strong>-sized interval. </p>

<p>What I want to do in pseudo-code looks something like this.</p>

<blockquote>
  <p>croppedList = fullList on the domain [a + (N * <strong>OrbitalPeriod</strong>), a + (N+1 * <strong>OrbitalPeriod</strong>)] </p>
</blockquote>

<p>where <strong>a</strong> is the x-value of the first meaningful data point.</p>

<p>If you have a workaround for this or a cropping method that would accept values instead of indices as arguments, please let me know. Thanks!</p>

<p>If you are working with <code>numpy</code>, you can use it inside the brackets</p>

<pre><code>m = x
M = x + OrbitalPeriod
croppedList = List[m &lt;= List]
croppedList = croppedList[croppedList &lt; M]
</code></pre>

python list plot crop slice