2

I am working with VLBI data (Very Long Baseline Interferometry, like one that was used to make a recently trended black hole shadow image). I am plotting an image which is taken from a FITS file. By the means of a WCS transformation, it is converted from pixels to physical units, i.e. degrees. Also, I have put a central pixel to (0,0) in physical units.

It looks nice when plotted. But I want to label axes in mas(milliarcseconds) because the imaged area on the sky is really small. So instead of 0deg0'0.001" or 0.001" I would like to see 1 as the tick label.

Now, x-axis looks like this, units are arcseconds I want it to look like this. Units are milliarcseconds, i.e. 0.001 of an arcsecond

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]

  • 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

  • Changing axis mode to 'scalar', i.e.
ra.set_coord_type('scalar') 

breaks the locator, I believe. => all tick labels are overlapping at 0 of the x axis.

  • Addind scale did not work at all (supposing I did everything correctly)
ax.ticklabel_format(useoffset = 1000, style = 'sci')

=> no changes

Are there any other means of converting axis labels for coordinate data to milliarcseconds?

Mikhail Lisakov
  • 1,600
  • 1
  • 9
  • 7

2 Answers2

1

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.

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. :)

Walfits
  • 446
  • 5
  • 9
0

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, i.e.

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

This solves the whole issue and no major tweaking is required anymore.

Mikhail Lisakov
  • 1,600
  • 1
  • 9
  • 7
  • Your approach helped me a bit, but I still get problems on the scales. Do you have any idea what is it wrong? Please check this, https://stackoverflow.com/questions/64480066/astropy-coordinate-conversion-problem-of-a-fits-file – Wara Oct 22 '20 at 17:58
  • the link brings me to nowhere. But we may discuss the issue here. And please upvote if you find it useful. – Mikhail Lisakov Oct 23 '20 at 21:50
  • Now the link is available. – Wara Oct 24 '20 at 13:18