I have a fits map mollview projection but in ecliptic coordinates. I want to convert it to galactic coordinates. Please suggest a code so that I can visualize it in galactic coordinates.
import numpy as np
import matplotlib.pyplot as plt
import healpy as hp
from pixell import enmap, reproject, utils
from matplotlib import cm
path = "/home/masroor/fazl/"
imap = enmap.read_map(path +
"act_planck_dr5.01_s08s18_AA_f150_daynight_map.fits")[0]
try:
imap
exce pt NameError:
imap = None
def eshow(x,**kwargs):
''' Define a function to help us plot the maps neatly '''
plots = enplot.get_plots(x, **kwargs)
enplot.show(plots, method = "ipython")
smap_healpix = reproject.healpix_from_enmap(imap, lmax=6000,
nside=128)
lonra = np.sort(imap.box()[:, 1])/utils.degree
latra = np.sort(imap.box()[:, 0])/utils.degree
rang = 300
ecliptic_to_galactic_matrix = hp.Rotator(coord=['G', 'E'],
deg=True).mat
galactic_map = hp.mollview(smap_healpix,min = -rang, max =
rang,coord='CE', rot=ecliptic_to_galactic_matrix, xsize=800,
title='Galactic Coordinates', cmap=cm.get_cmap('RdYlBu'))
hp.graticule()
this is the code I used but I don't think this is in galactic coordinates
if you just want to plot in Galactic, just do:
if you want an actual map array in Galactic coordinates:
for more details and an example you can take a look at this tutorial https://www.zonca.dev/posts/2021-03-11-rotate-maps-healpy