forked from mtpenny/gbtds_optimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclip_map_test.py
62 lines (40 loc) · 1.42 KB
/
clip_map_test.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
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from fields import fov,fovHandler
from yieldMap import yieldMap
#Create a map
lspike=45
bspike=33
yspike=50000.0
filename = 'H22.6_eventrates.rates'
lbmap = yieldMap(filename)
#Load the field vertices
scafile = 'sca_layout.txt'
romanFoV = fov(scafile,unit='deg')
fieldsFile = 'field_layouts/layout_7f_3.centers'
fields = pd.read_csv(fieldsFile,sep='\s+',header=None,names=['field','l','b'])
#Create an fovHandler object and initialize it with the yield map, field
#of view and fields
handler = fovHandler()
handler.fromCentersChips(fields,romanFoV,lbmap)
plt.figure()
handler.plotFields()
lbmap.plotMap()
plt.xlim([2.5,-2.5])
plt.ylim([-2.5,2.5])
plt.gca().set_aspect('equal')
totalYield, totalAreaPix, totalArea = handler.computeYield()
print(totalYield,totalAreaPix,totalArea)
plt.show()
#Test map and clipping with a map that is all zero except for small part(s)
for offl in np.arange(-0.5,0.5,0.1):
fieldsNew = fields.copy(deep=True)
fieldsNew['l'] += offl
handler.fromCentersChips(fieldsNew,romanFoV,lbmap)
#lidx, bidx, area, slices = clip_multi(handler.lpix, handler.bpix, lbmap.map_naxis)
#totalYield=0
#for i, s in enumerate(slices):
# totalYield += np.sum(area[s]*lbmap.yieldmap[bidx[s],lidx[s]]*lbmap.lspacing*lbmap.bspacing)
totalYield, totalAreaPix, totalArea = handler.computeYield()
print(offl,totalYield)