Created
February 11, 2018 19:00
-
-
Save rickbassham/b02e7c4f095e173c220da2b216bd476c to your computer and use it in GitHub Desktop.
Convert FIT to TIFF Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.io import fits | |
from PIL import Image | |
import numpy | |
import sys | |
import os | |
filepath = 'test.fit' | |
name, ext = os.path.splitext(filepath) | |
img = fits.open(filepath) | |
img.info() | |
data = img[0].data | |
width = data.shape[1] | |
height = data.shape[0] | |
outputArray = numpy.array(data, dtype=numpy.int16) | |
output = Image.fromarray(outputArray.reshape((height, width)), "I;16") | |
output.save(name + ".tif") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment