Created
November 9, 2018 16:31
-
-
Save baileyji/2fc2a741be12898db06b8d6ad56bc4ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def loadBeammap(self): | |
""" | |
This function loads the beammap into the roach firmware | |
It uses the beammapFile property in the config file | |
If it can't find the beammap file then it loads in the defualt beammap from default.txt | |
We set self.beammapFailed here for later use. It's a 2D boolean array with the (row,col)=(y,x) | |
indicating if that pixel is in the beammap or not | |
""" | |
self.beammapFN = self.config.beammap | |
try: | |
resID, flag, xCoord, yCoord = np.loadtxt(self.beammapFN, usecols=[0,1,2,3], unpack=True) | |
except IOError: | |
getLogger('Dashboard').info("Could not find beammap %s. Using default %s", self.beammapFN, | |
) | |
self.beammapFN = self.config.get('properties','defaultBeammapFile') | |
resID, flag, xCoord, yCoord = np.loadtxt(self.beammapFN, usecols=[0,1,2,3], unpack=True) | |
getLogger('Dashboard').info("Loaded default beammap instead") | |
for roach in self.roachList: | |
freqList = self.config.roaches.freqlistfor(roach) | |
getLogger('Dashboard').info(freqList) | |
# old version for loading freqList, causing issues 3/18/17 | |
resID_roach, freqs, _ = np.loadtxt(freqList,unpack=True) | |
#print resID_roach | |
roach.generateResonatorChannels(freqs) | |
freqCh_roach = np.arange(0, len(resID_roach)) | |
#print resID | |
freqCh = np.ones(len(resID))*-2 | |
for rID, fCh in zip(resID_roach, freqCh_roach): | |
freqCh[resID == rID] = fCh | |
beammapDict = {'resID':resID, 'freqCh':freqCh, 'xCoord':xCoord, 'yCoord':yCoord,'flag':flag} | |
roach.loadBeammapCoords(beammapDict) | |
self.beammapFailed = np.ones((self.config.detector.nrows,self.config.detector.ncols), dtype=bool) | |
for i in range(len(resID)): | |
try: | |
self.beammapFailed[int(yCoord[i]),int(xCoord[i])]=(flag[i]!=0) | |
except IndexError: | |
pass | |
getLogger('Dashboard').info('nGoodBeammapped:', | |
self.config.detector.nrows * self.config.detector.ncols - self.beammapFailed.sum()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment