Mikhail Lisakov
Mikhail Lisakov

Reputation: 1670

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

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

ra.set_coord_type('scalar') 

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

ax.ticklabel_format(useoffset = 1000, style = 'sci')

=> no changes

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

Upvotes: 2

Views: 774

Answers (2)

Mikhail Lisakov
Mikhail Lisakov

Reputation: 1670

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.

Upvotes: 0

Walfits
Walfits

Reputation: 446

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

Upvotes: 1

Related Questions