Class: Eot
- Inherits:
-
Object
- Object
- Eot
- Includes:
- Math
- Defined in:
- lib/eot/init.rb,
lib/eot/times.rb,
lib/eot/angles.rb,
lib/eot/deltas.rb,
lib/eot/version.rb,
lib/eot/constants.rb,
lib/eot/utilities.rb,
lib/eot/time_displays.rb,
lib/eot/trigonometric.rb,
lib/eot/angle_displays.rb,
ext/eot/eot.c
Overview
class Eot file = angle_displays.rb
Constant Summary collapse
- VERSION =
'4.1.5'
- ARCSEC =
Arc seconds in a degree = 3_600.0
3_600.0
- ASD =
Arc seconds in a degree = 3_600.0
3_600.0
- DAS2R =
from desktop calculator DAS2R = 4.8481368110953599358991410235795e-6
4.8481368110953599358991410235795e-6
- DAY_HOURS =
Hours in a day = 24.0
24.0
- DAY_MINUTES =
Minutes in a day = 1_440.0
1_440.0
- DAY_SECONDS =
Seconds in a day = 86_400.0
86_400.0
- DAYSEC =
Seconds in a day = 86_400.0
86_400.0
- DAY_USECS =
Micro Seconds in a day = 86_400_000_000.0
86_400_000_000.0
- D2R =
from desktop calculator D2R = 0.017453292519943295769236907684886
0.017453292519943295769236907684886
- DJ00 =
Reference epoch (J2000.0), Julian Date Default Julian Number = 2451545.0
2_451_545.0
- DJC =
Days per Julian century = 36525.0
36_525.0
- DT2000 =
Default DateTime = DateTime.new( 2000, 01, 01, 12, 00, 00, “+00:00” )
DateTime.new(2000, 01, 01, 12, 00, 00, '+00:00')
- PI =
from desktop calculator PI = 3.1415926535897932384626433832795
3.1415926535897932384626433832795
- P2 =
2Pi from Math module = Math::PI * 2.0
PI * 2.0
- R2D =
from desktop calculator R2D = 57.295779513082320876798154814105
57.295779513082320876798154814105
- RTD =
from desktop calculator RTD = 0.015915494309189533576888376337251
0.015915494309189533576888376337251
- SM =
from desktop calculator Sidereal minutes = 4.0 / 1.0027379093507953456536618754278
4.0 / 1.0027379093507953456536618754278
Instance Attribute Summary collapse
-
#addr ⇒ Object
From init.rb: address used for GeoLatLng.addr.
-
#ajd ⇒ Object
From init.rb: Astronomical Julian Day Number is an instance of DateTime class.
-
#date ⇒ Object
From init.rb: When new Eot class is initialized @date = ajd_to_datetime(@ajd).
-
#jd ⇒ Object
From init.rb: Julian Day Number is an instance of DateTime class.
-
#latitude ⇒ Object
From init.rb: Latitude input is an instance of Float class.
-
#longitude ⇒ Object
From init.rb: Longitude input is an instance of Float class.
-
#ma ⇒ Object
From init.rb: Mean Anomaly gets called a lot so class attribute saves it.
-
#ta ⇒ Object
From init.rb: JCT gets called a lot so class attribute it.
Instance Method Summary collapse
-
#ajd_to_datetime(ajd) ⇒ Object
From times.rb: Pass in an AJD number Returns a DateTime object.
- #al(vma, vt, vo) ⇒ Object
-
#al_sun ⇒ Object
(also: #apparent_longitude, #alsun)
From angles.rb: Apparent solar longitude = true longitude - aberation.
-
#angle_delta_epsilon ⇒ Object
(also: #delta_epsilon)
From deltas.rb: delta epsilon component of equation of equinox.
-
#angle_delta_oblique ⇒ Object
(also: #delta_t_ecliptic, #delta_oblique)
From deltas.rb: one time component to total equation of time.
-
#angle_delta_orbit ⇒ Object
(also: #delta_t_elliptic, #delta_orbit)
From angles.rb: one time component to total equation of time.
-
#angle_delta_psi ⇒ Object
(also: #delta_psi)
From angles.rb: component of equation of equinox.
-
#angle_equation_of_time ⇒ Object
(also: #eot)
From angles.rb: total equation of time.
-
#center ⇒ Object
(also: #equation_of_center)
From angles.rb: equation of centre added to mean anomaly to get true anomaly.
-
#check_jd_nil(jd = DJ00) ⇒ Object
From utilities.rb: A check for default J2000 sets default when arg is nil.
-
#check_jd_zero(jd = DJ00) ⇒ Object
From utilities.rb: A check for default J2000 sets default when arg is zero.
-
#check_t_nil(dt = DT2000) ⇒ Object
From utilities.rb: A check for default DT2000 sets default when arg is nil.
-
#check_t_zero(dt = DT2000) ⇒ Object
From utilities.rb: A check for default DT2000 sets default when arg is zero.
- #cos_al_sun(vals) ⇒ Object
- #cos_dec_sun(vds) ⇒ Object
- #cos_lat(vlat) ⇒ Object
- #cos_tl_sun(vtls) ⇒ Object
- #cos_to_earth(vtoe) ⇒ Object
-
#cosine_al_sun ⇒ Object
(also: #cosine_apparent_longitude, #cosalsun)
From trigometric.rb: cosine apparent longitude could be useful when dividing.
-
#cosine_tl_sun ⇒ Object
(also: #cosine_true_longitude)
From trigometric.rb: cosine true longitude used in solar right ascension.
-
#cosine_to_earth ⇒ Object
(also: #cosine_true_obliquity)
From trigometric.rb: cosine true obliquity used in solar right ascension and equation of equinox.
- #cosZ(vz) ⇒ Object
-
#dec_sun ⇒ Object
(also: #declination)
From angles.rb: solar declination.
- #deg_string(sgn, d, m, s, ds) ⇒ Object
-
#degrees_to_s(radians = 0.0) ⇒ Object
From displays.rb String formatter for d:m:s display.
- #dt_parts(val) ⇒ Object
-
#eccentricity_earth ⇒ Object
(also: #eccentricity_earth_orbit)
From angles.rb: eccentricity of elliptical Earth orbit around Sun Horners’ calculation method.
- #eoe(vt) ⇒ Object
-
#eot_jd ⇒ Object
From times.rb: Uses @ajd attribute Returns EOT as an AJD Julian number.
-
#eq_of_equinox ⇒ Object
From angles.rb: equation of equinox used for true longitude of Aries Depricated by Celes.gst06a().
- #eqc(vma, vt) ⇒ Object
- #float_parts(val) ⇒ Object
- #format_time(h, m, s, ds) ⇒ Object
-
#gml_sun ⇒ Object
(also: #geometric_mean_longitude)
From angles.rb: angle geometric mean longitude needed to get true longitude for low accuracy.
-
#ha_sun ⇒ Object
(also: #horizon_angle)
From angles.rb: horizon angle for provided geo coordinates used for angles from transit to horizons.
-
#initialize ⇒ Eot
constructor
From init.rb: Initialize to set attributes You may use GeoLatLng to set up @latitude and @longitude.
-
#local_noon_dt ⇒ Object
From times.rb: Uses @ajd and @longitude attributes Returns DateTime object of local noon or solar transit.
-
#ma_sun ⇒ Object
(also: #mean_anomaly)
From angles.rb: angle of Suns’ mean anomaly calculated in nutation.rb via celes function sets ta attribute for the rest the methods needing it.
-
#mean_local_noon_dt ⇒ Object
From times.rb: Uses @ajd and @longitude attributes Returns DateTime object of local mean noon or solar transit.
- #ml(vt) ⇒ Object
-
#ml_aries ⇒ Object
(also: #mean_longitude_aries)
From angles.rb: Mean equinox point where right ascension is measured from as zero hours.
-
#mo_earth ⇒ Object
(also: #mean_obliquity_of_ecliptic, #mean_obliquity)
From angles.rb: mean obliquity of Earth.
-
#mod_360(x = 0.0) ⇒ Object
(also: #truncate)
From utilities.rb: Keeps large angles in range of 360.0 aliased by truncate.
-
#now ⇒ Object
From times.rb: sets @ajd to DateTime.now Returns EOT (equation of time) now in decimal minutes form.
-
#omega ⇒ Object
From angles.rb: omega is a component of nutation and used in apparent longitude omega is the longitude of the mean ascending node of the lunar orbit on the ecliptic plane measured from the mean equinox of date.
-
#ra_sun ⇒ Object
(also: #right_ascension)
From angles.rb: solar right ascension.
-
#show_minutes(min = 0.0) ⇒ Object
From displays.rb String formatter for + and - time.
-
#show_now(now = now(Time.now.utc)) ⇒ Object
From displays.rb String for time now.
- #sign_min(min) ⇒ Object
- #sin_al_sun(vals) ⇒ Object
- #sin_dec_sun(vds) ⇒ Object
- #sin_lat(vlat) ⇒ Object
- #sin_tl_sun(vtls) ⇒ Object
- #sin_to_earth(vtoe) ⇒ Object
-
#sine_al_sun ⇒ Object
(also: #sine_apparent_longitude)
From trigometric.rb: sine apparent longitude used in solar declination.
-
#sine_tl_sun ⇒ Object
(also: #sine_true_longitude)
From trigometric.rb: sine true longitude used in solar right ascension.
-
#sine_to_earth ⇒ Object
From trigometric.rb: sine true obliquity angle of Earth used in solar declination.
-
#string_al_sun ⇒ Object
(also: #apparent_longitude_string)
From displays.rb String format of apparent longitude.
-
#string_day_fraction_to_time(jpd_time = 0.0) ⇒ Object
(also: #julian_period_day_fraction_to_time)
From displays.rb String formatter for fraction of Julian day number.
-
#string_dec_sun ⇒ Object
(also: #declination_string)
From displays.rb String format of declination.
-
#string_delta_oblique ⇒ Object
From displays.rb String format for delta oblique.
-
#string_delta_orbit ⇒ Object
From displays.rb String format for delta orbit.
-
#string_eot ⇒ Object
(also: #display_equation_of_time)
From displays.rb Equation of time output for minutes and seconds.
-
#string_eqc ⇒ Object
From displays.rb String format for centre.
-
#string_jd_to_date(jd = DJ00) ⇒ Object
(also: #jd_to_date_string)
From displays.rb String format conversion of jd to date.
-
#string_ma_sun ⇒ Object
(also: #mean_anomaly_string)
From displays.rb String format of mean anomaly.
-
#string_ra_sun ⇒ Object
(also: #right_ascension_string)
From displays.rb String format of right ascension.
-
#string_ta_sun ⇒ Object
(also: #true_anomaly_string)
From displays.rb String format of true anomaly.
-
#string_time(dt = DT2000) ⇒ Object
(also: #display_time_string)
From displays.rb String formatter for h:m:s display.
-
#string_tl_sun ⇒ Object
(also: #true_longitude_string)
From displays.rb String format of true longitude.
-
#string_to_earth ⇒ Object
(also: #true_obliquity_string)
From displays.rb String format of true obliquity.
-
#sunrise_dt ⇒ Object
From times.rb: Uses @ajd attribute Returns a DateTime object of local sunrise.
-
#sunrise_jd ⇒ Object
From times.rb: Uses @ajd attribute Returns Sunrise as a Julian Day Number.
-
#sunset_dt ⇒ Object
From times.rb: Uses @ajd attribute Returns a DateTime object of local sunset.
-
#sunset_jd ⇒ Object
From times.rb: Uses @ajd attribute Returns Sunset as a Julian Day Number.
-
#ta_sun ⇒ Object
(also: #true_anomaly)
From angles.rb: angle true anomaly used in equation of time.
-
#time_delta_oblique ⇒ Object
From times.rb: Uses @ajd attribute Returns Oblique component of EOT in decimal minutes time.
-
#time_delta_orbit ⇒ Object
From times.rb: Uses @ajd attribute Returns Orbit component of EOT in decimal minutes time.
-
#time_eot ⇒ Object
From times.rb: Uses @ajd attribute Returns EOT as a float for decimal minutes time.
-
#time_julian_century ⇒ Object
(also: #time_julian_centurey)
From times.rb: All calculations with ( ta ) were based on this.
- #tl(vma, vt) ⇒ Object
-
#tl_aries ⇒ Object
(also: #true_longitude_aries)
From angles.rb: true longitude of equinox ‘first point of aries’ considers nutation.
-
#tl_sun ⇒ Object
(also: #true_longitude, #ecliptic_longitude, #lambda)
From angles.rb: angle of true longitude sun used in equation of time.
-
#to_earth ⇒ Object
(also: #obliquity_correction, #true_obliquity, #toearth)
From angles.rb: true obliquity considers nutation.
Constructor Details
#initialize ⇒ Eot
From init.rb: Initialize to set attributes You may use GeoLatLng to set up @latitude and @longitude
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/eot/init.rb', line 55 def initialize @geo = GeoLatLng.new @addr = @geo.default_int @geo.addr = @addr @ajd = DateTime.now.to_time.utc.to_datetime.jd.to_f @date, @jd = ajd_to_datetime(@ajd), @ajd @geo.set_coordinates # queries could excede quotas or you get disconnected. @geo.lat.zero? ? @latitude = 0.0 : @latitude = @geo.lat @geo.lng.zero? ? @longitude = 0.0 : @longitude = @geo.lng end |
Instance Attribute Details
#addr ⇒ Object
From init.rb: address used for GeoLatLng.addr
5 6 7 |
# File 'lib/eot/init.rb', line 5 def addr @addr end |
#ajd ⇒ Object
From init.rb: Astronomical Julian Day Number is an instance of DateTime class. ajd or jd. Use ajd for time now and jd for suntimes. Initially
11 12 13 |
# File 'lib/eot/init.rb', line 11 def ajd @ajd end |
#date ⇒ Object
From init.rb: When new Eot class is initialized @date = ajd_to_datetime(@ajd)
22 23 24 |
# File 'lib/eot/init.rb', line 22 def date @date end |
#jd ⇒ Object
From init.rb: Julian Day Number is an instance of DateTime class. When new Eot class is initialized @jd = @ajd
27 28 29 |
# File 'lib/eot/init.rb', line 27 def jd @jd end |
#latitude ⇒ Object
From init.rb: Latitude input is an instance of Float class. When new Eot class is initialized @latitude = 0.0 if GeoLatLng class can’t set it.
33 34 35 |
# File 'lib/eot/init.rb', line 33 def latitude @latitude end |
#longitude ⇒ Object
From init.rb: Longitude input is an instance of Float class. When new Eot class is initialized @longitude = 0.0 if GeoLatLng class can’t set it.
39 40 41 |
# File 'lib/eot/init.rb', line 39 def longitude @longitude end |
#ma ⇒ Object
From init.rb: Mean Anomaly gets called a lot so class attribute saves it.
50 51 52 |
# File 'lib/eot/init.rb', line 50 def ma @ma end |
#ta ⇒ Object
From init.rb: JCT gets called a lot so class attribute it. Setting @ajd will set this and @ma
45 46 47 |
# File 'lib/eot/init.rb', line 45 def ta @ta end |
Instance Method Details
#ajd_to_datetime(ajd) ⇒ Object
From times.rb: Pass in an AJD number Returns a DateTime object
6 7 8 |
# File 'lib/eot/times.rb', line 6 def ajd_to_datetime(ajd) DateTime.jd(ajd + 0.5) end |
#al(vma, vt, vo) ⇒ Object
30 31 32 33 |
# File 'ext/eot/eot.c', line 30
VALUE func_al(VALUE klass, VALUE vma, VALUE vt, VALUE vo) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(alSun(NUM2DBL(vma), NUM2DBL(vt), NUM2DBL(vo)));
}
|
#al_sun ⇒ Object Also known as: apparent_longitude, alsun
From angles.rb: Apparent solar longitude = true longitude - aberation
6 7 8 |
# File 'lib/eot/angles.rb', line 6 def al_sun Celes.anp(al(@ma, @ta, Celes.faom03(@ta))) end |
#angle_delta_epsilon ⇒ Object Also known as: delta_epsilon
From deltas.rb: delta epsilon component of equation of equinox
6 7 8 |
# File 'lib/eot/deltas.rb', line 6 def angle_delta_epsilon Celes.nut06a(@ajd, 0)[1] end |
#angle_delta_oblique ⇒ Object Also known as: delta_t_ecliptic, delta_oblique
From deltas.rb: one time component to total equation of time
13 14 15 |
# File 'lib/eot/deltas.rb', line 13 def angle_delta_oblique al_sun - ra_sun end |
#angle_delta_orbit ⇒ Object Also known as: delta_t_elliptic, delta_orbit
From angles.rb: one time component to total equation of time
21 22 23 |
# File 'lib/eot/deltas.rb', line 21 def angle_delta_orbit -1.0 * eqc(@ma, @ta) end |
#angle_delta_psi ⇒ Object Also known as: delta_psi
From angles.rb: component of equation of equinox
29 30 31 |
# File 'lib/eot/deltas.rb', line 29 def angle_delta_psi Celes.nut06a(@ajd, 0)[0] end |
#angle_equation_of_time ⇒ Object Also known as: eot
From angles.rb: total equation of time
36 37 38 |
# File 'lib/eot/deltas.rb', line 36 def angle_equation_of_time delta_orbit + delta_oblique end |
#center ⇒ Object Also known as: equation_of_center
From angles.rb: equation of centre added to mean anomaly to get true anomaly.
15 16 17 |
# File 'lib/eot/angles.rb', line 15 def center eqc(@ma, @ta) end |
#check_jd_nil(jd = DJ00) ⇒ Object
From utilities.rb: A check for default J2000 sets default when arg is nil
7 8 9 |
# File 'lib/eot/utilities.rb', line 7 def check_jd_nil(jd = DJ00) jd.nil? ? DJ00 : jd end |
#check_jd_zero(jd = DJ00) ⇒ Object
From utilities.rb: A check for default J2000 sets default when arg is zero
14 15 16 |
# File 'lib/eot/utilities.rb', line 14 def check_jd_zero(jd = DJ00) jd == 0 ? DJ00 : check_jd_nil(jd) end |
#check_t_nil(dt = DT2000) ⇒ Object
From utilities.rb: A check for default DT2000 sets default when arg is nil
21 22 23 |
# File 'lib/eot/utilities.rb', line 21 def check_t_nil(dt = DT2000) dt.nil? ? DT2000 : dt end |
#check_t_zero(dt = DT2000) ⇒ Object
From utilities.rb: A check for default DT2000 sets default when arg is zero
28 29 30 |
# File 'lib/eot/utilities.rb', line 28 def check_t_zero(dt = DT2000) dt == 0 ? DT2000 : check_t_nil(dt) end |
#cos_al_sun(vals) ⇒ Object
40 41 42 43 |
# File 'ext/eot/eot.c', line 40
VALUE func_cos_al_sun(VALUE klass, VALUE vals) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(cos_al_sun(NUM2DBL(vals)));
}
|
#cos_dec_sun(vds) ⇒ Object
75 76 77 78 |
# File 'ext/eot/eot.c', line 75
VALUE func_cos_dec_sun(VALUE klass, VALUE vds) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(cos_dec_sun(NUM2DBL(vds)));
}
|
#cos_lat(vlat) ⇒ Object
85 86 87 88 |
# File 'ext/eot/eot.c', line 85
VALUE func_cos_lat(VALUE klass, VALUE vlat) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(cos_lat(NUM2DBL(vlat)));
}
|
#cos_tl_sun(vtls) ⇒ Object
45 46 47 48 |
# File 'ext/eot/eot.c', line 45
VALUE func_cos_tl_sun(VALUE klass, VALUE vtls) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(cos_al_sun(NUM2DBL(vtls)));
}
|
#cos_to_earth(vtoe) ⇒ Object
50 51 52 53 |
# File 'ext/eot/eot.c', line 50
VALUE func_cos_to_earth(VALUE klass, VALUE vtoe) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(cos_to_earth(NUM2DBL(vtoe)));
}
|
#cosine_al_sun ⇒ Object Also known as: cosine_apparent_longitude, cosalsun
From trigometric.rb: cosine apparent longitude could be useful when dividing
7 8 9 |
# File 'lib/eot/trigonometric.rb', line 7 def cosine_al_sun cos_al_sun(al(@ma, @ta, Celes.faom03(@ta))) end |
#cosine_tl_sun ⇒ Object Also known as: cosine_true_longitude
From trigometric.rb: cosine true longitude used in solar right ascension
16 17 18 |
# File 'lib/eot/trigonometric.rb', line 16 def cosine_tl_sun cos_tl_sun(tl(@ma, @ta)) end |
#cosine_to_earth ⇒ Object Also known as: cosine_true_obliquity
From trigometric.rb: cosine true obliquity used in solar right ascension and equation of equinox
24 25 26 |
# File 'lib/eot/trigonometric.rb', line 24 def cosine_to_earth cos_to_earth(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0)) end |
#cosZ(vz) ⇒ Object
35 36 37 38 |
# File 'ext/eot/eot.c', line 35
VALUE func_cosZ(VALUE klass, VALUE vz) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(cosZ(NUM2DBL(vz)));
}
|
#dec_sun ⇒ Object Also known as: declination
From angles.rb: solar declination
22 23 24 25 |
# File 'lib/eot/angles.rb', line 22 def dec_sun asin(sin(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0)) * sin(al(@ma, @ta, Celes.faom03(@ta)))) end |
#deg_string(sgn, d, m, s, ds) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/eot/angle_displays.rb', line 3 def deg_string(sgn, d, m, s, ds) sgn + format('%03d', d) + ':' + format('%02d', m) + ':' + format('%02d', s) + '.' + format('%3.3d', ds) end |
#degrees_to_s(radians = 0.0) ⇒ Object
From displays.rb String formatter for d:m:s display
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eot/angle_displays.rb', line 16 def degrees_to_s(radians = 0.0) radians.nil? ? radians = 0.0 : radians radians < 0 ? sign = '-' : sign = '+' deg = (radians * R2D).abs int_deg = Integer(deg) min = 60.0 * (deg - int_deg) int_min = Integer(min) sec = 60.0 * (min - int_min) int_sec = Integer(sec) int_ds = Integer(1000.0 * (sec - int_sec)) deg_string(sign, int_deg, int_min, int_sec, int_ds) end |
#dt_parts(val) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/eot/time_displays.rb', line 78 def dt_parts(val) h = val.hour m = val.min s = val.sec is = Integer(s) ds = Integer((s - is).round(3) * 1000.0) [h, m, is, ds] end |
#eccentricity_earth ⇒ Object Also known as: eccentricity_earth_orbit
From angles.rb: eccentricity of elliptical Earth orbit around Sun Horners’ calculation method
31 32 33 |
# File 'lib/eot/angles.rb', line 31 def eccentricity_earth eoe(@ta) end |
#eoe(vt) ⇒ Object
15 16 17 18 |
# File 'ext/eot/eot.c', line 15
VALUE func_eoe(VALUE klass, VALUE vt) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(eoe(NUM2DBL(vt)));
}
|
#eot_jd ⇒ Object
From times.rb: Uses @ajd attribute Returns EOT as an AJD Julian number
13 14 15 |
# File 'lib/eot/times.rb', line 13 def eot_jd time_eot / DAY_MINUTES end |
#eq_of_equinox ⇒ Object
From angles.rb: equation of equinox used for true longitude of Aries Depricated by Celes.gst06a()
40 41 42 43 44 |
# File 'lib/eot/angles.rb', line 40 def eq_of_equinox cos(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0)) * Celes.nut06a(@ajd, 0)[0] end |
#eqc(vma, vt) ⇒ Object
20 21 22 23 |
# File 'ext/eot/eot.c', line 20
VALUE func_eqc(VALUE klass, VALUE vma, VALUE vt) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(eqc(NUM2DBL(vma), NUM2DBL(vt)));
}
|
#float_parts(val) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/eot/time_displays.rb', line 87 def float_parts(val) hours = Integer(val % DAY_HOURS) mins = 60.0 * (val % DAY_HOURS - hours) imins = Integer(mins) secs = 60.0 * (mins - imins) isecs = Integer(secs) ds = Integer((secs - isecs).round(3) * 1000.0) [hours, imins, isecs, ds] end |
#format_time(h, m, s, ds) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/eot/time_displays.rb', line 68 def format_time(h, m, s, ds) format('%02d', h) + ':' + format('%02d', m) + ':' + format('%02d', s) + '.' + format('%3.3d', ds) end |
#gml_sun ⇒ Object Also known as: geometric_mean_longitude
From angles.rb: angle geometric mean longitude needed to get true longitude for low accuracy.
49 50 51 |
# File 'lib/eot/angles.rb', line 49 def gml_sun ml(@ta) end |
#ha_sun ⇒ Object Also known as: horizon_angle
From angles.rb: horizon angle for provided geo coordinates used for angles from transit to horizons
57 58 59 60 61 62 63 64 |
# File 'lib/eot/angles.rb', line 57 def ha_sun zenith = 90.8333 # use other zeniths here for non commercial top = cosZ(zenith) - sin_dec_sun(dec_sun) * sin_lat(@latitude * D2R) bottom = cos_dec_sun(dec_sun) * cos_lat(@latitude * D2R) t_cosine = top / bottom t_cosine > 1.0 || t_cosine < -1.0 ? cos = 1.0 : cos = t_cosine acos(cos) end |
#local_noon_dt ⇒ Object
From times.rb: Uses @ajd and @longitude attributes Returns DateTime object of local noon or solar transit
20 21 22 |
# File 'lib/eot/times.rb', line 20 def local_noon_dt ajd_to_datetime(@ajd - @longitude / 360.0 - eot_jd) end |
#ma_sun ⇒ Object Also known as: mean_anomaly
From angles.rb: angle of Suns’ mean anomaly calculated in nutation.rb via celes function sets ta attribute for the rest the methods needing it. used in equation of time and to get true anomaly true longitude via center equation
73 74 75 76 |
# File 'lib/eot/angles.rb', line 73 def ma_sun @ta = (@ajd - DJ00) / DJC @ma = Celes.falp03(@ta) end |
#mean_local_noon_dt ⇒ Object
From times.rb: Uses @ajd and @longitude attributes Returns DateTime object of local mean noon or solar transit
27 28 29 |
# File 'lib/eot/times.rb', line 27 def mean_local_noon_dt ajd_to_datetime(@ajd - @longitude / 360.0) end |
#ml(vt) ⇒ Object
10 11 12 13 |
# File 'ext/eot/eot.c', line 10
VALUE func_ml(VALUE klass, VALUE vt) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(mlSun(NUM2DBL(vt)));
}
|
#ml_aries ⇒ Object Also known as: mean_longitude_aries
From angles.rb: Mean equinox point where right ascension is measured from as zero hours. # see www.iausofa.org/publications/aas04.pdf
82 83 84 85 86 |
# File 'lib/eot/angles.rb', line 82 def ml_aries dt = 67.184 tt = @ajd + dt / 86_400.0 Celes.gmst06(@ajd, 0, tt, 0) end |
#mo_earth ⇒ Object Also known as: mean_obliquity_of_ecliptic, mean_obliquity
From angles.rb: mean obliquity of Earth
91 92 93 |
# File 'lib/eot/angles.rb', line 91 def mo_earth Celes.obl06(@ajd, 0) end |
#mod_360(x = 0.0) ⇒ Object Also known as: truncate
From utilities.rb: Keeps large angles in range of 360.0 aliased by truncate
35 36 37 38 |
# File 'lib/eot/utilities.rb', line 35 def mod_360(x = 0.0) x.nil? ? x = 0.0 : x 360.0 * (x / 360.0 - Integer(x / 360.0)) end |
#now ⇒ Object
From times.rb: sets @ajd to DateTime.now Returns EOT (equation of time) now in decimal minutes form
34 35 36 37 38 |
# File 'lib/eot/times.rb', line 34 def now @ajd = DateTime.now.to_time.utc.to_datetime.ajd @ta = (@ajd - DJ00) / DJC time_eot end |
#omega ⇒ Object
From angles.rb: omega is a component of nutation and used in apparent longitude omega is the longitude of the mean ascending node of the lunar orbit on the ecliptic plane measured from the mean equinox of date.
102 103 104 |
# File 'lib/eot/angles.rb', line 102 def omega Celes.faom03(@ta) end |
#ra_sun ⇒ Object Also known as: right_ascension
From angles.rb: solar right ascension
108 109 110 111 112 |
# File 'lib/eot/angles.rb', line 108 def ra_sun y0 = sin(al(@ma, @ta, Celes.faom03(@ta))) * cos(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0)) Celes.anp(PI + atan2(-y0, -cos(al(@ma, @ta, Celes.faom03(@ta))))) end |
#show_minutes(min = 0.0) ⇒ Object
From displays.rb String formatter for + and - time
5 6 7 8 9 10 11 |
# File 'lib/eot/time_displays.rb', line 5 def show_minutes(min = 0.0) min.nil? ? min = 0.0 : min time = Time.utc(1, 1, 1, 0, 0, 0, 0.0) time += (min.abs * 60.0) sign = sign_min(min) time.strftime("#{sign}%M:%S.%3N") end |
#show_now(now = now(Time.now.utc)) ⇒ Object
From displays.rb String for time now
15 16 17 |
# File 'lib/eot/time_displays.rb', line 15 def show_now(now = now(Time.now.utc)) show_minutes(now) end |
#sign_min(min) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/eot/time_displays.rb', line 35 def sign_min(min) if min < 0.0 sign = '-' else sign = '+' end sign end |
#sin_al_sun(vals) ⇒ Object
55 56 57 58 |
# File 'ext/eot/eot.c', line 55
VALUE func_sin_al_sun(VALUE klass, VALUE vals) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(sin_al_sun(NUM2DBL(vals)));
}
|
#sin_dec_sun(vds) ⇒ Object
70 71 72 73 |
# File 'ext/eot/eot.c', line 70
VALUE func_sin_dec_sun(VALUE klass, VALUE vds) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(sin_dec_sun(NUM2DBL(vds)));
}
|
#sin_lat(vlat) ⇒ Object
80 81 82 83 |
# File 'ext/eot/eot.c', line 80
VALUE func_sin_lat(VALUE klass, VALUE vlat) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(sin_lat(NUM2DBL(vlat)));
}
|
#sin_tl_sun(vtls) ⇒ Object
60 61 62 63 |
# File 'ext/eot/eot.c', line 60
VALUE func_sin_tl_sun(VALUE klass, VALUE vtls) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(sin_al_sun(NUM2DBL(vtls)));
}
|
#sin_to_earth(vtoe) ⇒ Object
65 66 67 68 |
# File 'ext/eot/eot.c', line 65
VALUE func_sin_to_earth(VALUE klass, VALUE vtoe) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(sin_to_earth(NUM2DBL(vtoe)));
}
|
#sine_al_sun ⇒ Object Also known as: sine_apparent_longitude
From trigometric.rb: sine apparent longitude used in solar declination
32 33 34 |
# File 'lib/eot/trigonometric.rb', line 32 def sine_al_sun sin_al_sun(al(@ma, @ta, Celes.faom03(@ta))) end |
#sine_tl_sun ⇒ Object Also known as: sine_true_longitude
From trigometric.rb: sine true longitude used in solar right ascension
40 41 42 |
# File 'lib/eot/trigonometric.rb', line 40 def sine_tl_sun sin_tl_sun(tl(@ma, @ta)) end |
#sine_to_earth ⇒ Object
From trigometric.rb: sine true obliquity angle of Earth used in solar declination
48 49 50 |
# File 'lib/eot/trigonometric.rb', line 48 def sine_to_earth sin_to_earth(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0)) end |
#string_al_sun ⇒ Object Also known as: apparent_longitude_string
From displays.rb String format of apparent longitude
31 32 33 |
# File 'lib/eot/angle_displays.rb', line 31 def string_al_sun degrees_to_s(al_sun) end |
#string_day_fraction_to_time(jpd_time = 0.0) ⇒ Object Also known as: julian_period_day_fraction_to_time
From displays.rb String formatter for fraction of Julian day number
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/eot/time_displays.rb', line 21 def string_day_fraction_to_time(jpd_time = 0.0) jpd_time.nil? ? jpd_time = 0.0 : jpd_time fraction = jpd_time + 0.5 - Integer(jpd_time) h = Integer(fraction * DAY_HOURS) m = Integer((fraction - h / DAY_HOURS) * DAY_MINUTES) s = Integer((fraction - h / 24.0 - m / DAY_MINUTES) * DAY_SECONDS) format('%02d', h) + ':' + format('%02d', m) + ':' + format('%02d', s) end |
#string_dec_sun ⇒ Object Also known as: declination_string
From displays.rb String format of declination
38 39 40 |
# File 'lib/eot/angle_displays.rb', line 38 def string_dec_sun degrees_to_s(dec_sun) end |
#string_delta_oblique ⇒ Object
From displays.rb String format for delta oblique
45 46 47 |
# File 'lib/eot/angle_displays.rb', line 45 def string_delta_oblique show_minutes(delta_oblique) end |
#string_delta_orbit ⇒ Object
From displays.rb String format for delta orbit
51 52 53 |
# File 'lib/eot/angle_displays.rb', line 51 def string_delta_orbit show_minutes(delta_orbit) end |
#string_eot ⇒ Object Also known as: display_equation_of_time
From displays.rb Equation of time output for minutes and seconds
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/eot/time_displays.rb', line 46 def string_eot min_eot = time_eot sign = sign_min(min_eot) eot = min_eot.abs minutes = Integer(eot) seconds = (eot - minutes) * 60.0 decimal_seconds = (seconds - Integer(seconds)) * 100.0 min = format('%02d', minutes) sec = format('%02d', seconds) dec_sec = format('%01d', decimal_seconds) sign << min << 'm, ' << sec << '.' << dec_sec << 's' end |
#string_eqc ⇒ Object
From displays.rb String format for centre
57 58 59 |
# File 'lib/eot/angle_displays.rb', line 57 def string_eqc degrees_to_s(center) end |
#string_jd_to_date(jd = DJ00) ⇒ Object Also known as: jd_to_date_string
From displays.rb String format conversion of jd to date
62 63 64 65 |
# File 'lib/eot/time_displays.rb', line 62 def string_jd_to_date(jd = DJ00) jd = check_jd_zero(jd) Date.jd(jd).to_s end |
#string_ma_sun ⇒ Object Also known as: mean_anomaly_string
From displays.rb String format of mean anomaly
63 64 65 |
# File 'lib/eot/angle_displays.rb', line 63 def string_ma_sun degrees_to_s(@ma) end |
#string_ra_sun ⇒ Object Also known as: right_ascension_string
From displays.rb String format of right ascension
70 71 72 |
# File 'lib/eot/angle_displays.rb', line 70 def string_ra_sun degrees_to_s(ra_sun) end |
#string_ta_sun ⇒ Object Also known as: true_anomaly_string
From displays.rb String format of true anomaly
77 78 79 |
# File 'lib/eot/angle_displays.rb', line 77 def string_ta_sun degrees_to_s(ta_sun) end |
#string_time(dt = DT2000) ⇒ Object Also known as: display_time_string
From displays.rb String formatter for h:m:s display
99 100 101 102 103 |
# File 'lib/eot/time_displays.rb', line 99 def string_time(dt = DT2000) dt = check_t_zero(dt) dt.class == DateTime ? ta = dt_parts(dt) : ta = float_parts(dt) format_time(ta[0], ta[1], ta[2], ta[3]) end |
#string_tl_sun ⇒ Object Also known as: true_longitude_string
From displays.rb String format of true longitude
84 85 86 |
# File 'lib/eot/angle_displays.rb', line 84 def string_tl_sun degrees_to_s(tl_sun) end |
#string_to_earth ⇒ Object Also known as: true_obliquity_string
From displays.rb String format of true obliquity
91 92 93 |
# File 'lib/eot/angle_displays.rb', line 91 def string_to_earth degrees_to_s(to_earth) end |
#sunrise_dt ⇒ Object
From times.rb: Uses @ajd attribute Returns a DateTime object of local sunrise
43 44 45 |
# File 'lib/eot/times.rb', line 43 def sunrise_dt ajd_to_datetime(sunrise_jd) end |
#sunrise_jd ⇒ Object
From times.rb: Uses @ajd attribute Returns Sunrise as a Julian Day Number
50 51 52 |
# File 'lib/eot/times.rb', line 50 def sunrise_jd local_noon_dt.ajd - ha_sun / P2 end |
#sunset_dt ⇒ Object
From times.rb: Uses @ajd attribute Returns a DateTime object of local sunset
57 58 59 |
# File 'lib/eot/times.rb', line 57 def sunset_dt ajd_to_datetime(sunset_jd) end |
#sunset_jd ⇒ Object
From times.rb: Uses @ajd attribute Returns Sunset as a Julian Day Number
64 65 66 |
# File 'lib/eot/times.rb', line 64 def sunset_jd local_noon_dt.ajd + ha_sun / P2 end |
#ta_sun ⇒ Object Also known as: true_anomaly
From angles.rb: angle true anomaly used in equation of time
118 119 120 |
# File 'lib/eot/angles.rb', line 118 def ta_sun Celes.anp(@ma + eqc(@ma, @ta)) end |
#time_delta_oblique ⇒ Object
From times.rb: Uses @ajd attribute Returns Oblique component of EOT in decimal minutes time
71 72 73 |
# File 'lib/eot/times.rb', line 71 def time_delta_oblique (tl_sun - ra_sun) * R2D * SM end |
#time_delta_orbit ⇒ Object
From times.rb: Uses @ajd attribute Returns Orbit component of EOT in decimal minutes time
78 79 80 |
# File 'lib/eot/times.rb', line 78 def time_delta_orbit (@ma - ta_sun) * R2D * SM end |
#time_eot ⇒ Object
From times.rb: Uses @ajd attribute Returns EOT as a float for decimal minutes time
85 86 87 |
# File 'lib/eot/times.rb', line 85 def time_eot eot * R2D * SM end |
#time_julian_century ⇒ Object Also known as: time_julian_centurey
From times.rb: All calculations with ( ta ) were based on this. Julian Century Time is a fractional century Julian Day Number DJ00 is subtracted from the JDN or AJDN and then divided by days in a Julian Century. Deprecated
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/eot/times.rb', line 95 def time_julian_century t1 = (@ajd - DJ00) / DJC # t2 = t1 * t1 # t3 = t1 * t2 # t4 = t2 * t2 # t5 = t2 * t3 # t6 = t3 * t3 # t7 = t3 * t4 # t8 = t4 * t4 # t9 = t4 * t5 # t10 = t5 * t5 # @ta = [ t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 ] @ta = t1 end |
#tl(vma, vt) ⇒ Object
25 26 27 28 |
# File 'ext/eot/eot.c', line 25
VALUE func_tl(VALUE klass, VALUE vma, VALUE vt) {
rb_ivar_set(klass, id_status, INT2FIX(0));
return DBL2NUM(tlSun(NUM2DBL(vma), NUM2DBL(vt)));
}
|
#tl_aries ⇒ Object Also known as: true_longitude_aries
From angles.rb: true longitude of equinox ‘first point of aries’ considers nutation
126 127 128 129 130 |
# File 'lib/eot/angles.rb', line 126 def tl_aries dt = 67.184 tt = @ajd + dt / 86_400.0 Celes.gst06a(@ajd, 0, tt, 0) end |
#tl_sun ⇒ Object Also known as: true_longitude, ecliptic_longitude, lambda
From angles.rb: angle of true longitude sun used in equation of time
136 137 138 |
# File 'lib/eot/angles.rb', line 136 def tl_sun tl(@ma, @ta) end |
#to_earth ⇒ Object Also known as: obliquity_correction, true_obliquity, toearth
From angles.rb: true obliquity considers nutation
145 146 147 |
# File 'lib/eot/angles.rb', line 145 def to_earth Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0) end |