Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-46784: Add function for getting ecliptic coordinates #127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions python/lsst/summit/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,3 +1258,54 @@ def getCameraFromInstrumentName(instrumentName: str) -> lsst.afw.cameraGeom.Came
case _:
raise ValueError(f"Unsupported instrument: {instrumentName}")
return camera


def calcEclipticCoords(ra: float, dec: float) -> tuple[float, float]:
"""Get the ecliptic coordinates of the specified ra and dec.

Transform J2000 (ra, dec), both in degrees, to
IAU1976 Ecliptic coordinates (also returning degrees).

Matches the results of:

from astropy.coordinates import SkyCoord, HeliocentricEclipticIAU76
import astropy.units as u

p = SkyCoord(ra=ra0*u.deg, dec=dec0*u.deg, distance=1*u.au, frame='hcrs')
ecl = p.transform_to(HeliocentricEclipticIAU76)
print(ecl.lon.value, ecl.lat.value)

except that it's fast.

Parameters
----------
ra : `float`
The right ascension, in degrees.
dec : `float`
The declination, in degrees.

Returns
-------
lambda : `float`
The ecliptic longitude in degrees.
beta : `float`
The ecliptic latitude in degrees.
"""

ra, dec = np.deg2rad(ra), np.deg2rad(dec)

# IAU 1976 obliquity
epsilon = np.deg2rad(23.43929111111111)
cos_eps, sin_eps = np.cos(epsilon), np.sin(epsilon)

sra, cra = np.sin(ra), np.cos(ra)
sdec, cdec = np.sin(dec), np.cos(dec)

lambda_ = np.arctan2((sra * cos_eps + sdec / cdec * sin_eps), cra)
beta = np.arcsin(sdec * cos_eps - cdec * sin_eps * sra)

# normalize
if lambda_ < 0:
lambda_ += np.pi * 2

return (np.rad2deg(lambda_), np.rad2deg(beta))
Loading