Class: Eot

Inherits:
Object
  • Object
show all
Defined in:
lib/eot/init.rb,
lib/eot/times.rb,
lib/eot/angles.rb,
lib/eot/deltas.rb,
lib/eot/version.rb,
lib/eot/jd_times.rb,
lib/eot/constants.rb,
lib/eot/utilities.rb,
lib/eot/delta_times.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: methods for display of angles.

Constant Summary collapse

VERSION =

current version

'4.1.8'
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 probably 3.989 would be close enough because it’s not that constant anyway

4.0 / 1.0027379093507953456536618754278

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEot

From init.rb: Initialize to set attributes



62
63
64
65
66
67
68
69
# File 'lib/eot/init.rb', line 62

def initialize
  d = DateTime.now.to_time.utc.to_datetime
  djm0, djm = Celes::cal2jd(d.year, d.month, d.day + d.day_fraction)
  @ajd = djm0 + djm + 0.5
  ma_ta_set
  @date, @jd = ajd_to_datetime(@ajd), @ajd    
  @latitude,  @longitude = 0.0,  0.0      
end

Instance Attribute Details

#addrObject

From init.rb: address is a String ex: “houston, tx”



6
7
8
# File 'lib/eot/init.rb', line 6

def addr
  @addr
end

#ajdObject

From init.rb: Astronomical Julian Day Number instance of Float class. ajd or jd. Use ajd for time now and jd for noon init sets ajd = DateTime.now.to_time.utc.to_datetime.jd.to_f



13
14
15
# File 'lib/eot/init.rb', line 13

def ajd
  @ajd
end

#dateObject

From init.rb: Date instance of DateTime class initialized to = ajd_to_datetime(@ajd)



28
29
30
# File 'lib/eot/init.rb', line 28

def date
  @date
end

#jdObject

From init.rb: Julian Day Number instance of Float class initialized to = ajd



34
35
36
# File 'lib/eot/init.rb', line 34

def jd
  @jd
end

#latitudeObject

From init.rb: Latitude input instance of Float class initialized to = 0.0



40
41
42
# File 'lib/eot/init.rb', line 40

def latitude
  @latitude
end

#longitudeObject

From init.rb: Longitude input instance of Float class initialized to = 0.0



46
47
48
# File 'lib/eot/init.rb', line 46

def longitude
  @longitude
end

#maObject

From init.rb: Mean Anomaly gets called often instance of Float class ma = Celes.falp03(@ta) see: celes gem



58
59
60
# File 'lib/eot/init.rb', line 58

def ma
  @ma
end

#taObject

From init.rb: Julian Century gets called often instance of Float class ta = (( @ajd - DJ00 ) / DJC).to_f



52
53
54
# File 'lib/eot/init.rb', line 52

def ta
  @ta
end

Instance Method Details

#ajd_to_datetime(ajd) ⇒ Object

Pass in an AJD number Returns a DateTime object only DateTime#jd() to work with so add a half day to make it work.



15
16
17
# File 'lib/eot/times.rb', line 15

def ajd_to_datetime(ajd)
  DateTime.jd(ajd + 0.5)
end

#al(vma, vt, vo) ⇒ Object

Apparent longitude of the Sun C extension. p1 = mean anomaly p2 = time in julian centuries p3 = angle of Omega



16
17
18
19
# File 'ext/eot/eot.c', line 16

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_sunObject Also known as: apparent_longitude, alsun

Apparent solar longitude = true longitude - aberation



12
13
14
# File 'lib/eot/angles.rb', line 12

def al_sun
  Celes.anp(al(@ma, @ta, omega))
end

#angle_delta_epsilonObject Also known as: delta_epsilon

From deltas.rb: delta epsilon component of equation of equinox



7
8
9
# File 'lib/eot/deltas.rb', line 7

def angle_delta_epsilon
  Celes.nut06a(@ajd, 0)[1]
end

#angle_delta_obliqueObject Also known as: delta_t_ecliptic, delta_oblique

From deltas.rb: one time component to total equation of time



14
15
16
# File 'lib/eot/deltas.rb', line 14

def angle_delta_oblique
  al_sun - ra_sun
end

#angle_delta_orbitObject Also known as: delta_t_elliptic, delta_orbit

From angles.rb: one time component to total equation of time



