Ovito's Particle Index and Lammps Particle Identifier Mismatch

I was trying to use CutoffNeighborFinder, but it only takes Index as a parameter and not the Particle Identifier generated by Lammps dump file. Now when particles are ordered in terms of index, the particle identifiers are completely jumbled i.e. index and identifier are not related in any way hence I can’t use any expression to relate them. How can I find the neighbor distances of a bunch of particles in a system if I only know the Particle identifiers?

just in case you didn’t know: You can turn on particle sorting by id when importing your file. See section Particle Sorting in our scripting reference.

Alternatively, this is how you could find the corresponding indices of a list of target particle identifiers in the unsorted particle identifiers array:

target_ids = np.array([2,5,7,1,22,11])
mask = numpy.in1d(data.particles.identifiers, target_ids, assume_unique = True)
indices = numpy.where(mask)[0]