문제
는 방법이 있 C#을 계산하는 주어진 위도 경도할 때 태양을 설정하고 상승을 위한이 주어진 날?
다른 팁
이 게시물은 오래된하지만,경우에는 사람은 아직 보고...
CoordinateSharp 로 사용할 수 있 Nuget 패키지입니다.그것은 독립 packge 처리할 수 있는 태양뿐만 아니라 달의 시간.
Celestial cel = Celestial.CalculateCelestialTimes(85.57682, -70.75678, new DateTime(2017,8,21));
Console.WriteLine(cel.SunRise.Value.ToString());
참고:
가정 DateTimes 는 항상 UTC.
마지막으로,필요할 수 있습을 참조 천체에 해/달 .Condition
면 날짜는 null 을 반환합니다.이 발생합니다 태양은 up/down 습니다.
편집 1/9/2019
라이브러리가 크게 변경되었기 때문이다.그것은 처리할 수 있게 현지 시간뿐만 아니라.
Naa JavaScript와 C#을 사용하여 C# 에서이 라이브러리를 만들었습니다.
이 두 사이트에 대해 테스트했으며 사이트와 같은 시간을 보여줍니다.
이 API는 나에게 효과가있는 것 같습니다.
이에 대한 허용 된 답변은 JavaScript 구현으로 C#에서 계산을해야했기 때문에 응용 프로그램에 적합하지 않았습니다.
이 C# 코드를 사용했습니다. http://wiki.crowe.co.nz/calculate%20SUNRISE%2FSUNSET.ASHX, 여기에서 일출/일몰 시간에 대해 검증되었습니다. http://www.timeanddate.com/astronomy/.
내가 가장 가까운 1 분까지 1 초 동안 C# 구현의 일출 및 일몰 시간은 일광 절약 사례를 포함하여 TimeandDate.com에 표시되는 해당 값과 일치합니다. 코드는 약간 압도적이므로 (달 위상 데이터도 원하지 않는 한)이므로 지금은 제가 요구하는 바가 정확합니다.
이 정보로 시작하십시오.
나는 이것을 사용하여 여전히 제작중인 루비 스크립트를 Wright에 사용하고 있습니다. 나는 멀티 부문 Julian 날짜를 이해하는 데 어려움을 겪고 있습니다.
분명한 한 가지는 정확한 태양 통과 시간을 가야한다는 것입니다. 그런 다음 위도와 태양류를 기반으로하는 Semi_diurnal_arc = acos (cos_omega)를 빼고 추가하십시오. 오! 그리고 태양 광 센터와 지구 굴절을 포함하십시오. 이 지구는 꽤 마술사 인 것 같습니다.
VB.NET DOTSA의 답변의 VB.NET 버전으로 자동으로 시간을 결정할 수 있습니다.
출력 (오늘 저녁 일몰을 시청하여 확인) :
main.vb :
Module Main
Sub Main()
' http://www.timeanddate.com/sun/usa/seattle
' http://www.esrl.noaa.gov/gmd/grad/solcalc/
' Vessy, Switzerland
Dim latitude As Double = 46.17062
Dim longitude As Double = 6.161667
Dim dst As Boolean = True
Dim timehere As DateTime = DateTime.Now
Console.WriteLine("It is currently {0:HH:mm:ss} UTC", DateTime.UtcNow)
Console.WriteLine("The time here, at {0}°,{1}° is {2:HH:mm:ss}", latitude, longitude, timehere)
Dim local As TimeZoneInfo = TimeZoneInfo.Local
Dim zone As Integer = local.BaseUtcOffset().TotalHours
If local.SupportsDaylightSavingTime Then
Dim standard As String = local.StandardName
Dim daylight As String = local.DaylightName
dst = local.IsDaylightSavingTime(timehere)
Dim current As String = IIf(dst, daylight, standard)
Console.WriteLine("Daylight-saving time is supported here. Current offset {0:+0} hours, {1}", zone, current)
Else
Console.WriteLine("Daylight-saving time is not supported here")
End If
System.Console.WriteLine("Sunrise today {0}", Sunrises(latitude, longitude))
System.Console.WriteLine("Sunset today {0}", Sunsets(latitude, longitude))
System.Console.ReadLine()
End Sub
End Module
Sun.vb :
Public Module Sun
' Get sunrise time at latitude, longitude using local system timezone
Function Sunrises(latitude As Double, longitude As Double) As DateTime
Dim julian As Double = JulianDay(DateTime.Now)
Dim rises As Double = SunRiseUTC(julian, latitude, longitude)
Dim timehere As DateTime = DateTime.Now
Dim local As TimeZoneInfo = TimeZoneInfo.Local
Dim dst As Boolean = local.IsDaylightSavingTime(timehere)
Dim zone As Integer = local.BaseUtcOffset().TotalHours
Dim result As DateTime = getDateTime(rises, zone, timehere, dst)
Return result
End Function
' Get sunset time at latitude, longitude using local system timezone
Function Sunsets(latitude As Double, longitude As Double) As DateTime
Dim julian As Double = JulianDay(DateTime.Now)
Dim rises As Double = SunSetUTC(julian, latitude, longitude)
Dim timehere As DateTime = DateTime.Now
Dim local As TimeZoneInfo = TimeZoneInfo.Local
Dim dst As Boolean = local.IsDaylightSavingTime(timehere)
Dim zone As Integer = local.BaseUtcOffset().TotalHours
Dim result As DateTime = getDateTime(rises, zone, timehere, dst)
Return result
End Function
' Convert radian angle to degrees
Public Function Degrees(angleRad As Double) As Double
Return (180.0 * angleRad / Math.PI)
End Function
' Convert degree angle to radians
Public Function Radians(angleDeg As Double) As Double
Return (Math.PI * angleDeg / 180.0)
End Function
'* Name: JulianDay
'* Type: Function
'* Purpose: Julian day from calendar day
'* Arguments:
'* year : 4 digit year
'* month: January = 1
'* day : 1 - 31
'* Return value:
'* The Julian day corresponding to the date
'* Note:
'* Number is returned for start of day. Fractional days should be
'* added later.
Public Function JulianDay(year As Integer, month As Integer, day As Integer) As Double
If month <= 2 Then
year -= 1
month += 12
End If
Dim A As Double = Math.Floor(year / 100.0)
Dim B As Double = 2 - A + Math.Floor(A / 4)
Dim julian As Double = Math.Floor(365.25 * (year + 4716)) + Math.Floor(30.6001 * (month + 1)) + day + B - 1524.5
Return julian
End Function
Public Function JulianDay([date] As DateTime) As Double
Return JulianDay([date].Year, [date].Month, [date].Day)
End Function
'***********************************************************************/
'* Name: JulianCenturies
'* Type: Function
'* Purpose: convert Julian Day to centuries since J2000.0.
'* Arguments:
'* julian : the Julian Day to convert
'* Return value:
'* the T value corresponding to the Julian Day
'***********************************************************************/
Public Function JulianCenturies(julian As Double) As Double
Dim T As Double = (julian - 2451545.0) / 36525.0
Return T
End Function
'***********************************************************************/
'* Name: JulianDayFromJulianCentury
'* Type: Function
'* Purpose: convert centuries since J2000.0 to Julian Day.
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* the Julian Day corresponding to the t value
'***********************************************************************/
Public Function JulianDayFromJulianCentury(t As Double) As Double
Dim julian As Double = t * 36525.0 + 2451545.0
Return julian
End Function
'***********************************************************************/
'* Name: calGeomMeanLongSun
'* Type: Function
'* Purpose: calculate the Geometric Mean Longitude of the Sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* the Geometric Mean Longitude of the Sun in degrees
'***********************************************************************/
Public Function GemoetricMeanLongitude(t As Double) As Double
Dim L0 As Double = 280.46646 + t * (36000.76983 + 0.0003032 * t)
While L0 > 360.0
L0 -= 360.0
End While
While L0 < 0.0
L0 += 360.0
End While
Return L0
' in degrees
End Function
'***********************************************************************/
'* Name: calGeomAnomalySun
'* Type: Function
'* Purpose: calculate the Geometric Mean Anomaly of the Sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* the Geometric Mean Anomaly of the Sun in degrees
'***********************************************************************/
Public Function GemoetricMeanAnomaly(t As Double) As Double
Dim M As Double = 357.52911 + t * (35999.05029 - 0.0001537 * t)
Return M
' in degrees
End Function
'***********************************************************************/
'* Name: EarthOrbitEccentricity
'* Type: Function
'* Purpose: calculate the eccentricity of earth's orbit
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* the unitless eccentricity
'***********************************************************************/
Public Function EarthOrbitEccentricity(t As Double) As Double
Dim e As Double = 0.016708634 - t * (0.000042037 + 0.0000001267 * t)
Return e
' unitless
End Function
'***********************************************************************/
'* Name: SunCentre
'* Type: Function
'* Purpose: calculate the equation of center for the sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* in degrees
'***********************************************************************/
Public Function SunCentre(t As Double) As Double
Dim m As Double = GemoetricMeanAnomaly(t)
Dim mrad As Double = Radians(m)
Dim sinm As Double = Math.Sin(mrad)
Dim sin2m As Double = Math.Sin(mrad + mrad)
Dim sin3m As Double = Math.Sin(mrad + mrad + mrad)
Dim C As Double = sinm * (1.914602 - t * (0.004817 + 0.000014 * t)) + sin2m * (0.019993 - 0.000101 * t) + sin3m * 0.000289
Return C
' in degrees
End Function
'***********************************************************************/
'* Name: SunTrueLongitude
'* Type: Function
'* Purpose: calculate the true longitude of the sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* sun's true longitude in degrees
'***********************************************************************/
Public Function SunTrueLongitude(t As Double) As Double
Dim l0 As Double = GemoetricMeanLongitude(t)
Dim c As Double = SunCentre(t)
Dim O As Double = l0 + c
Return O
' in degrees
End Function
'***********************************************************************/
'* Name: SunTrueAnomaly
'* Type: Function
'* Purpose: calculate the true anamoly of the sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* sun's true anamoly in degrees
'***********************************************************************/
Public Function SunTrueAnomaly(t As Double) As Double
Dim m As Double = GemoetricMeanAnomaly(t)
Dim c As Double = SunCentre(t)
Dim v As Double = m + c
Return v
' in degrees
End Function
'***********************************************************************/
'* Name: SunDistanceAU
'* Type: Function
'* Purpose: calculate the distance to the sun in AU
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* sun radius vector in AUs
'***********************************************************************/
Public Function SunDistanceAU(t As Double) As Double
Dim v As Double = SunTrueAnomaly(t)
Dim e As Double = EarthOrbitEccentricity(t)
Dim R As Double = (1.000001018 * (1 - e * e)) / (1 + e * Math.Cos(Radians(v)))
Return R
' in AUs
End Function
'***********************************************************************/
'* Name: SunApparentLongitude
'* Type: Function
'* Purpose: calculate the apparent longitude of the sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* sun's apparent longitude in degrees
'***********************************************************************/
Public Function SunApparentLongitude(t As Double) As Double
Dim o As Double = SunTrueLongitude(t)
Dim omega As Double = 125.04 - 1934.136 * t
Dim lambda As Double = o - 0.00569 - 0.00478 * Math.Sin(Radians(omega))
Return lambda
' in degrees
End Function
'***********************************************************************/
'* Name: MeanObliquityOfEcliptic
'* Type: Function
'* Purpose: calculate the mean obliquity of the ecliptic
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* mean obliquity in degrees
'***********************************************************************/
Public Function MeanObliquityOfEcliptic(t As Double) As Double
Dim seconds As Double = 21.448 - t * (46.815 + t * (0.00059 - t * (0.001813)))
Dim e0 As Double = 23.0 + (26.0 + (seconds / 60.0)) / 60.0
Return e0
' in degrees
End Function
'***********************************************************************/
'* Name: calcObliquityCorrection
'* Type: Function
'* Purpose: calculate the corrected obliquity of the ecliptic
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* corrected obliquity in degrees
'***********************************************************************/
Public Function calcObliquityCorrection(t As Double) As Double
Dim e0 As Double = MeanObliquityOfEcliptic(t)
Dim omega As Double = 125.04 - 1934.136 * t
Dim e As Double = e0 + 0.00256 * Math.Cos(Radians(omega))
Return e
' in degrees
End Function
'***********************************************************************/
'* Name: SunRightAscension
'* Type: Function
'* Purpose: calculate the right ascension of the sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* sun's right ascension in degrees
'***********************************************************************/
Public Function SunRightAscension(t As Double) As Double
Dim e As Double = calcObliquityCorrection(t)
Dim lambda As Double = SunApparentLongitude(t)
Dim tananum As Double = (Math.Cos(Radians(e)) * Math.Sin(Radians(lambda)))
Dim tanadenom As Double = (Math.Cos(Radians(lambda)))
Dim alpha As Double = Degrees(Math.Atan2(tananum, tanadenom))
Return alpha
' in degrees
End Function
'***********************************************************************/
'* Name: SunDeclination
'* Type: Function
'* Purpose: calculate the declination of the sun
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* sun's declination in degrees
'***********************************************************************/
Public Function SunDeclination(t As Double) As Double
Dim e As Double = calcObliquityCorrection(t)
Dim lambda As Double = SunApparentLongitude(t)
Dim sint As Double = Math.Sin(Radians(e)) * Math.Sin(Radians(lambda))
Dim theta As Double = Degrees(Math.Asin(sint))
Return theta
' in degrees
End Function
'***********************************************************************/
'* Name: TrueSolarToMeanSolar
'* Type: Function
'* Purpose: calculate the difference between true solar time and mean
'* solar time
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* Return value:
'* equation of time in minutes of time
'***********************************************************************/
Public Function TrueSolarToMeanSolar(t As Double) As Double
Dim epsilon As Double = calcObliquityCorrection(t)
Dim l0 As Double = GemoetricMeanLongitude(t)
Dim e As Double = EarthOrbitEccentricity(t)
Dim m As Double = GemoetricMeanAnomaly(t)
Dim y As Double = Math.Tan(Radians(epsilon) / 2.0)
y *= y
Dim sin2l0 As Double = Math.Sin(2.0 * Radians(l0))
Dim sinm As Double = Math.Sin(Radians(m))
Dim cos2l0 As Double = Math.Cos(2.0 * Radians(l0))
Dim sin4l0 As Double = Math.Sin(4.0 * Radians(l0))
Dim sin2m As Double = Math.Sin(2.0 * Radians(m))
Dim Etime As Double = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0 - 0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m
Return Degrees(Etime) * 4.0
' in minutes of time
End Function
'***********************************************************************/
'* Name: SunriseHourAngle
'* Type: Function
'* Purpose: calculate the hour angle of the sun at sunrise for the
'* latitude
'* Arguments:
'* lat : latitude of observer in degrees
'* solarDec : declination angle of sun in degrees
'* Return value:
'* hour angle of sunrise in radians
'***********************************************************************/
Public Function SunriseHourAngle(lat As Double, solarDec As Double) As Double
Dim latRad As Double = Radians(lat)
Dim sdRad As Double = Radians(solarDec)
Dim HAarg As Double = (Math.Cos(Radians(90.833)) / (Math.Cos(latRad) * Math.Cos(sdRad)) - Math.Tan(latRad) * Math.Tan(sdRad))
Dim HA As Double = (Math.Acos(Math.Cos(Radians(90.833)) / (Math.Cos(latRad) * Math.Cos(sdRad)) - Math.Tan(latRad) * Math.Tan(sdRad)))
Return HA
' in radians
End Function
'***********************************************************************/
'* Name: SunsetHourAngle
'* Type: Function
'* Purpose: calculate the hour angle of the sun at sunset for the
'* latitude
'* Arguments:
'* lat : latitude of observer in degrees
'* solarDec : declination angle of sun in degrees
'* Return value:
'* hour angle of sunset in radians
'***********************************************************************/
Public Function SunsetHourAngle(lat As Double, solarDec As Double) As Double
Dim latRad As Double = Radians(lat)
Dim sdRad As Double = Radians(solarDec)
Dim HAarg As Double = (Math.Cos(Radians(90.833)) / (Math.Cos(latRad) * Math.Cos(sdRad)) - Math.Tan(latRad) * Math.Tan(sdRad))
Dim HA As Double = (Math.Acos(Math.Cos(Radians(90.833)) / (Math.Cos(latRad) * Math.Cos(sdRad)) - Math.Tan(latRad) * Math.Tan(sdRad)))
Return -HA
' in radians
End Function
'***********************************************************************/
'* Name: SunRiseUTC
'* Type: Function
'* Purpose: calculate the Universal Coordinated Time (UTC) of sunrise
'* for the given day at the given location on earth
'* Arguments:
'* julian : julian day
'* latitude : latitude of observer in degrees
'* longitude : longitude of observer in degrees
'* Return value:
'* time in minutes from zero Z
'***********************************************************************/
'Public Function SunRiseUTC(julian As Double, latitude As Double, longitude As Double) As Double
' Dim t As Double = JulianCenturies(julian)
' ' *** Find the time of solar noon at the location, and use
' ' that declination. This is better than start of the
' ' Julian day
' Dim noonmin As Double = SolarNoonUTC(t, longitude)
' Dim tnoon As Double = JulianCenturies(julian + noonmin / 1440.0)
' ' *** First pass to approximate sunrise (using solar noon)
' Dim eqTime As Double = TrueSolarToMeanSolar(tnoon)
' Dim solarDec As Double = SunDeclination(tnoon)
' Dim hourAngle As Double = SunriseHourAngle(latitude, solarDec)
' Dim delta As Double = longitude - Degrees(hourAngle)
' Dim timeDiff As Double = 4 * delta
' ' in minutes of time
' Dim timeUTC As Double = 720 + timeDiff - eqTime
' ' in minutes
' ' alert("eqTime = " + eqTime + "\nsolarDec = " + solarDec + "\ntimeUTC = " + timeUTC);
' ' *** Second pass includes fractional julianay in gamma calc
' Dim newt As Double = JulianCenturies(JulianDayFromJulianCentury(t) + timeUTC / 1440.0)
' eqTime = TrueSolarToMeanSolar(newt)
' solarDec = SunDeclination(newt)
' hourAngle = SunriseHourAngle(latitude, solarDec)
' delta = longitude - Degrees(hourAngle)
' timeDiff = 4 * delta
' timeUTC = 720 + timeDiff - eqTime
' ' in minutes
' ' alert("eqTime = " + eqTime + "\nsolarDec = " + solarDec + "\ntimeUTC = " + timeUTC);
' Return timeUTC
'End Function
'***********************************************************************/
'* Name: SolarNoonUTC
'* Type: Function
'* Purpose: calculate the Universal Coordinated Time (UTC) of solar
'* noon for the given day at the given location on earth
'* Arguments:
'* t : number of Julian centuries since J2000.0
'* longitude : longitude of observer in degrees
'* Return value:
'* time in minutes from zero Z
'***********************************************************************/
Public Function SolarNoonUTC(t As Double, longitude As Double) As Double
' First pass uses approximate solar noon to calculate eqtime
Dim tnoon As Double = JulianCenturies(JulianDayFromJulianCentury(t) + longitude / 360.0)
Dim eqTime As Double = TrueSolarToMeanSolar(tnoon)
Dim solNoonUTC As Double = 720 + (longitude * 4) - eqTime
' min
Dim newt As Double = JulianCenturies(JulianDayFromJulianCentury(t) - 0.5 + solNoonUTC / 1440.0)
eqTime = TrueSolarToMeanSolar(newt)
' double solarNoonDec = SunDeclination(newt);
solNoonUTC = 720 + (longitude * 4) - eqTime
' min
Return solNoonUTC
End Function
'***********************************************************************/
'* Name: SunSetUTC
'* Type: Function
'* Purpose: calculate the Universal Coordinated Time (UTC) of sunset
'* for the given day at the given location on earth
'* Arguments:
'* julian : julian day
'* latitude : latitude of observer in degrees
'* longitude : longitude of observer in degrees
'* Return value:
'* time in minutes from zero Z
'***********************************************************************/
Public Function SunSetUTC(julian As Double, latitude As Double, longitude As Double) As Double
Dim t = JulianCenturies(julian)
Dim eqTime = TrueSolarToMeanSolar(t)
Dim solarDec = SunDeclination(t)
Dim hourAngle = SunriseHourAngle(latitude, solarDec)
hourAngle = -hourAngle
Dim delta = longitude + Degrees(hourAngle)
Dim timeUTC = 720 - (4.0 * delta) - eqTime
' in minutes
Return timeUTC
End Function
Public Function SunRiseUTC(julian As Double, latitude As Double, longitude As Double) As Double
Dim t = JulianCenturies(julian)
Dim eqTime = TrueSolarToMeanSolar(t)
Dim solarDec = SunDeclination(t)
Dim hourAngle = SunriseHourAngle(latitude, solarDec)
Dim delta = longitude + Degrees(hourAngle)
Dim timeUTC = 720 - (4.0 * delta) - eqTime
' in minutes
Return timeUTC
End Function
Public Function getTimeString(time As Double, timezone As Integer, julian As Double, dst As Boolean) As String
Dim timeLocal = time + (timezone * 60.0)
Dim riseT = JulianCenturies(julian + time / 1440.0)
timeLocal += (If((dst), 60.0, 0.0))
Return getTimeString(timeLocal)
End Function
Public Function getDateTime(time As Double, timezone As Integer, [date] As DateTime, dst As Boolean) As System.Nullable(Of DateTime)
Dim julian As Double = JulianDay([date])
Dim timeLocal = time + (timezone * 60.0)
Dim riseT = JulianCenturies(julian + time / 1440.0)
timeLocal += (If((dst), 60.0, 0.0))
Return getDateTime(timeLocal, [date])
End Function
Private Function getTimeString(minutes As Double) As String
Dim output As String = ""
If (minutes >= 0) AndAlso (minutes < 1440) Then
Dim floatHour = minutes / 60.0
Dim hour = Math.Floor(floatHour)
Dim floatMinute = 60.0 * (floatHour - Math.Floor(floatHour))
Dim minute = Math.Floor(floatMinute)
Dim floatSec = 60.0 * (floatMinute - Math.Floor(floatMinute))
Dim second = Math.Floor(floatSec + 0.5)
If second > 59 Then
second = 0
minute += 1
End If
If (second >= 30) Then
minute += 1
End If
If minute > 59 Then
minute = 0
hour += 1
End If
output = [String].Format("{0:00}:{1:00}", hour, minute)
Else
Return "error"
End If
Return output
End Function
Private Function getDateTime(minutes As Double, [date] As DateTime) As System.Nullable(Of DateTime)
Dim retVal As System.Nullable(Of DateTime) = Nothing
If (minutes >= 0) AndAlso (minutes < 1440) Then
Dim floatHour = minutes / 60.0
Dim hour = Math.Floor(floatHour)
Dim floatMinute = 60.0 * (floatHour - Math.Floor(floatHour))
Dim minute = Math.Floor(floatMinute)
Dim floatSec = 60.0 * (floatMinute - Math.Floor(floatMinute))
Dim second = Math.Floor(floatSec + 0.5)
If second > 59 Then
second = 0
minute += 1
End If
If (second >= 30) Then
minute += 1
End If
If minute > 59 Then
minute = 0
hour += 1
End If
Return New DateTime([date].Year, [date].Month, [date].Day, CInt(hour), CInt(minute), CInt(second))
Else
Return retVal
End If
End Function
End Module
이를 위해 빠른 파이썬 스크립트를 만들었습니다. SunrisesUnsetCalculator
나는 아직 수업 안에 그것을 감싸지 않았지만 다른 사람들에게 유용 할 수 있습니다.
편집 : 오픈 소스는 대단합니다. 기본 스크립트를 커밋하기 때문에 누군가가 모듈로 싸서 다른 하나는 CLI 인터페이스를 추가했습니다! Mbideau와 Nfischer에게 감사의 말을 전합니다!
태양 주위의 지구 문 시스템의 편심 궤도를 허용하는 시간 방정식을 포함하는 공식이 필요합니다. WGS84 또는 NAD27과 같은 적절한 데이텀 포인트와 함께 좌표를 사용해야합니다. 당신은 줄리안 달력을 사용해야하며, 우리가 매일 사용하는 것은이 시간을 올바르게 얻기 위해 매일 사용하는 것이 아닙니다. 잠시 안에 추측하는 것은 쉬운 일이 아닙니다. Id는 그림자 길이가 어느 높이와 같은 내 위치에 시간을 갖고 싶어합니다. 이것은 정오 정오 전후에 태양이 수평선 위로 60도 높아지면 하루에 두 번 발생해야합니다. 또한, 내가 이해하는 한, 당신은 합리적 시간을 얻기 위해 연간 하루에 정확히 하루를 추가하면됩니다. 따라서 시계 주파수를 늘리면 x 366.25/365.25를 늘리면 이제 토목 시계 대신 냉담한 시계가있을 수 있습니까 ??? "수학은 강력한 사람이 우주를 쓴 언어입니다."
또 다른 좋은 JS 구현은입니다 선언.
코드 라인의 수는 관리 가능하므로 다른 언어 (C#)로 포팅 할 수 있습니다.
외부 서비스를 선호하는 경우이 멋지고 무료 일출 및 일몰 시간 API를 사용할 수 있습니다. http://sunrise-sunset.org/api
여러 프로젝트에 사용해 왔으며 매우 잘 작동하며 데이터는 매우 정확한 것 같습니다. HTTP를 받으십시오 http://api.sunrise-sunset.org/json
허용 된 매개 변수 :
- LAT : 소수도의 위도. 필수의.
- LNG : 소수도의 경도. 필수의.
- 날짜 : yyyy-mm-dd 형식의 날짜. 또한 다른 날짜 형식 및 상대 날짜 형식도 허용합니다. 존재하지 않으면 날짜 기본값은 현재 날짜입니다. 선택 과목.
- 콜백 : JSONP 응답의 콜백 함수 이름. 선택 과목.
- 형식 : 0 또는 1 (1은 기본값)입니다. 응답의 시간 값은 ISO 8601에 따라 표현되며 Day_length는 초 안에 표현됩니다. 선택 과목.
응답에는 일출 및 일몰 시간과 황혼 시간이 포함됩니다.
UWP 에서이 NUGET 패키지를 테스트했습니다.
https://www.nuget.org/packages/solarcalculator/
문서는 약간 스케치이며 여기에 있습니다.
https://github.com/porrey/solar-calculator
이것을 사용하여 일출을 얻을 수 있습니다.
la = 위도; 그리고 lo = 경도; 당신의 지역 :
SolarTimes solarTimes = new SolarTimes(DateTime.Now, la, lo);
DateTime sr = solarTimes.Sunrise;
DateTime dt = Convert.ToDateTime(sr);
textblockb.Text = dt.ToString("h:mm:ss");
PM 관리자를 사용하여 Visual Studio에 설치할 수 있습니다.
Install-Package SolarCalculator -Version 2.0.2
또는 "Nuget 패키지 관리"Visual Studio 라이브러리에서 태양 계산기를 찾아.
예 종료하는 몇 가지 있습니다.
몇 가지의 링크에 대한 패턴이 있습니다.
http://williams.best.vwh.net/sunrise_sunset_example.htm
http://www.codeproject.com/Articles/29306/C-Class-for-Calculating-Sunrise-and-Sunset-Times
https://gist.github.com/cstrahan/767532
http://pointofint.blogspot.com/2014/06/sunrise-and-sunset-in-c.html
http://yaddb.blogspot.com/2013/01/how-to-calculate-sunrise-and-sunset.html
https://forums.asp.net/t/1810934.aspx?Sunrise+and+Sunset+timings+Calculation+
http://www.ip2location.com/tutorials/display-sunrise-sunset-time-using-csharp-and-mysql-database
http://en.pudn.com/downloads270/sourcecode/windows/csharp/detail1235934_en.html
http://regator.com/p/25716249/c_class_for_calculating_sunrise_and_sunset_times
http://forums.xkcd.com/viewtopic.php?t=102253
http://www.redrok.com/solar_position_algorithm.pdf
http://sidstation.loudet.org/sunazimuth-en.xhtml
https://sourceforge.net/directory/os:windows/?q=sunrise/set%20times
https://www.nuget.org/packages/SolarCalculator/
http://www.grasshopper3d.com/forum/topics/solar-calculation-plugin
이 프로젝트는 내가 한 행성의 소스 코드에 오래 전에 하지만 다행히 저는 다른 곳에서 그것 때문에는 사이트로 데이터가 손실됩니다.
https://github.com/DouglasAllen/SunTimes.VSCS.Net
사이 Gist plus
https://gist.github.com/DouglasAllen/c682e4c412a0b9d8f536b014c1766f20
이를 위해 간략한 설명의 기술이다.
첫째로 어떤 일에 대한 필요 진정한 태양 전지 정오 또는 대중 교통에 대한 귀하의 위치에 있습니다.
는 계정으로 로컬 경도.그것으로 변환될 수 있습니다 시간에 의해 나누어에 의해 15.
는 시간이 얼마나 나중에 당신은에서 Zulu 지역 또는 시간 제도 경도.
에서 시작 12:00PM 또는 정오.
과에서 당신의 시간에서 계산됩니다.
이제 어려운 부분입니다.당신은 방법이 필요를 계산하는 방정식의 시간입니다.
그 시간 차이에 의해 발생 땅을 기울기와 궤도 주변니다.
이 아이디어를 줄 것이다... https://en.wikipedia.org/wiki/Equation_of_time
하지만 그들은 있는 수식은 매우 쉽다.... https://en.wikipedia.org/wiki/Sunrise_equation
이 사람은 어떤 책을 많은 사람들에 의해 이동하거나입니다.:-D https://en.wikipedia.org/wiki/Jean_Meeus
사용의 처음 계산을 위한 당신의 것을 의미 태양한 교통과 계산 JDN... https://en.wikipedia.org/wiki/Julian_day
이에 의해 사용되는 모든 각도의 수식으로 시간에는 줄리안 세기에 https://en.wikipedia.org/wiki/Julian_year_(천문학)
https://en.wikipedia.org/wiki/Epoch_(천문학)
그것은 기본적으로 귀하의 JDN epoch 마이너스 등으로 J2000 또는 2451545.0 모든 나누 36525.0 당신에게 줄리안 세기 또는 t 는 대부분을 사용하는 공식이 있 t 을 매개 변수로 사용할 수 있습니다.때때로 줄리안은 천년이 사용됩니다.이 경우에는 그것의 3652500.0
트릭은 사람들을 찾아 각도는 수식을 해결하는 데 도움이 방정식의 시간입니다.
다음 당신은 당신의 진정한 태양한 교통과 빼는 반나절 또는 추가 절반이 하루의 햇빛에 대한 귀하의 위치에 있습니다.당신이 찾아 주위 사람들에 대한 답변 및 소프트웨어입니다.
일단 당신이 무언가가는 당신은 그것을 확인할 수 있습니다에 대하여 검색이 시간 또는 온라인 계산기.
이는 충분히 당신을 얻을 것이다.라이브러리가 있지만 그것을 이해하는 것은 어렵지 않아 당신의 자신을 만든다.았지만 그에 Ruby.그것을 증명할 수 있는 유용합니다....https://github.com/DouglasAllen/gem-equationoftime
행운을 빕니다!