equationoftime 3.0.0

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 (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.md +22 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +80 -0
  8. data/README2.txt +70 -0
  9. data/Rakefile +80 -0
  10. data/doc/GeoLatLng.html +770 -0
  11. data/doc/_index.html +123 -0
  12. data/doc/class_list.html +54 -0
  13. data/doc/css/common.css +1 -0
  14. data/doc/css/full_list.css +57 -0
  15. data/doc/css/style.css +339 -0
  16. data/doc/file.README.html +179 -0
  17. data/doc/file_list.html +56 -0
  18. data/doc/frames.html +26 -0
  19. data/doc/index.html +179 -0
  20. data/doc/js/app.js +219 -0
  21. data/doc/js/full_list.js +178 -0
  22. data/doc/js/jquery.js +4 -0
  23. data/doc/method_list.html +611 -0
  24. data/doc/top-level-namespace.html +112 -0
  25. data/equationoftime.gemspec +35 -0
  26. data/examples/Equation_of_Time.jpg +0 -0
  27. data/examples/analemma_data_generator.rb +53 -0
  28. data/examples/check_date_type.rb +57 -0
  29. data/examples/compare_geoc_long_ra.rb +31 -0
  30. data/examples/data_table.rb +26 -0
  31. data/examples/earth_rotation.rb +13 -0
  32. data/examples/eot_methods_list.rb +16 -0
  33. data/examples/eot_plot.r +57 -0
  34. data/examples/eot_suntimes.rb +140 -0
  35. data/examples/equation_of_time.py +186 -0
  36. data/examples/figure_1.jpg +0 -0
  37. data/examples/file_converter.rb +31 -0
  38. data/examples/from_readme.rb +10 -0
  39. data/examples/geo_locator.rb +12 -0
  40. data/examples/getjd.rb +45 -0
  41. data/examples/input_suntimes.rb +21 -0
  42. data/examples/julian_day_formula.rb +29 -0
  43. data/examples/julian_day_formula.txt +12 -0
  44. data/examples/my_time_conversion.rb +21 -0
  45. data/examples/nutation_series.txt +678 -0
  46. data/examples/nutation_series.yaml +14239 -0
  47. data/examples/nutation_table5_3a.txt +682 -0
  48. data/examples/nutation_table5_3a.yaml +9532 -0
  49. data/examples/ptime.rb +162 -0
  50. data/examples/read_nutation_data.rb +399 -0
  51. data/examples/suntimes.rb +28 -0
  52. data/examples/suntimes_test.rb +47 -0
  53. data/examples/test_poly_eval.rb +38 -0
  54. data/examples/time_scales.rb +29 -0
  55. data/examples/usage_example.rb +13 -0
  56. data/examples/use_angles.rb +155 -0
  57. data/lib/eot/angles.rb +337 -0
  58. data/lib/eot/constants.rb +168 -0
  59. data/lib/eot/displays.rb +213 -0
  60. data/lib/eot/geo_lat_lng_smt.rb +80 -0
  61. data/lib/eot/init.rb +93 -0
  62. data/lib/eot/nutation.rb +70 -0
  63. data/lib/eot/nutation_table5_3a.yaml +9532 -0
  64. data/lib/eot/times.rb +130 -0
  65. data/lib/eot/utilities.rb +129 -0
  66. data/lib/eot/version.rb +6 -0
  67. data/lib/eot.rb +11 -0
  68. data/tests/minitest/aliased_angles_spec.rb +287 -0
  69. data/tests/minitest/aliased_displays_spec.rb +106 -0
  70. data/tests/minitest/aliased_times_spec.rb +36 -0
  71. data/tests/minitest/aliased_utilities_spec.rb +49 -0
  72. data/tests/minitest/angles_spec.rb +313 -0
  73. data/tests/minitest/constants_spec.rb +27 -0
  74. data/tests/minitest/delta_epsilon_spec.rb +35 -0
  75. data/tests/minitest/displays_spec.rb +111 -0
  76. data/tests/minitest/geo_spec.rb +36 -0
  77. data/tests/minitest/init_spec.rb +32 -0
  78. data/tests/minitest/nutation_spec.rb +33 -0
  79. data/tests/minitest/times_spec.rb +137 -0
  80. data/tests/minitest/utilities_spec.rb +121 -0
  81. data/tests/spec_config.rb +3 -0
  82. data/wiki.md +46 -0
  83. data/wiki2.md +4 -0
  84. metadata +240 -0
data/examples/ptime.rb ADDED
@@ -0,0 +1,162 @@
1
+ require 'date'
2
+ require 'bigdecimal'
3
+ include Math
4
+
5
+
6
+ def degrees_to_radians(degrees)
7
+ bd(degrees * PI / 180.0)
8
+ end
9
+
10
+ def radians_to_degrees(radians)
11
+ bd(radians * 180.0 / PI)
12
+ end
13
+
14
+ # Truncate large angles
15
+ def truncate(x)
16
+ bd(360.0 * ( x / 360.0 - Integer( x / 360.0)))
17
+ end
18
+
19
+ def bd(var)
20
+ BigDecimal(var.to_s).round(16)# * 1.0
21
+ end
22
+
23
+ def calc_time_julian_century(t)
24
+ # Julian Day Number j(2000) subtracted
25
+ (t - 2451545.0)/36525.0
26
+ # Time in fractional centurey
27
+ end
28
+
29
+ def calc_eccentricity_earth_orbit(t)
30
+ 0.016708617 - t * (0.000042037 + 0.0000001235 * t)#unitless
31
+ #~ puts "EccentricityEarthOrbit = #{eccentricity}"
32
+ end
33
+
34
+ def mean_anomaly(t)
35
+ (357.527723333 + truncate(35640.0 * t) \
36
+ + t * (359.05034 - t * (0.0001602777778 \
37
+ + t / 300000.0))) % 360.0
38
+ #~ t2 = t **2
39
+ #~ t3 = t **3
40
+ #~ t4 = t **4
41
+ #~ @mean_anomaly = 1287104.79305 + 129596581.0481 * t - 0.5532 * t2 + 0.000136 * t3 - 0.00001149 * t4
42
+ #~ @mean_anomaly = 357.527723333 + 359.05034 * t + trunc(35640.0 * t) - 0.0001602777778 * t2 - t3/300000.0
43
+ #~ @mean_anomaly = 357.52910 + t * 35999.05034 - t2 * 0.0001559 - t3 * 0.00000048
44
+ #~ puts "GeomMeanAnomalySun = #{mean_anomaly%360}"
45
+ #~ return mean_anomaly % 360 # in degrees
46
+ end
47
+
48
+ def calc_geom_mean_long_sun(t)
49
+ #~ //Mean longitude of the sun
50
+ t2 = t * t
51
+ t3 = t2 * t
52
+ t4 = t3 * t
53
+ t5 = t4 * t
54
+ truncate(280.4664567 + t * 36000.76982779 \
55
+ + t2 * 0.0003032028 + t3/49931.0 \
56
+ - t4/15299.0 - t5/1988000.0)
57
+ end
58
+
59
+ def sun_eq_of_center(t)
60
+ #t2 = t **2
61
+ mean_anomaly = mean_anomaly(t)
62
+ #~ puts "GeomMeanAnomalySun = #{m}"
63
+ marad = degrees_to_radians(mean_anomaly)
64
+ sinmarad = sin(marad)
65
+ eccentricity = calc_eccentricity_earth_orbit(t)
66
+ sin2marad = sin(2.0 * marad)
67
+ sin3marad = sin(3.0 * marad)
68
+ sinmarad * (1.914602 - t * (0.004817 + 0.000014 * t))\
69
+ + sin2marad * (0.019993 - 0.000101 * t)\
70
+ + sin3marad * 0.000289
71
+ end
72
+
73
+ def true_anomaly(t)
74
+ mean_anomaly = mean_anomaly(t)
75
+ eqc = sun_eq_of_center(t)
76
+ bd(mean_anomaly + eqc) * 1.0
77
+ end
78
+
79
+ def calc_sun_true_long(t)
80
+ mean_lon = calc_geom_mean_long_sun(t)
81
+ eqc = sun_eq_of_center(t)
82
+ mean_lon + eqc - 0.01397 * (Time.now.year - 2000)
83
+ end
84
+
85
+ def mean_obliquity_of_ecliptic(t)
86
+ bd(23.4392911111 - t * (0.0130041666667 + t * (1.63888888889e-07 - (5.03611111111e-07 * t)))) * 1.0
87
+ end
88
+
89
+ def omega(t)
90
+ bd(125.04455501 - truncate(1800.0 * t) \
91
+ - t * (134.136261972 \
92
+ - t * (0.00207561111111 \
93
+ + t * (2.13944444444e-06 \
94
+ - t * 1.64972222222e-08 \
95
+ )))) * 1.0
96
+ bd(125.04455501 - truncate(1800.0 * t) \
97
+ - t * 134.136261972 \
98
+ + t * t * 0.00207561111111 \
99
+ + t * t * t * 2.13944444444e-06 \
100
+ - t * t * t * t * 1.64972222222e-08 \
101
+ ) * 1.0
102
+ end
103
+
104
+ def obliquity_correction(t)
105
+ eps0 = mean_obliquity_of_ecliptic(t)
106
+ omega = omega(t)
107
+ delta_eps = bd(0.00256 * cos(degrees_to_radians(omega)))
108
+ bd(eps0 + delta_eps)
109
+ end
110
+
111
+ def sun_right_ascension(t)
112
+ lambda = calc_sun_true_long(t)
113
+ epsilon = obliquity_correction(t)
114
+ y0 = bd(sin(degrees_to_radians(lambda)))
115
+ x0 = bd(cos(degrees_to_radians(lambda)))
116
+ y0 = bd(y0 * cos(degrees_to_radians(epsilon)))
117
+ bd(radians_to_degrees(atan2(-y0, -x0)) + 180.0) * 1.0
118
+ end
119
+
120
+ def mean_long_aries(t)
121
+ d = bd(t * 36525.0)
122
+ bd(truncate(280.46061666 + d * 360.98564736629\
123
+ + t * (t * 0.000387933\
124
+ - t * (t / 38710000.0)))) * 1.0
125
+ end
126
+
127
+ pdate = Date.new(2014, 1, 3)
128
+ pd = pdate.ajd * 1.0
129
+ #puts pd
130
+ daysecs = 2 * 84600.0
131
+
132
+ for seconds in 1..daysecs
133
+ #puts seconds / 84600.0
134
+ jdt = calc_time_julian_century(pd + seconds / 84600.0)
135
+ mas = bd(mean_anomaly(jdt)).round(3) * 1.0
136
+ #puts mas
137
+ tas = bd(true_anomaly(jdt)).round(3) * 1.0
138
+ #puts tas
139
+ if (mas + tas) == 720
140
+ d = pd + seconds / 84600.0
141
+ #puts d
142
+ pt = jdt % 1.0
143
+ break
144
+ #~ else
145
+ #~ d = 0
146
+ #~ pt = 0
147
+ end
148
+ end
149
+
150
+ #~ puts d
151
+ #~ puts pt
152
+ puts "2014 perihelion occurred at #{d}"
153
+ tls = calc_sun_true_long(pt)
154
+ puts "lambda perihelion = #{tls}"
155
+ sra = sun_right_ascension(pt)
156
+ puts "Right ascesion = #{sra}"
157
+ ma = mean_long_aries(pt)
158
+ puts "GHA Aries = #{ma}"
159
+
160
+
161
+
162
+
@@ -0,0 +1,399 @@
1
+ # read_nutation_data.rb
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'eot'
7
+ #~ require 'safe_yaml'
8
+
9
+ # create an instance of Equation_of_Time class
10
+ eot = Eot.new
11
+
12
+
13
+ =begin
14
+
15
+ The file this data comes from is 'Circular_179.pdf' IAU 2000A Nutation Series.
16
+ The first 678 lines are for lunisolar data.
17
+
18
+ # Try to make an array using each line of the file
19
+ filename = 'nutation_series.txt'
20
+ temp_array = []
21
+ data = File.readlines(filename)
22
+ # Clean out whitespace and new line breaks.
23
+ data.each {|i| temp_array << i.strip}
24
+ # Make new muti-dimensional data array.
25
+ data = []
26
+ temp_array.each {|i| data << i.split}
27
+ # Save the array in a file.
28
+ File::open( "nutation_series.data", "w" ) do |f|
29
+ f << data
30
+ end
31
+
32
+ # Make new muti-dimensional data array using yaml
33
+ data = []
34
+ temp_array.each {|i| data << i.split}
35
+ # Save the array in a yaml file.
36
+ File::open( "nutation_series.yaml", "w" ) do |f|
37
+ f << data.to_yaml
38
+ end
39
+
40
+
41
+ # $:.unshift(File.expand_path(File.dirname(__FILE__)))
42
+ # require 'nutation_series_data'
43
+ # or for => Ruby 1.9.2
44
+ require_relative 'nutation_series_data'
45
+ # I manually added @data = to the beginning of the new array file nutation_series.rb so we may use it
46
+ # data = @data
47
+
48
+ # load in the yaml data
49
+ data = []
50
+ File.open( "nutation_series2.yaml" ) do |f|
51
+ YAML.load_documents( f ) do |doc|
52
+ data = doc
53
+ end
54
+ end
55
+
56
+ =end
57
+
58
+ # data was initialized when the class instance was via nutation_series2.yaml file.
59
+ #data = eot.data
60
+ file_path = File.expand_path( File.dirname( __FILE__ ) + "/nutation_table5_3a.yaml" )
61
+ data = YAML::load( File.open( file_path, 'r'), :safe => true ).freeze
62
+ # Arc seconds to radians formula
63
+ ARCSEC = 3600.0
64
+ dtr = Math::PI / 180.0 / ARCSEC # adjusted for working in the arc seconds values
65
+
66
+ # sine degrees
67
+ def sind(dtr, x)
68
+ Math::sin(dtr*x)
69
+ end
70
+ # cod degrees
71
+ def cosd(dtr, x)
72
+ Math::cos(dtr*x)
73
+ end
74
+
75
+
76
+ # The JD is at Noon 12:00 UTC for today
77
+ # In all of these expressions, T is the number of Julian centuries of TDB since 2000 Jan 1, 12h TDB (or,
78
+ # with negligible error, the number of Julian centuries of TT since J2000.0).
79
+ jd2000 = 2451545.0 # the J2000 Julian Day Number
80
+
81
+ ajd = DateTime.now.to_time.utc.to_datetime.ajd.to_f
82
+
83
+ # calculate time to julian centuries
84
+ t = eot.time_julian_century(ajd)
85
+
86
+ # Values are in arc seconds see below for definitions of terms
87
+ ma_moon = 485868.249036 + 1717915923.2178 * t[0] + 31.8792 * t[1] + 0.051635 * t[2] - 0.00024470 * t[3]
88
+ ma_sun = 1287104.79305 + 129596581.0481 * t[0] - 0.5532 * t[1] + 0.000136 * t[2] - 0.00001149 * t[3]
89
+ md_moon = 335779.526232 + 1739527262.8478 * t[0] - 12.7512 * t[1] - 0.001037 * t[2] + 0.00000417 * t[3]
90
+ me_moon = 1072260.70369 + 1602961601.2090 * t[0] - 6.3706 * t[1] + 0.006593 * t[2] - 0.00003169 * t[3]
91
+ omega = 450160.398036 - 6962890.5431 * t[0] + 7.4722 * t[1] + 0.007702 * t[2] - 0.00005939 * t[3]
92
+
93
+ # declare and clear these two variables for the sigma loop
94
+ delta_psi, delta_eps = 0, 0
95
+
96
+ lines = data.size - 1
97
+ for i in 0..lines
98
+ fma_sun = data[i][0].to_i
99
+ fma_moon = data[i][1].to_i
100
+ fmd_moon = data[i][2].to_i
101
+ fme_moon = data[i][3].to_i
102
+ fomega = data[i][4].to_i
103
+ sine = sind(dtr, fma_moon * ma_moon +
104
+ fma_sun * ma_sun +
105
+ fmd_moon * md_moon +
106
+ fme_moon * me_moon +
107
+ fomega * omega)
108
+ cosine = cosd(dtr, fma_moon * ma_moon +
109
+ fma_sun * ma_sun +
110
+ fmd_moon * md_moon +
111
+ fme_moon * me_moon +
112
+ fomega * omega)
113
+ delta_psi += (data[i][6].to_f +
114
+ data[i][7].to_f * t[0]) * sine +
115
+ data[i][10].to_f * cosine
116
+
117
+ delta_eps += (data[i][8].to_f +
118
+ data[i][9].to_f * t[0]) * cosine +
119
+ data[i][12].to_f * sine
120
+
121
+ end
122
+
123
+ # convert arc seconds to degree
124
+ def to_deg( arc_secs )
125
+ arc_secs / ARCSEC
126
+ end
127
+
128
+ delta_eps = to_deg( delta_eps ) / 1000.0
129
+ delta_eps = eot.delta_epsilon(t)
130
+
131
+ delta_psi = to_deg( delta_psi ) / 1000.0
132
+ delta_psi = eot.delta_psi(t)
133
+
134
+ #Delta epsilon degrees decimal = #{to_deg(delta_eps)}
135
+
136
+ #Mean Obliquity of Ecliptic degrees = #{eot.display_degrees(eps0)}
137
+ eps0 = eot.mo_Earth(t)
138
+ #True Obliquity of Ecliptic degrees = #{eot.display_degrees(eps)}
139
+ eps = eot.to_Earth(t)
140
+
141
+ #Delta psi needs to be degrees and eps is degrees but dtr uses ARCSEC constant also we need the result back in ARCSEC / 15 to get time in secs.
142
+ # eoe = delta_psi / ARCSEC * cosd( dtr * ARCSEC, eps ) * ARCSEC / 15.0
143
+ eoe = eot.eq_of_equinox(t) / 15.0
144
+ #p eot.ml_Aries(t)
145
+ gmst = eot.ml_Aries(t) / 15.0 # make angle to time.
146
+ # eoe is ARCSEC so convert it to hours.
147
+ gast = gmst + eoe
148
+
149
+ #~ puts gmst
150
+
151
+ run = <<EOS
152
+
153
+ #{DateTime.now.to_time.utc.to_datetime}
154
+
155
+ The JD = #{ajd}
156
+
157
+ Mean Obliquity of Ecliptic = #{eot.degrees_to_s(eps0)}
158
+
159
+ Delta epsilon in arc seconds = #{delta_eps * 3600}
160
+
161
+ True Obliquity of Ecliptic degrees = #{eot.degrees_to_s(eps)}
162
+
163
+ Delta psi in arc seconds = #{delta_psi * 3600}
164
+
165
+ Equation of equinox in seconds = Delta psi * cos epsilon = #{eoe * 3600}
166
+
167
+ Greenwich Mean Sidereal Time = #{eot.string_time(gmst)}
168
+
169
+ Greenwich Apparent Sideral Time = #{eot.string_time(gast)}
170
+
171
+ To compare results enter the date and time into http://www.celnav.de/longterm.htm
172
+
173
+ You can use the methods in EOT instead of this example as this just shows how it works.
174
+
175
+ EOS
176
+
177
+ puts run
178
+
179
+ # Helpful info
180
+ =begin
181
+ these values are in arc seconds
182
+
183
+ Mean anomaly of the moon
184
+ ma_moon = 485868.249036 + 1717915923.2178 * t + 31.8792 * t2 + 0.051635 * t3 - 0.00024470 * t4
185
+
186
+ Mean anomaly of the sun
187
+ ma_sun = 1287104.79305 + 129596581.0481 * t - 0.5532 * t2 + 0.000136 * t3 - 0.00001149 * t4
188
+
189
+
190
+ Mean distance of the moon from the ascending node
191
+ md_moon = 335779.526232 + 1739527262.8478 * t - 12.7512 * t2 - 0.001037 * t3 + 0.00000417 * t4
192
+
193
+
194
+ Mean elongation of the moon
195
+ me_moon = 1072260.70369 + 1602961601.2090 * t - 6.3706 * t2 + 0.006593 * t3 - 0.00003169 * t4
196
+
197
+
198
+ Longitude of the ascending node of the moon
199
+ omega = 450160.398036 - 6962890.5431 * t + 7.4722 * t2 + 0.007702 * t3 - 0.00005939 * t4
200
+
201
+ =end
202
+
203
+ =begin
204
+
205
+ Manualy converted values from arc seconds to dergrees(not used here)
206
+
207
+ ma_moon = 134.96340251 + 477198.8675605 * t + t2 / 112.92629677 + t3 / 69720.15106 - t4 / 14711892.112791
208
+ ma_sun = 357.52910918 + 35999.0502911389 * t - t2 / 6507.592191 + t3 / 26470588.2353 - t4 / 313315926.89295
209
+ md_moon = 93.27209062 + 483202.01745772 * t - t2 / 282.3264 - t3 / 3471552.555 + t4 / 863309352.5179856
210
+ me_moon = 297.8501954694 + 445267.11144694 * t - t2 / 565.0959 + t3 / 546033.672 - t4 / 113600504.891
211
+ omega = 125.04455501 - 1934.136261972 * t + t2 / 481.78582 + 0.007702 * t3 / 467411.062 - t4 / 60616265.3645
212
+
213
+ =end
214
+
215
+
216
+ =begin
217
+
218
+ An example of usage for 'Circular_179.pdf' IAU 2000A Nutation Series
219
+ The JavaScript from: view-source:http://www.celnav.de/longterm.htm
220
+ //Nutation, obliquity of the ecliptic
221
+ function Nutation()
222
+ {
223
+ //IAU 1980 nutation theory:
224
+
225
+ //Mean anomaly of the moon
226
+ var Mm = 134.962981389+198.867398056*TE+trunc(477000*TE)+0.008697222222*TE2+TE3/56250;
227
+
228
+ //Mean anomaly of the sun
229
+ var M = 357.527723333+359.05034*TE+trunc(35640*TE)-0.0001602777778*TE2-TE3/300000;
230
+
231
+ //Mean distance of the moon from the ascending node
232
+ var F = 93.271910277+82.017538055*TE+trunc(483120*TE)-0.0036825*TE2+TE3/327272.7273;
233
+
234
+ //Mean elongation of the moon
235
+ var D = 297.850363055+307.11148*TE+trunc(444960*TE)-0.001914166667*TE2+TE3/189473.6842;
236
+
237
+ //Longitude of the ascending node of the moon
238
+ var omega = 125.044522222-134.136260833*TE-trunc(1800*TE)+0.002070833333*TE2+TE3/450000;
239
+
240
+ //Periodic terms for nutation
241
+ var nut = new Array(106);
242
+ nut[0] = " 0 0 0 0 1-171996-174.2 92025 8.9 ";
243
+ nut[1] = " 0 0 2-2 2 -13187 -1.6 5736-3.1 ";
244
+ nut[2] = " 0 0 2 0 2 -2274 -0.2 977-0.5 ";
245
+ nut[3] = " 0 0 0 0 2 2062 0.2 -895 0.5 ";
246
+ nut[4] = " 0-1 0 0 0 -1426 3.4 54-0.1 ";
247
+ nut[5] = " 1 0 0 0 0 712 0.1 -7 0.0 ";
248
+ nut[6] = " 0 1 2-2 2 -517 1.2 224-0.6 ";
249
+ nut[7] = " 0 0 2 0 1 -386 -0.4 200 0.0 ";
250
+ nut[8] = " 1 0 2 0 2 -301 0.0 129-0.1 ";
251
+ nut[9] = " 0-1 2-2 2 217 -0.5 -95 0.3 ";
252
+ nut[10] = "-1 0 0 2 0 158 0.0 -1 0.0 ";
253
+ nut[11] = " 0 0 2-2 1 129 0.1 -70 0.0 ";
254
+ nut[12] = "-1 0 2 0 2 123 0.0 -53 0.0 ";
255
+ nut[13] = " 1 0 0 0 1 63 0.1 -33 0.0 ";
256
+ nut[14] = " 0 0 0 2 0 63 0.0 -2 0.0 ";
257
+ nut[15] = "-1 0 2 2 2 -59 0.0 26 0.0 ";
258
+ nut[16] = "-1 0 0 0 1 -58 -0.1 32 0.0 ";
259
+ nut[17] = " 1 0 2 0 1 -51 0.0 27 0.0 ";
260
+ nut[18] = "-2 0 0 2 0 -48 0.0 1 0.0 ";
261
+ nut[19] = "-2 0 2 0 1 46 0.0 -24 0.0 ";
262
+ nut[20] = " 0 0 2 2 2 -38 0.0 16 0.0 ";
263
+ nut[21] = " 2 0 2 0 2 -31 0.0 13 0.0 ";
264
+ nut[22] = " 2 0 0 0 0 29 0.0 -1 0.0 ";
265
+ nut[23] = " 1 0 2-2 2 29 0.0 -12 0.0 ";
266
+ nut[24] = " 0 0 2 0 0 26 0.0 -1 0.0 ";
267
+ nut[25] = " 0 0 2-2 0 -22 0.0 0 0.0 ";
268
+ nut[26] = "-1 0 2 0 1 21 0.0 -10 0.0 ";
269
+ nut[27] = " 0 2 0 0 0 17 -0.1 0 0.0 ";
270
+ nut[28] = " 0 2 2-2 2 -16 0.1 7 0.0 ";
271
+ nut[29] = "-1 0 0 2 1 16 0.0 -8 0.0 ";
272
+ nut[30] = " 0 1 0 0 1 -15 0.0 9 0.0 ";
273
+ nut[31] = " 1 0 0-2 1 -13 0.0 7 0.0 ";
274
+ nut[32] = " 0-1 0 0 1 -12 0.0 6 0.0 ";
275
+ nut[33] = " 2 0-2 0 0 11 0.0 0 0.0 ";
276
+ nut[34] = "-1 0 2 2 1 -10 0.0 5 0.0 ";
277
+ nut[35] = " 1 0 2 2 2 -8 0.0 3 0.0 ";
278
+ nut[36] = " 0-1 2 0 2 -7 0.0 3 0.0 ";
279
+ nut[37] = " 0 0 2 2 1 -7 0.0 3 0.0 ";
280
+ nut[38] = " 1 1 0-2 0 -7 0.0 0 0.0 ";
281
+ nut[39] = " 0 1 2 0 2 7 0.0 -3 0.0 ";
282
+ nut[40] = "-2 0 0 2 1 -6 0.0 3 0.0 ";
283
+ nut[41] = " 0 0 0 2 1 -6 0.0 3 0.0 ";
284
+ nut[42] = " 2 0 2-2 2 6 0.0 -3 0.0 ";
285
+ nut[43] = " 1 0 0 2 0 6 0.0 0 0.0 ";
286
+ nut[44] = " 1 0 2-2 1 6 0.0 -3 0.0 ";
287
+ nut[45] = " 0 0 0-2 1 -5 0.0 3 0.0 ";
288
+ nut[46] = " 0-1 2-2 1 -5 0.0 3 0.0 ";
289
+ nut[47] = " 2 0 2 0 1 -5 0.0 3 0.0 ";
290
+ nut[48] = " 1-1 0 0 0 5 0.0 0 0.0 ";
291
+ nut[49] = " 1 0 0-1 0 -4 0.0 0 0.0 ";
292
+ nut[50] = " 0 0 0 1 0 -4 0.0 0 0.0 ";
293
+ nut[51] = " 0 1 0-2 0 -4 0.0 0 0.0 ";
294
+ nut[52] = " 1 0-2 0 0 4 0.0 0 0.0 ";
295
+ nut[53] = " 2 0 0-2 1 4 0.0 -2 0.0 ";
296
+ nut[54] = " 0 1 2-2 1 4 0.0 -2 0.0 ";
297
+ nut[55] = " 1 1 0 0 0 -3 0.0 0 0.0 ";
298
+ nut[56] = " 1-1 0-1 0 -3 0.0 0 0.0 ";
299
+ nut[57] = "-1-1 2 2 2 -3 0.0 1 0.0 ";
300
+ nut[58] = " 0-1 2 2 2 -3 0.0 1 0.0 ";
301
+ nut[59] = " 1-1 2 0 2 -3 0.0 1 0.0 ";
302
+ nut[60] = " 3 0 2 0 2 -3 0.0 1 0.0 ";
303
+ nut[61] = "-2 0 2 0 2 -3 0.0 1 0.0 ";
304
+ nut[62] = " 1 0 2 0 0 3 0.0 0 0.0 ";
305
+ nut[63] = "-1 0 2 4 2 -2 0.0 1 0.0 ";
306
+ nut[64] = " 1 0 0 0 2 -2 0.0 1 0.0 ";
307
+ nut[65] = "-1 0 2-2 1 -2 0.0 1 0.0 ";
308
+ nut[66] = " 0-2 2-2 1 -2 0.0 1 0.0 ";
309
+ nut[67] = "-2 0 0 0 1 -2 0.0 1 0.0 ";
310
+ nut[68] = " 2 0 0 0 1 2 0.0 -1 0.0 ";
311
+ nut[69] = " 3 0 0 0 0 2 0.0 0 0.0 ";
312
+ nut[70] = " 1 1 2 0 2 2 0.0 -1 0.0 ";
313
+ nut[71] = " 0 0 2 1 2 2 0.0 -1 0.0 ";
314
+ nut[72] = " 1 0 0 2 1 -1 0.0 0 0.0 ";
315
+ nut[73] = " 1 0 2 2 1 -1 0.0 1 0.0 ";
316
+ nut[74] = " 1 1 0-2 1 -1 0.0 0 0.0 ";
317
+ nut[75] = " 0 1 0 2 0 -1 0.0 0 0.0 ";
318
+ nut[76] = " 0 1 2-2 0 -1 0.0 0 0.0 ";
319
+ nut[77] = " 0 1-2 2 0 -1 0.0 0 0.0 ";
320
+ nut[78] = " 1 0-2 2 0 -1 0.0 0 0.0 ";
321
+ nut[79] = " 1 0-2-2 0 -1 0.0 0 0.0 ";
322
+ nut[80] = " 1 0 2-2 0 -1 0.0 0 0.0 ";
323
+ nut[81] = " 1 0 0-4 0 -1 0.0 0 0.0 ";
324
+ nut[82] = " 2 0 0-4 0 -1 0.0 0 0.0 ";
325
+ nut[83] = " 0 0 2 4 2 -1 0.0 0 0.0 ";
326
+ nut[84] = " 0 0 2-1 2 -1 0.0 0 0.0 ";
327
+ nut[85] = "-2 0 2 4 2 -1 0.0 1 0.0 ";
328
+ nut[86] = " 2 0 2 2 2 -1 0.0 0 0.0 ";
329
+ nut[87] = " 0-1 2 0 1 -1 0.0 0 0.0 ";
330
+ nut[88] = " 0 0-2 0 1 -1 0.0 0 0.0 ";
331
+ nut[89] = " 0 0 4-2 2 1 0.0 0 0.0 ";
332
+ nut[90] = " 0 1 0 0 2 1 0.0 0 0.0 ";
333
+ nut[91] = " 1 1 2-2 2 1 0.0 -1 0.0 ";
334
+ nut[92] = " 3 0 2-2 2 1 0.0 0 0.0 ";
335
+ nut[93] = "-2 0 2 2 2 1 0.0 -1 0.0 ";
336
+ nut[94] = "-1 0 0 0 2 1 0.0 -1 0.0 ";
337
+ nut[95] = " 0 0-2 2 1 1 0.0 0 0.0 ";
338
+ nut[96] = " 0 1 2 0 1 1 0.0 0 0.0 ";
339
+ nut[97] = "-1 0 4 0 2 1 0.0 0 0.0 ";
340
+ nut[98] = " 2 1 0-2 0 1 0.0 0 0.0 ";
341
+ nut[99] = " 2 0 0 2 0 1 0.0 0 0.0 ";
342
+ nut[100]= " 2 0 2-2 1 1 0.0 -1 0.0 ";
343
+ nut[101]= " 2 0-2 0 1 1 0.0 0 0.0 ";
344
+ nut[102]= " 1-1 0-2 0 1 0.0 0 0.0 ";
345
+ nut[103]= "-1 0 0 1 1 1 0.0 0 0.0 ";
346
+ nut[104]= "-1-1 0 2 1 1 0.0 0 0.0 ";
347
+ nut[105]= " 0 1 0 1 0 1 0.0 0 0.0 ";
348
+
349
+ //Reading periodic terms
350
+ var fMm, fM, fF, fD, f_omega, dp=0, de=0;
351
+
352
+ for (x=0; x<105; x++)
353
+ {
354
+ fMm = eval(nut[x].substring(0,2));
355
+ fM = eval(nut[x].substring(2,4));
356
+ fF = eval(nut[x].substring(4,6));
357
+ fD = eval(nut[x].substring(6,8));
358
+ f_omega = eval(nut[x].substring(8,10));
359
+ dp += (eval(nut[x].substring(10,17))+TE*eval(nut[x].substring(17,23)))*sind(fD*D+fM*M+fMm*Mm+fF*F+f_omega*omega);
360
+ de += (eval(nut[x].substring(23,29))+TE*eval(nut[x].substring(29,33)))*cosd(fD*D+fM*M+fMm*Mm+fF*F+f_omega*omega);
361
+ }
362
+
363
+ //Corrections (Herring, 1987)
364
+ /*
365
+ var corr = new Array(4);
366
+ corr[0] = " 0 0 0 0 1-725 417 213 224 ";
367
+ corr[1] = " 0 1 0 0 0 523 61 208 -24 ";
368
+ corr[2] = " 0 0 2-2 2 102-118 -41 -47 ";
369
+ corr[3] = " 0 0 2 0 2 -81 0 32 0 ";
370
+
371
+ for (x=0; x<4; x++)
372
+ {
373
+ fMm = eval(corr[x].substring(0,2));
374
+ fM = eval(corr[x].substring(2,4));
375
+ fF = eval(corr[x].substring(4,6));
376
+ fD = eval(corr[x].substring(6,8));
377
+ f_omega = eval(corr[x].substring(8,10));
378
+ dp += 0.1*(eval(corr[x].substring(10,14))*sind(fD*D+fM*M+fMm*Mm+fF*F+f_omega*omega)+eval(corr[x].substring(14,18))*cosd(fD*D+fM*M+fMm*Mm+fF*F+f_omega*omega));
379
+ de += 0.1*(eval(corr[x].substring(18,22))*cosd(fD*D+fM*M+fMm*Mm+fF*F+f_omega*omega)+eval(corr[x].substring(22,26))*sind(fD*D+fM*M+fMm*Mm+fF*F+f_omega*omega));
380
+ }
381
+ */
382
+
383
+ //Nutation in longitude
384
+ delta_psi = dp/36000000;
385
+
386
+ //Nutation in obliquity
387
+ delta_eps = de/36000000;
388
+
389
+ //Mean obliquity of the ecliptic
390
+ eps0 = (84381.448-46.815*TE-0.00059*TE2+0.001813*TE3)/3600;
391
+
392
+ //True obliquity of the ecliptic
393
+ eps = eps0+delta_eps;
394
+ }
395
+
396
+ //Equation of the equinoxes
397
+ EoE = 240*delta_psi*cosd(eps);
398
+
399
+ =end
@@ -0,0 +1,28 @@
1
+ # suntimes.rb
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ # The following gem is not in rubygems.org yet. Please use the gem on github. Thanks!
7
+ require 'eot'
8
+
9
+ eot = Eot.new
10
+ # Change these for your geo location
11
+ @latitude = 41.9474 # + in Northern Hemishere, - in Southern Hemisphere
12
+ @longitude = -88.74467 # + East of zulu time zone, - West of zulu time zone
13
+ @zone = -5 # Time offset for zone.
14
+
15
+
16
+ eot.longitude= @longitude
17
+ eot.latitude= @latitude
18
+ puts
19
+ @date = Date.today
20
+ # get the times for a few more days.
21
+ for i in 0..10
22
+
23
+ eot.ajd = (@date.jd + i)
24
+
25
+ puts "Sunrise #{(eot.sunrise_dt().to_time).strftime("%c")}"
26
+ puts "Sunset #{(eot.sunset_dt().to_time).strftime("%c")}"
27
+ puts
28
+ end
@@ -0,0 +1,47 @@
1
+ # suntimes_test.rb
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'eot'
7
+
8
+ eot = Eot.new
9
+
10
+ # Change these for your geographic location Ex: of mine.
11
+ # Note the two coordinate parameters must be passed as floats.
12
+ # All parameters may be passed at any time.
13
+ # eot.date = @date
14
+ # eot.longitude = @longitude
15
+ # eot.latitude = @latitude
16
+ @latitude = 0.0 # sign in Northern Hemishere is none, - (minus)for Southern Hemisphere
17
+ @longitude = 0.0 # East of UTC is none, - (minus)West of UTC
18
+ @date = "2000-01-01"
19
+ eot.jd = Date.parse(@date).jd
20
+
21
+ print "Enter your longitude in decimal format Ex: -125.099 \n"
22
+
23
+ lng = gets
24
+
25
+ lng.nil? ? eot.longitude = @longitude : eot.longitude = lng.chomp.to_f
26
+
27
+ puts "Your longitude is #{eot.longitude}"
28
+
29
+ print "Enter your latitude in decimal format Ex: 39.3339 \n"
30
+
31
+ lat = gets
32
+
33
+ lat.nil? ? eot.latitude = @latitude : eot.latitude = lat.chomp.to_f
34
+
35
+ puts "Your latitude is #{eot.latitude}"
36
+
37
+ print "Enter the date you want to compute sun times for Ex: yyyy-mm-dd \n"
38
+
39
+ date = gets
40
+
41
+ date.nil? ? eot.date = @date : eot.date = date.chomp.to_f
42
+
43
+ puts "The date is #{eot.date}"
44
+
45
+ puts "Sunrise #{eot.sunrise_dt.to_time}"
46
+ puts "Sunset #{eot.sunset_dt.to_time}"
47
+
@@ -0,0 +1,38 @@
1
+ # test_poly_eval.rb
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ # class Array
7
+ # Evaluate polynomial using Horner's method.
8
+ # Array consists of coefficients of a polynomial, the
9
+ # coefficient of the highest order term first, the
10
+ # constant coefficient last.
11
+ # Returns evaluation of polynomial at +x+.
12
+ #
13
+ # Example: evaluate the polynomial x**2 - 0.5*x + 3.0 where x = 2.0
14
+ # [1.0, -0.5, 3.0].poly_eval(2.0) # => 6.0
15
+ # def poly_eval(x)
16
+ # self.inject(0.0) {|p, a|
17
+ # p*x + a}
18
+ # end
19
+ # end
20
+
21
+ require 'eot'
22
+ eot = Eot.new
23
+
24
+ @current = DateTime.now.to_time.utc
25
+ # comparing the difference for two methods of day_fraction
26
+ df1 = @current.to_datetime.day_fraction.to_f
27
+ df2 = @current.hour / 24.0 + @current.min / 1_440.0 + @current.sec / 86_400.0 + @current.usec / 86_400_000_000.0
28
+
29
+ ajd = @current.to_datetime.ajd.to_f
30
+
31
+ # setting up to test poly_eval in each angle method using it.
32
+ tjc = eot.time_julian_century(2456734.00110875)
33
+ #t = (Date.today.jd - 2451545.0)/365250.0
34
+
35
+ eot.eccentricity_Earth( tjc )
36
+ eot.gml_Sun( tjc )
37
+ p eot.ml_Aries( tjc )
38
+ eot.mo_Earth( tjc )