code: def calcperc(b, perc=(0.1,99.9)):
      
      b = checkma(b)
      if b.count() > 0:
          #low = scoreatpercentile(b.compressed(), perc[0])
          #high = scoreatpercentile(b.compressed(), perc[1])
          low = np.percentile(b.compressed(), perc[0])
          high = np.percentile(b.compressed(), perc[1])
      else:
          low = 0
          high = 0
  
      #low = scipy.stats.mstats.scoreatpercentile(b, perc[0])
      #high = scipy.stats.mstats.scoreatpercentile(b, perc[1])
  
      #This approach can be used for unmasked array, but values less than 0 are problematic
      #bma_low = b.min()
      #bma_high = b.max()
      #low = scipy.stats.scoreatpercentile(b.data.flatten(), perc[0], (bma_low, bma_high))
      #high = scipy.stats.scoreatpercentile(b.data.flatten(), perc[1], (bma_low, bma_high))
      return low, high
docs: Calculate values at specified percentiles