用matplotlib绘制RA vs DEC(赤道坐标系)二维绘图

2024-04-27 13:37:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我想绘制一些二维地图,显示天文学源在天空中的位置。在

即:

我有一些数据ASCII表和赤道坐标源(RA-赤经,DEC-赤纬)。 例如:

enter image description here

这里RA以小时(h)、分(m)和秒(s)为单位;DEC-以度(°)、分(')和秒(“)为单位。在

现在我正在用TOPCAT绘制地图,它看起来像这样:

enter image description here

一切都很好,只不过与顶级猫咪的合作不能照本宣科。但我有大量的数据。在

我决定使用matplotlib(与astropy一起使用),但发现在上面的图中,以HH:MM:SS和°:':“设置轴是一个困难的问题。在

阿童木教程说:

The axis object, ax, knows to expect angular coordinate values. An important fact is that it expects the values to be in radians, and it expects the azimuthal angle values to be between (-180º,180º). This is (currently) not customizable, so we have to coerce our RA data to conform to these rules!

但是教程中的“当前”是2013年,也许已经修复了?在

所以问题是:我能用matplotlib绘制RA/DEC数据并将轴设置为HH:MM:SS和°:':”吗?P、 没有添加FITS文件。


Tags: to数据matplotlibishh绘制单位it
1条回答
网友
1楼 · 发布于 2024-04-27 13:37:26

您可以使用xticks()yticks()函数作为轴刻度标签。例如,函数调用xticks([1, 2, 3], ["a", "b", "c"])将在沿x轴的1、2和3的位置给您标记为a、b和c的记号。所以一个(有点脏)的解决方案看起来像这样:

  1. 用度数绘制坐标
  2. 使用xticks()和yticks()函数配置轴,以显示hh:mm:ss和°:':”值:

    # Set up RA coordinates along x-axis
    ticksLocationsRA = linspace(minRA, maxRA, numberOfTicks)
    ticksLabelsRA = degrees_to_hhmmss(ticksLocatoinsRA)
    xticks(ticksLocationsRA, ticksLabelsRA)
    
    # The same with DEC coodinates
    ticksLocationsDEC = linspace(minDEC, maxDEC, numberOfTicks)
    ticksLabelsDEC = degrees_to_ddmmss(ticksLocatoinsDEC)
    yticks(ticksLocationsDEC, ticksLabelsDEC)
    

只需编写degrees_to_hhmmss()和degrees_to_ddmmss()函数,就可以将十进制度数转换为HH:MM:SS和°:':”之类的字符串(注意,可以在matplotlib中使用LaTex符号)

相关问题 更多 >