 <p>This is weird:</p> <pre><code>avg_rel_track_nan=avg_rel_track_nan(avg_rel_track) </code></pre> <p>You probably meant:</p> <pre><code>avg_rel_track_nan=averaged_rel_track_nan(avg_rel_track) </code></pre> <p>I can't tell for sure what is happening because a lot of your code depends on some other code but you are assigning the result of a (supposedly) function call to the name of this function. I'm guessing that's not what you meant to do.</p>