code: def index_to_loc(self, index):
          
          sz = int(self.shape[0] * self.shape[1])
          idxs = np.array([i for i in range(sz)], dtype=int).reshape(self.shape)
          args = np.argwhere(idxs == index)
          if len(args) < 1:
              raise RuntimeError('Index ({}) is out of range.')
          return args[0]
docs: Convert a 1D index location to the 2D location on the plotting grid