code: def save_fits(self, data, name):
          
          data = data.reshape(1, 1, data.shape[0], data.shape[0])
          new_file = pyfits.PrimaryHDU(data,self.img_hdu_list[0].header)
          new_file.writeto("{}".format(name), overwrite=True)
docs: This method simply saves the model components and the residual.
  
          INPUTS:
          data    (no default)    Data which is to be saved.
          name    (no default)    File name for new .fits file. Will overwrite.