SOFA Astronomical Calculation Module
SOFA Astronomical Calculation Module
Note: This document is AI-translated.
Module Overview
The SOFA module is the core astronomical calculation module in the ast project, implemented based on the SOFA (Standards of Fundamental Astronomy) library from the International Astronomical Union (IAU). This module provides a series of high-precision astronomical calculation functions for processing astronomical phenomena such as precession, nutation, and sidereal time.
The SOFA module has been adapted from the original SOFA library to seamlessly integrate with custom types in the ast project (such as TimePoint) and provides a more flexible extension mechanism.
Core Concepts
1. SOFA Library Introduction
The SOFA library is an authoritative astronomical algorithm library published by the International Astronomical Union (IAU), containing algorithms and programs that implement various astronomical standard models. The SOFA module is implemented based on SOFA library version 2023-10-11.
2. Time Systems
The SOFA module involves multiple time systems:
- TT (Terrestrial Time): Used for calculating long-term astronomical phenomena such as precession and nutation
- TDB (Barycentric Dynamical Time): Theoretically used for high-precision astronomical calculations
- UT1 (Universal Time): Used for calculating Earth rotation angle
3. Astronomical Standards
The SOFA module implements various IAU astronomical standards:
- IAU1976: Precession model
- IAU1980: Nutation model
- IERS1996: Nutation correction model
- IAU1982: Greenwich Mean Sidereal Time model
- IAU1994: Greenwich Apparent Sidereal Time model
- IAU2000: Earth Rotation Angle model
Main Features
1. Precession Calculation
aPrecession_IAU1976: Calculate precession angles according to IAU1976 specification
2. Nutation Calculation
aNutation_IAU1980: Calculate nutation angles according to IAU1980 specificationaNutation_IERS1996: Calculate nutation angles according to IERS1996 specificationaNutationFuncSet: Set custom nutation angle calculation functionaNutationMethodSet: Set nutation angle calculation method
3. Obliquity Calculation
aMeanObliquity_IAU1980: Calculate mean obliquity of the ecliptic
4. Sidereal Time Calculation
aGMST_IAU1982: Calculate Greenwich Mean Sidereal TimeaGAST_IAU1994: Calculate Greenwich Apparent Sidereal TimeaEquationOfEquinoxes_IAU1994: Calculate equation of equinoxes
5. Earth Rotation Calculation
aEarthRotationAngle_IAU2000: Calculate Earth Rotation Angle
Usage Examples
1. Precession Angle Calculation
#include "AstCore/SOFA.hpp"
#include "AstCore/TimePoint.hpp"
AST_USING_NAMESPACE
int main()
{
// 创建时间点
TimePoint tp = TimePoint::FromUTC(2026, 1, 1, 0, 0, 0);
// 计算岁差角
double zeta, z, theta;
aPrecession_IAU1976(tp, zeta, z, theta);
// 输出结果
printf("时间点: 2026-01-01 00:00:00 UTC\n");
printf("岁差角 zeta: %.9f 弧度\n", zeta);
printf("岁差角 z: %.9f 弧度\n", z);
printf("岁差角 theta: %.9f 弧度\n", theta);
return 0;
}2. Nutation Angle Calculation
#include "AstCore/SOFA.hpp"
#include "AstCore/TimePoint.hpp"
AST_USING_NAMESPACE
int main()
{
// 创建时间点
TimePoint tp = TimePoint::FromUTC(2026, 1, 1, 0, 0, 0);
// 计算章动角
double dpsi, deps;
aNutation(tp, dpsi, deps);
// 输出结果
printf("时间点: 2026-01-01 00:00:00 UTC\n");
printf("黄经章动角 dpsi: %.9f 弧度\n", dpsi);
printf("交角章动角 deps: %.9f 弧度\n", deps);
return 0;
}3. Greenwich Sidereal Time Calculation
#include "AstCore/SOFA.hpp"
#include "AstCore/TimePoint.hpp"
#include "AstCore/RunTime.hpp"
AST_USING_NAMESPACE
int main()
{
// 加载基础数据并初始化,需要EOP数据中的 UT1 - UTC
aInitialize();
// 创建时间点
TimePoint tp = TimePoint::FromUTC(2026, 1, 1, 0, 0, 0);
// 计算格林尼治平恒星时
double gmst = aGMST_IAU1982(tp);
// 计算格林尼治视恒星时
double gast = aGAST_IAU1994(tp);
// 计算地球自转角度
double era = aEarthRotationAngle_IAU2000(tp);
// 输出结果
printf("时间点: 2026-01-01 00:00:00 UTC\n");
printf("格林尼治平恒星时 (GMST): %.9f 弧度\n", gmst);
printf("格林尼治视恒星时 (GAST): %.9f 弧度\n", gast);
printf("地球自转角度 (ERA): %.9f 弧度\n", era);
// 清理资源
aUninitialize();
return 0;
}Dependencies
- AstCore/TimePoint.hpp: Time point type definition
- AstUtil/Constants.h: Physical constant definitions
- AstUtil/Logger.hpp: Logging functionality
Notes
- Time System Differences: Pay attention to distinguishing between different time systems such as TT, TDB, and UT1
- Precision Considerations: The SOFA module provides high-precision calculations, but certain approximate calculations (such as directly using TT instead of TDB) may affect precision in extreme cases
- Custom Implementation: You can set a custom nutation angle calculation function through
aNutationFuncSet, but need to ensure interface consistency - SOFA License: The SOFA module is derived from the SOFA library and must comply with SOFA software license terms
API Reference
Precession Calculation
aPrecession_IAU1976
void aPrecession_IAU1976(const TimePoint& tp, double& zeta, double& z, double& theta);Calculate precession angles for a given time point according to IAU1976 specification.
Parameters:
tp: Time pointzeta: Output zeta precession angle (radians)z: Output z precession angle (radians)theta: Output theta precession angle (radians)
Nutation Calculation
aNutation
NutationFunc aNutation;Nutation angle calculation function pointer, default pointing to aNutation_IAU1980.
aNutationFuncSet
void aNutationFuncSet(NutationFunc func);Set nutation angle calculation function pointer.
Parameters:
func: Custom nutation angle calculation function pointer
aNutationMethodSet
errc_t aNutationMethodSet(ENutationMethod method);Set nutation angle calculation method according to enum value.
Parameters:
method: Nutation calculation method enum value
Return Value:
- Error code, 0 for success
Obliquity Calculation
aMeanObliquity_IAU1980
double aMeanObliquity_IAU1980(const TimePoint& tp);Calculate mean obliquity of the ecliptic for a given time point according to IAU1980 specification.
Parameters:
tp: Time point
Return Value:
- Mean obliquity of the ecliptic (radians)
Sidereal Time Calculation
aGMST_IAU1982
double aGMST_IAU1982(const TimePoint& tp);Calculate Greenwich Mean Sidereal Time for a given time point according to IAU1982 specification.
Parameters:
tp: Time point
Return Value:
- Greenwich Mean Sidereal Time (radians)
aGAST_IAU1994
double aGAST_IAU1994(const TimePoint& tp);Calculate Greenwich Apparent Sidereal Time for a given time point according to IAU1994 specification.
Parameters:
tp: Time point
Return Value:
- Greenwich Apparent Sidereal Time (radians)
Earth Rotation Calculation
aEarthRotationAngle_IAU2000
double aEarthRotationAngle_IAU2000(const TimePoint& tp);Calculate Earth Rotation Angle for a given time point according to IAU2000 specification.
Parameters:
tp: Time point
Return Value:
- Earth Rotation Angle (radians)
Version History
- v1.0.0: Implemented based on SOFA library version 2023-10-11
- Initial version, including core functions for precession, nutation, sidereal time, etc.
License Statement
The SOFA module is derived from the SOFA library of the International Astronomical Union (IAU) and must comply with the SOFA software license terms. For details, please refer to the license statement in the source code files.