docs: def fisher_by_pol(data):
      """
      input:    as in dolnp (list of dictionaries with 'dec' and 'inc')
      description: do fisher mean after splitting data into two polarity domains.
      output: three dictionaries:
          'A'= polarity 'A'
          'B = polarity 'B'
          'ALL'= switching polarity of 'B' directions, and calculate fisher mean of all data
      code modified from eqarea_ell.py b rshaar 1/23/2014
      """
      FisherByPoles = {}
      DIblock, nameblock, locblock = [], [], []
      for rec in data:
          if 'dec' in list(rec.keys()) and 'inc' in list(rec.keys()):
              # collect data for fisher calculation
              DIblock.append([float(rec["dec"]), float(rec["inc"])])
          else:
              continue
          if 'name' in list(rec.keys()):
              nameblock.append(rec['name'])
          else:
              nameblock.append("")
          if 'loc' in list(rec.keys()):
              locblock.append(rec['loc'])
          else:
              locblock.append("")
  
      ppars = doprinc(np.array(DIblock))  # get principal directions
      # choose the northerly declination principe component ("normal")
      reference_DI = [ppars['dec'], ppars['inc']]
      # make reference direction in northern hemisphere
      if reference_DI[0] > 90 and reference_DI[0] < 270:
          reference_DI[0] = (reference_DI[0] + 180.) % 360
          reference_DI[1] = reference_DI[1] * -1.
      nDIs, rDIs, all_DI, npars, rpars = [], [], [], [], []
      nlist, rlist, alllist = "", "", ""
      nloclist, rloclist, allloclist = "", "", ""
      for k in range(len(DIblock)):
          if angle([DIblock[k][0], DIblock[k][1]], reference_DI) > 90.:
              rDIs.append(DIblock[k])
              rlist = rlist + ":" + nameblock[k]
              if locblock[k] not in rloclist:
                  rloclist = rloclist + ":" + locblock[k]
              all_DI.append([(DIblock[k][0] + 180.) % 360., -1. * DIblock[k][1]])
              alllist = alllist + ":" + nameblock[k]
              if locblock[k] not in allloclist:
                  allloclist = allloclist + ":" + locblock[k]
          else:
              nDIs.append(DIblock[k])
              nlist = nlist + ":" + nameblock[k]
              if locblock[k] not in nloclist:
                  nloclist = nloclist + ":" + locblock[k]
              all_DI.append(DIblock[k])
              alllist = alllist + ":" + nameblock[k]
              if locblock[k] not in allloclist:
                  allloclist = allloclist + ":" + locblock[k]
  
      for mode in ['A', 'B', 'All']:
          if mode == 'A' and len(nDIs) > 2:
              fpars = fisher_mean(nDIs)
              fpars['sites'] = nlist.strip(':')
              fpars['locs'] = nloclist.strip(':')
              FisherByPoles[mode] = fpars
          elif mode == 'B' and len(rDIs) > 2:
              fpars = fisher_mean(rDIs)
              fpars['sites'] = rlist.strip(':')
              fpars['locs'] = rloclist.strip(':')
              FisherByPoles[mode] = fpars
          elif mode == 'All' and len(all_DI) > 2:
              fpars = fisher_mean(all_DI)
              fpars['sites'] = alllist.strip(':')
              fpars['locs'] = allloclist.strip(':')
              FisherByPoles[mode] = fpars
      return FisherByPoles