I\'m attempting to index an array based on conditions in the array itself, and corresponding locations in other arrays. I\'ve produced a mwe but this will be hopefully used