code: def select_step(
      v1, v2, nv, hour=False, include_last=True, threshold_factor=3600.0
  ):
      if v1 > v2:
          v1, v2 = v2, v1
  
      dv = (v2 - v1) / nv
  
      if hour:
          _select_step = select_step_hour
          cycle = 24.0
      else:
          _select_step = select_step_degree
          cycle = 360.0
  
      # for degree
      if dv > 1 / threshold_factor:
          step, factor = _select_step(dv)
      else:
          step, factor = select_step_sub(dv * threshold_factor)
  
          factor = factor * threshold_factor
  
      levs = (
          np.arange(
              np.floor(v1 * factor / step),
              np.ceil(v2 * factor / step) + 0.5,
              dtype=int,
          )
          * step
      )
  
      # n : number of valid levels. If there is a cycle, e.g., [0, 90, 180,
      # 270, 360], the grid line needs to be extended from 0 to 360, so
      # we need to return the whole array. However, the last level (360)
      # needs to be ignored often. In this case, so we return n=4.
  
      n = len(levs)
  
      # we need to check the range of values
      # for example, -90 to 90, 0 to 360,
  
      if (
          factor == 1.0 and levs[-1] >= levs[0] + cycle
      ):  # check for cycle
          nv = int(cycle / step)
          if include_last:
              levs = levs[0] + np.arange(0, nv + 1, 1) * step
          else:
              levs = levs[0] + np.arange(0, nv, 1) * step
  
          n = len(levs)
  
      return np.array(levs), n, factor
  
imports: import numpy
  import math
  from mpl_toolkits.axisartist.grid_finder import ExtremeFinderSimple
label_desc: Use image node_id 4 for calling a global function with example usage: select_step(v1, v2, nv, hour, include_last, threshold_factor) and returns: np,  n,  factor