docs: def to_npz(self, bigwig, metric='mean0', outdir=None):
          """
          Bin data for bigwig and save to disk.
  
          The .npz file will have the pattern
          {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two
          arrays, x (genomic coordinates of midpoints of each window) and
          y (metric for each window).  It can be loaded like this::
  
              d = np.load(filename, mmap_mode='r')
  
          bigwig : str or BigWigSignal object
              BigWig data that will be used to create the array
  
          metric : 'covered', 'sum', 'mean0', 'mean'
              Metric to store in array, as reported by bigWigAverageOverBed:
                  * "covered": the number of bases covered by the bigWig.
                  * "sum": sum of values over all bases covered
                  * "mean0": average over bases with non-covered bases counted as
                    zeros
                  * mean: average over just the covered bases
  
          outdir : str or None
              Where to store output filenames.  If None, store the file in the
              same directory as the bigwig file.
  
          """
          if isinstance(bigwig, _genomic_signal.BigWigSignal):
              bigwig = bigwig.fn
  
          if outdir is None:
              outdir = os.path.dirname(bigwig)
  
          basename = os.path.basename(bigwig)
          windowsize = self.windowsize
  
          outfiles = []
          for chrom in self.chroms:
              tmp_output = pybedtools.BedTool._tmp()
              windows = self.make_windows(chrom)
  
              outfile = os.path.join(
                  outdir,
                  '{basename}.{chrom}.{windowsize}.{metric}'.format(**locals())
                  + '.npz')
              cmds = [
                  'bigWigAverageOverBed',
                  bigwig,
                  windows,
                  tmp_output]
              os.system(' '.join(cmds))
              names = ['name', 'size', 'covered', 'sum', 'mean0', 'mean']
              df = pandas.read_table(tmp_output, names=names)
              x = df.size.cumsum() - df.size / 2
              y = df[metric]
              np.savez(outfile, x=x, y=y)
              outfiles.append(outfile)
              del x, y, df
          return outfiles