code: def pad(self, lmax):
          
          clm = self.copy()
  
          if lmax <= self.lmax:
              clm.coeffs = clm.coeffs[:, :lmax+1, :lmax+1]
              clm.mask = clm.mask[:, :lmax+1, :lmax+1]
              if self.errors is not None:
                  clm.errors = clm.errors[:, :lmax+1, :lmax+1]
          else:
              clm.coeffs = _np.pad(clm.coeffs, ((0, 0), (0, lmax - self.lmax),
                                   (0, lmax - self.lmax)), 'constant')
              if self.errors is not None:
                  clm.errors = _np.pad(
                      clm.errors, ((0, 0), (0, lmax - self.lmax),
                                   (0, lmax - self.lmax)), 'constant')
              mask = _np.zeros((2, lmax + 1, lmax + 1), dtype=_np.bool)
              for l in _np.arange(lmax + 1):
                  mask[:, l, :l + 1] = True
              mask[1, :, 0] = False
              clm.mask = mask
  
          clm.lmax = lmax
          return clm
docs: Return an SHMagCoeffs class where the coefficients are zero padded or
          truncated to a different lmax.
  
          Usage
          -----
          clm = x.pad(lmax)
  
          Returns
          -------
          clm : SHMagCoeffs class instance
  
          Parameters
          ----------
          lmax : int
              Maximum spherical harmonic degree to output.