[.NET] 有关日出日落的公式

楼主: newkoks (战斗工兵%)   2016-03-26 17:27:15
不知道有先进朋友有没有写过,日出日落类似的方程式,以下是我找到的类似文章,如果
有可以提供一下参考!谢谢...
这里提供一个简便的方法来计算日出与日没时间。为了说明方便,牺牲了计算的精密度。
用此方法计算日出与日没时间,大约会有4分钟以内的误差。
步骤一
定义日出时间的时角(Hour Angle)
Z=90? 实际的日出,但天色已微亮
Z=96? 民用的日出,一般为街道熄灯的参考时刻
Z=102? 航海用日出时间
Z=108? 天文用日出没时间,此时天空全黑
步骤二
修正时角
由于太阳有0.5度的视角,因此它的中心点位于地平下1/4度时即可看到,因此实际日出的
时角必须加以修正,Z=90.5?
此外因为大气折射的影响,在地平线下34'的位置,会让我们以为它正处于地平线的位置
。因此实际日出的时角必须再次加以修正,Z=91.067?
至于其它的选项则不需修正日出时间的时角。
步骤三
观测当日,太阳中午时刻的赤道经度与纬度 (α,δ) ( 请参考“太阳位置的计算”
网页)
观测者地理经纬度 (λ,ψ)
观测当日的均时差 E ( 计算方法可参考“时间”的网页 )
步骤四
τ=cos-1{ [ cos(Z)-sin(δ) sin(ψ)] / [ cos(ψ) cos(δ)] } /15
日没时间=12+τ+(Υ-λ)/15-E/60 (小时)
日出时间=日没时间+24-2τ
说明:Υ-λ之中的Υ是指地方时间的地理经度。例如台湾位于东经121?31'38'',Υ=1
20陛Aλ=121?31'38''。
范例
2000年9月1日的实际日出与日没时间?
步骤一
选择实际的日出 Z=90?
步骤二
修正时角
由于太阳有0.5度的视角,因此它的中心点位于地平下1/4度时即可看到,因此实际日出的
时角必须加以修正,Z=90.5?
此外因为大气折射的影响,在地平线下34'的位置,会让我们以为它正处于地平线的位置
。因此实际日出的时角必须再次加以修正,Z=91.067?
步骤三
观测当日,太阳中午时刻的赤道经度与纬度 (10h42m29s,8?10'59'')
观测者地理经纬度 (121?31'38'',25? 4'40'') ( 以台北为例 )
观测当日的均时差 E=-0.21分
步骤四
τ=cos-1{ [ cos(91.067?)-sin(8?10'59'') sin(25? 4'40'')] / [ cos(25? 4'40'')
cos(8?10'59'')] } /15
τ=6.267 hour
日没时间=18h10m
日出时间= 5h38m
说明:由于我们计算太阳的出没时刻是以当日中午的太阳位置为基础,事实上太阳与均时
差值无时无刻不在天球上移动,因此我们可以根据初次计算出来的时间,再次修正太阳的
实际位置,然后在依此方法重复计算。约三次的修正后,可以得到不错的精确度,时间误
差应该在分钟以内。结果如下:
日没时间=18h12m41s
日出时间= 5h34m42s
...................
Sunrise/Sunset Algorithm
Source:
Almanac for Computers, 1990
published by Nautical Almanac Office
United States Naval Observatory
Washington, DC 20392
Inputs:
day, month, year: date of sunrise/sunset
latitude, longitude: location for sunrise/sunset
zenith: Sun's zenith for sunrise/sunset
offical = 90 degrees 50'
civil = 96 degrees
nautical = 102 degrees
astronomical = 108 degrees
NOTE: longitude is positive for East and negative for West
NOTE: the algorithm assumes the use of a calculator with the
trig functions in "degree" (rather than "radian") mode. Most
programming languages assume radian arguments, requiring back
and forth convertions. The factor is 180/pi. So, for instance,
the equation RA = atan(0.91764 * tan(L)) would be coded as RA
= (180/pi)*atan(0.91764 * tan((pi/180)*L)) to give a degree
answer with a degree input for L.
1. first calculate the day of the year
N1 = floor(275 * month / 9)
N2 = floor((month + 9) / 12)
N3 = (1 + floor((year - 4 * floor(year / 4) + 2) / 3))
N = N1 - (N2 * N3) + day - 30
2. convert the longitude to hour value and calculate an approximate time
lngHour = longitude / 15
if rising time is desired:
t = N + ((6 - lngHour) / 24)
if setting time is desired:
t = N + ((18 - lngHour) / 24)
3. calculate the Sun's mean anomaly
M = (0.9856 * t) - 3.289
4. calculate the Sun's true longitude
L = M + (1.916 * sin(M)) + (0.020 * sin(2 * M)) + 282.634
NOTE: L potentially needs to be adjusted into the range [0,360) by adding/sub
tracting 360
5a. calculate the Sun's right ascension
RA = atan(0.91764 * tan(L))
NOTE: RA potentially needs to be adjusted into the range [0,360) by adding/su
btracting 360
5b. right ascension value needs to be in the same quadrant as L
Lquadrant = (floor( L/90)) * 90
RAquadrant = (floor(RA/90)) * 90
RA = RA + (Lquadrant - RAquadrant)
5c. right ascension value needs to be converted into hours
RA = RA / 15
6. calculate the Sun's declination
sinDec = 0.39782 * sin(L)
cosDec = cos(asin(sinDec))
7a. calculate the Sun's local hour angle
cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude))
if (cosH > 1)
the sun never rises on this location (on the specified date)
if (cosH < -1)
the sun never sets on this location (on the specified date)
7b. finish calculating H and convert into hours
if if rising time is desired:
H = 360 - acos(cosH)
if setting time is desired:
H = acos(cosH)
H = H / 15
8. calculate local mean time of rising/setting
T = H + RA - (0.06571 * t) - 6.622
9. adjust back to UTC
UT = T - lngHour
NOTE: UT potentially needs to be adjusted into the range [0,24) by adding/sub
tracting 24
10. convert UT value to local time zone of latitude/longitude
localT = UT + localOffset........
请输入专案类型(网站专案或者应用程式专案):
作者: MOONRAKER (㊣牛鹤鳗毛人)   2016-03-26 18:32:00
后面不就是方法了 你还有什么问题
楼主: newkoks (战斗工兵%)   2016-03-26 19:15:00
想问写法怎样写比较好
作者: peakhour   2016-03-27 01:21:00
或许你可找这本书: astronomical algorithms
作者: MOONRAKER (㊣牛鹤鳗毛人)   2016-03-27 01:29:00
最好的写法: 呼叫API不然硬干出来 客户问怎么跟气象局不一样电得你百口莫辩至于怎样写,他步骤不是都给了。
楼主: newkoks (战斗工兵%)   2016-03-27 09:07:00
谢谢先进的指导
作者: llzzyy01 (我是清流)   2016-04-02 19:29:00
这个问题是地球科学的领域了 超出程式问题了吧

Links booklink

Contact Us: admin [ a t ] ucptt.com