Hi Pedro, Try these two changes:
# shape - 1 xinc, yinc, zinc = ( abs(xmax - xmin) / (field.shape[0] - 1), abs(ymax - ymin) / (field.shape[1] - 1), abs(zmax - zmin) / (field.shape[2] - 1), ) # position rounding by +0.5 idx = ( int((at.coord[0] - xmin) / xinc + 0.5), int((at.coord[1] - ymin) / yinc + 0.5), int((at.coord[2] - zmin) / zinc + 0.5), ) Cheers, Thomas > On Nov 8, 2020, at 11:20 AM, Pedro Lacerda <pslace...@gmail.com> wrote: > > Hi, > > I'm using `cmd.get_volume_field(copy=0)` to edit maps. Each grid cell must > increase by 1 each time the condition `atom.text_type in atomtypes` is met. > > But something went wrong and the map mesh didn't align with the atoms. > > `ensemble.selection` and `obj` spawns atoms in the exact same positions. > > > > map_obj = prefix + "." + title > pm.map_new(map_obj, type="vdw", selection=ensemble.selection) > field = pm.get_volume_field(map_obj, copy=0) > if -1 is field: > colorprinting.error("Unable to get volume field.") > continue > xinc, yinc, zinc = ( > abs(xmax - xmin) / field.shape[0], > abs(ymax - ymin) / field.shape[1], > abs(zmax - zmin) / field.shape[2], > ) > field[:] = 0 > for at in pm.get_model(obj).atom: > if at.text_type in atomtypes: > idx = ( > int((at.coord[0] - xmin) / xinc)-1, > int((at.coord[1] - ymin) / yinc)-1, > int((at.coord[2] - zmin) / zinc)-1, > ) > field[idx] += 1 > > -- > Pedro Sousa Lacerda > > Laboratório de Bioinformática e Modelagem Molecular / UFBA > Mestrando em Ciências Farmácias / UEFS > > @pslacerda > +55 71 9 9981-1856 > http://lattes.cnpq.br/8338596525330907 > _______________________________________________ > PyMOL-users mailing list > Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net > Unsubscribe: > https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe -- Thomas Holder PyMOL Principal Developer Schrödinger, Inc. _______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe