-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added python make multiple file and FITS pixel increase by 10000
- Loading branch information
1 parent
922be92
commit 60da8a9
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
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])) |
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
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..."); |