简体   繁体   English

坐标图的刻度轴刻度标签

[英]Scale axis tick labels for coordinates plot

I am working with VLBI data (Very Long Baseline Interferometry, like one that was used to make a recently trended black hole shadow image).我正在处理 VLBI 数据(超长基线干涉测量法,例如用于制作最近流行的黑洞阴影图像的数据)。 I am plotting an image which is taken from a FITS file.我正在绘制一张取自 FITS 文件的图像。 By the means of a WCS transformation, it is converted from pixels to physical units, ie degrees.通过 WCS 变换,它从像素转换为物理单位,即度。 Also, I have put a central pixel to (0,0) in physical units.另外,我将中心像素放在 (0,0) 的物理单位中。

It looks nice when plotted.绘制时看起来不错。 But I want to label axes in mas(milliarcseconds) because the imaged area on the sky is really small.但我想以 mas(毫弧秒)为单位标记轴,因为天空中的成像区域非常小。 So instead of 0deg0'0.001" or 0.001" I would like to see 1 as the tick label.因此,我希望看到 1 作为刻度标签,而不是 0deg0'0.001" 或 0.001"。

现在,x 轴看起来像这样,单位是角秒 我希望它看起来像这样。单位是毫角秒,即 0.001 角秒

Here is a basic code to open a figure: wcs = WCS(i[0].header).celestial # where i is a FITS object wcs.wcs.crval = [0,0] # to remove absolute coordinates of a source fig = plt.figure() ax = fig.add_subplot(111, projection = wcs) ra, dec = ax.coords[0], ax.coords[1]这是打开图形的基本代码: wcs = WCS(i[0].header).celestial # where i is a FITS object wcs.wcs.crval = [0,0] # to remove absolute coordinates of a source fig = plt.figure() ax = fig.add_subplot(111, projection = wcs) ra, dec = ax.coords[0], ax.coords[1]

  • I have tried playing with我试过玩
ax.xaxis.set_major_formatter(FuncFormatter(format_func))

but it seems to be not implemented yet for axis which are not 'scalar'.但对于不是“标量”的轴,它似乎还没有实现。 => raise NotImplementedError() # figure out how to swap out formatter => raise NotImplementedError() # 弄清楚如何换出格式化程序

  • Changing axis mode to 'scalar', ie将轴模式更改为“标量”,即
ra.set_coord_type('scalar') 

breaks the locator, I believe.打破定位器,我相信。 => all tick labels are overlapping at 0 of the x axis. => 所有刻度标签在 x 轴的 0 处重叠。

  • Addind scale did not work at all (supposing I did everything correctly) Addind scale 根本不起作用(假设我做的一切都正确)
ax.ticklabel_format(useoffset = 1000, style = 'sci')

=> no changes => 没有变化

Are there any other means of converting axis labels for coordinate data to milliarcseconds?是否有任何其他方法可以将坐标数据的轴标签转换为毫角秒?

I have used a not very elegant way of doing this, maybe it will work in this case.我使用了一种不太优雅的方法来执行此操作,也许在这种情况下它会起作用。 I use labels for the axis that are strings instead of int.我为轴使用的标签是字符串而不是 int。

x_values = [0.000, -0.003, -0.006]
labels = []
for value in x_values:
    labels.append(str(convert_to_mas(value)))

ax.set_xticks(x_values)
ax.set_xticklabels(labels) 

This is just the general idea, but you will have to adapt it to your code.这只是一般的想法,但您必须根据您的代码进行调整。 I could be more specific if you added a small reproducible example.如果您添加一个可重现的小示例,我可以更具体。 :) :)

Okay, after some efforts, I have found the root of the issue.好的,经过一番努力,我找到了问题的根源。 For VLBI maps, the axes should be defined as offsets, not RA and DEC, ie对于 VLBI 地图,轴应定义为偏移量,而不是 RA 和 DEC,即

w.wcs.ctype = [ 'XOFFSET' , 'YOFFSET' ]

This solves the whole issue and no major tweaking is required anymore.这解决了整个问题,不再需要进行重大调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM