Plotting with .get_transform?


I’m having issues with plotting things on top of images (using imshow, and SkyCoord). When I try plotting on top of an image with a SkyCoord object, I have to use ax.get_transform(‘fk5’) to get it to line up, but I don’t understand why if the coordinates are in ICRS and the image should be in ICRS.

I have a point I want to plot as a SkyCoord object (In this case it’s the known center of the source):
center = SkyCoord('18:57:25.59555586 ', ‘+16:24:55.8404388’, unit=(un.hourangle, un.deg));

When I go to plot it, I try:
ax.plot(,, markersize=15, marker=‘*’, color=‘white’);

Now, using the ax.get_transform, with different arguments passed I get a variety of different plots I don’t understand.

Using ax.get_transform(‘icrs’), which means it would transform the passed coordinates (which are in ICRS as it’s the SkyCoord default, right?) that are in ICRS, to the WCS (or the image’s coordinates), right? However, it seems that doesn’t work exactly… As I get the orange star.
Now, if I try ax.get_transform(‘fk5’), it works (albeit some error)! Which is the black star (under the white dot).

However, this would mean the coordinates should be in FK5 (they’re not), and/or the image would be in FK5 (which I find hard to believe).

Also, just to try it I did ax.get_transform(‘world’), which also works?! This is the white dot (which is on top of the black star).

I tried looking around in the documentation, and what I came up with was: in ax.get_transform(‘frame’) the frame and the frame of the coordinates should be the same, even the documentation uses ax.get_transform(‘fk5’), but if ICRS is the standard why would the example use FK5.

Everything you have described indicates that your WCS is in FK5, even if that is not what is intended. Can you print out ax.wcs.wcs?

Ah! It seems you are right!
flag: 137
naxis: 2
crpix: 0x7fe937a483d0
256.00 257.00
pc: 0x7fe937a4f4c0
pc[0]: 1.0000 0.0000
pc[1]: -0.0000 1.0000
cdelt: 0x7fe937a5a3d0
-4.1667e-08 4.1667e-08
crval: 0x7fe937a4c490
284.36 16.416
cunit: 0x7fe937a58450
ctype: 0x7fe937a56790
lonpole: 180.000000
latpole: 16.415511
restfrq: 0.000000
restwav: 0.000000
npv: 0
npvmax: 64
pv: 0x7fe9985d4000
nps: 0
npsmax: 8
ps: 0x7fe937a512b0
cd: 0x7fe937a5b6e0
cd[0]: 0.0000 0.0000
cd[1]: 0.0000 0.0000
crota: 0x7fe937a5c0f0
0.0000 0.0000
altlin: 4
velref: 3
alt: ’ ’
colnum: 0
colax: 0x7fe937a57180
0 0
cname: 0x7fe937a4ecf0
crder: 0x7fe937a4fd20
csyer: 0x7fe937a506b0
czphs: 0x7fe937a4ec70
cperi: 0x7fe937a4f740
wcsname: UNDEFINED
timesys: UNDEFINED
trefpos: UNDEFINED
trefdir: UNDEFINED
plephem: UNDEFINED
timeunit: UNDEFINED
dateref: UNDEFINED
mjdref: 0.000000000 0.000000000
timeoffs: UNDEFINED
dateobs: “2021-07-02”
datebeg: UNDEFINED
dateavg: UNDEFINED
dateend: UNDEFINED
mjdobs: 59397.000000000
xposure: UNDEFINED
telapse: UNDEFINED
timsyer: UNDEFINED
timrder: UNDEFINED
timedel: UNDEFINED
timepixr: UNDEFINED
obsorbit: UNDEFINED
radesys: “FK5”
equinox: 2000.000000000
specsys: “TOPOCENT”
ssysobs: UNDEFINED
velosys: UNDEFINED
zsource: UNDEFINED
ssyssrc: UNDEFINED
velangl: UNDEFINED
aux: 0x0
ntab: 0
tab: 0x0
nwtb: 0
wtb: 0x0
types: 0x7fe937a4ca30
2200 2201
lngtyp: “RA”
lattyp: “DEC”
lng: 0
lat: 1
spec: -1
time: -1
cubeface: -1
err: 0x0
lin: (see below)
cel: (see below)
spc: (see below)
m_flag: 137
m_naxis: 2
m_crpix: 0x7fe937a483d0 (= crpix)
m_pc: 0x7fe937a4f4c0 (= pc)
m_cdelt: 0x7fe937a5a3d0 (= cdelt)
m_crval: 0x7fe937a4c490 (= crval)
m_cunit: 0x7fe937a58450 (= cunit)
m_ctype: 0x7fe937a56790 (= ctype)
m_pv: 0x7fe9985d4000 (= pv)
m_ps: 0x7fe937a512b0 (= ps)
m_cd: 0x7fe937a5b6e0 (= cd)
m_crota: 0x7fe937a5c0f0 (= crota)

