def configPlot(scale=1e4, verbose=False): prefix = '/data/user/fmcnally/anisotropy/maps/merged/' fileList = np.array(glob.glob(prefix + 'IC?*_24H_sid.fits')) alpha = 1/20. deg = 180./np.pi # Sort fileList according to configs configs = np.array([os.path.basename(f).split('_')[0] for f in fileList]) csort = configs.argsort() configs, fileList = configs[csort], fileList[csort] dipoleParams = np.zeros((len(fileList), 6)) for i, f in enumerate(fileList): data = mapFunctions.getMap(f, mapName='data') bg = mapFunctions.getMap(f, mapName='bg') p = mapFunctions.multifit(1, data, bg, alpha, params=True) if verbose: print configs[i] ptable = [[key, p[key], p['d'+key]] for key in sorted(p.keys())] print tabulate(ptable, headers=['Ylm','Value','Error']) dipoleParams[i] = getDipole(p) p0, dp0, theta, dTheta, phi, dPhi = dipoleParams.T if verbose: for i, config in enumerate(configs): print config, ':' print 'Theta: %.3f +/- %.3f' % (theta[i]*deg, dTheta[i]*deg) print 'Phi: %.3f +/- %.3f' % (phi[i]*deg, dPhi[i]*deg) fig = plt.figure(figsize=(17,6)) x = range(len(configs)) pltParams = {'fmt':'.','lw':2,'ms':14} ax = fig.add_subplot(121) ax.set_title('Dipole Strength vs Energy') ax.set_xlabel(r'log$_{10}$(E/GeV)') ax.set_ylabel('Dipole Strength (x %s)' % scale) ax.errorbar(x, p0*scale, yerr=dp0*scale, **pltParams) ax.set_xlim(-1, x[-1]+1) ax.set_xticks(x) ax.set_xticklabels(configs) ax = fig.add_subplot(122) ax.set_title('Dipole Phase vs Energy') ax.set_xlabel(r'log$_{10}$(E/GeV)') ax.set_ylabel(r'Dipole Phase ($\phi^{\circ}$)') phi, dPhi = phi*deg, dPhi*deg phi[phi>180] -= 360 ax.errorbar(x, phi, yerr=dPhi, **pltParams) ax.set_xlim(-1, x[-1]+1) ax.set_xticks(x) ax.set_xticklabels(configs) plt.show()
deccut = (dec >= decmin) * (dec <= decmax) ra = np.array([rad2deg * i for i in ra]) dipole_avg = [] phase_avg = [] fig = plt.figure(0) num_bands = 24.0 for j in range(len(maps)): dI = [] angle = [] if len(maps[j]) == 1: data, bg, local = hp.read_map(maps[j][0], range(3), verbose=False) else: data, bg, local = np.sum([hp.read_map(f, range(3), verbose=False) for f in maps[j]], axis=0) for i in range(int(num_bands)): if args.usefit: relint = multifit(args.lmax, data, bg, alpha, **opts) else: with np.errstate(invalid="ignore"): relint = (data - bg) / bg relint[np.isnan(relint)] = 0.0 # Right ascension cut ramin = (360.0 / num_bands) * i ramax = (360.0 / num_bands) * (i + 1) racut = (ra >= ramin) * (ra <= ramax) # hp.write_map("racut.fits", [data, bg, local]) n_pix = (racut * deccut).sum() # print('n_pix = {}'.format(n_pix)) relint[np.logical_not(racut)] = 0.0 relint[np.logical_not(deccut)] = 0.0
def energyPlot(scale=1e4,offset=180, out=False, batch=False, verbose=False): prefix = '/data/user/fmcnally/anisotropy/maps/merged' alpha = 1/20. deg = 180./np.pi colorDict = {0:'b'} # IceCube information files, meds, sigL, sigR = [],[],[],[] ebins = getEbins() files = getEnergyMaps('IC') for i in range(len(ebins)-1): distInfo = readDist_IC('IC', ebins[i], ebins[i+1]) meds += [distInfo[0]] sigL += [distInfo[1]] sigR += [distInfo[2]] # IceTop information idx0 = len(files) colorDict[idx0] = 'r' files += [['%s/IT_24H_sid_STA8.fits' % (prefix)]] distInfo = readDist_IT('IT', 8, 100) meds += [distInfo[0]] sigL += [distInfo[1]] sigR += [distInfo[2]] dipoleParams = np.zeros((len(files), 6)) for i, files_i in enumerate(files): data = mapFunctions.getMap(*files_i, mapName='data') bg = mapFunctions.getMap(*files_i, mapName='bg') p = mapFunctions.multifit(1, data, bg, alpha, params=True) if verbose: print meds[i] print('key = {}'.format(sorted(p.keys()))) #ptable = [[key, p[key], p['d'+key]] for key in sorted(p.keys())] ptable = [[key, p[key]] for key in sorted(p.keys())] #print tabulate(ptable, headers=['Ylm','Value','Error']) #print tabulate(ptable, headers=['Ylm','Value']) print('files_i = {}'.format(files_i)) for key in sorted(p.keys()): print('p[{}] = {}'.format(key,p[key])) print('p[Y(1,1)]+p[Y(1,-1)] = {}'.format(np.sqrt(3.0/(4.0*np.pi))*np.power(p['Y(1,1)'],2.0)+np.power(p['Y(1,-1)'],2.0))) dipoleParams[i] = getDipole(p) p0, dp0, thetas, dThetas, phis, dPhis = dipoleParams.T if verbose: for i, median in enumerate(meds): print 'Median energy : %.3f' % median print 'Theta: %.3f +/- %.3f' % (thetas[i]*deg, dThetas[i]*deg) print 'Phi: %.3f +/- %.3f' % (phis[i]*deg, dPhis[i]*deg) #fig = plt.figure(figsize=(17,6)) fig = plt.figure() #pltParams = {'fmt':'.','lw':2,'ms':14} pltParams = {'lw':2,'ms':14} #ax = fig.add_subplot(121) #ax.set_title('Dipole Strength vs Energy') #ax.set_xlabel(r'log$_{10}$(E/GeV)') #ax.set_ylabel('Dipole Strength (x %s)' % scale) #ax.errorbar(x, p0*scale, yerr=dp0*scale, **pltParams) #ax = fig.add_subplot(122) ax = fig.add_subplot(111) ax.set_title('Dipole Phase vs Energy') ax.set_xlabel(r'Reconstructed Energy (log$_{10}$(E/GeV))') ax.set_ylabel(r'Dipole Phase ($\phi^{\circ}$)') for i in range(0, len(meds), idx0): x = meds[i:i+idx0] xerr = [sigL[i:i+idx0], sigR[i:i+idx0]] phi, dPhi = phis[i:i+idx0]*deg, dPhis[i:i+idx0]*deg # Phi offset (requires renaming ylabels) pcut = phi > offset phi[pcut] -= offset phi[np.logical_not(pcut)] += (360-offset) ax.errorbar(x, phi, xerr=xerr, yerr=dPhi, fmt=colorDict[i]+'.', **pltParams) ax.set_ylim(-10,370) ax.set_yticks(range(0, 361, 45)) ylabels = [str(i) for i in range(offset, 360-1, 45)] ylabels += [str(i) for i in range(0, offset+1, 45)] ax.set_yticklabels(ylabels) plt.axhline(360-offset, linewidth=1.5, linestyle='--', color='black') if out: plt.savefig(out, dpi=300, bbox_inches='tight') if not batch: plt.show()
# Produce dipole expansion coeeficient plot #fig = plt.figure(1) labels = [r'$l=1$',r'$l=2$',r'$l=3$'] for i in range(1): #for i in range(len(maps)): for k in range(10): # Read in (multiple) input files data, bg, local = np.sum([hp.read_map(f, range(3), verbose=False)\ for f in maps[i]], axis=0) a11 = [] a1n1 = [] a11_err = [] a1n1_err = [] for j in [1,2,3]: p = multifit(j, data, bg, alpha, **opts) #print('p = {}'.format(p)) a11.append(p['Y(1,1)']) a1n1.append(p['Y(1,-1)']) a11_err.append(p['dY(1,1)']) a1n1_err.append(p['dY(1,-1)']) fig = plt.figure(i) plt.errorbar(a1n1,a11,xerr=[a1n1_err,a1n1_err],yerr=[a11_err,a11_err],marker='.',markersize=10,linestyle=':', label='IC energy bin {}'.format(i+1)) #plt.plot(a1n1,a11,marker='.',markersize=10,linestyle=':', label='IC energy bin {}'.format(i+1)) plt.plot([0.0],[0.0],marker='.',markersize=10,linestyle='None', color='black') #plt.hlines(0.0,-1.,1.,linestyle='-.',color='grey') #plt.vlines(0.0,-1.,1.,linestyle='-.',color='grey') ax = fig.axes[0] ax.axis('on') tPars = {'fontsize':16}