Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中将RA Dec坐标转换为银河系坐标_Python_Python 2.7_Astropy_Fits - Fatal编程技术网

如何在python中将RA Dec坐标转换为银河系坐标

如何在python中将RA Dec坐标转换为银河系坐标,python,python-2.7,astropy,fits,Python,Python 2.7,Astropy,Fits,我正在用Python将像素坐标拟合文件转换为世界坐标。标题显示此fits文件位于RA Dec坐标系中。我想把它转换成银河系坐标。这是我试过的 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

我正在用Python将像素坐标拟合文件转换为世界坐标。标题显示此fits文件位于RA Dec坐标系中。我想把它转换成银河系坐标。这是我试过的

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'
这是行不通的。有什么建议吗?

根据,语法是:

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

这不起作用。这个代码的结果如下,我需要银河系坐标的结果。这个GVE的结果是Ra DecCoordinates@LALI不,@HBouy的回答是正确的。你错过了最后一步
c=SkyCoord(ra=wx*u.degree,dec=wy*u.degree,frame='icrs')
从ra-dec中的坐标创建一个
SkyCoord
对象。您可以使用该对象查询有关坐标的内容,以及将其转换为其他表示形式
c.galactic
提供了天空中同一点的副本,但在银河坐标系中。没有所谓的
astropy.coordinates.icrsocord
AttributeError
表示您试图使用不存在的东西。你是从哪里得到这个主意的?最接近的是
ICRS
,但您通常不会直接在
SkyCoord
上使用它: