mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-04-13 02:58:34 -04:00
Python: Implemented EQJ/GAL conversions.
Ported conversion to/from galactic coordinates to Python. Added unit test for new Python code. Updated documentation for all 4 supported languages. Fixed mistakes in JavaScript function documentation.
This commit is contained in:
@@ -107,7 +107,7 @@ To get started quickly, here are some [examples](../../demo/python/).
|
||||
|
||||
### Coordinate transforms
|
||||
|
||||
The following four orientation systems are supported.
|
||||
The following five orientation systems are supported.
|
||||
Astronomy Engine can convert a vector from any of these orientations to any of the others.
|
||||
It also allows converting from a vector to spherical (angular) coordinates and back,
|
||||
within a given orientation. Note the 3-letter codes for each of the orientation systems;
|
||||
@@ -117,6 +117,7 @@ these are used in function and type names.
|
||||
- **EQD = Equator of-date**: Uses the Earth's equator on a given date and time, adjusted for precession and nutation.
|
||||
- **ECL = Ecliptic**: Uses the mean plane of the Earth's orbit around the Sun. The x-axis is referenced against the J2000 equinox.
|
||||
- **HOR = Horizontal**: Uses the viewpoint of an observer at a specific location on the Earth at a given date and time.
|
||||
- **GAL = Galactic**: Based on the IAU 1958 definition of galactic coordinates.
|
||||
|
||||
| Function | Description |
|
||||
| -------- | ----------- |
|
||||
@@ -142,6 +143,8 @@ these are used in function and type names.
|
||||
| [Rotation_HOR_EQD](#Rotation_HOR_EQD) | Calculates a rotation matrix from horizontal (HOR) to equatorial of-date (EQD). |
|
||||
| [Rotation_HOR_EQJ](#Rotation_HOR_EQJ) | Calculates a rotation matrix from horizontal (HOR) to J2000 equatorial (EQJ). |
|
||||
| [Rotation_HOR_ECL](#Rotation_HOR_ECL) | Calculates a rotation matrix from horizontal (HOR) to ecliptic J2000 (ECL). |
|
||||
| [Rotation_EQJ_GAL](#Rotation_EQJ_GAL) | Calculates a rotation matrix from equatorial J2000 (EQJ) to galactic (GAL). |
|
||||
| [Rotation_GAL_EQJ](#Rotation_GAL_EQJ) | Calculates a rotation matrix from galactic (GAL) to equatorial J2000 (EQJ). |
|
||||
|
||||
---
|
||||
|
||||
@@ -1907,6 +1910,21 @@ A rotation matrix that converts EQJ to EQD at `time`.
|
||||
|
||||
---
|
||||
|
||||
<a name="Rotation_EQJ_GAL"></a>
|
||||
### Rotation_EQJ_GAL()
|
||||
|
||||
**Calculates a rotation matrix from equatorial J2000 (EQJ) to galactic (GAL).**
|
||||
|
||||
This is one of the family of functions that returns a rotation matrix
|
||||
for converting from one orientation to another.
|
||||
Source: EQJ = equatorial system, using the equator at the J2000 epoch.
|
||||
Target: GAL = galactic system (IAU 1958 definition).
|
||||
|
||||
### Returns: [`RotationMatrix`](#RotationMatrix)
|
||||
A rotation matrix that converts EQJ to GAL.
|
||||
|
||||
---
|
||||
|
||||
<a name="Rotation_EQJ_HOR"></a>
|
||||
### Rotation_EQJ_HOR(time, observer)
|
||||
|
||||
@@ -1933,6 +1951,21 @@ and so that north represents the direction where azimuth = 0.
|
||||
|
||||
---
|
||||
|
||||
<a name="Rotation_GAL_EQJ"></a>
|
||||
### Rotation_GAL_EQJ()
|
||||
|
||||
**Calculates a rotation matrix from galactic (GAL) to equatorial J2000 (EQJ).**
|
||||
|
||||
This is one of the family of functions that returns a rotation matrix
|
||||
for converting from one orientation to another.
|
||||
Source: GAL = galactic system (IAU 1958 definition).
|
||||
Target: EQJ = equatorial system, using the equator at the J2000 epoch.
|
||||
|
||||
### Returns: [`RotationMatrix`](#RotationMatrix)
|
||||
A rotation matrix that converts GAL to EQJ.
|
||||
|
||||
---
|
||||
|
||||
<a name="Rotation_HOR_ECL"></a>
|
||||
### Rotation_HOR_ECL(time, observer)
|
||||
|
||||
|
||||
@@ -6813,13 +6813,57 @@ def Rotation_HOR_ECL(time, observer):
|
||||
The location of the horizontal observer.
|
||||
|
||||
Returns
|
||||
-------
|
||||
RotationMatrix
|
||||
A rotation matrix that converts HOR to ECL.
|
||||
-------
|
||||
"""
|
||||
rot = Rotation_ECL_HOR(time, observer)
|
||||
return InverseRotation(rot)
|
||||
|
||||
def Rotation_EQJ_GAL():
|
||||
"""Calculates a rotation matrix from equatorial J2000 (EQJ) to galactic (GAL).
|
||||
|
||||
This is one of the family of functions that returns a rotation matrix
|
||||
for converting from one orientation to another.
|
||||
Source: EQJ = equatorial system, using the equator at the J2000 epoch.
|
||||
Target: GAL = galactic system (IAU 1958 definition).
|
||||
|
||||
Returns
|
||||
-------
|
||||
RotationMatrix
|
||||
A rotation matrix that converts EQJ to GAL.
|
||||
"""
|
||||
# This rotation matrix was calculated by the following script
|
||||
# in this same source code repository:
|
||||
# demo/python/galeqj_matrix.py
|
||||
return RotationMatrix([
|
||||
[-0.0548624779711344, +0.4941095946388765, -0.8676668813529025],
|
||||
[-0.8734572784246782, -0.4447938112296831, -0.1980677870294097],
|
||||
[-0.4838000529948520, +0.7470034631630423, +0.4559861124470794]
|
||||
])
|
||||
|
||||
def Rotation_GAL_EQJ():
|
||||
"""Calculates a rotation matrix from galactic (GAL) to equatorial J2000 (EQJ).
|
||||
|
||||
This is one of the family of functions that returns a rotation matrix
|
||||
for converting from one orientation to another.
|
||||
Source: GAL = galactic system (IAU 1958 definition).
|
||||
Target: EQJ = equatorial system, using the equator at the J2000 epoch.
|
||||
|
||||
Returns
|
||||
-------
|
||||
RotationMatrix
|
||||
A rotation matrix that converts GAL to EQJ.
|
||||
"""
|
||||
# This rotation matrix was calculated by the following script
|
||||
# in this same source code repository:
|
||||
# demo/python/galeqj_matrix.py
|
||||
return RotationMatrix([
|
||||
[-0.0548624779711344, -0.8734572784246782, -0.4838000529948520],
|
||||
[+0.4941095946388765, -0.4447938112296831, +0.7470034631630423],
|
||||
[-0.8676668813529025, -0.1980677870294097, +0.4559861124470794]
|
||||
])
|
||||
|
||||
class ConstellationInfo:
|
||||
"""Reports the constellation that a given celestial point lies within.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user