Skip to content

Instantly share code, notes, and snippets.

@eteq
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eteq/4b7536e6923a4f97e3ef to your computer and use it in GitHub Desktop.
Save eteq/4b7536e6923a4f97e3ef to your computer and use it in GitHub Desktop.
Code to show galactocentric stuff
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from astropy.coordinates import *
from astropy import units as u
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
icrszaxspher = ICRS(np.repeat([0,180], 60)*u.deg,np.tile(np.linspace(-90,90,60),2)*u.deg,8.3*u.kpc)
icrsxaxspher = ICRS(np.linspace(0,360,120)*u.deg,0*u.deg,8.3*u.kpc)
disk=SphericalRepresentation(np.linspace(0,360,120)*u.deg,0*u.deg,8.3*u.kpc)
galzaxspher = Galactic(np.repeat([0,180], 60)*u.deg,np.tile(np.linspace(-90,90,60),2)*u.deg,8.3*u.kpc)
icrscen=ICRS([0]*u.deg,[0]*u.deg,[0]*u.kpc)
ax.plot3D(*icrsxaxspher.transform_to(Galactocentric).cartesian.xyz.value, c='b', label='ICRS XY-plane')
ax.plot3D(*icrszaxspher.transform_to(Galactocentric).cartesian.xyz.value, c='r', label='ICRS XZ-plane')
ax.scatter3D([0],[0],[0],c='g')
ax.scatter3D(*icrscen.transform_to(Galactocentric).cartesian.xyz.value, c='r')
ax.plot3D(*disk.to_cartesian().xyz.value, c='g', label='Galactocentric XY-plane')
ax.plot3D(*galzaxspher.transform_to(Galactocentric).cartesian.xyz.value, c='k', label='Galactic XZ-plane')
ax.set_zlabel('$z_{galo}$',fontsize=24)
ax.set_xlabel('$x_{galo}$',fontsize=24)
ax.set_ylabel('$y_{galo}$',fontsize=24)
ax.set_xlim(-15, 10)
ax.set_ylim(-12.5, 12.5)
ax.set_zlim(-12.5, 12.5)
ax.set_aspect(1)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment