code: def geometric_center(coords, periodic):
      '''Geometric center taking into account periodic boundaries'''
      max_vals = periodic
      theta = 2 * np.pi * (coords / max_vals)
      eps = np.cos(theta) * max_vals / (2 * np.pi)
      zeta = np.sin(theta) * max_vals / (2 * np.pi)
  
      eps_avg = eps.sum(axis=0)
      zeta_avg = zeta.sum(axis=0)
      theta_avg = np.arctan2(-zeta_avg, -eps_avg) + np.pi
  
      return theta_avg * max_vals / (2 * np.pif geometric_center(coords, periodic):
      '''Geometric center taking into account periodic boundaries'''
      max_vals = periodic
      theta = 2 * np.pi * (coords / max_vals)
      eps = np.cos(theta) * max_vals / (2 * np.pi)
      zeta = np.sin(theta) * max_vals / (2 * np.pi)
  
      eps_avg = eps.sum(axis=0)
      zeta_avg = zeta.sum(axis=0)
      theta_avg = np.arctan2(-zeta_avg, -eps_avg) + np.pi
  
      return theta_avg * max_vals / (2 * np.pi)
docs: Geometric center taking into account periodic boundaries