0

I have a numpy array which is 5 by 182 that looks similar to something like this:

matched_data = '/home/myname/data.csv'
matched_data = Table.read(matched_data, format="ascii")

ID_1 = np.array(matched_data['name'])
ID_1.astype(str)

ID_2 = np.array(matched_data['col1_1'])
ID_2.astype(str)

mag = np.array(matched_data['Magnitude'])
mag.astype(float)

semi_major_axis = np.array(matched_data['SMA'])
semi_major_axis.astype(float)

semi_minor_axis = np.array(matched_data['sma'])
semi_minor_axis.astype(float)

position_angle = np.array(matched_data['pos_ang'])
position_angle.astype(float)


match = (ID_1, ID_2, mag, (semi_major_axis/semi_minor_axis), position_angle)
match = np.array(match) 

How would I be able to get data out of this line by line? For example when I type :

print(match[0])

it prints out the list of IDs from ID_1 where as I would like the ID_1, ID_2, magnitude, (semi_major_axis/semi_minor_axis) and position_angle of the first object. How would I do this?

1 Answer 1

2

Instead of match = np.array(match) you can use match = np.stack(match, axis=1). This way the various quantities (ID_1, ID_2, mag, ...) will be columns of the resulting array and you can access them via match[index]. If you did np.stack(match, axis=0) then this is similar to what you did originally and the data will be rows in the resulting array. Here it's still possible to access it by providing a column index: match[:, 0].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.