22
23
24
# File 'lib/eot/deltas.rb', line 22

def angle_delta_orbit
  -1.0 * eqc(@ma, @ta)
end

#angle_delta_psiObject Also known as: delta_psi

From angles.rb: component of equation of equinox



30
31
32
# File 'lib/eot/deltas.rb', line 30

def angle_delta_psi
  Celes.nut06a(@ajd, 0)[0]
end

#angle_equation_of_timeObject Also known as: eot

From angles.rb: total equation of time



37
38
39
# File 'lib/eot/deltas.rb', line 37

def angle_equation_of_time
  delta_orbit + delta_oblique
end

#astronomical_twilight_end_dtObject

From times.rb: Uses @ajd attribute Returns astronomical twilight end as a DateTime



22
23
24
# File 'lib/eot/times.rb', line 22

def astronomical_twilight_end_dt
  ajd_to_datetime(astronomical_twilight_end_jd)
end

#astronomical_twilight_end_jdObject

From jd_times.rb: Uses @ajd attribute Returns astronomical twilight end as a Julian Day Number



7
8
9
# File 'lib/eot/jd_times.rb', line 7

def astronomical_twilight_end_jd
  local_noon_dt.ajd + ha_sun(4) / P2
end

#astronomical_twilight_start_dtObject

From times.rb: Uses @ajd attribute Returns astronomical twilight start as a DateTime



29
30
31
# File 'lib/eot/times.rb', line 29

def astronomical_twilight_start_dt
  ajd_to_datetime(astronomical_twilight_start_jd)
end

#astronomical_twilight_start_jdObject

From jd_times.rb: Uses @ajd attribute Returns astronomical twilight start as a Julian Day Number



14
15
16
# File 'lib/eot/jd_times.rb', line 14

def astronomical_twilight_start_jd
  local_noon_dt.ajd - ha_sun(4) / P2
end

#centerObject Also known as: equation_of_center

equation of centre is added to mean anomaly to get true anomaly.



24
25
26
# File 'lib/eot/angles.rb', line 24

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

#choice(c) ⇒ Object

used by ha_sun method to select rise set and civil, nautical, astronomical twilights.



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/eot/angles.rb', line 92

def choice(c)
  case c
  when 1
    return 90.8333 # Sunrise and Sunset
  when 2
    return 96 # Civil Twilight
  when 3
    return 102 # Nautical Twilight
  when 4
    return 108 # Astronomical Twilight
  end
end

#civil_twilight_end_dtObject

From times.rb: Uses @ajd attribute Returns civil twilight end as a DateTime



36
37
38
# File 'lib/eot/times.rb', line 36

def civil_twilight_end_dt
  ajd_to_datetime(civil_twilight_end_jd)
end

#civil_twilight_end_jdObject

From jd_times.rb: Uses @ajd attribute Returns civil twilight end as a Julian Day Number



21
22
23
# File 'lib/eot/jd_times.rb', line 21

def civil_twilight_end_jd
  local_noon_dt.ajd + ha_sun(2) / P2
end

#civil_twilight_start_dtObject

From times.rb: Uses @ajd attribute Returns civil twilight start as a DateTime



43
44
45
# File 'lib/eot/times.rb', line 43

def civil_twilight_start_dt
  ajd_to_datetime(civil_twilight_start_jd)
end

#civil_twilight_start_jdObject

From jd_times.rb: Uses @ajd attribute Returns civil twilight start as a Julian Day Number



28
29
30
# File 'lib/eot/jd_times.rb', line 28

def civil_twilight_start_jd
  local_noon_dt.ajd - ha_sun(2) / P2
end

#cos_al_sun(vals) ⇒ Object

Cosine of Apparent Longitude Sun C extension. p1 = Apparent Longitude Sun see al



32
33
34
35
# File 'ext/eot/eot.c', line 32

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

Cosine of Solar Declination C extension



39
40
41
42
# File 'ext/eot/eot.c', line 39

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

C extension



123
124
125
126
# File 'ext/eot/eot.c', line 123

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

C extension



74
75
76
77
# File 'ext/eot/eot.c', line 74

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

C extension



81
82
83
84
# File 'ext/eot/eot.c', line 81

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_sunObject 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_sun)
end

#cosine_tl_sunObject 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_sun)
end

#cosine_to_earthObject 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(to_earth)
end

#cosZ(vz) ⇒ Object

Cosine of the Zenith type C extension. p1 = zenith angle sent by choice method



24
25
26
27
# File 'ext/eot/eot.c', line 24

VALUE func_cosZ(VALUE klass, VALUE vz) {
  rb_ivar_set(klass, id_status, INT2FIX(0));
  return DBL2NUM(cosZ(NUM2DBL(vz)));
}

#dec_sunObject Also known as: declination

solar declination



34
35
36
# File 'lib/eot/angles.rb', line 34

def dec_sun
  sun_dec(al_sun, to_earth)
end

#degrees_to_s(radians = 0.0) ⇒ Object

String formatter for d:m:s display



10
11
12
13
14
# File 'lib/eot/angle_displays.rb', line 10

def degrees_to_s(radians = 0.0)
  radians.nil? ? radians = 0.0 : radians
  s, idmsf = Celes.a2af(3, radians)
  f_string(s, idmsf[0], idmsf[1], idmsf[2], idmsf[3])
end

#dt_parts(val) ⇒ Object

From displays.rb creates [h,m,s,ds] array from Time or DateTime



93
94
95
96
97
98
99
100
# File 'lib/eot/time_displays.rb', line 93

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_earthObject Also known as: eccentricity_earth_orbit

eccentricity of elliptical Earth orbit around Sun Horners’ calculation method



45
46
47
# File 'lib/eot/angles.rb', line 45

def eccentricity_earth
  eoe(@ta)
end

#eoe(vt) ⇒ Object

C extension



53
54
55
56
# File 'ext/eot/eot.c', line 53

VALUE func_eoe(VALUE klass, VALUE vt) {
  rb_ivar_set(klass, id_status, INT2FIX(0));
  return DBL2NUM(eoe(NUM2DBL(vt)));
}

#eot_jdObject

From jd_times.rb: Uses @ajd attribute Returns EOT as an AJD Julian number



35
36
37
# File 'lib/eot/jd_times.rb', line 35

def eot_jd
  time_eot / DAY_MINUTES
end

#eq_of_equinoxObject

equation of equinox is used for true longitude of Aries but Depricated by Celes.gst06a() compinents are still used see: #cosine_to_earth and #angle_delta_psi



59
60
61
# File 'lib/eot/angles.rb', line 59

def eq_of_equinox
  Celes.ee06a(@ajd, 0.0)
end

#eqc(vma, vt) ⇒ Object

C extension



60
61
62
63
# File 'ext/eot/eot.c', line 60

VALUE func_eqc(VALUE klass, VALUE vma, VALUE vt) {
 rb_ivar_set(klass, id_status, INT2FIX(0));
 return DBL2NUM(eqc(NUM2DBL(vma), NUM2DBL(vt)));  
}

#eraObject

Earth rotation angle (for comparison to tl_aries which uses gmst06)



70
71
72
# File 'lib/eot/angles.rb', line 70

def era
  Celes.era00(@ajd, 0.0)
end

#f_string(sgn, u, m, s, ds) ⇒ Object

From utilities.rb: formats degree string



34
35
36
37
38
39
40
41
42
43
# File 'lib/eot/utilities.rb', line 34

def f_string(sgn, u, m, s, ds)
  sgn +
    format('%03d', u) +
  ':' +
    format('%02d', m) +
  ':' +
    format('%02d', s) +
  '.' +
  format('%3.3d', ds)
end

#float_parts(val) ⇒ Object

From displays.rb creates [h,m,s,ds] from hours Float



104
105
106
107
108
109
110
111
112
# File 'lib/eot/time_displays.rb', line 104

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

From displays.rb formats time components



81
82
83
84
85
86
87
88
89
# File 'lib/eot/time_displays.rb', line 81

def format_time(h, m, s, ds)
  format('%02d', h)   +
               ':' +
  format('%02d', m) +
               ':' +
  format('%02d', s) +
               '.' +
  format('%3.3d', ds)
end

#gml_sunObject Also known as: geometric_mean_longitude, ml_sun

angle geometric mean longitude needed to get true longitude for low accuracy.



80
81
82
# File 'lib/eot/angles.rb', line 80

def gml_sun
  ml(@ta)
end

#ha_sun(c) ⇒ Object Also known as: horizon_angle

