-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_map_dir.py
51 lines (48 loc) · 1.59 KB
/
plot_map_dir.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
import argparse
import glob, sys
from os import path
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as pl
from sptpol_software.util import files
def plot(mapfile, plot_dir):
print mapfile
m = files.read(mapfile)
m.removeWeight()
f = pl.figure()
# m.plot('T', bw = True, vmin = -1e-3, vmax = 1e-3, figure = 1)
m.plot('T', bw = True, weight = True, figure = 1)
name = '.'.join(path.basename(mapfile).split('.')[:-1])
f.set_size_inches(12.15, 6.)
pl.savefig(path.join(plot_dir, name + '.png'))
pl.close('all')
def plotCmap(mapfile, plot_dir):
m = files.read(mapfile)
f = pl.figure()
pl.imshow(m.Map.real_map_T, vmin = -5e-3, vmax = 5e-3,
cmap = matplotlib.cm.gray)
pl.colorbar()
name = '.'.join(path.basename(mapfile).split('.')[:-1])
pl.savefig(path.join(plot_dir, name + '.png'))
pl.close('all')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('map_dir', type = str)
parser.add_argument('plot_dir', type = str)
parser.add_argument('--band', type = int, default = None)
parser.add_argument('--cmap', action = 'store_true')
args = parser.parse_args()
if args.band is None:
args.band = [90, 150]
else:
args.band = [args.band]
if args.cmap:
plotfn = plotCmap
else:
plotfn = plot
for band in args.band:
# band_name = '{:03d}ghz'.format(band)
band_name = band
mapfiles = glob.glob(path.join(args.map_dir, '*%s.h5' %band_name))
for mf in mapfiles:
plotfn(mf, args.plot_dir)