Forum Navigation
You need to log in to create posts and topics.

data manipulation

Hi, I have a very simple question regarding the dataframe object in python interface. How can I remove particular indices from a data structure without using "DeleteSelectedModifier()". In other words, is there any command similar to create_particles that remove particular atoms from both position and particleType array accordingly?



The PropertyContainer class doesn't provide a direct method yet to delete elements. We can add that in a future version of OVITO if there is a need. In the meantime, I suggest you create a particle selection first and then apply the DeleteSelectedModifier in place by calling DataCollection.apply():

indices = [97, 24, 203] # The particle indices to delete

data.particles_.create_property('Selection')[indices] = 1



Just to inform you and others ahead of time: The upcoming OVITO release 3.2 will provide two new Python API functions for deleting particles and the like:



(Note: These functions are not available in OVITO 3.1.x yet)