horizon angle for provided geo coordinates used for angles from transit to horizons.



111
112
113
114
# File 'lib/eot/angles.rb', line 111

def ha_sun(c)
  zenith = choice(c)
  sun(zenith, dec_sun, @latitude)
end

#local_noon_dtObject

From times.rb: Uses @ajd and @longitude attributes Returns DateTime object of local noon or solar transit



50
51
52
# File 'lib/eot/times.rb', line 50

def local_noon_dt
  ajd_to_datetime(mean_local_noon_jd - eot_jd)
end

#ma_sunObject Also known as: mean_anomaly

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



126
127
128
129
# File 'lib/eot/angles.rb', line 126

def ma_sun
  @ta = (@ajd - DJ00) / DJC
  @ma = Celes.falp03(@ta)
end

#ma_ta_setObject

From init.rb method to reset ma and ta after initialization init sets them using ajd initial Float value see: :ajd attribute



19
20
21
22
# File 'lib/eot/init.rb', line 19

def ma_ta_set
  @ta = ((@ajd - DJ00) / DJC).to_f
  @ma = Celes.falp03(@ta)
end

#mean_local_noon_jdObject

From jd_times.rb: Uses @ajd and @longitude attributes Returns DateTime object of local mean noon or solar transit



42
43
44
# File 'lib/eot/jd_times.rb', line 42

def mean_local_noon_jd
  @ajd - @longitude / 360.0
end

#ml(vt) ⇒ Object

C extension



46
47
48
49
# File 'ext/eot/eot.c', line 46

VALUE func_ml(VALUE klass, VALUE vt) {
  rb_ivar_set(klass, id_status, INT2FIX(0));
  return DBL2NUM(mlSun(NUM2DBL(vt)));
}

#ml_ariesObject Also known as: mean_longitude_aries

Mean equinox point where right ascension is measured from as zero hours. # see www.iausofa.org/publications/aas04.pdf



138
139
140
141
142
# File 'lib/eot/angles.rb', line 138

def ml_aries
  dt = 67.184
  tt = @ajd + dt / 86_400.0
  Celes.gmst06(@ajd, 0, tt, 0)
end

#mo_earthObject Also known as: mean_obliquity_of_ecliptic, mean_obliquity

mean obliquity of Earth



150
151
152
# File 'lib/eot/angles.rb', line 150

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



48
49
50
51
# File 'lib/eot/utilities.rb', line 48

def mod_360(x = 0.0)
  x.nil? ? x = 0.0 : x
  360.0 * (x / 360.0 - Integer(x / 360.0))
end

#nautical_twilight_end_dtObject

From times.rb: Uses @ajd attribute Returns nautical twilight end as a DateTime



57
58
59
# File 'lib/eot/times.rb', line 57

def nautical_twilight_end_dt
  ajd_to_datetime(nautical_twilight_end_jd)
end

#nautical_twilight_end_jdObject

From jd_times.rb: Uses @ajd attribute Returns nautical twilight end as a Julian Day Number



49
50
51
# File 'lib/eot/jd_times.rb', line 49

def nautical_twilight_end_jd
  local_noon_dt.ajd + ha_sun(3) / P2
end

#nautical_twilight_start_dtObject

From times.rb: Uses @ajd attribute Returns nautical twilight start as a DateTime



64
65
66
# File 'lib/eot/times.rb', line 64

def nautical_twilight_start_dt
  ajd_to_datetime(nautical_twilight_start_jd)
end

#nautical_twilight_start_jdObject

From jd_times.rb: Uses @ajd attribute Returns nautical twilight start as a Julian Day Number



56
57
58
# File 'lib/eot/jd_times.rb', line 56

def nautical_twilight_start_jd
  local_noon_dt.ajd - ha_sun(3) / P2
end

#nowObject

From times.rb: sets @ajd to DateTime.now Returns EOT (equation of time) now in decimal minutes form



71
72
73
74
75
# File 'lib/eot/times.rb', line 71

def now
  @ajd = DateTime.now.to_time.utc.to_datetime.ajd
  @ta = (@ajd - DJ00) / DJC
  time_eot
end

#omegaObject

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.



164
165
166
# File 'lib/eot/angles.rb', line 164

def omega
  Celes.faom03(@ta)
end

#ra_sunObject Also known as: right_ascension

solar right ascension



