-2

I was converting a pixel coordinate fits file to world coordinates in Python. The header shows that this fits file is in RA-Dec coordinate system . I want to convert this to galactic coordinates. Here is what I've tried.

from astropy import coordinates as coord
from astropy import units as u
c=coord.icrscoord(ra=wx,dec=wy,unit=(u.degree,u.degree))
c.galactic

AttributeError: 'module' object has no attribute 'icrscoord'

This does not work. Any suggestions?

Rose
  • 25
  • 7
LALI
  • 1
  • 1
  • 2
  • 1
    There's no such thing as `astropy.coordinates.icrscoord`. The `AttributeError` means you're trying to use something that doesn't exist. Where did you get the idea it would? The closest thing is `ICRS`, but you wouldn't typically use that directly over `SkyCoord`: http://docs.astropy.org/en/stable/coordinates/index.html – Iguananaut Jun 14 '16 at 13:01

1 Answers1

6

According to the Astropy documentation, the syntax is:

from astropy import units as u
from astropy.coordinates import SkyCoord
c = SkyCoord(ra=wx*u.degree, dec=wy*u.degree, frame='icrs')
c.galactic
HBouy
  • 245
  • 3
  • 14
  • THIS DOES NOT WORK.THE RESULT OF THIS CODE IS AS FOLLOWS I need result in the Galactic coordinates.This gves result in the Ra-Dec Coordinates – LALI Jun 14 '16 at 11:30
  • @LALI No, @HBouy's answer is correct. You missed the last step. `c = SkyCoord(ra=wx*u.degree, dec=wy*u.degree, frame='icrs')` creates a `SkyCoord` *object* from your coordinates in RA-Dec. You can that use this object to query things about the coordinates, as well as convert it to other representations. `c.galactic` gives you a copy of the same point on the sky but in galactic coordinates. – Iguananaut Jun 14 '16 at 13:06