-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfits.py
More file actions
executable file
·71 lines (54 loc) · 1.61 KB
/
fits.py
File metadata and controls
executable file
·71 lines (54 loc) · 1.61 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
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 23:03:45 2020
@author: blahblahmac
"""
from astropy.io import fits
from astropy import wcs
from astropy import units as u
import numpy as np
from astropy.coordinates import SkyCoord
from matplotlib.image import NonUniformImage
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
'''
hdul = fits.open('1.fits')
w = wcs.WCS(hdul[0].header)
hdr = hdul[0].header
#print(w.wcs.name)
#w.wcs.print_contents()
pixcrd = np.array([[0, 0], [24, 38], [45, 98]], dtype=np.float64)
world = w.wcs_pix2world(pixcrd, 0)
print(world)
pixcrd2 = w.wcs_world2pix(world, 0)
print(pixcrd2)
'''
'''
#hdul.info()
print(repr(hdr))
print(list(hdr.keys()))
from astropy import units as u
from astropy.coordinates import SkyCoord
import numpy as np
c = SkyCoord(ra=(1.080015330000E+01)*u.degree, dec=(4.165377920000E+01)*u.degree, frame='icrs')
w = wcs('1.fits')
r = np.load('ra.npy')
d = np.load('dec.npy')
c = SkyCoord(ra=(r)*u.degree, dec=(d)*u.degree, frame='icrs')
'''
r = np.load('ra.npy')
d = np.load('dec.npy')
c = np.vstack((r, d)).T
#c = SkyCoord(ra=(r)*u.degree, dec=(d)*u.degree, frame='icrs')
w = wcs.WCS(naxis=2)
w.wcs.crpix = [1.080015330000E+01, 4.165377920000E+01]
pixcrd2 = w.wcs_world2pix(c, 0)
#print(pixcrd2[0:, 1])
#np.histogram2d(pixcrd2[0:, 0],pixcrd2[0:, 1])
#plt.hexbin(pixcrd2[0:, 0],pixcrd2[0:, 1])
#plt.hist2d(pixcrd2[0:, 0],pixcrd2[0:, 1],bins = (200,200),cmap = 'Greys')
#clustering = DBSCAN(eps=1.69000005722046).fit(pixcrd2)
#labels = clustering.labels_
plt.hist2d(pixcrd2[0:, 0],pixcrd2[0:, 1],bins = (200,200),cmap = 'Reds')
plt.show()