I have a set of 100 data files containing information about particles (ID, velocity, position etc). I need to pick out 10000 specific particles having certain ID numbers from each of them. The way i am doing it is as follows
for i in range(n_files+1):
data= load_data_file(i, datatype="double_precision")
for j in chosen_id_arr:
my_index= np.where((particleID_in_data)==j)
identity.append(ID[my_index])
x.append(x_component[my_index])
y.append(y_component[my_index])
z.append(z_component[my_index])
The list "chosen_id_array" contains all such IDs. The data files are structured with respect to list index.
This snippet runs very slow for some reason, i was looking for a faster more efficient alternative for this. Thank you very much in advance. :)