Open vivgastro opened 5 years ago
@vg2691994 Do you any code snippet that works outside of astropy?
import ephem as e
from datetime import datetime
def convert_to_J2000(ra, dec, utc = datetime.utcnow()):
coords_now = e.Equatorial(ra, dec, epoch=utc)
coords_J2000 = e.Equatorial(coords_now, epoch=e.J2000)
return str(coords_J2000.ra), str(coords_J2000.dec)
#Example coords for PSR J0437-4715
ra = "04:37:15.8961737"
dec = "-47:15:09.110714"
new_ra, new_dec = convert_to_J2000(ra, dec)
print("Given coords of PSR J0437-4715:\
RA={0} \tDEC={1}".format(ra, dec))
print("J2000 coords of PSR J0437-4715:\
RA={0} \tDEC={1}".format(new_ra, new_dec))
Here is the output:
This is an example using Pyephem, which is deprecated now (hence the need to move to astropy). Also, now that have I read in some detail about coordinate epoch transformations, I wonder if this example gives an accurate result or not. I have been trusting this blindly so far and never bothered to check.
I am certainly not the expert in this. We need to locate people that are...
I am struggling to find a way in astropy to convert a set of current apparent coordinates (RA, DEC) into coordinates at a different epoch (eg. J2000), and vice-versa. Astropy has mulitple frames of coordinates (FK5, ICRS, etc) and any coordinate has two properties: equinox and obstime. I cannot figure out what functions to use to be able to convert the coordinates in a given frame (say ICRS) between two epochs.