def phaseMap(tile,nPhases,nSlopes,maxSlope=10,displayMap=False,minFreqSep=.5): phases = np.linspace(0.,2.*np.pi,nPhases) slopes = np.linspace(0.5,maxSlope,nSlopes) pmap = np.zeros((nSlopes,nPhases)) for iSlope,slope in enumerate(slopes): if iSlope % 100 == 0: print iSlope for iPhase,phase in enumerate(phases): tileWithGrad = addGradient(tile,slope,phase) #plotArray(tileWithGrad,title='slope {} angle {}'.format(slope,phase)) pmap[iSlope,iPhase] = countCollisions(tileWithGrad,minFreqSep=minFreqSep) percentMap = 100.*pmap/len(np.ravel(tile)) print 'median unusable pixels (%) above slope {}: {}'.format(slopes[0],np.median(percentMap.ravel())) print 'sdev unusable pixels (%) above slope {}: {}'.format(slopes[0],np.std(percentMap.ravel())) print 'min,max unusable pixels (%) above slope {}: {} {}'.format(slopes[0],np.min(percentMap.ravel()),np.max(percentMap.ravel())) hist,binEdges = np.histogram(percentMap,bins=150) plt.plot(binEdges[0:-1],hist) plt.show() if displayMap: pop = PopUp(showMe=False) pop.plotArray(percentMap,cbarLabel='Unusable Pixels (%)') xticks = np.array(pop.axes.get_xticks(),dtype=np.int) yticks = np.array(pop.axes.get_yticks(),dtype=np.int) print xticks print yticks pop.axes.set_xticklabels(['{:.0f}'.format(phase*180./np.pi) for phase in phases[xticks[0:-1]]]) pop.axes.set_yticklabels(['{:.1f}'.format(slope) for slope in slopes[yticks[0:-1]]]) pop.axes.set_xlabel('Gradient Angle (${}^{\circ}$)') pop.axes.set_ylabel('Gradient Slope (MHz/pixel)') pop.axes.xaxis.tick_bottom() pop.show() return {'numberUnusablePixels':pmap,'gradientAnglesDeg':(phases*180./np.pi),'gradientSlopesMHz':slopes,'percentUnusable':percentMap}
dateMask = np.array([tstamp in obsSeq for tstamp in tstamps]) phaseProfilesOnDate = phaseProfiles[dateMask] combineProfiles(phaseBinEdges,phaseProfilesOnDate,label=sunsetDates[iDate]) dateMasks.append(dateMask) combineProfiles(phaseBinEdges,phaseProfiles,label='total') #print '20140924',tstamps[0:17] #print '20140925',tstamps[17:47] #print '20141021',tstamps[47:] #profileErrors = dataDict['profileErrors'] pop = PopUp(showMe=False) pop.plotArray(phaseProfiles,aspect=2.) pop.axes.set_yticks(np.arange(np.shape(phaseProfiles)[0])) pop.axes.tick_params(axis='both', which='major', labelsize=7) pop.axes.set_yticklabels(tstamps) pop.show() #plotArray(phaseProfiles) # combineProfiles(phaseBinEdges,phaseProfiles,label='total') # combineProfiles(phaseBinEdges,phaseProfiles[0:15],label='20140924') # combineProfiles(phaseBinEdges,phaseProfiles[17:47],label='20140925') # combineProfiles(phaseBinEdges,phaseProfiles[47:],label='20141021') timeProfile = np.mean(phaseProfiles,axis=1) fig,(ax,ax2,ax3,ax4) = plt.subplots(4,1,sharex='col') ax.plot(apertureRadiusList) ax2.plot([psfFit['flux'] for psfFit in psfFits]) ax3.plot([psfFit['parameters'][0] for psfFit in psfFits]) ax4.plot(timeProfile) for iTime,tstamp in enumerate(tstamps): print iTime,tstamp