Elegant SunPy method to get heliographic (Carrington) coordinates of SDO?

I’m trying to match of the view of a 3-D rendered PFSS model with the view from SDO.

I have a kind of messy way to get the heliographic longitude and latitude via SpiceyPy and appropriate kernels, but wonder if there might be a more elegant way in SunPy.

Most of the SunPy coordinate examples seem focused on Earth-based observatories, but certainly someone has done this for spacecraft observatories.

Thanks,
Tom

1 Like

You can retrieve the location of SDO by querying the JPL Horizons system using the function get_horizons_coord(). See get_horizons_coord — sunpy 6.0.1 documentation

>>> from sunpy.coordinates import get_horizons_coord
>>> sdo = get_horizons_coord('SDO', '2024-09-04')
INFO: Obtained JPL HORIZONS location for Solar Dynamics Observatory (spacecraft) (-136395) [sunpy.coordinates.ephemeris]
>>> print(sdo)
<SkyCoord (HeliographicStonyhurst: obstime=2024-09-04T00:00:00.000, rsun=695700.0 km): (lon, lat, radius) in (deg, deg, AU)
    (-0.01233942, 7.24335971, 1.00849196)>

This coordinate can be used to specify the observer location for other coordinates rather than simply assuming an Earth observer. See Specifying an Observer by Coordinate — sunpy 6.1.dev105+g52acab6aa documentation

Converting to Carrington heliographic coordinates can be unintuitive because Carrington longitude is implemented in sunpy in a way that may be unfamiliar to you (and may disagree with some sources). See Calculating Carrington longitude — sunpy 6.0.1 documentation

>>> from sunpy.coordinates import HeliographicCarrington
>>> sdo_hgc = sdo.transform_to(HeliographicCarrington(obstime=sdo.obstime, observer="self"))
>>> print(sdo_hgc)
<SkyCoord (HeliographicCarrington: obstime=2024-09-04T00:00:00.000, rsun=695700.0 km, observer=self): (lon, lat, radius) in (deg, deg, AU)
    (205.90158338, 7.24335971, 1.00849196)>

Feel free to ask follow-up questions!

1 Like

Here is a quick script:

import sunpy.coordinates
from sunpy.time import parse_time
from astropy.time import Time
import astropy.units as u

# Import get_horizons_coord for SDO coordinates retrieval
from sunpy.coordinates.ephemeris import get_horizons_coord

# Define the time for which you want the SDO location
time = Time('2024-09-04T00:00:00')

# Get the SDO coordinates from JPL Horizons
sdo_coord = get_horizons_coord('SDO', time)

# Convert to Heliographic Stonyhurst coordinates
heliographic_coord = sdo_coord.transform_to(sunpy.coordinates.HeliographicStonyhurst)

1 Like

Wow. Two quick responses.
Not sure if the Carrington longitude issue will impact me, but I’ll experiment.
Will let you know how it goes. Thanks!
Tom