3

EDIT:

Ok I figured out a botchey way of doing this involving scipy.interpolate.griddata

I have some maps that are in the form of two dimensional arrays 130x360 with each value in the array corresponding to the measurment at that point.

These maps are provided in right ascension (ra) and declination (dec) and the extents are from

ra : 0 to 360 deg

dec : -40 to 90 deg

I have managed to plot the map in Equatorial coordinates via the following:

import matplotlib.pyplot as plt
import numpy as np

z = np.load('map.npy')

fig = plt.figure()

ax = fig.add_subplot(111, projection='aitoff')
ra = np.linspace(-np.pi, np.pi, 360)
dec = np.linspace(-40 * np.pi/180, np.pi/2, 130)
Ra, Dec = np.meshgrid(ra, dec)

im = ax.pcolormesh(Ra, Dec, z, cmap=plt.cm.jet, norm=colors.LogNorm(vmax=z.max()))

plt.grid()
plt.show()

which yields me the following plot:

Plot

I now wish to convert this plot into galactic coordinates, so that the band of the milky way runs accross the image.

I have tried using astropy's SkyCoord module to convert the Ra and Dec arrays to galactic

from astropy.coordinates import SkyCoord

coords = SkyCoord(ra=Ra, dec=Dec, unit='rad').galactic

B = coords.galactic.b.rad
L = coords.galactic.l.rad


im = ax.pcolormesh(L, B, z, cmap=plt.cm.jet, norm=colors.LogNorm(vmax=np.nanmax(z)))

and I get something that looks like this

enter image description here

Not quite right...

I have also created a list of

ra, dec and z for every point in my image, and have converted each point to galactic coordinates,

perhaps I can transform this back into the correct shape i require so i can plot it using pcolormesh?

here's what it looks like using the following code


x_list = np.array(df['GLON_rad'])
y_list = np.array(df['GLAT_rad'])
z_list = np.array(df['z'])

coords = SkyCoord(l=x_list, b=y_list, unit='rad', frame="galactic")

plt.figure()
plt.subplot(111, projection='aitoff')

plt.scatter(-coords.l.wrap_at('180d').radian, coords.b.radian, c=z_list, cmap='plasma', norm=colors.LogNorm(vmax=np.nanmax(z)))

definitely on the right track but not quite there as i feel using plt.scatter with a color argument is a bit botchey.

enter image description here

0 Answers0