Skip to content

Commit

Permalink
added python make multiple file and FITS pixel increase by 10000
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkmpoon committed Dec 14, 2018
1 parent 922be92 commit 60da8a9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
27 changes: 27 additions & 0 deletions increase10000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from astropy.io import fits


script_dir = os.path.dirname(__file__)
correction_folder = os.path.join(script_dir, 'corrected_FITS/')
if not os.path.isdir(correction_folder):
os.makedirs(correction_folder)

data_path = script_dir + '/Data_low_value/'
filenames = [f for f in os.listdir(data_path) if os.path.isfile(os.path.join(data_path, f))]

for index in range(len(filenames)):
if index % 2 == 0:
hG = fits.getheader(data_path + filenames[index])
hR = fits.getheader(data_path + filenames[index + 1])
imG = fits.getdata(data_path + filenames[index])
imR = fits.getdata(data_path + filenames[index + 1])

imR *= 10000
imG *= 10000

hduG, hduR = fits.PrimaryHDU(imG, header=hG), fits.PrimaryHDU(imR, header=hR)
hduG = fits.HDUList([hduG])
hduG.writeto(correction_folder + str(filenames[index]))
hduR = fits.HDUList([hduR])
hduR.writeto(correction_folder + str(filenames[index + 1]))
46 changes: 46 additions & 0 deletions makecolor_multiple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
from astropy.io import fits
from astropy.visualization import *
import matplotlib.pyplot as plt
plt.ion()

script_dir = os.path.dirname(__file__)
image_folder = os.path.join(script_dir, 'HiPS/')
if not os.path.isdir(image_folder):
os.makedirs(image_folder)

data_path = script_dir + '/Data/'
filenames = [f for f in os.listdir(data_path) if os.path.isfile(os.path.join(data_path, f))]

for index in range(len(filenames)):
if index % 2 == 0:
hG = fits.getheader(data_path + filenames[index])
hR = fits.getheader(data_path + filenames[index + 1])
imG = fits.getdata(data_path + filenames[index])
imR = fits.getdata(data_path + filenames[index + 1])

if 'BACKVAL' not in hR:
imR *= 10000
imG *= 10000
else:
imR -= float(hR['BACKVAL'])
imG -= float(hG['BACKVAL'])

try:
r = imR.copy()
b = imG.copy()
b *= 1.2
g = (r+b)*0.5


q = 12
s = 170
m = 15

rgb = make_lupton_rgb(r,g,b,Q=q,stretch=s,minimum=m,
filename = image_folder + str(filenames[index])[:-6] + ".png") #[:-6] to get rid of file extension

print("Image made")

except:
print("Image data for r and b are different shapes. Skipping image and moving on...");

0 comments on commit 60da8a9

Please # to comment.