# Takes an input FITS file and clears all the history keywords

import math
import numpy
from astropy.io import fits as pyfits
import os

# FITS file name
fitsfilename = 'WAVES_SW_Virgo_CleanedSN_p2.fits'

outfile = 'WAVES_SW_Virgo_CleanedSN_p2_nohistoryheader.fits'


os.system('cls')

# Changes to the directory where the script is located
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)


# Open the FITS file
FitsFile = pyfits.open(fitsfilename)
header = FitsFile[0].header
image = FitsFile[0].data

del header['HISTORY']
 

# Save a new file using the image of the second and the header of the first			
NewFitsFile = pyfits.writeto(outfile, image, header=header)

FitsFile.close()
			

	
