AstroPy to transform coordinates

99 views Asked by At

I want to transform the icrs coordinates (ar and dr) from epoch 1991.25 to epoch 2016.0, also in the icrs system.

But I got this error. It's my first time using AstroPy.

<SkyCoord (ICRS): (ra, dec) in deg
(243.90472242, -8.36823651)>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 8
  5 c = SkyCoord(ar, dr, frame='icrs', unit='deg')
  7 print(c)
----> 8 print(c.transform_to(ICRS(equinox='J2016')))

File /usr/lib/python3/dist-packages/astropy/coordinates/baseframe.py:336, in BaseCoordinateFrame.__init__(self, copy, representation_type, differential_type, *args, **kwargs)
333         self._attr_names_with_defaults.append(fnm)
335 if kwargs:
--> 336     raise TypeError(
337         f"Coordinate frame {self.__class__.__name__} got unexpected "
338         f"keywords: {list(kwargs)}"
339     )
341 # We do ``is None`` because self._data might evaluate to false for
342 # empty arrays or data == 0
343 if self._data is None:
344     # No data: we still need to check that any non-scalar attributes
345     # have consistent shapes. Collect them for all attributes with
346     # size > 1 (which should be array-like and thus have a shape).

TypeError: Coordinate frame ICRS got unexpected keywords: ['equinox']

The code is below:

from astropy.coordinates import SkyCoord, ICRS

ar = 243.90472242
dr = -8.36823651
c = SkyCoord(ar, dr, frame='icrs', unit='deg')

print(c)
print(c.transform_to(ICRS(equinox='J2016')))

I made another attempt: I start with values ar=x and dr=y in icrs; then I switch to FK5 before transforming to Equinox J2016. But when I go back to icrs, the x and y values remain unchanged.

It appears that when switching back to the icrs system, the transformation from equinox 1991.25 to equinox 2016 is "undone". Code:

from astropy.coordinates import SkyCoord, ICRS, FK5

ar = 243.90472242
dr = -8.36823651


c_icrs = SkyCoord(ar, dr, frame='icrs', unit='deg')
print("Original coordinates in icrs\n", c_icrs)
print("")

c_fk5 = c_icrs.transform_to(FK5)  # c_icrs.fk5 does the same thing
print("Switch to fk5 system\n",c_fk5)
print("")

c_fk5 = c_fk5.transform_to(FK5(equinox='J2016'))  # precess to a different equinox .transform_to('fk5')  # c_icrs.fk5 does the same thing
print("Transform to equinox J2016\n",c_fk5) 
print("")

c_icrs = c_fk5.transform_to('icrs')
print("Back to icrs\n",c_icrs)

Output:

Original coordinates in icrs
 <SkyCoord (ICRS): (ra, dec) in deg
(243.90472242, -8.36823651)>

Switch to fk5 system
 <SkyCoord (FK5: equinox=J2000.000): (ra, dec) in deg
(243.90472947, -8.36823266)>

Transform to equinox J2016
 <SkyCoord (FK5: equinox=J2016.000): (ra, dec) in deg
(244.12153008, -8.40725993)>

Back to icrs
 <SkyCoord (ICRS): (ra, dec) in deg
(243.90472242, -8.36823651)>

This is a big problem, because I need the coordinates (ar and dr) in the icrs system with equinox J2016 and they necessarily need to be different from the original coordinates in the J1991.25 epoch.

0

There are 0 answers