-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotmaps.py
47 lines (42 loc) · 1.6 KB
/
plotmaps.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
import sys
import matplotlib
matplotlib.use("agg")
import numpy as np
import matplotlib.pyplot as plt
import healpy as hp
lim = { '': {'bin':20, 'destriped':20, 'baselines':10, 'filtbin':1},
'Q':{'bin':500, 'destriped':4, 'baselines':500, 'filtbin':10} }
lim['U'] = lim['Q']
smooth = False
maps = {}
folder = sys.argv[1] + "/"
hits = np.array(np.memmap(folder + "hits.bin",dtype=np.double))
hp.write_map(folder + "hits.fits", hits)
comps = ['','Q','U']
binned = [hp.ma(np.array(np.memmap(folder + "binned%s.bin" % comp, dtype=np.double))) for comp in comps]
m = [hp.ma(np.array(np.memmap(folder + "map%s.bin" % comp, dtype=np.double))) for comp in comps]
baselines = [bb-mm for bb,mm in zip(binned, m)]
mapcombs = [(binned, 'bin'), (m, 'destriped'), (baselines, 'baselines')]
try:
binnedf = [binned[0].copy()]
binnedf += [hp.ma(np.array(np.memmap(folder + "binnedf%s.bin" % comp, dtype=np.double))) for comp in comps[1:]]
mapcombs.append((binnedf, 'filtbin'))
except:
pass
hp.mollview(hits, unit='hitcount',xsize=2000)
plt.savefig(folder + "hits.png")
for iqumap, name in mapcombs:
for comp, what in zip(comps, iqumap):
l = lim[comp][name]
what -= what.mean()
if comp == '':
what *=-1
if smooth:
whatsm = hp.ma(hp.smoothing(what, fwhm=np.radians(40/60.)))
whatsm.mask = what.mask
what = whatsm
l /= 2
maps[comp] = what
hp.mollview((what*1e3), min=-l,max=l, unit='mK',title="",xsize=2000)
plt.savefig(folder + "%s%s.png" % (name, comp))
hp.write_map(folder + "%s.fits" % (name), iqumap)