def layered_contour(imap, imap_contour, contour_levels, contour_color, contour_width=1, mask=None, filename=None, ticks=1, downgrade=1, font_size=20, **kwargs): from pixell import enplot p1 = enplot.plot(imap, layers=True, mask=mask, ticks=ticks, downgrade=downgrade, font_size=font_size, **kwargs) p2 = enplot.plot(imap_contour, layers=True, contours=contour_levels, contour_width=contour_width, mask=mask, contour_color=contour_color, ticks=ticks, downgrade=downgrade, font_size=font_size) p1 += [a for a in p2 if "cont" in a.name] img = enplot.merge_images([a.img for a in p1]) if filename is not None: enplot.write(filename, img) return img
def s18dStamp(ra, dec, data, name, width=0.5, write=True): #Find tile corresponding to RA, Dec path = '/scratch/r/rbond/jorlo/S18d_202006/filteredMaps/' tileName = tileFinder(ra, dec, data) if tileName == None: return None tile = enmap.read_map(path + tileName + '/Arnaud_M2e14_z0p4#' + tileName + '_filteredMap.fits') stamp = reproject.postage_stamp(tile, ra, dec, width * 60, 0.5) if write: #tempdec, tempra = np.deg2rad([dec, ra]) #tempwid = np.deg2rad(width) #box = [[tempdec-tempwid,tempra-tempwid],[tempdec+tempwid,tempra+tempwid]] #stampgeo = tile.submap(box) box = np.array([[ra - width / 2, dec - width / 2], [ra + width / 2, dec + width / 2]]) * utils.degree shape, wcs = enmap.geometry(pos=box, res=0.5 * utils.arcmin, proj='car') print(shape) #print(stampgeo.wcs) #print(stamp.wcs) stamp.wcs = wcs print(stamp.wcs) print(stamp[0].shape) #plt.imshow(stamp[0]) #plt.show() #Return map plot = enplot.plot(stamp, mask=0) enplot.show(plot) enmap.write_map('./for_tony/{}.fits'.format(name), stamp) return stamp
def plot(fname,imap,dg=4,grid=False,**kwargs): from orphics import io img = enplot.plot(enmap.downgrade(imap,dg),grid=grid,**kwargs) if fname is None: enplot.show(img) else: enplot.write(fname,img) print(io.bcolors.OKGREEN+"Saved high-res plot to", fname+io.bcolors.ENDC)
tilecMap = d56 * tilecMaskD56 + bn * tilecMaskBN # also reproject the PS mask psMask = enmap.project(psMask, tilecMask.shape, tilecMask.wcs, order=1, mode='constant', cval=0.0, force=False, prefilter=True, mask_nan=True, safe=True) # Plot the combined maps to check plot = enplot.plot(tilecMask, grid=True) enplot.write(pathFig + "foot_mask", plot) plot = enplot.plot(tilecMap, grid=True) enplot.write(pathFig + "map", plot) # Save the map now, to clear memory print "saving map to " + pathOut + "tilec_maps.fits" enmap.write_map(pathOut + "tilec_map.fits", tilecMap) ######################################################################### # Mask the Milky Way with a Planck mask # Read the Planck Galactic mask pathPlanckMask = "/global/cscratch1/sd/eschaan/project_ucsc/data/planck_galactic_mask/HFI_Mask_GalPlane-apo0_2048_R2.00.fits" # field, fsky:
"/scratch/r/rbond/msyriac/data/for_sigurd/mask_boss.fits", geometry=m1.geometry) + enmap.read_map( "/scratch/r/rbond/msyriac/data/for_sigurd/mask_deep56.fits", geometry=m1.geometry) print(m1.wcs) print(m2.wcs) off = [0, 1000] m1s = enmap.shift(enmap.downgrade(m1, 10), off) m2s = enmap.shift(enmap.downgrade(m2, 10), off) p1 = enplot.plot(m1s, min=500, max=1e4, color="cooltowarm", ticks="10", layers=True, font_size=50, contour_color='ffffff') p2 = enplot.plot(m2s, min=0, max=1, ticks="10", layers=True, contours="0.5,", contour_width=6, annotate="paper/annot.txt", font_size=50, contour_color='ffffff') ptot = enplot.merge_plots(p1 + p2[1:3])
if args.signal_map is not None: freq = [x for x in mapdir.split('_') if x.startswith('f')][0] signal_map = args.signal_map if len(signal_map) == 1: signal_map = signal_map[0] signal = read_signal_map(signal_map, freq, ratio.shape, ratio.wcs) signal = enmap.downgrade(signal, args.downgrade) hitmap = enmap.downgrade(hitmap, args.downgrade) cutmap = enmap.downgrade(cutmap, args.downgrade) ratio = enmap.downgrade(ratio, args.downgrade) ratio[hitmap == 0] = np.nan plot = enplot.plot(hitmap, **plot_opts) enplot.write(opj(mapdir, 'hits'), plot) plot = enplot.plot(cutmap, **plot_opts) enplot.write(opj(mapdir, 'cuts'), plot) plot = enplot.plot(ratio, min=0, max=args.range, **plot_opts) enplot.write(opj(mapdir, 'ratio'), plot) if args.signal_map is not None: ratio[hitmap == 0] = 0. ratio_sm = enmap.downgrade(ratio, 32 / float(args.downgrade)) ratio_sm = enmap.project(ratio_sm, ratio.shape, ratio.wcs, order=1) contours = '0.003, 0.01'
def eshow(x, **kwargs): enplot.show(enplot.plot(x, downgrade=4, **kwargs))
def stack(ras, decs, map): stack = 0 for i in range(len(ras)): stamp = reproject.postage_stamp(map, ras[i], decs[i], 20., 0.5) if stamp is None: continue stack += stamp[0] stack /= len(ras) return stack print("Starting ACT Maps") imap = enmap.read_map('/maps/ACTPol_148_D56_PA1_S2_1way_I.fits') plots = enplot.plot(imap, range=300, mask=0) enplot.write("ACT_map", plots) width = np.deg2rad(30. / 60.) t = QTable.read('madcows/AdvACT_S18Clusters_v1.0-beta.fits') ra_temp = t['RADeg'] dec_temp = t['decDeg'] ra, dec = np.array(ra_temp), np.array(dec_temp) s18stack = stack(ra, dec, imap) plots = enplot.plot(enmap.upgrade(s18stack, 5), grid=False, colorbar=True, color='gray') enplot.write("s18stack_act", plots)