173
174
175
176
177
178
# File 'lib/eot/angles.rb', line 173

def ra_sun
  y0 = sine_al_sun * cosine_to_earth
  ra = sun_ra(y0, cosine_al_sun) 
  # Celes.anp(PI + atan2(-y0, -cosine_al_sun))
  Celes.anp(PI + ra)
end

#show_minutes(min = 0.0) ⇒ Object

From displays.rb String formatter for + and - time



6
7
8
9
10
11
12
# File 'lib/eot/time_displays.rb', line 6

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



16
17
18
# File 'lib/eot/time_displays.rb', line 16

def show_now(now = now(Time.now.utc))
  show_minutes(now)
end

#sign_min(min) ⇒ Object

From displays.rb displays + or - sign



46
47
48
49
50
51
52
53
# File 'lib/eot/time_displays.rb', line 46

def sign_min(min)
  if min < 0.0
    sign = '-'
  else
    sign = '+'
  end
  sign
end

#sin_al_sun(vals) ⇒ Object

C extension



88
89
90
91
# File 'ext/eot/eot.c', line 88

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

C extension



109
110
111
112
# File 'ext/eot/eot.c', line 109

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

C extension



116
117
118
119
# File 'ext/eot/eot.c', line 116

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

C extension



95
96
97
98
# File 'ext/eot/eot.c', line 95

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

C extension



102
103
104
105
# File 'ext/eot/eot.c', line 102

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_sunObject 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_sun)
end

#sine_tl_sunObject 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_sun)
end

#sine_to_earthObject

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(to_earth)
end

#string_al_sunObject Also known as: apparent_longitude_string

String format of apparent longitude



19
20
21
# File 'lib/eot/angle_displays.rb', line 19

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



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/eot/time_displays.rb', line 22

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_sunObject Also known as: declination_string

String format of declination



27
28
29
# File 'lib/eot/angle_displays.rb', line 27

def string_dec_sun
  degrees_to_s(dec_sun)
end

#string_deg_to_time(radians = 0.0) ⇒ Object

From displays.rb radians to time method



38
39
40
41
42
# File 'lib/eot/time_displays.rb', line 38

def string_deg_to_time(radians = 0.0)
  radians.nil? ? radians = 0.0 : radians
  s, ihmsf = Celes.a2tf(3, radians)
  f_string(s, ihmsf[0], ihmsf[1], ihmsf[2], ihmsf[3])
end

#string_delta_obliqueObject

String format for delta oblique



35
36
37
# File 'lib/eot/angle_displays.rb', line 35

def string_delta_oblique
  show_minutes(delta_oblique)
end

#string_delta_orbitObject

String format for delta orbit



42
43
44
# File 'lib/eot/angle_displays.rb', line 42

def string_delta_orbit
  show_minutes(delta_orbit)
end

#string_eotObject Also known as: display_equation_of_time

From displays.rb Equation of time output for minutes and seconds



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/eot/time_displays.rb', line 57

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_eqcObject

String format for centre



49
50
51
# File 'lib/eot/angle_displays.rb', line 49

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



73
74
75
76
# File 'lib/eot/time_displays.rb', line 73

def string_jd_to_date(jd = DJ00)
  jd = check_jd_zero(jd)
  Date.jd(jd).to_s
end

#string_ma_sunObject Also known as: mean_anomaly_string

String format of mean anomaly



56
57
58
# File 'lib/eot/angle_displays.rb', line 56

def string_ma_sun
  degrees_to_s(@ma)
end

#string_ra_sunObject Also known as: right_ascension_string

String format of right ascension



64
65
66
# File 'lib/eot/angle_displays.rb', line 64

def string_ra_sun
  degrees_to_s(ra_sun)
end

#string_ta_sunObject Also known as: true_anomaly_string

String format of true anomaly



72
73
74
# File 'lib/eot/angle_displays.rb', line 72

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



116
117
118
119
120
# File 'lib/eot/time_displays.rb', line 116

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_sunObject Also known as: true_longitude_string

String format of true longitude



80
81
82
# File 'lib/eot/angle_displays.rb', line 80

def string_tl_sun
  degrees_to_s(tl_sun)
end

#string_to_earthObject Also known as: true_obliquity_string

String format of true obliquity



88
89
90
# File 'lib/eot/angle_displays.rb', line 88

