code: def _do_save_as(self, filename):
          
  
          if len(self.spectrum.x) < 2:
              raise RuntimeError("Spectrum must have at least two points")
          if os.path.isfile(filename):
              os.unlink(filename)  # PyFITS does not overwrite file
  
          hdu = self.spectrum.to_hdu()
          overwrite_fits(hdu, filename)
docs: Saves spectrum back to FITS file.