equationoftime 4.1.2 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +6 -4
  5. data/Gemfile.lock +21 -14
  6. data/Guardfile +4 -21
  7. data/Manifest.txt +18 -52
  8. data/README.rdoc +6 -6
  9. data/Rakefile +53 -92
  10. data/equationoftime.gemspec +48 -49
  11. data/examples/my_lst.rb +9 -0
  12. data/examples/use_addr.rb +20 -0
  13. data/examples/use_ajd.rb +40 -0
  14. data/ext/eot/ceot.c +18 -14
  15. data/ext/eot/extconf.rb +4 -5
  16. data/lib/eot/angle_displays.rb +95 -0
  17. data/lib/eot/angles.rb +160 -291
  18. data/lib/eot/constants.rb +78 -81
  19. data/lib/eot/deltas.rb +40 -0
  20. data/lib/eot/geo_lat_lng_smt.rb +30 -57
  21. data/lib/eot/init.rb +86 -124
  22. data/lib/eot/time_displays.rb +105 -0
  23. data/lib/eot/times.rb +118 -121
  24. data/lib/eot/trigometric.rb +51 -0
  25. data/lib/eot/utilities.rb +49 -50
  26. data/lib/eot/version.rb +3 -2
  27. data/lib/eot.rb +11 -5
  28. data/test/eot/aliased_angles_spec.rb +291 -0
  29. data/test/eot/aliased_displays_spec.rb +126 -0
  30. data/test/{aliased_utilities_spec.rb → eot/aliased_utilities_spec.rb} +32 -36
  31. data/test/eot/angles_spec.rb +261 -0
  32. data/test/eot/constants_spec.rb +17 -0
  33. data/test/eot/displays_spec.rb +111 -0
  34. data/test/eot/geo_spec.rb +40 -0
  35. data/test/eot/init_spec.rb +45 -0
  36. data/test/eot/times_spec.rb +137 -0
  37. data/wiki.md +55 -0
  38. data/wiki2.md +4 -0
  39. data.tar.gz.sig +0 -0
  40. metadata +55 -69
  41. metadata.gz.sig +0 -0
  42. data/.settings/org.eclipse.ltk.core.refactoring.prefs +0 -2
  43. data/examples/analemma_data_generator.rb +0 -58
  44. data/examples/check_date_type.rb +0 -60
  45. data/examples/compare_geoc_long_ra.rb +0 -44
  46. data/examples/data_table_for_astro_dog.rb +0 -45
  47. data/examples/earth_rotation.rb +0 -42
  48. data/examples/eot_methods_list.rb +0 -48
  49. data/examples/eot_plot.r +0 -57
  50. data/examples/eot_suntimes.rb +0 -149
  51. data/examples/equation_of_time.py +0 -186
  52. data/examples/figure_1.jpg +0 -0
  53. data/examples/file_converter.rb +0 -31
  54. data/examples/from_readme.rb +0 -14
  55. data/examples/from_wiki.rb +0 -46
  56. data/examples/geo_locator.rb +0 -16
  57. data/examples/getjd.rb +0 -45
  58. data/examples/gmst_gast_non_sofa.rb +0 -406
  59. data/examples/input_suntimes.rb +0 -24
  60. data/examples/julian_day_formula.rb +0 -29
  61. data/examples/julian_day_formula.txt +0 -12
  62. data/examples/my_time_conversion.rb +0 -21
  63. data/examples/nutation_series.txt +0 -678
  64. data/examples/nutation_table5_3a.txt +0 -682
  65. data/examples/ptime.rb +0 -162
  66. data/examples/suntimes.rb +0 -30
  67. data/examples/suntimes_test.rb +0 -50
  68. data/examples/t_sofa.rb +0 -8228
  69. data/examples/test_celes.rb +0 -51
  70. data/examples/test_ceot.rb +0 -55
  71. data/examples/test_poly_eval.rb +0 -32
  72. data/examples/time_scales.rb +0 -29
  73. data/examples/times_year.rb +0 -53
  74. data/examples/usage_example.rb +0 -26
  75. data/examples/use_angles.rb +0 -222
  76. data/lib/eot/displays.rb +0 -216
  77. data/lib/eot/eot.so +0 -0
  78. data/lib/eot/nutation.rb +0 -78
  79. data/run_tests_eclipse.rb +0 -1
  80. data/test/aliased_angles_spec.rb +0 -239
  81. data/test/aliased_displays_spec.rb +0 -105
  82. data/test/angles_spec.rb +0 -264
  83. data/test/constants_spec.rb +0 -20
  84. data/test/displays_spec.rb +0 -110
  85. data/test/geo_spec.rb +0 -38
  86. data/test/init_spec.rb +0 -44
  87. data/test/nutation_spec.rb +0 -37
  88. data/test/spec_config.rb +0 -8
  89. data/test/times_spec.rb +0 -133
  90. data/test/utilities_spec.rb +0 -35
