from numpy import shape, pi, histogram2d, arange, newaxis, exp, log, array, sin, cos from scipy.signal import convolve2d from matplotlib.pyplot import figure, show, matshow from matplotlib.colors import LogNorm from Read import ReadEnergy, ReadExtraFile, ReadMomentumAngle, ReadPositionAngle, ReadProfile from Constants import degre thetalim = 180 philim = 180 step = 0.25 #deg nbBins = array([int(2*philim/step)+1,int(2*thetalim/step)+1]) philim=float(philim) thetalim=float(thetalim) limits = [[-thetalim,thetalim],[-philim,philim]] def isotrop(): return array([[1]]) def Gaussian2D(center=[0,0],fwhm=0.01): x = arange(-thetalim,thetalim+step,step) y = arange(-philim,philim+step,step) y = y[:,newaxis] return exp(-4*log(2) * ((x-center[0])**2 + (y+center[1])**2) / fwhm**2) def drawMap(files,Elim=0.1,source=isotrop(),borne=[180,180]): ''' Plot 2D histogram of arrival direction of the photons with energy upper than Elim Input: list of directories Input (optional): lower energy limit (in GeV (default = 100MeV) Input (optional): nature of the source (default isotrop) Input (optional): limits on theta, phi Output: 2D histogram of theta cos(phi), theta sin(phi) ''' print "Cut at", Elim, "GeV" fig = figure() nbplots = len(files) ind=1 for fileId in files: thetaDir,phiDir = ReadMomentumAngle(fileId)*degre thetaPos,phiPos = ReadPositionAngle(fileId)*degre theta = thetaDir - thetaPos phi = phiDir -phiPos energy = ReadEnergy(fileId) weightini, Esource = ReadExtraFile(fileId,[2,5]) zsource, Dsource, nbPhotonsEmitted, EGMF = ReadProfile(fileId,[1,2,3,4]) # apply source spectrum powerlaw_index = 2 weight = weightini*(Esource/min(Esource))**(1-powerlaw_index) cond=(energy>Elim) & (abs(theta)