# Takes two input files and transplants the entire header of one onto the other. Outputs a third
# file.

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

# File to use for the header information
headfile = 'WAVES_SW_Virgo_CleanedSN_p2.fits'

# File to use for the image information
imagefile = 'WAVESFull_UpdateHeader.fits'

outfile = 'WAVESFull_IndividualHeader.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 header file and get the header
FitsFile1 = pyfits.open(headfile)
header = FitsFile1[0].header

# Open the image file and get the image
FitsFile2 = pyfits.open(imagefile)
image = FitsFile2[0].data


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

	
