Astropy matplotlib and galactic site coordinates

I am trying to plot the galactic coordinates using python. Say I have this data:

data = [(0.261, -7.123, 13.03, 'Unidentified'), (-0.326, 77, 13.03, 'Galaxies')]

Where each tuple has the form (ra, dec, flux, type).

I will be asked to use astropy + matplotlib, therefore:

c = SkyCoord(ra = ra*u.degree, dec = dec*u.degree) galactic = c.galactic 

This is where my problem arises, I use this code:

 from mpl_toolkits.basemap import Basemap import numpy as np import matplotlib.pyplot as plt # lon_0 is central longitude of projection. # resolution = 'c' means use crude resolution coastlines. m = Basemap(projection='hammer',lon_0=0,resolution='c') m.drawcoastlines() m.fillcontinents(color='coral',lake_color='aqua') # draw parallels and meridians. m.drawparallels(np.arange(-90.,120.,30.)) m.drawmeridians(np.arange(0.,420.,60.)) m.drawmapboundary(fill_color='aqua') plt.title("Hammer Projection") plt.show() 

However, I cannot build data in galactic coordinates, and I do not know why. I also need each dot to have a different color depending on the type and different size depending on the value of the stream. I need to achieve something like this (I'm a little new to python, and I have never used astropy, I have not found good examples):

enter image description here

Hope someone can help.

+6
source share
1 answer

Check out the examples below http://www.astropy.org/astropy-tutorials/plot-catalog.html . The general problem that I encounter when building the coordinates of the Galaxy is that you want to plot a graph from -180 to +180, but the coordinates are set from 0 to 360 by default. You can change this using wrap_at , for example:

 plot(galactic.l.wrap_at(180*u.deg), galactic.b.wrap_at(180*u.deg)) 
+6
source

All Articles