@@ -0,0 +1,105 @@
1
+ # class Eot file = time_displays.rb
2
+ class Eot
3
+ # From displays.rb
4
+ # String formatter for + and - time
5
+ def show_minutes(min = 0.0)
6
+ min.nil? ? min = 0.0 : min
7
+ time = Time.utc(1, 1, 1, 0, 0, 0, 0.0)
8
+ time += (min.abs * 60.0)
9
+ sign = sign_min(min)
10
+ time.strftime("#{sign}%M:%S.%3N")
11
+ end
12
+
13
+ # From displays.rb
14
+ # String for time now
15
+ def show_now(now = now(Time.now.utc))
16
+ show_minutes(now)
17
+ end
18
+
19
+ # From displays.rb
20
+ # String formatter for fraction of Julian day number
21
+ def string_day_fraction_to_time(jpd_time = 0.0)
22
+ jpd_time.nil? ? jpd_time = 0.0 : jpd_time
23
+ fraction = jpd_time + 0.5 - Integer(jpd_time)
24
+ h = Integer(fraction * DAY_HOURS)
25
+ m = Integer((fraction - h / DAY_HOURS) * DAY_MINUTES)
26
+ s = Integer((fraction - h / 24.0 - m / DAY_MINUTES) * DAY_SECONDS)
27
+ format('%02d', h) +
28
+ ':' +
29
+ format('%02d', m) +
30
+ ':' +
31
+ format('%02d', s)
32
+ end
33
+ alias_method :julian_period_day_fraction_to_time, :string_day_fraction_to_time
34
+
35
+ def sign_min(min)
36
+ if min < 0.0
37
+ sign = '-'
38
+ else
39
+ sign = '+'
40
+ end
41
+ sign
42
+ end
43
+
44
+ # From displays.rb
45
+ # Equation of time output for minutes and seconds
46
+ def string_eot
47
+ min_eot = time_eot
48
+ sign = sign_min(min_eot)
49
+ eot = min_eot.abs
50
+ minutes = Integer(eot)
51
+ seconds = (eot - minutes) * 60.0
52
+ decimal_seconds = (seconds - Integer(seconds)) * 100.0
53
+ min = format('%02d', minutes)
54
+ sec = format('%02d', seconds)
55
+ dec_sec = format('%01d', decimal_seconds)
56
+ sign << min << 'm, ' << sec << '.' << dec_sec << 's'
57
+ end
58
+ alias_method :display_equation_of_time, :string_eot
59
+
60
+ # From displays.rb
61
+ # String format conversion of jd to date
62
+ def string_jd_to_date(jd = DJ00)
63
+ jd = check_jd_zero(jd)
64
+ Date.jd(jd).to_s
65
+ end
66
+ alias_method :jd_to_date_string, :string_jd_to_date
67
+
68
+ def format_time(h, m, s, ds)
69
+ format('%02d', h) +
70
+ ':' +
71
+ format('%02d', m) +
72
+ ':' +
73
+ format('%02d', s) +
74
+ '.' +
75
+ format('%3.3d', ds)
76
+ end
77
+
78
+ def dt_parts(val)
79
+ h = val.hour
80
+ m = val.min
81
+ s = val.sec
82
+ is = Integer(s)
83
+ ds = Integer((s - is).round(3) * 1000.0)
84
+ [h, m, is, ds]
85
+ end
86
+
87
+ def float_parts(val)
88
+ hours = Integer(val % DAY_HOURS)
89
+ mins = 60.0 * (val % DAY_HOURS - hours)
90
+ imins = Integer(mins)
91
+ secs = 60.0 * (mins - imins)
92
+ isecs = Integer(secs)
93
+ ds = Integer((secs - isecs).round(3) * 1000.0)
94
+ [hours, imins, isecs, ds]
95
+ end
96
+
97
+ # From displays.rb
98
+ # String formatter for h:m:s display
99
+ def string_time(dt = DT2000)
100
+ dt = check_t_zero(dt)
101
+ dt.class == DateTime ? ta = dt_parts(dt) : ta = float_parts(dt)
102
+ format_time(ta[0], ta[1], ta[2], ta[3])
103
+ end
104
+ alias_method :display_time_string, :string_time
105
+ end
data/lib/eot/times.rb CHANGED
@@ -1,121 +1,118 @@
1
- # times.rb
2
-
3
- class Eot
4
-
5
- # From times.rb:
6
- # Pass in an AJD number
7
- # Returns a DateTime object
8
- def ajd_to_datetime(ajd)
9
- DateTime.jd(ajd + 0.5)
10
- end
11
-
12
- # From times.rb:
13
- # Uses @ajd attribute
14
- # Returns EOT as an AJD Julian number
15
- def eot_jd
16
- time_eot() / DAY_MINUTES
17
- end
18
-
19
- # From times.rb:
20
- # Uses @ajd and @longitude attributes
21
- # Returns DateTime object of local noon or solar transit
22
- def local_noon_dt()
23
- ajd_to_datetime(@ajd - @longitude / 360.0 - eot_jd())
24
- end
25
-
26
- # From times.rb:
27
- # Uses @ajd and @longitude attributes
28
- # Returns DateTime object of local mean noon or solar transit
29
- def mean_local_noon_dt()
30
- ajd_to_datetime(@ajd - @longitude / 360.0)
31
- end
32
-
33
- # From times.rb:
34
- # sets @ajd to DateTime.now
35
- # Returns EOT (equation of time) now in decimal minutes form
36
- def now()
37
- @ajd = DateTime.now.to_time.utc.to_datetime.ajd
38
- @ta = (@ajd - DJ00)/DJC
39
- time_eot()
40
- end
41
-
42
- # From times.rb:
43
- # Uses @ajd attribute
44
- # Returns a DateTime object of local sunrise
45
- def sunrise_dt()
46
- ajd_to_datetime(sunrise_jd())
47
- end
48
-
49
- # From times.rb:
50
- # Uses @ajd attribute
51
- # Returns Sunrise as a Julian Day Number
52
- def sunrise_jd()
53
- local_noon_dt().ajd - ha_Sun() * R2D / 360.0
54
- end
55
-
56
- # From times.rb:
57
- # Uses @ajd attribute
58
- # Returns a DateTime object of local sunset
59
- def sunset_dt()
60
- ajd_to_datetime(sunset_jd())
61
- end
62
-
63
- # From times.rb:
64
- # Uses @ajd attribute
65
- # Returns Sunset as a Julian Day Number
66
- def sunset_jd()
67
- local_noon_dt().ajd + ha_Sun() * R2D / 360.0
68
- end
69
-
70
- # From times.rb:
71
- # Uses @ajd attribute
72
- # Returns Oblique component of EOT in decimal minutes time
73
- def time_delta_oblique()
74
- (tl_Sun() - ra_Sun()) * R2D * SM
75
- end
76
-
77
- # From times.rb:
78
- # Uses @ajd attribute
79
- # Returns Orbit component of EOT in decimal minutes time
80
- def time_delta_orbit()
81
- (@ma - ta_Sun()) * R2D * SM
82
- end
83
-
84
- # From times.rb:
85
- # Uses @ajd attribute
86
- # Returns EOT as a float for decimal minutes time
87
- def time_eot()
88
- eot() * R2D * SM
89
- end
90
-
91
- # From times.rb:
92
- # All calculations with ( ta ) were based on this.
93
- # Julian Century Time is a fractional century
94
- # Julian Day Number DJ00 is subtracted from the JDN or AJDN and then divided
95
- # by days in a Julian Century.
96
- # Deprecated
97
- def time_julian_century()
98
- t1 = ( @ajd - DJ00 ) / DJC
99
- # t2 = t1 * t1
100
- # t3 = t1 * t2
101
- # t4 = t2 * t2
102
- # t5 = t2 * t3
103
- # t6 = t3 * t3
104
- # t7 = t3 * t4
105
- # t8 = t4 * t4
106
- # t9 = t4 * t5
107
- # t10 = t5 * t5
108
- # @ta = [ t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 ]
109
- @ta = t1
110
- end
111
- alias_method :time_julian_centurey, :time_julian_century
112
-
113
- end
114
-
115
- if __FILE__ == $PROGRAM_NAME
116
-
117
- spec = File.expand_path('../../../tests/minitest', __FILE__)
118
- $LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
119
- require 'times_spec'
120
-
121
- end
1
+ # class Eot file = times.rb
2
+ class Eot
3
+ # From times.rb:
4
+ # Pass in an AJD number
5
+ # Returns a DateTime object
6
+ def ajd_to_datetime(ajd)
7
+ DateTime.jd(ajd + 0.5)
8
+ end
9
+
10
+ # From times.rb:
11
+ # Uses @ajd attribute
12
+ # Returns EOT as an AJD Julian number
13
+ def eot_jd
14
+ time_eot / DAY_MINUTES
15
+ end
16
+
17
+ # From times.rb:
18
+ # Uses @ajd and @longitude attributes
19
+ # Returns DateTime object of local noon or solar transit
20
+ def local_noon_dt
21
+ ajd_to_datetime(@ajd - @longitude / 360.0 - eot_jd)
22
+ end
23
+
24
+ # From times.rb:
25
+ # Uses @ajd and @longitude attributes
26
+ # Returns DateTime object of local mean noon or solar transit
27
+ def mean_local_noon_dt
28
+ ajd_to_datetime(@ajd - @longitude / 360.0)
29
+ end
30
+
31
+ # From times.rb:
32
+ # sets @ajd to DateTime.now
33
+ # Returns EOT (equation of time) now in decimal minutes form
34
+ def now
35
+ @ajd = DateTime.now.to_time.utc.to_datetime.ajd
36
+ @ta = (@ajd - DJ00) / DJC
37
+ time_eot
38
+ end
39
+
40
+ # From times.rb:
41
+ # Uses @ajd attribute
42
+ # Returns a DateTime object of local sunrise
43
+ def sunrise_dt
44
+ ajd_to_datetime(sunrise_jd)
45
+ end
46
+
47
+ # From times.rb:
48
+ # Uses @ajd attribute
49
+ # Returns Sunrise as a Julian Day Number
50
+ def sunrise_jd
51
+ local_noon_dt.ajd - ha_sun * R2D / 360.0
52
+ end
53
+
54
+ # From times.rb:
55
+ # Uses @ajd attribute
56
+ # Returns a DateTime object of local sunset
57
+ def sunset_dt
58
+ ajd_to_datetime(sunset_jd)
59
+ end
60
+
61
+ # From times.rb:
62
+ # Uses @ajd attribute
63
+ # Returns Sunset as a Julian Day Number
64
+ def sunset_jd
65
+ local_noon_dt.ajd + ha_sun * R2D / 360.0
66
+ end
67
+
68
+ # From times.rb:
69
+ # Uses @ajd attribute
70
+ # Returns Oblique component of EOT in decimal minutes time
71
+ def time_delta_oblique
72
+ (tl_sun - ra_sun) * R2D * SM
73
+ end
74
+
75
+ # From times.rb:
76
+ # Uses @ajd attribute
77
+ # Returns Orbit component of EOT in decimal minutes time
78
+ def time_delta_orbit
79
+ (@ma - ta_sun) * R2D * SM
80
+ end
81
+
82
+ # From times.rb:
83
+ # Uses @ajd attribute
84
+ # Returns EOT as a float for decimal minutes time
85
+ def time_eot
86
+ eot * R2D * SM
87
+ end
88
+
89
+ # From times.rb:
90
+ # All calculations with ( ta ) were based on this.
91
+ # Julian Century Time is a fractional century
92
+ # Julian Day Number DJ00 is subtracted from the JDN or AJDN and then divided
93
+ # by days in a Julian Century.
94
+ # Deprecated
95
+ def time_julian_century
96
+ t1 = (@ajd - DJ00) / DJC
97
+ # t2 = t1 * t1
98
+ # t3 = t1 * t2
99
+ # t4 = t2 * t2
100
+ # t5 = t2 * t3
101
+ # t6 = t3 * t3
102
+ # t7 = t3 * t4
103
+ # t8 = t4 * t4
104
+ # t9 = t4 * t5
105
+ # t10 = t5 * t5
106
+ # @ta = [ t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 ]
107
+ @ta = t1
108
+ end
109
+ alias_method :time_julian_centurey, :time_julian_century
110
+ end
111
+
112
+ if __FILE__ == $PROGRAM_NAME
113
+
114
+ spec = File.expand_path('../../../tests/minitest', __FILE__)
115
+ $LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
116
+ require 'times_spec'
117
+
118
+ end
@@ -0,0 +1,51 @@
1
+ # class Eot file = trigometric.rb
2
+ class Eot
3
+ include Math
4
+ # From trigometric.rb:
5
+ # cosine apparent longitude
6
+ # could be useful when dividing
7
+ def cosine_al_sun
8
+ cos(al(@ma, @ta, Celes.faom03(@ta)))
9
+ end
10
+ alias_method :cosine_apparent_longitude, :cosine_al_sun
11
+ alias_method :cosalsun, :cosine_al_sun
12
+
13
+ # From trigometric.rb:
14
+ # cosine true longitude
15
+ # used in solar right ascension
16
+ def cosine_tl_sun
17
+ cos(tl(@ma, @ta))
18
+ end
19
+ alias_method :cosine_true_longitude, :cosine_tl_sun
20
+
21
+ # From trigometric.rb:
22
+ # cosine true obliquity
23
+ # used in solar right ascension and equation of equinox
24
+ def cosine_to_earth
25
+ cos(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0))
26
+ end
27
+ alias_method :cosine_true_obliquity, :cosine_to_earth
28
+
29
+ # From trigometric.rb:
30
+ # sine apparent longitude
31
+ # used in solar declination
32
+ def sine_al_sun
33
+ sin(al(@ma, @ta, Celes.faom03(@ta)))
34
+ end
35
+ alias_method :sine_apparent_longitude, :sine_al_sun
36
+
37
+ # From trigometric.rb:
38
+ # sine true longitude
39
+ # used in solar right ascension
40
+ def sine_tl_sun
41
+ sin(tl(@ma, @ta))
42
+ end
43
+ alias_method :sine_true_longitude, :sine_tl_sun
44
+
45
+ # From trigometric.rb:
46
+ # sine true obliquity angle of Earth
47
+ # used in solar declination
48
+ def sine_to_earth
49
+ sin(Celes.nut06a(@ajd, 0)[1] + Celes.obl06(@ajd, 0))
50
+ end
51
+ end
data/lib/eot/utilities.rb CHANGED
@@ -1,50 +1,49 @@
1
- # utilities.rb
2
-
3
- class Eot
4
- # From utilities.rb:
5
- # A check for default J2000
6
- # sets default when arg is nil
7
- def check_jd_nil( jd = DJ00 )
8
- jd.nil? ? jd = DJ00 : jd
9
- end
10
-
11
- # From utilities.rb:
12
- # A check for default J2000
13
- # sets default when arg is zero
14
- def check_jd_zero( jd = DJ00 )
15
- jd == 0 ? jd = DJ00 : jd = check_jd_nil( jd )
16
- end
17
-
18
- # From utilities.rb:
19
- # A check for default DT2000
20
- # sets default when arg is nil
21
- def check_t_nil( dt = DT2000 )
22
- dt.nil? ? dt = DT2000 : dt
23
- end
24
-
25
- # From utilities.rb:
26
- # A check for default DT2000
27
- # sets default when arg is zero
28
- def check_t_zero( dt = DT2000 )
29
- dt == 0 ? dt = DT2000 : dt = check_t_nil( dt )
30
- end
31
-
32
- # From utilities.rb:
33
- # Keeps large angles in range of 360.0
34
- # aliased by truncate
35
- def mod_360( x = 0.0 )
36
- x.nil? ? x = 0.0 : x
37
- 360.0 * ( x / 360.0 - Integer( x / 360.0 ) )
38
- end
39
- alias_method :truncate, :mod_360
40
-
41
- end
42
-
43
- if __FILE__ == $PROGRAM_NAME
44
-
45
- spec = File.expand_path('../../../tests/minitest', __FILE__)
46
- $LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
47
- require 'utilities_spec'
48
- require 'aliased_utilities_spec'
49
-
50
- end
1
+ # utilities.rb
2
+ # class Eot
3
+ class Eot
4
+ # From utilities.rb:
5
+ # A check for default J2000
6
+ # sets default when arg is nil
7
+ def check_jd_nil(jd = DJ00)
8
+ jd.nil? ? DJ00 : jd
9
+ end
10
+
11
+ # From utilities.rb:
12
+ # A check for default J2000
13
+ # sets default when arg is zero
14
+ def check_jd_zero(jd = DJ00)
15
+ jd == 0 ? DJ00 : check_jd_nil(jd)
16
+ end
17
+
18
+ # From utilities.rb:
19
+ # A check for default DT2000
20
+ # sets default when arg is nil
21
+ def check_t_nil(dt = DT2000)
22
+ dt.nil? ? DT2000 : dt
23
+ end
24
+
25
+ # From utilities.rb:
26
+ # A check for default DT2000
27
+ # sets default when arg is zero
28
+ def check_t_zero(dt = DT2000)
29
+ dt == 0 ? DT2000 : check_t_nil(dt)
30
+ end
31
+
32
+ # From utilities.rb:
33
+ # Keeps large angles in range of 360.0
34
+ # aliased by truncate
35
+ def mod_360(x = 0.0)
36
+ x.nil? ? x = 0.0 : x
37
+ 360.0 * (x / 360.0 - Integer(x / 360.0))
38
+ end
39
+ alias_method :truncate, :mod_360
40
+ end
41
+
42
+ if __FILE__ == $PROGRAM_NAME
43
+
44
+ spec = File.expand_path('../../../tests/minitest', __FILE__)
45
+ $LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
46
+ require 'utilities_spec'
47
+ require 'aliased_utilities_spec'
48
+
49
+ end
data/lib/eot/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # class Eot file = version.rb
1
2
  class Eot
2
- VERSION = "4.1.2"
3
- end
3
+ VERSION = '4.1.4'
4
+ end
data/lib/eot.rb CHANGED
@@ -1,13 +1,19 @@
1
1
  # eot.rb
2
-
3
-
2
+ # require 'multi_xml'
3
+ require 'addressable/uri'
4
+ require 'rest-client'
5
+ require 'json'
6
+ require 'celes'
7
+ require 'date'
4
8
  require 'eot/version'
5
9
  require 'eot/eot'
6
10
  require 'eot/constants'
7
11
  require 'eot/init'
8
12
  require 'eot/utilities'
9
13
  require 'eot/angles'
14
+ require 'eot/deltas'
15
+ require 'eot/trigometric'
10
16
  require 'eot/times'
11
- require 'eot/displays'
12
- require 'eot/nutation'
13
- require 'eot/geo_lat_lng_smt'
17
+ require 'eot/angle_displays'
18
+ require 'eot/time_displays'
19
+ require 'eot/geo_lat_lng_smt'