class_docstr: This is the basic field structure,
       which contains the weighted graph structure
       plus an array of data (the 'field')
  field is an array of size(n, p)
        where n is the number of vertices of the graph
        and p is the field dimension
class_docstr_tok: ["This","is","the","basic","field","structure",",","which","contains","the","weighted","graph","structure","plus","an","array","of","data","(","the","'field","'",")","field","is","an","array","of","size","(","n",",","p",")","where","n","is","the","number","of","vertices","of","the","graph","and","p","is","the","field","dimension"]
docstr: Returns all the local maxima of a field
  
  Parameters
  ----------
  refdim (int) field dimension over which the maxima are looked after
  th: float, optional
      threshold so that only values above th are considered
  
  Returns
  -------
  depth: array of shape (nmax)
         a labelling of the vertices such that
         depth[v] = 0 if v is not a local maximum
         depth[v] = 1 if v is a first order maximum
         ...
         depth[v] = q if v is a q-order maximum
docstr_tok: ["Returns","all","the","local","maxima","of","a","field","Parameters","--","--","--","--","--","refdim","(","int",")","field","dimension","over","which","the","maxima","are","looked","after","th",":","float",",","optional","threshold","so","that","only","values","above","th","are","considered","Returns","--","--","--","-","depth",":","array","of","shape","(","nmax",")","a","labelling","of","the","vertices","such","that","depth","[","v","]","=","0","if","v","is","not","a","local","maximum","depth","[","v","]","=","1","if","v","is","a","first","order","maximum","...","depth","[","v","]","=","q","if","v","is","a","q-order","maximum"]
code: def local_maxima(self, refdim=0, th=NEGINF):
      """Returns all the local maxima of a field
  
      Parameters
      ----------
      refdim (int) field dimension over which the maxima are looked after
      th: float, optional
          threshold so that only values above th are considered
  
      Returns
      -------
      depth: array of shape (nmax)
             a labelling of the vertices such that
             depth[v] = 0 if v is not a local maximum
             depth[v] = 1 if v is a first order maximum
             ...
             depth[v] = q if v is a q-order maximum
      """
      refdim = int(refdim)
      if np.size(self.field) == 0:
          raise ValueError("No field has been defined so far")
      if self.field.shape[1] - 1 < refdim:
          raise ValueError(refdim > self.shape[1])
      depth = np.zeros(self.V, np.int_)
  
      # create a subfield(thresholding)
      sf = self.subfield(self.field.T[refdim] >= th)
      initial_field = sf.field.T[refdim]
      sf.field = initial_field.astype(np.float64)
  
      # compute the depth in the subgraph
      ldepth = sf.V * np.ones(sf.V, np.int_)
      for k in range(sf.V):
          dilated_field_old = sf.field.ravel().copy()
          sf.dilation(1)
          non_max = sf.field.ravel() > dilated_field_old
          ldepth[non_max] = np.minimum(k, ldepth[non_max])
          if (non_max == False).all():
              ldepth[sf.field.ravel() == initial_field] = np.maximum(
                  k, 1
              )
              break
  
      # write all the depth values
      depth[self.field[:, refdim] >= th] = ldepth
      return depth
  
imports: from warnings import warn
  import numpy
  from .graph import Graph, WeightedGraph
label_desc: Use image node_id 10 for calling the Field obj's underlying member method code with example usage: obj.local_maxima(refdim, th) and returns: depth