docs: def plot_irm(fignum, B, M, title):
      """
      function to plot IRM backfield curves
  
      Parameters
      _________
      fignum : matplotlib figure number
      B : list or array of field values
      M : list or array of magnetizations
      title : string title for plot
      """
      rpars = {}
      Mnorm = []
      backfield = 0
      X, Y = [], []
      for k in range(len(B)):
          if M[k] < 0:
              break
      if k <= 5:
          kmin = 0
      else:
          kmin = k - 5
      for k in range(kmin, k + 1):
          X.append(B[k])
          if B[k] < 0:
              backfield = 1
          Y.append(M[k])
      if backfield == 1:
          poly = np.polyfit(X, Y, 1)
          if poly[0] != 0:
              bcr = (old_div(-poly[1], poly[0]))
          else:
              bcr = 0
          rpars['remanence_mr_moment'] = '%8.3e' % (M[0])
          rpars['remanence_bcr'] = '%8.3e' % (-bcr)
          rpars['magic_method_codes'] = 'LP-BCR-BF'
          if M[0] != 0:
              for m in M:
                  Mnorm.append(old_div(m, M[0]))  # normalize to unity Msat
              title = title + ':' + '%8.3e' % (M[0])
      else:
          if M[-1] != 0:
              for m in M:
                  Mnorm.append(old_div(m, M[-1]))  # normalize to unity Msat
              title = title + ':' + '%8.3e' % (M[-1])
  # do plots if desired
      if fignum != 0 and M[0] != 0:  # skip plot for fignum = 0
          plt.figure(num=fignum)
          plt.clf()
          if not isServer:
              plt.figtext(.02, .01, version_num)
          plt.plot(B, Mnorm)
          plt.axhline(0, color='k')
          plt.axvline(0, color='k')
          plt.xlabel('B (T)')
          plt.ylabel('M/Mr')
          plt.title(title)
          if backfield == 1:
              plt.scatter([bcr], [0], marker='s', c='b')
              bounds = plt.axis()
              n1 = 'Bcr: ' + '%8.2e' % (-bcr) + ' T'
              plt.figtext(.2, .5, n1)
              n2 = 'Mr: ' + '%8.2e' % (M[0]) + ' Am^2'
              plt.figtext(.2, .45, n2)
      elif fignum != 0:
          plt.figure(num=fignum)
          # plt.clf()
          if not isServer:
              plt.figtext(.02, .01, version_num)
          print('M[0]=0,  skipping specimen')
      return rpars