lunar

package
v0.0.0-...-17244d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChunFen int = iota
	QingMing
	GuYu
	LiXia
	XiaoMan
	MangZhong
	XiaZhi
	XiaoShu
	DaShu
	LiQiu
	ChuShu
	BaiLu
	QiuFen
	HanLu
	ShuangJiang
	LiDong
	XiaoXue
	DaXue
	DongZhi
	XiaoHan
	DaHan
	LiChun
	YuShui
	JingZhe
)

Variables

View Source
var (
	// 十二生肖
	Animals = []string{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"}
	// 天干
	Gan = []string{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}
	// 地支
	Zhi = []string{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}
)
View Source
var MoonLongitude = [60]MoonEclipticLongitudeCoeff{
	{0, 0, 1, 0, 6288744, -20905355},
	{2, 0, -1, 0, 1274027, -3699111},
	{2, 0, 0, 0, 658314, -2955968},
	{0, 0, 2, 0, 213618, -569925},
	{0, 1, 0, 0, -185116, 48888},
	{0, 0, 0, 2, -114332, -3149},
	{2, 0, -2, 0, 58793, 246158},
	{2, -1, -1, 0, 57066, -152138},
	{2, 0, 1, 0, 53322, -170733},
	{2, -1, 0, 0, 45758, -204586},
	{0, 1, -1, 0, -40923, -129620},
	{1, 0, 0, 0, -34720, 108743},
	{0, 1, 1, 0, -30383, 104755},
	{2, 0, 0, -2, 15327, 10321},
	{0, 0, 1, 2, -12528, 0},
	{0, 0, 1, -2, 10980, 79661},
	{4, 0, -1, 0, 10675, -34782},
	{0, 0, 3, 0, 10034, -23210},
	{4, 0, -2, 0, 8548, -21636},
	{2, 1, -1, 0, -7888, 24208},
	{2, 1, 0, 0, -6766, 30824},
	{1, 0, -1, 0, -5163, -8379},
	{1, 1, 0, 0, 4987, -16675},
	{2, -1, 1, 0, 4036, -12831},
	{2, 0, 2, 0, 3994, -10445},
	{4, 0, 0, 0, 3861, -11650},
	{2, 0, -3, 0, 3665, 14403},
	{0, 1, -2, 0, -2689, -7003},
	{2, 0, -1, 2, -2602, 0},
	{2, -1, -2, 0, 2390, 10056},
	{1, 0, 1, 0, -2348, 6322},
	{2, -2, 0, 0, 2236, -9884},
	{0, 1, 2, 0, -2120, 5751},
	{0, 2, 0, 0, -2069, 0},
	{2, -2, -1, 0, 2048, -4950},
	{2, 0, 1, -2, -1773, 4130},
	{2, 0, 0, 2, -1595, 0},
	{4, -1, -1, 0, 1215, -3958},
	{0, 0, 2, 2, -1110, 0},
	{3, 0, -1, 0, -892, 3258},
	{2, 1, 1, 0, -810, 2616},
	{4, -1, -2, 0, 759, -1897},
	{0, 2, -1, 0, -713, -2117},
	{2, 2, -1, 0, -700, 2354},
	{2, 1, -2, 0, 691, 0},
	{2, -1, 0, -2, 596, 0},
	{4, 0, 1, 0, 549, -1423},
	{0, 0, 4, 0, 537, -1117},
	{4, -1, 0, 0, 520, -1571},
	{1, 0, -2, 0, -487, -1739},
	{2, 1, 0, -2, -399, 0},
	{0, 0, 2, -2, -381, -4421},
	{1, 1, 1, 0, 351, 0},
	{3, 0, -2, 0, -340, 0},
	{4, 0, -3, 0, 330, 0},
	{2, -1, 2, 0, 327, 0},
	{0, 2, 1, 0, -323, 1165},
	{1, 1, -1, 0, 299, 0},
	{2, 0, 3, 0, 294, 0},
	{2, 0, -1, -2, 0, 8752},
}
月球黄经周期项(ΣI)及距离(Σr).
黄经单位:0.000001度,距离单位:0.001千米.

--------------------------------------------------

角度的组合系数  ΣI的各项振幅A  Σr的各项振幅A
D  M  M' F        (正弦振幅)       (余弦振幅)

--------------------------------------------------

View Source
var SolarTermNames = []string{
	"春分",
	"清明",
	"谷雨",
	"立夏",
	"小满",
	"芒种",
	"夏至",
	"小暑",
	"大暑",
	"立秋",
	"处暑",
	"白露",
	"秋分",
	"寒露",
	"霜降",
	"立冬",
	"小雪",
	"大雪",
	"冬至",
	"小寒",
	"大寒",
	"立春",
	"雨水",
	"惊蛰",
}

Functions

func CalcEarthLongitudeNutation

func CalcEarthLongitudeNutation(T float64) float64

计算某时刻的黄经章动干扰量 T 儒略世纪数 返回弧度

func CalcEarthObliquityNutation

func CalcEarthObliquityNutation(dt float64) float64

计算某时刻的黄赤交角章动干扰量 dt 是儒略世纪数 返回弧度

func CalcMoonECLongitudePeriodic

func CalcMoonECLongitudePeriodic(D, M, Mp, F, E float64) float64

计算月球地心黄经周期项的和

func CalcMoonLongitudePerturbation

func CalcMoonLongitudePerturbation(T, Lp, F float64) float64

计算金星摄动,木星摄动以及地球扁率摄动对月球地心黄经的影响, T 是儒略世纪数,Lp和F单位是弧度 A1 = 119.75 + 131.849 * T (4.13式) A2 = 53.09 + 479264.290 * T (4.14式) A3 = 313.45 + 481266.484 * T (4.15式)

func DmsToDegrees

func DmsToDegrees(degrees int, mintues int, seconds float64) float64

DmsToDegrees 把度分秒表示的角度换算成度

func DmsToRadians

func DmsToRadians(d int, m int, s float64) float64

DmsToRadians 把度分秒表示的角度换算成弧度(rad)

func DmsToSeconds

func DmsToSeconds(d int, m int, s float64) float64

DmsToSeconds 把度分秒表示的角度换算成角秒(arcsecond)

func GetDayGanZhi

func GetDayGanZhi(year, month, day int) string

GetDayGanZhi 计算日干支

func GetEarthB0

func GetEarthB0(t float64) float64

func GetEarthB1

func GetEarthB1(t float64) float64

func GetEarthB2

func GetEarthB2(t float64) float64

func GetEarthB3

func GetEarthB3(t float64) float64

func GetEarthB4

func GetEarthB4(t float64) float64

func GetEarthEclipticLongitudeForSun

func GetEarthEclipticLongitudeForSun(jd float64) float64

func GetEarthL0

func GetEarthL0(t float64) float64

func GetEarthL1

func GetEarthL1(t float64) float64

func GetEarthL2

func GetEarthL2(t float64) float64

func GetEarthL3

func GetEarthL3(t float64) float64

func GetEarthL4

func GetEarthL4(t float64) float64

func GetEarthL5

func GetEarthL5(t float64) float64

func GetEarthNutationParameter

func GetEarthNutationParameter(T float64) (D, M, Mp, F, Omega float64)

T 是 儒略世纪数 返回 弧度

func GetEarthR0

func GetEarthR0(t float64) float64

func GetEarthR1

func GetEarthR1(t float64) float64

func GetEarthR2

func GetEarthR2(t float64) float64

func GetEarthR3

func GetEarthR3(t float64) float64

func GetEarthR4

func GetEarthR4(t float64) float64

func GetEarthR5

func GetEarthR5(t float64) float64

func GetMoonEclipticLongitudeEC

func GetMoonEclipticLongitudeEC(jd float64) float64

计算月球地心黄经 jd 儒略日 返回 弧度

func GetMoonEclipticParameter

func GetMoonEclipticParameter(T float64) (Lp, D, M, Mp, F, E float64)

参数 T 儒略世纪数 返回 弧度

func GetSolarTermJD

func GetSolarTermJD(year, order int) float64

GetSolarTermJD 使用牛顿迭代法计算24节气的时间 f(x) = Vsop87dEarthUtil.getEarthEclipticLongitudeForSun(x) - angle = 0 year 年 order 节气序号 返回 节气的儒略日力学时间 TD

func GetSolarTermName

func GetSolarTermName(order int) string

GetSolarTermName 获取二十四节气名

func GetSunEclipticLatitudeForEarth

func GetSunEclipticLatitudeForEarth(jd float64) float64

func GetSunEclipticLongitudeForEarth

func GetSunEclipticLongitudeForEarth(jd float64) float64

func GetSunRadiusForEarth

func GetSunRadiusForEarth(jd float64) float64

*

  • 按照儒略日计算地球和太阳的距离 *
  • 参数 jd 儒略日
  • 返回 地球和太阳的距离,单位是天文单位(au)

func GetYearGanZhi

func GetYearGanZhi(year int) string

GetYearGanZhi 计算年份的干支

func GetYearZodiac

func GetYearZodiac(year int) string

GetYearZodiac 计算年份的生肖

func Mod2Pi

func Mod2Pi(r float64) float64

Mod2Pi 把角度限制在[0, 2π]之间

func ModPi

func ModPi(r float64) float64

ModPi 把角度限制在[-π, π]之间

func NewtonIteration

func NewtonIteration(f func(float64) float64, x0 float64) float64

NewtonIteration 牛顿迭代法求解方程的根

func SecondsToDegrees

func SecondsToDegrees(seconds float64) float64

SecondsToDegrees 把角秒换算成角度

func SecondsToRadians

func SecondsToRadians(seconds float64) float64

SecondsToRadians 把角秒换算成弧度

func ToDegrees

func ToDegrees(rad float64) float64

ToDegrees 弧度转换为角度

func ToRadians

func ToRadians(degrees float64) float64

ToRadians 角度转换为弧度

func Vsop2Fk5LongitudeCorrection

func Vsop2Fk5LongitudeCorrection(l float64, b float64, jd float64) float64

*

  • 用于把vsop87理论算出来的经度转换成fk5目视系统的经度的修正值,参考 Jean Meeus 的 Astronomical
  • Algorithms 第二版(1998)第32章219页(32.3)式 *
  • 参数 l
  • vsop87经度(rad)
  • 参数 b
  • vsop87纬度(rad)
  • 参数 jd
  • 儒略日
  • 返回 修正量(rad)

Types

type Calendar

type Calendar struct {
	Year           int            // 公历年份
	SolarTermJDs   *[25]float64   // 相关的 25 节气 北京时间 儒略日
	SolarTermTimes *[25]time.Time // 对应 SolarTermJDs 转换为 time.Time 的时间
	NewMoonJDs     *[15]float64   // 相关的 15 个朔日 北京时间 儒略日
	Months         []*Month       // 月
	// contains filtered or unexported fields
}

Calendar 保存公历年内计算农历所需的信息

func New

func New(year int) *Calendar

New 从缓存获取 Calendar 对象,没有则先创建

func (*Calendar) SolarDayToLunarDay

func (cc *Calendar) SolarDayToLunarDay(month, day int) *Day

SolarDayToLunarDay 指定年份内公历日期转换为农历日

type Day

type Day struct {
	Year      int    // 公历年
	Day       int    // 农历日
	Month     *Month // 农历月
	MonthZhi  int    // 农历日所在的月的地支
	SolarTerm int    // 0~23 二十四节气 ,-1 非节气
}

Day 保存农历日信息

func (*Day) DayName

func (d *Day) DayName() string

DayName 获取当天的农历日名

func (*Day) Festival

func (d *Day) Festival() string

Festival 获取当天的农历节日名 没有则返回空字符串

func (*Day) GanZhiMonth

func (d *Day) GanZhiMonth() string

GanZhiMonth 获取当天的月干支

func (*Day) MonthName

func (d *Day) MonthName() string

MonthName 获取当天的农历月名称

func (*Day) SolarTermName

func (d *Day) SolarTermName() string

SolarTermName 获取当天的二十四节气名 没有则返回空字符串

type Month

type Month struct {
	Name     int       // 农历月名
	Days     int       // 本月天数
	ShuoJD   float64   // 本月朔日时间 北京时间 儒略日
	ShuoTime time.Time // 本月朔日时间 北京时间
	IsLeap   bool      // 是否为闰月
}

Month 保存农历月信息

type MoonEclipticLongitudeCoeff

type MoonEclipticLongitudeCoeff struct {
	D   float64
	M   float64
	Mp  float64
	F   float64
	EiA float64
	ErA float64
}

月地心黄经系数

type NuationCoefficient

type NuationCoefficient struct {
	D       float64
	M       float64
	Mp      float64
	F       float64
	Omega   float64
	Sine1   float64
	Sine2   float64
	Cosine1 float64
	Cosine2 float64
}

天体章动系数类型变量

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL