Quyoshning pozitsiyasi, vaqt tengligi: 27 KUNDALIK

Men AQSh dengizdagi observatoriyaning quyoshning joylashishini aniqlash uchun algoritmini yaxshilashga harakat qilmoqdaman ni ishlatib, barcha raqamlar to'g'ri aniqlanganligini oddiy tarzda yozib, oddiy odamlar uni ham tushunishlari mumkin.

Biroq, bir xil tarzda, vaqt tengligi 27 kun yopiq. Ehtimol, kimdir bu erda noto'g'ri narsani ko'rishi mumkin?

Viktorina jarayoni:

1) Failure:
test_equation_of_time(TestSolarCalculations):
Expected 2011-10-01 10:23:00 UTC, not 2011-10-28 10:59:31 UTC.

2) Failure:
test_suns_declination(TestSolarCalculations):
Expected -3.18, not -3.2087920449753007.

Yangi algoritm:

# Constants for J2000.0/1 Jan 2000 12:00Z:
#
EPOCHS_JULIAN_DATE = 2451545
ANOMALISTIC_YEAR_IN_DAYS = 365.259636
TROPICAL_YEAR_IN_DAYS = 365.2421897
SUNS_MEAN_ANOMALY_AT_EPOCH = degrees_to_radians 357.5291
SUNS_MEAN_LONGITUDE_AT_EPOCH = degrees_to_radians 280.459
SUNS_GEODETIC_PRECESSION = degrees_to_radians 1.915
EARTHS_ORBITAL_ECCENTRICITY = 0.020
EARTHS_ADJUSTED_AVERAGE_RADIUS_IN_AU = 1.00014
EARTHS_APPROXIMATE_ATMOSPHERIC_REFRACTION = degrees_to_radians 0.01671
EARTHS_ECLIPTIC_MEAN_OBLIQUITY = degrees_to_radians 23.439
EARTHS_ECLIPTIC_OBLIQUITY_CHANGE_RATE = degrees_to_radians 0.00000036

def days_from_epoch
  @todays_julian_date - EPOCHS_JULIAN_DATE
end

def suns_daily_mean_anomaly_change_rate
  degrees_to_radians(360/ANOMALISTIC_YEAR_IN_DAYS)
end

def suns_mean_anomaly
  SUNS_MEAN_ANOMALY_AT_EPOCH + suns_daily_mean_anomaly_change_rate * days_from_epoch
end

def suns_daily_mean_longitude_change_rate
  degrees_to_radians(360/TROPICAL_YEAR_IN_DAYS)
end

def suns_mean_longitude
  SUNS_MEAN_LONGITUDE_AT_EPOCH + suns_daily_mean_longitude_change_rate * days_from_epoch
end

def suns_apparent_ecliptic_longitude
  suns_mean_longitude + SUNS_GEODETIC_PRECESSION * sin(suns_mean_anomaly) + EARTHS_ORBITAL_ECCENTRICITY * sin(2 * suns_mean_anomaly)
end

def suns_distance_from_earth_in_au
  EARTHS_ADJUSTED_AVERAGE_RADIUS_IN_AU - EARTHS_APPROXIMATE_ATMOSPHERIC_REFRACTION * cos(suns_mean_anomaly) - (EARTHS_APPROXIMATE_ATMOSPHERIC_REFRACTION ^ 2/2) * cos(2 * suns_mean_anomaly)
end

def earths_ecliptic_mean_obliquity
  EARTHS_ECLIPTIC_MEAN_OBLIQUITY - EARTHS_ECLIPTIC_OBLIQUITY_CHANGE_RATE * days_from_epoch
end

def suns_right_ascension
  atan2(cos(suns_apparent_ecliptic_longitude) * sin(suns_apparent_ecliptic_longitude), cos(suns_apparent_ecliptic_longitude))/15
end

# Time.utc(Time.now.year) => 2011-01-01 00:00:00 UTC
#
def equation_of_time
  Time.utc(Time.now.year) + (radians_to_degrees(suns_mean_longitude)/15 - suns_right_ascension) * 60 * 60 * 24
end

def suns_declination
  radians_to_degrees(asin(sin(earths_ecliptic_mean_obliquity) * sin(suns_apparent_ecliptic_longitude)))
end

Rahmat!

Mats

1
Eski kodni chop qila olasizmi, (menimcha) ishlaydi?
qo'shib qo'ydi muallif Beta, manba
@ ja72: ruby kabi ko'rinadi.
qo'shib qo'ydi muallif Mechanical snail, manba
Iltimos, ishlatiladigan tilni belgilang va codereview.stackexchange.com ga o'tishni ko'rib chiqing.
qo'shib qo'ydi muallif ja72, manba
@ ja72 kodlashni ko'rish ishlaydigan kodi uchun emas, balki emasmi?
qo'shib qo'ydi muallif AakashM, manba
Sizning kodingiz biroz aralashgan deb hisoblayman: erlarning eksantrikligi qiymati 0.01671 (Vikipediyani ko'ring). Siz bu qiymatni atmosfera sinishi uchun aniq foydalanasiz va uni radyanlardan radionlarga aylantirmoqdasiz. Bu bema'nilik.
qo'shib qo'ydi muallif Curd, manba
@ ja72: Bu, aslida, Rubyga tegishli savol emas.
qo'shib qo'ydi muallif Molvær, manba

3 javoblar

Ba'zi kodlarim.

# From angles.rb:
# eccentricity of elliptical Earth orbit around Sun # Horner calculation method def eccentricity_Earth( ta = A2000 ) ta = check_jct_zero( ta ) # 0.016708617 - ta[ 0 ] * ( 0.000042037 + ta[ 0 ] * 0.0000001235 ) [-0.0000001235, -0.000042037, 0.016708617].inject(0.0) {|p, a| p * ta[0] + a} end alias_method :eccentricity_earth_orbit, :eccentricity_Earth

From: Equation of Time ruby gem

Qaerda ishlatiladi?

# From angles.rb:
# equation of centre # added to mean anomaly to get true anomaly. def center( ta = A2000) ta = check_jct_zero( ta ) sine_1M = sin( 1.0 * deg_to_rad( @ma ) ) sine_2M = sin( 2.0 * deg_to_rad( @ma ) ) sine_3M = sin( 3.0 * deg_to_rad( @ma ) ) sine_4M = sin( 4.0 * deg_to_rad( @ma ) ) sine_5M = sin( 5.0 * deg_to_rad( @ma ) ) e = eccentricity_Earth( ta ) rad_to_deg( sine_1M * ( 2.0 * e - e**3/4.0 + 5/96.0 * e**5 ) + sine_2M * ( 5/4.0 * e**2 - 11/24.0 * e**4 ) + sine_3M * ( 13/12.0 * e**3 - 43/64.0 * e**5 ) + sine_4M * 103/96.0 * e**4 + sine_5M * 1097/960.0 * e**5 ) # sine_1M *( 1.914602 - ta[ 0 ] * ( 0.004817 + ta[ 0 ] * 0.000014 )) + # sine_2M *( 0.019993 - ta[ 0 ] * 0.000101 ) + # sine_3M * 0.000289 end alias_method :equation_of_center, :center
1
qo'shib qo'ydi

Bu yerda:

def suns_apparent_ecliptic_longitude
  suns_mean_longitude 
  + SUNS_GEODETIC_PRECESSION * sin(suns_mean_anomaly) 
  + EARTHS_ORBITAL_ECCENTRICITY * sin(2 * suns_mean_anomaly)
end

siz aralashmalarni qidirasiz. suns_mean_longitude - SUNS_GEODETIC_PRECESSION kabi radyanlar (va shuning uchun ikkinchi muddat), lekin EARTHS_ORBITAL_ECCENTRICITY - 0.020 kuchli> darajalar .

Bundan tashqari:

EARTHS_APPROXIMATE_ATMOSPHERIC_REFRACTION = degrees_to_radians 0.01671

faqat bo'lishi kerak

EARTHS_APPROXIMATE_ATMOSPHERIC_REFRACTION = 0.01671

Menimcha, bu masofa ni belgilaydigan formulada qo'llanilgan.

Bundan tashqari,

def suns_right_ascension
  atan2(cos(suns_apparent_ecliptic_longitude) * sin(suns_apparent_ecliptic_longitude), cos(suns_apparent_ecliptic_longitude))/15
end

Men bu kodni tekshirganim yo'q atan2 funktsiyasi - siz 15 darajaga bo'linish uchun bo'ladigan daraja ekanligiga ishonchingiz komilmi?

Boshqa muammolar ham bo'lishi mumkin; bular faqat men ko'rgan narsalar.

1
qo'shib qo'ydi
To'g'ri! ruby-doc.org/core-1.9.3/Math.html#method-c-atan2 Qaytish oralig'i PI qiymatlari sifatida ifoda etilganida, ular radyanlarda ekanligiga ishonch hosil qiling. Quyidagi formulani qo'llashni o'ylab ko'ring y0 = sine_al_Sun (ta) * cosine_to_Earth (ta) al suns_apparent_ecliptic_longitude va uzunlik emas, balki haqiqiy uzunligi hisoblanadi. Bu osmon shoxiga nisbatan Erlarning burchagi. 180.0 + rad_to_deg (atan2 (-y0, -cosine_al_Sun (ta))) Bu qaytish qiymatini to'g'ri oraliqda saqlashga yordam beradi. U kishi aytganidek, apelsin bilan olma aralashtirmang. deg rad
qo'shib qo'ydi muallif Douglas G. Allen, manba

May be it is an issue with the precision of ruby floating point numbers, not an issue with your program's logic? I haven't used ruby, but it seems there are some issues in ruby floating point operations exists according to thisposts. Issue with precision of ruby math operations

Xabarga ko'ra, suzuvchi nuqta operatsiyalari uchun BigDecimal sinfidan foydalanishingiz mumkin. Men sizning dasturingizdan o'tmagan edim, bu faqat taxmin.

0
qo'shib qo'ydi
Matematiklar
Matematiklar
633 ishtirokchilar

Kanalga obuna buling @Matematikak Masala va misollar yechimlari uchun guruh Guruhda faqat matematikaga oid ma'lumot bo'lishi shart.

MATEMATIKA GRANT
MATEMATIKA GRANT
356 ishtirokchilar

Guruh muallifi : @Yusupov_Ahadjon Guruh rasmiy kanali @dtm_axborotnoma Kimda chiqmagan misoli bo'lsa guruhga jo'natishi mumkin! Guruh qoidalari Chat Reklama Soʻkingan Futbol Sticker Xamma bir birini xurmat qilsin