m_colax: 0x7fe937a57180  (= colax)
m_cname: 0x7fe937a4ecf0  (= cname)
m_crder: 0x7fe937a4fd20  (= crder)
m_csyer: 0x7fe937a506b0  (= csyer)
m_czphs: 0x7fe937a4ec70  (= czphs)
m_cperi: 0x7fe937a4f740  (= cperi)
  m_aux: 0x0  (= aux)
  m_tab: 0x0  (= tab)
  m_wtb: 0x0  (= wtb)

flag: 137
naxis: 2
crpix: 0x7fe937a483d0
256.00 257.00
pc: 0x7fe937a4f4c0
pc[0]: 1.0000 0.0000
pc[1]: -0.0000 1.0000
cdelt: 0x7fe937a5a3d0
-4.1667e-08 4.1667e-08
dispre: 0x0
disseq: 0x0
piximg: (nil)
imgpix: (nil)
i_naxis: 0
unity: 1
affine: 1
simple: 1
err: 0x0
tmpcrd: 0x7fe937a585f0
m_flag: 0
m_naxis: 0
m_crpix: 0x0
m_pc: 0x0
m_cdelt: 0x0
m_dispre: 0x0
m_disseq: 0x0

flag: 137
offset: 0
phi0: 0.000000
theta0: 90.000000
ref: 284.36 16.416 180.00 16.416
prj: (see below)
euler: 284.36 73.584 180.00 0.28260 0.95924
latpreq: 0 (not required)
isolat: 0
err: 0x0

flag: 105
code: “SIN”
r0: 57.295780
pv: (0)
0.0000 0.0000
phi0: 0.000000
theta0: 90.000000
bounds: 7

   name: "orthographic/synthesis"

category: 1 (zenithal)
pvrange: 102
simplezen: 1
equiareal: 0
conformal: 0
global: 0
divergent: 0
x0: 0.000000
y0: 0.000000
err: 0x0
w: 0.017453 0.0000 1.0000 -1.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
m: 0
n: 0
prjx2s: 0x0133eeda90
prjs2x: 0x0133eee320

flag: 0
type: " "
code: " "
restfrq: 0.000000
restwav: 0.000000
pv: (not used)
w: 0.0000 0.0000 0.0000 (remainder unused)
isGrism: 0
err: 0x0
spxX2P: 0x0
spxP2S: 0x0
spxS2P: 0x0
spxP2X: 0x0

Would astropy default to FK5, or does it choose it based on the original file? I looked in the FITS header and it never said FK5 or ICRS.

The two FITS keywords to look for are RADESYS and EQUINOX. It sounds like RADESYS is not defined in your FITS header, so I’m guessing that EQUINOX is explicitly defined in your header to be 2000. The FITS standard says:

RADESYSa – [string; default: ’FK4’, ’FK5’, or ’ICRS’: see
    below]. Name of the reference frame of equatorial or eclip-
    tic coordinates, whose value must be one of those speci-
    fied in Table 24. The default value is ’FK4’ if the value of
    EQUINOXa < 1984.0, ’FK5’ if ’EQUINOX’a ≥ 1984.0, or
    ’ICRS’ if ’EQUINOX’a is not given.

That is, you’re getting FK5 rather than ICRS because EQUINOX is defined.

Got it! Thank you so much!!