-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeCombinedImgs.py
52 lines (36 loc) · 1.14 KB
/
makeCombinedImgs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from matplotlib.colors import LogNorm
from astropy.io import fits
from astropy.wcs import WCS
from astropy import units as u
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import zscale as zs
import sys
def plot_image(infile,outfile,ext):
print(infile,outfile,ext)
fig = plt.figure(figsize=(10,10))
ax = fig.gca()
fig.suptitle('%s' % (outfile), fontsize=15)
try: hdu = fits.open(infile)
except:
print("cannot open file!!! ")
#print hdu[0].header
image_data = hdu[ext].data
#ax.axes.get_xaxis().set_visible(False)
#ax.axes.get_yaxis().set_visible(False)
image_data[image_data<0] = 1e-20
clow,chigh = zs.zscale(image_data,nsamples=2000)
# percentage
'''
clow = np.percentile(image_data,50)
chigh = np.percentile(image_data,60)
'''
#plt.imshow(image_data, cmap='afmhot',interpolation='none', norm=LogNorm(),clim=[clow,chigh])
plt.imshow(image_data, cmap='binary',interpolation='none', clim=[clow,chigh], origin='lower')
#plt.imshow(image_data, cmap='gray',interpolation='nearest', clim=[clow,chigh])
#fig.set_tight_layout(True)
plt.savefig(outfile, pad_inches = 0.)
#plt.show()
#exit()