Commit 09338e30 authored by marta-sd's avatar marta-sd
Browse files

FIX: removed abs from convert_atom_to_voxel and added a warning if coords are...

FIX: removed abs from convert_atom_to_voxel and added a warning if coords are outside of the box (< 0 or >= max index)
parent f6189a43
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -595,10 +595,15 @@ def convert_atom_to_voxel(molecule_xyz, atom_index, box_width, voxel_width):
  """
  Converts an atom to an i,j,k grid index.
  """
  coordinates = molecule_xyz[atom_index, :]
  from warnings import warn

  indices = np.floor(
      np.abs(molecule_xyz[atom_index, :] + np.array(
          [box_width, box_width, box_width]) / 2.0) / voxel_width).astype(int)
      (molecule_xyz[atom_index, :] + np.array([box_width, box_width, box_width]
                                             ) / 2.0) / voxel_width).astype(int)
  if ((indices < 0) | (indices >= box_width / voxel_width)).any():
    warn(
        'Coordinates are outside of the box (atom id = %s, coords xyz = %s, coords in box = %s'
        % (atom_index, molecule_xyz[atom_index], indices))
  return ([indices])