forked from Schudel888/ImagePop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpng.py
More file actions
60 lines (35 loc) · 1.2 KB
/
png.py
File metadata and controls
60 lines (35 loc) · 1.2 KB
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
52
53
54
55
56
57
58
#Imports
import matplotlib
import matplotlib.pyplot as pl
from astropy.io import fits
def fits_to_png(name_of_fits_file, name_of_png_file):
hdulist = fits.open(name_of_fits_file, mode='readonly')#, memmap=True)
hdu = hdulist[0]
data = hdu.data
assert data.ndim == 2
ACTUAL_PNG_FILENAME = name_of_png_file+'.png'
pl.imshow(data, cmap = matplotlib.cm.Greys_r, origin='lower')
#pl.grid(True)
pl.savefig(ACTUAL_PNG_FILENAME, format='png', dpi=600)
pl.close()
hdulist.close()
with open(name_of_png_file, 'w') as placeholder:
placeholder.write(ACTUAL_PNG_FILENAME)
return #DONE Return Nothing
def fits_to_contour_png(name_of_fits_file, name_of_png_file):
hdulist = fits.open(name_of_fits_file, mode='readonly')#, memmap=True)
hdu = hdulist[0]
data = hdu.data
assert data.ndim == 2
ACTUAL_PNG_FILENAME = name_of_png_file+'.png'
pl.contour(data, origin='lower')
#pl.grid(True)
pl.savefig(ACTUAL_PNG_FILENAME, format='png',dpi=600)
pl.close()
hdulist.close()
with open(name_of_png_file, 'w') as placeholder:
placeholder.write(ACTUAL_PNG_FILENAME)
return #DONE Return Nothing
Functions = dict()
Functions['png'] = fits_to_png
Functions['png_contour'] = fits_to_contour_png