So I have an array of values in which I would like to take out only certain ones to put in a new list or array. To better explain, here is an example of what I'm getting at.
Say I have this array
>>> import numpy as np
>>> x = np.arange(10)
>>> x
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>>
From this array I would want 0, 2, 3, 5, 6, and 8 in a new list or array. No matter the range of the array, I always want the 1st, next to last, and every two between them. Does anyone have a good way to do this?
So I guess if I explain why I need these values in such a specific way it might help in the solutions. The array I have in my code is a series angles I calculated in previous steps. However, I don't need all the values for the next part of my program.
So far my best guess has been to try and make a dictionary that might assign the values to the angle names I'm looking for.
Something like this...
angle_name = { i=f, i+1=s, i+2=o}
if angle_name.haskey(x[i]):
somenewlist.append(angle_name[x[i]])
Does that make any sense? My end goal is to eventually pick out the desired angles, name them appropriately and organize them in to a nice looking output.