def string_to_earth
  degrees_to_s(to_earth)
end

#sun(vz, vds, vlat) ⇒ Object

C extension



130
131
132
133
# File 'ext/eot/eot.c', line 130

VALUE func_sun(VALUE klass, VALUE vz, VALUE vds, VALUE vlat) {
  rb_ivar_set(klass, id_status, INT2FIX(0));
  return DBL2NUM(sun(NUM2DBL(vz), NUM2DBL(vds), NUM2DBL(vlat)));
}

#sun_dec(vals, vtoe) ⇒ Object

C extension



137
138
139
140
# File 'ext/eot/eot.c', line 137

VALUE func_sun_dec(VALUE klass, VALUE vals, VALUE vtoe) {
  rb_ivar_set(klass, id_status, INT2FIX(0));
  return DBL2NUM(sun_dec(NUM2DBL(vals), NUM2DBL(vtoe)));
}

#sun_ra(vy0, vcas) ⇒ Object

C extension



144
145
146
147
# File 'ext/eot/eot.c', line 144

VALUE func_sun_ra(VALUE klass, VALUE vy0, VALUE vcas) {
  rb_ivar_set(klass, id_status, INT2FIX(0));
  return DBL2NUM(raSun(NUM2DBL(vy0), NUM2DBL(vcas)));
}

#sunrise_dtObject

From times.rb: Uses @ajd attribute Returns a DateTime object of local sunrise



80
81
82
# File 'lib/eot/times.rb', line 80

def sunrise_dt
  ajd_to_datetime(sunrise_jd)
end

#sunrise_jdObject

From jd_times.rb: Uses @ajd attribute Returns Sunrise as a Julian Day Number



63
64
65
# File 'lib/eot/jd_times.rb', line 63

def sunrise_jd
  local_noon_dt.ajd - ha_sun(1) / P2
end

#sunset_dtObject

From times.rb: Uses @ajd attribute Returns a DateTime object of local sunset



87
88
89
# File 'lib/eot/times.rb', line 87

def sunset_dt
  ajd_to_datetime(sunset_jd)
end

#sunset_jdObject

From jd_times.rb: Uses @ajd attribute Returns Sunset as a Julian Day Number



70
71
72
# File 'lib/eot/jd_times.rb', line 70

def sunset_jd
  local_noon_dt.ajd + ha_sun(1) / P2
end

#ta_sunObject Also known as: true_anomaly

angle true anomaly used in equation of time



187
188
189
# File 'lib/eot/angles.rb', line 187

def ta_sun
  Celes.anp(@ma + eqc(@ma, @ta))
end

#time_delta_obliqueObject

From delta_times.rb: Uses @ajd attribute Returns Oblique component of EOT in decimal minutes time



7
8
9
# File 'lib/eot/delta_times.rb', line 7

def time_delta_oblique
  delta_oblique * R2D * SM
end

#time_delta_orbitObject

From delta_times.rb: Uses @ajd attribute Returns Orbit component of EOT in decimal minutes time



14
15
16
# File 'lib/eot/delta_times.rb', line 14

def time_delta_orbit
  delta_orbit * R2D * SM
end

#time_eotObject

From delta_times.rb: Uses @ajd attribute Returns EOT as a float for decimal minutes time



21
22
23
# File 'lib/eot/delta_times.rb', line 21

def time_eot
  eot * R2D * SM
end

#tl(vma, vt) ⇒ Object

C extension



67
68
69
70
# File 'ext/eot/eot.c', line 67

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_ariesObject Also known as: true_longitude_aries

true longitude of equinox ‘first point of aries’ considers nutation



198
199
200
201
202
# File 'lib/eot/angles.rb', line 198

def tl_aries
  dt = 67.184
  tt = @ajd + dt / 86_400.0
  Celes.gst06a(@ajd, 0, tt, 0)
end

#tl_sunObject Also known as: true_longitude, ecliptic_longitude, lambda

angle of true longitude sun used in equation of time



211
212
213
# File 'lib/eot/angles.rb', line 211

def tl_sun
  tl(@ma, @ta)
end

#to_earthObject Also known as: obliquity_correction, true_obliquity, toearth

true obliquity considers nutation



223
224
225
# File 'lib/eot/angles.rb', line 223

def to_earth
  mo_earth + angle_delta_epsilon
end