-
Notifications
You must be signed in to change notification settings - Fork 11
/
wssa.py
66 lines (55 loc) · 1.74 KB
/
wssa.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from astrometry.util.util import *
from astrometry.util.fits import *
import fitsio
import os
import numpy as np
from astrometry.util.multiproc import multiproc
def ext_one(fname):
fn = os.path.join('data','wssa','tiles',fname+'.gz')
print('File', fn)
cmd = 'imcopy data/wssa/tiles/%s.gz"[P]" data/wssa/%s' % (fname, fname)
print(cmd)
os.system(cmd)
def main():
T = fits_table('data/wssa/tiles/wisetile-index-allsky.fits.gz')
print(len(T), 'tiles')
args = T.fname
mp = multiproc(16)
mp.map(ext_one, args)
sys.exit(0)
T.magzp = np.zeros(len(T), np.float32)
T.ra1 = np.zeros(len(T), np.float32)
T.ra2 = np.zeros(len(T), np.float32)
ddec = 5.
T.dec1 = np.maximum(-90., T.dec - ddec)
T.dec2 = np.minimum(+90., T.dec + ddec)
decs = np.unique(T.dec)
for d in decs:
print('Dec', d)
I = np.flatnonzero(T.dec == d)
print('RAs:', T.ra[I])
print('dRA:', np.diff(T.ra[I]))
if len(I) == 1:
T.ra1[I] = 0.
T.ra2[I] = 360.
else:
dra = np.diff(T.ra[I])[0]
T.ra1[I] = T.ra[I] - dra/2.
T.ra2[I] = T.ra[I] + dra/2.
T.ra1 += (T.ra1 < 0)*360.
T.ra2 += (T.ra2 > 360)*(-360.)
for ii,t in enumerate(T):
fn = os.path.join('data','wssa','tiles',t.fname+'.gz')
print('File', fn)
cmd = 'imcopy data/wssa/tiles/%s.gz"+1" data/wssa/%s' % (t.fname, t.fname)
print(cmd)
if os.system(cmd):
break
fn = 'data/wssa/'+t.fname.strip()
hdr = fitsio.read_header(fn)
zp = hdr['MAGZP']
print('ZP', zp)
T.magzp[ii] = zp
T.writeto('data/wssa/wssa-bricks.fits')
if __name__ == '__main__':
main()