equationoftime 4.1.1 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.autotest +39 -0
  3. data/.gemtest +0 -0
  4. data/.minitest.rb +2 -0
  5. data/.ruby-version +1 -0
  6. data/.settings/org.eclipse.ltk.core.refactoring.prefs +2 -0
  7. data/CHANGELOG.rdoc +6 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +44 -3
  10. data/Guardfile +29 -0
  11. data/{LICENSE.md → LICENSE.rdoc} +0 -0
  12. data/Manifest.txt +82 -0
  13. data/README.rdoc +66 -0
  14. data/Rakefile +60 -45
  15. data/equationoftime.gemspec +17 -9
  16. data/examples/Equation_of_Time.jpg +0 -0
  17. data/examples/analemma_data_generator.rb +58 -0
  18. data/examples/check_date_type.rb +60 -0
  19. data/examples/compare_geoc_long_ra.rb +44 -0
  20. data/examples/data_table_for_astro_dog.rb +45 -0
  21. data/examples/earth_rotation.rb +42 -0
  22. data/examples/eot_methods_list.rb +48 -0
  23. data/examples/eot_plot.r +57 -0
  24. data/examples/eot_suntimes.rb +149 -0
  25. data/examples/equation_of_time.py +186 -0
  26. data/examples/figure_1.jpg +0 -0
  27. data/examples/file_converter.rb +31 -0
  28. data/examples/from_readme.rb +14 -0
  29. data/examples/from_wiki.rb +46 -0
  30. data/examples/geo_locator.rb +16 -0
  31. data/examples/getjd.rb +45 -0
  32. data/examples/gmst_gast_non_sofa.rb +406 -0
  33. data/examples/input_suntimes.rb +24 -0
  34. data/examples/julian_day_formula.rb +29 -0
  35. data/examples/julian_day_formula.txt +12 -0
  36. data/examples/my_time_conversion.rb +21 -0
  37. data/examples/nutation_series.txt +678 -0
  38. data/examples/nutation_table5_3a.txt +682 -0
  39. data/examples/ptime.rb +162 -0
  40. data/examples/suntimes.rb +30 -0
  41. data/examples/suntimes_test.rb +50 -0
  42. data/examples/t_sofa.rb +8228 -0
  43. data/examples/test_celes.rb +51 -0
  44. data/examples/test_ceot.rb +55 -0
  45. data/examples/test_poly_eval.rb +32 -0
  46. data/examples/time_scales.rb +29 -0
  47. data/examples/times_year.rb +53 -0
  48. data/examples/usage_example.rb +26 -0
  49. data/examples/use_angles.rb +222 -0
  50. data/ext/{ceot/eot.c → eot/ceot.c} +1 -1
  51. data/ext/{ceot/eot.h → eot/ceot.h} +0 -0
  52. data/ext/{ceot/ceot.c → eot/eot.c} +2 -2
  53. data/ext/{ceot → eot}/extconf.rb +1 -1
  54. data/lib/eot.rb +2 -1
  55. data/lib/eot/angles.rb +28 -28
  56. data/lib/eot/constants.rb +2 -0
  57. data/lib/eot/displays.rb +17 -17
  58. data/lib/eot/eot.so +0 -0
  59. data/lib/eot/geo_lat_lng_smt.rb +44 -31
  60. data/lib/eot/init.rb +20 -19
  61. data/lib/eot/nutation.rb +1 -1
  62. data/lib/eot/times.rb +22 -22
  63. data/lib/eot/utilities.rb +5 -5
  64. data/lib/eot/version.rb +2 -6
  65. data/test/aliased_angles_spec.rb +239 -0
  66. data/test/aliased_displays_spec.rb +105 -0
  67. data/test/aliased_utilities_spec.rb +36 -0
  68. data/test/angles_spec.rb +264 -0
  69. data/test/constants_spec.rb +20 -0
  70. data/test/displays_spec.rb +110 -0
  71. data/test/geo_spec.rb +38 -0
  72. data/test/init_spec.rb +44 -0
  73. data/test/nutation_spec.rb +37 -0
  74. data/test/spec_config.rb +8 -0
  75. data/test/times_spec.rb +133 -0
  76. data/test/utilities_spec.rb +35 -0
  77. metadata +109 -115
  78. data/.gitignore +0 -24
  79. data/.rvmrc +0 -1
  80. data/README.md +0 -83
  81. data/README2.txt +0 -70
  82. data/wiki.md +0 -43
  83. data/wiki2.md +0 -4
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env python
2
+ """
3
+ https://bitbucket.org/cmcqueen1975/sundials/src/26a0f54a7c18?at=default
4
+ Calculation of "equation of time".
5
+
6
+ References:
7
+ http://en.wikipedia.org/wiki/Equation_of_time
8
+ http://www.sundials.co.uk/equation.htm
9
+
10
+ Calculations have been done according to the Wikipedia reference.
11
+
12
+ Dependencies:
13
+ - Python 2.x
14
+ - NumPy
15
+ - SciPy (only strictly needed for the more accurate calculation)
16
+ - matplotlib to plot the graph
17
+ """
18
+
19
+ import datetime
20
+ from collections import namedtuple
21
+
22
+ import numpy as np
23
+ import scipy # only strictly needed for the more accurate calculation in equation_of_time_accurate()
24
+ import scipy.optimize
25
+
26
+ # Named tuple to hold geographic location
27
+ Location = namedtuple('Location', 'latitude, longitude')
28
+
29
+
30
+ # If a location is given, a longitude correction is calculated and included in the graph.
31
+ # If the sundial itself includes the longitude correction, just use the 0 value here.
32
+ LOCATION = Location(0, 0)
33
+ #LOCATION = Location(51.3809, -2.3603) # Bath, England
34
+ #LOCATION = Location(35.10, 138.86) # Numazu, Japan
35
+ #LOCATION = Location(-37.81, 144.96) # Melbourne, Victoria, Australia
36
+
37
+
38
+ DAYS_PER_TROPICAL_YEAR = 365.242
39
+ SUN_ECCENTRICITY = 0.01671
40
+
41
+ # The angle from the vernal equinox to the periapsis in the plane of the ecliptic.
42
+ SUN_ANGLE_OFFSET = 4.9358
43
+
44
+ # Angle of tilt of earth's axis--about 23.44 degrees
45
+ SUN_OBLIQUITY = 0.40910
46
+
47
+
48
+ # Date range for drawing a graph.
49
+ DATE_START = datetime.date(2009, 1, 1)
50
+ DATE_END = datetime.date(2010, 1, 1)
51
+ # Periapsis occurs on a slightly different date each year--varying by a couple
52
+ # of days. 4th of January is about the average.
53
+ DATE_PERIAPSIS = datetime.date(2009, 1, 4)
54
+
55
+
56
+ def longitude_offset(location):
57
+ """Given a location, return the offset due to longitude, in degrees
58
+ Location's longitude is used. Latitude isn't needed.
59
+ """
60
+ longitude = location.longitude
61
+ longitude_per_hour = (360. / 24)
62
+ longitude_offset = longitude % longitude_per_hour
63
+ if longitude_offset > longitude_per_hour / 2:
64
+ longitude_offset -= longitude_per_hour
65
+ return longitude_offset
66
+
67
+
68
+ def longitude_offset_min(location):
69
+ minute_per_longitude = 24 * 60 / 360.
70
+ return longitude_offset(location) * minute_per_longitude
71
+
72
+
73
+ def mean_anomaly(day_number_n):
74
+ """day_number_n is the number of days from periapsis."""
75
+ return day_number_n * (2 * np.pi / DAYS_PER_TROPICAL_YEAR)
76
+
77
+
78
+ @np.vectorize
79
+ def eccentric_anomaly(mean_anomaly_value):
80
+ local_sun_eccentricity = SUN_ECCENTRICITY
81
+
82
+ def eccentric_anomaly_function(eccentric_anomaly_value):
83
+ return eccentric_anomaly_value - local_sun_eccentricity * np.sin(eccentric_anomaly_value) - mean_anomaly_value
84
+
85
+ # eccentric_anomaly_value = scipy.optimize.brentq(eccentric_anomaly_function, 0 - 0.0001, 2 * np.pi + 0.0001)
86
+ eccentric_anomaly_value = scipy.optimize.fsolve(eccentric_anomaly_function, mean_anomaly_value)
87
+ return eccentric_anomaly_value
88
+
89
+
90
+ def true_anomaly(eccentric_anomaly_value):
91
+ local_sun_eccentricity = SUN_ECCENTRICITY
92
+
93
+ half_eccentric_anomaly = eccentric_anomaly_value / 2
94
+ a_x = np.cos(half_eccentric_anomaly)
95
+ a_y = np.sin(half_eccentric_anomaly)
96
+ a_y *= np.sqrt((1 + local_sun_eccentricity) / (1 - local_sun_eccentricity))
97
+ return 2 * np.arctan2(a_y, a_x)
98
+
99
+
100
+ def right_ascension(sun_angle):
101
+ """sun_angle is the angle from the vernal equinox to the Sun in the plane of the ecliptic.
102
+ It is the true_anomaly value plus the SUN_ANGLE_OFFSET."""
103
+ a_x = np.cos(sun_angle)
104
+ a_y = np.sin(sun_angle)
105
+ return np.arctan2(a_y * np.cos(SUN_OBLIQUITY), a_x)
106
+
107
+
108
+ def equation_of_time_accurate(day_number_n):
109
+ """Calculate the equation of time (in min), given a day number.
110
+
111
+ day_number_n is the number of days from periapsis.
112
+ Returns the difference between solar time and clock time, in minutes.
113
+ This uses a more accurate calculation.
114
+ """
115
+ mean_anomaly_value = mean_anomaly(day_number_n)
116
+ eccentric_anomaly_value = eccentric_anomaly(mean_anomaly_value)
117
+ true_anomaly_value = true_anomaly(eccentric_anomaly_value)
118
+ right_ascension_value = right_ascension(true_anomaly_value + SUN_ANGLE_OFFSET)
119
+ eot = mean_anomaly_value + SUN_ANGLE_OFFSET - right_ascension_value
120
+ # Get the angles into the range we want--that is, -pi to +pi
121
+ eot = (eot + np.pi) % (2 * np.pi) - np.pi
122
+ return eot * (24 * 60 / 2 / np.pi)
123
+
124
+
125
+ def equation_of_time_simple(day_number_n):
126
+ """Calculate the equation of time (in min), given a day number.
127
+
128
+ day_number_n is the number of days from periapsis.
129
+ Returns the difference between solar time and clock time, in minutes.
130
+ This uses a simple, approximate calculation.
131
+ """
132
+ mean_anomaly_value = mean_anomaly(day_number_n)
133
+ return -7.655 * np.sin(mean_anomaly_value) + 9.873 * np.sin(2 * mean_anomaly_value + 3.588)
134
+
135
+
136
+ #equation_of_time = equation_of_time_simple
137
+ equation_of_time = equation_of_time_accurate
138
+
139
+
140
+ def main():
141
+ import matplotlib
142
+ #matplotlib.use('pdf')
143
+ #matplotlib.use('svg')
144
+ from matplotlib import pyplot as plt
145
+
146
+
147
+ date_range = np.arange(matplotlib.dates.date2num(DATE_START), matplotlib.dates.date2num(DATE_END), 0.1)
148
+ day_numbers = date_range - matplotlib.dates.date2num(DATE_PERIAPSIS)
149
+
150
+ # Calculate the accurate and simple calculations of equation of time.
151
+ solar_offset_accurate_min = equation_of_time_accurate(day_numbers) + longitude_offset_min(LOCATION)
152
+ solar_offset_simple_min = equation_of_time_simple(day_numbers) + longitude_offset_min(LOCATION)
153
+
154
+ # Plot the graph, either solar vs clock, or vice-versa.
155
+ if 1:
156
+ # Solar time vs clock time
157
+ plt.plot_date(date_range, solar_offset_accurate_min, '-')
158
+ # plt.plot_date(date_range, solar_offset_simple_min, '--')
159
+ plt.ylabel('solar time - clock time (min)')
160
+ else:
161
+ # Clock time vs solar time
162
+ plt.plot_date(date_range, -solar_offset_accurate_min, '-')
163
+ # plt.plot_date(date_range, -solar_offset_simple_min, '--')
164
+ plt.ylabel('clock time - solar time (min)')
165
+
166
+ # Set month lines
167
+ ax = plt.subplot(111)
168
+ ax.xaxis.set_major_locator(matplotlib.dates.MonthLocator())
169
+ ax.xaxis.set_major_formatter(matplotlib.ticker.NullFormatter())
170
+ # Set month labels centred in the middle (actually on day 15) of each month.
171
+ ax.xaxis.set_minor_locator(matplotlib.dates.MonthLocator(bymonthday=15))
172
+ ax.xaxis.set_minor_formatter(matplotlib.dates.DateFormatter('%b'))
173
+ for tick in ax.xaxis.get_minor_ticks():
174
+ tick.tick1line.set_markersize(0)
175
+ tick.tick2line.set_markersize(0)
176
+
177
+ plt.grid(True)
178
+
179
+ plt.show()
180
+ # plt.savefig('equation_of_time.pdf')
181
+ # plt.savefig('equation_of_time.svg')
182
+ # plt.savefig('equation_of_time.png')
183
+
184
+
185
+ if __name__ == '__main__':
186
+ main()
Binary file
@@ -0,0 +1,31 @@
1
+ # the file this data comes from 'Circular_179.pdf' IAU 2000A Nutation Series
2
+ # the first 678 lines are for lunisolar data
3
+
4
+ require 'safe_yaml'
5
+
6
+ # make array elements from each line of the file
7
+ filename = "nutation_table5_3a.txt"
8
+ temp_array = []
9
+ data = File.readlines(filename)
10
+
11
+ # clean out whitespace and new line breaks
12
+ data.each {|i| temp_array << i.strip}
13
+
14
+ # make new muti-dimensional data array
15
+ data = []
16
+ temp_array.each {|i| data << i.split}
17
+
18
+ # save the array in a yaml file
19
+ File::open( "nutation_table5_3a.yaml", "w" ) do |f|
20
+ YAML.dump( data, f )
21
+ end
22
+
23
+ # show the new data file contents as an array.
24
+ data = []
25
+ File.open( "nutation_table5_3a.yaml" ) do |f|
26
+ YAML.load_documents( f ) do |doc|
27
+ data = doc
28
+ p data
29
+ end
30
+ p f
31
+ end
@@ -0,0 +1,14 @@
1
+ # from_readme.rb
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+
12
+ eot = Eot.new
13
+
14
+ puts eot.string_eot()
@@ -0,0 +1,46 @@
1
+ # from_wiki.rb
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+ eot = Eot.new()
12
+ # Wiki 1:
13
+
14
+ loop do
15
+ puts "#{Time.now} #{eot.show_minutes(eot.now)}"
16
+ sleep 11
17
+ end
18
+
19
+ # Wiki 2:
20
+
21
+ latitude, longitude, date = 41.9474, -88.74467, "2013-12-25"
22
+ eot.latitude = latitude; eot.longitude = longitude; eot.ajd = Date.parse(date).jd
23
+ p eot.sunrise_dt().to_time
24
+ p eot.sunset_dt().to_time
25
+
26
+ # Wiki 3:
27
+
28
+ loop do
29
+ eot.ajd = DateTime.now.to_time.utc.to_datetime.ajd
30
+ puts eot.string_time(eot.tl_Aries() / 15.0)
31
+ sleep 0.73
32
+ end
33
+
34
+ # Wiki 4:
35
+
36
+ puts "There are #{Eot::SM * 6} hours in a sidereal day."
37
+ puts "That is why on the next day the stars are about 4 minutes earlier."
38
+ p obtime0 = Time.now
39
+ p obtime1 = obtime0 + Eot::SM * 6 * 3600
40
+ puts "Now you know when to look next time."
41
+
42
+ # Wiki 5:
43
+
44
+ p DateTime.jd(eot.sunrise_jd + 0.5)
45
+ p DateTime.jd(eot.sunset_jd + 0.5)
46
+
@@ -0,0 +1,16 @@
1
+ # geo_locator.rb
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+
12
+ geo = GeoLatLng.new
13
+ geo.addr = "8000 South Michigan Ave., Chicago, IL"
14
+ geo.get_coordinates_from_address
15
+ p geo.lat
16
+ p geo.lng
data/examples/getjd.rb ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'date'
4
+ include Math
5
+
6
+ def calc_time_julian_centurey(t)
7
+ # Julian Day Number j(2000) subtracted
8
+ (t - 2451545.0) / 36525.0
9
+ # Time in fractional centurey
10
+ end
11
+
12
+ # Truncate large angles
13
+ def mod_360(x)
14
+ 360.0 * ( x / 360.0 - Integer( x / 360.0))
15
+ end
16
+
17
+ def calc_mean_long_aries(t)
18
+
19
+ mod_360(280.46061666 + t * 36525.0 * 360.98564736629 + t * (t * 0.000387933 - t * (t / 38710000.0)))
20
+
21
+ end
22
+
23
+ puts "outputs data every 5 seconds"
24
+ loop do
25
+ time = Time.now.utc
26
+ theDate = Date.new(time.year, time.month, time.day)
27
+ # puts time
28
+ # puts theDate
29
+ # puts "#{theDate.ajd} = Astronomical Julian Day"
30
+ # puts "#{theDate.jd - 0.5} = Astronomical Julian Day"
31
+ # puts "#{theDate.jd} = Julian Day"
32
+ t = time
33
+ theDayFraction = (t.usec / (1000000.0 * 3600.0) + t.min / 60.0 + t.hour + t.sec / 3600.0) / 24.0
34
+ # puts "#{theDayFraction} = Day Fraction time now"
35
+
36
+ theTotal = theDate.ajd + theDayFraction
37
+ # puts "#{theTotal} = Astronomical Julian Day + Day Fraction time now"
38
+
39
+ tjc = calc_time_julian_centurey(theTotal)
40
+ gmst = calc_mean_long_aries(tjc)
41
+
42
+ puts "#{gmst.round 3} = (GHA) Mean Hour Angle First Point of Aries (Vernal Equinox)"
43
+ puts "#{(gmst/15.0).round 3} = Mean Greenwich Siderial Time (GMST)"
44
+ sleep 5
45
+ end
@@ -0,0 +1,406 @@
1
+ # read_nutation_data.rb is a leftover from building it so I just left it in examples.
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+ eot = Eot.new
11
+
12
+ now = DateTime.now.to_time.utc.to_datetime
13
+
14
+ =begin
15
+
16
+ The file this data comes from is 'Circular_179.pdf' IAU 2000A Nutation Series.
17
+ The first 678 lines are for lunisolar data.
18
+
19
+ # Try to make an array using each line of the file
20
+ filename = 'nutation_series.txt'
21
+ temp_array = []
22
+ data = File.readlines(filename)
23
+ # Clean out whitespace and new line breaks.
24
+ data.each {|i| temp_array << i.strip}
25
+ # Make new muti-dimensional data array.
26
+ data = []
27
+ temp_array.each {|i| data << i.split}
28
+ # Save the array in a file.
29
+ File::open( "nutation_series.data", "w" ) do |f|
30
+ f << data
31
+ end
32
+
33
+ # Make new muti-dimensional data array using yaml
34
+ data = []
35
+ temp_array.each {|i| data << i.split}
36
+ # Save the array in a yaml file.
37
+ File::open( "nutation_series.yaml", "w" ) do |f|
38
+ f << data.to_yaml
39
+ end
40
+
41
+
42
+ # $:.unshift(File.expand_path(File.dirname(__FILE__)))
43
+ # require 'nutation_series_data'
44
+ # or for => Ruby 1.9.2
45
+ require_relative 'nutation_series_data'
46
+ # I manually added @data = to the beginning of the new array file nutation_series.rb so we may use it
47
+ # data = @data
48
+
49
+ # load in the yaml data
50
+ data = []
51
+ File.open( "nutation_series2.yaml" ) do |f|
52
+ YAML.load_documents( f ) do |doc|
53
+ data = doc
54
+ end
55
+ end
56
+
57
+ =end
58
+
59
+ ## data was initialized when the class instance was via nutation_series2.yaml file.
60
+ #data = eot.data
61
+ #file_path = File.expand_path( File.dirname( __FILE__ ) + "/nutation_table5_3a.yaml" )
62
+ #data = YAML::load( File.open( file_path, 'r'), :safe => true ).freeze
63
+ ## Arc seconds to radians formula
64
+ #ARCSEC = 3600.0
65
+ #dtr = Math::PI / 180.0 / ARCSEC # adjusted for working in the arc seconds values
66
+
67
+ ## sine degrees
68
+ #def sind(dtr, x)
69
+ # Math::sin(dtr*x)
70
+ #end
71
+ ## cod degrees
72
+ #def cosd(dtr, x)
73
+ # Math::cos(dtr*x)
74
+ #end
75
+
76
+
77
+ ## The JD is at Noon 12:00 UTC for today
78
+ ## In all of these expressions, T is the number of Julian centuries of TDB since 2000 Jan 1, 12h TDB (or,
79
+ ## with negligible error, the number of Julian centuries of TT since J2000.0).
80
+ #jd2000 = 2451545.0 # the J2000 Julian Day Number
81
+ #
82
+ #ajd = DateTime.now.to_time.utc.to_datetime.ajd.to_f
83
+ #
84
+ ## calculate time to julian centuries
85
+ #t = eot.time_julian_century()
86
+
87
+ ## Values are in arc seconds see below for definitions of terms
88
+ #ma_moon = 485868.249036 + 1717915923.2178 * t[0] + 31.8792 * t[1] + 0.051635 * t[2] - 0.00024470 * t[3]
89
+ #ma_sun = 1287104.79305 + 129596581.0481 * t[0] - 0.5532 * t[1] + 0.000136 * t[2] - 0.00001149 * t[3]
90
+ #md_moon = 335779.526232 + 1739527262.8478 * t[0] - 12.7512 * t[1] - 0.001037 * t[2] + 0.00000417 * t[3]
91
+ #me_moon = 1072260.70369 + 1602961601.2090 * t[0] - 6.3706 * t[1] + 0.006593 * t[2] - 0.00003169 * t[3]
92
+ #omega = 450160.398036 - 6962890.5431 * t[0] + 7.4722 * t[1] + 0.007702 * t[2] - 0.00005939 * t[3]
93
+
94
+ ## declare and clear these two variables for the sigma loop
95
+ #delta_psi, delta_eps = 0, 0
96
+ #
97
+ #lines = data.size - 1
98
+ #for i in 0..lines
99
+ # fma_sun = data[i][0].to_i
100
+ # fma_moon = data[i][1].to_i
101
+ # fmd_moon = data[i][2].to_i
102
+ # fme_moon = data[i][3].to_i
103
+ # fomega = data[i][4].to_i
104
+ # sine = sind(dtr, fma_moon * ma_moon +
105
+ # fma_sun * ma_sun +
106
+ # fmd_moon * md_moon +
107
+ # fme_moon * me_moon +
108
+ # fomega * omega)
109
+ # cosine = cosd(dtr, fma_moon * ma_moon +
110
+ # fma_sun * ma_sun +
111
+ # fmd_moon * md_moon +
112
+ # fme_moon * me_moon +
113
+ # fomega * omega)
114
+ # delta_psi += (data[i][6].to_f +
115
+ # data[i][7].to_f * t[0]) * sine +
116
+ # data[i][10].to_f * cosine
117
+ #
118
+ # delta_eps += (data[i][8].to_f +
119
+ # data[i][9].to_f * t[0]) * cosine +
120
+ # data[i][12].to_f * sine
121
+ #
122
+ #end
123
+ #
124
+ ## convert arc seconds to degree
125
+ #def to_deg( arc_secs )
126
+ # arc_secs / ARCSEC
127
+ #end
128
+ #
129
+ #delta_eps = to_deg( delta_eps ) / 1000.0
130
+ #delta_eps = eot.delta_epsilon(t)
131
+ #
132
+ #delta_psi = to_deg( delta_psi ) / 1000.0
133
+ #delta_psi = eot.delta_psi(t)
134
+
135
+ #Delta epsilon degrees decimal = #{to_deg(delta_eps)}
136
+
137
+
138
+
139
+ ##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.
140
+ ## eoe = delta_psi / ARCSEC * cosd( dtr * ARCSEC, eps ) * ARCSEC / 15.0
141
+ #eoe = eot.eq_of_equinox() / 15.0
142
+ ##p eot.ml_Aries()
143
+ #gmst = eot.ml_Aries() / 15.0 # make angle to time.
144
+ ## eoe is ARCSEC so convert it to hours.
145
+ #gast = gmst + eoe
146
+
147
+
148
+
149
+ ##Mean Obliquity of Ecliptic degrees = #{eot.display_degrees(eps0)}
150
+ #eot.mo_Earth()
151
+ ##True Obliquity of Ecliptic degrees = #{eot.display_degrees(eps)}
152
+ #eps = eot.to_Earth()
153
+
154
+ #eoe = eot.eq_of_equinox() / 15.0
155
+ #gmst = eot.ml_Aries() / 15.0 # make angle to time.
156
+ #gast = gmst + eoe
157
+ run = <<EOS
158
+ #{now}
159
+
160
+ #{now.to_time}
161
+
162
+ The JD = #{eot.ajd = now.ajd.to_f}
163
+
164
+ Mean Obliquity of Ecliptic = #{eot.degrees_to_s(eot.mo_Earth())}
165
+
166
+ Delta epsilon in arc seconds = #{eot.delta_epsilon() * Eot::R2D * 3600.0}
167
+
168
+ True Obliquity of Ecliptic degrees = #{eot.degrees_to_s(eot.to_Earth())}
169
+
170
+ Delta psi in arc seconds = #{eot.delta_psi * Eot::R2D * 3600}
171
+
172
+ Equation of equinox in seconds = Delta psi * cos epsilon = #{eot.eq_of_equinox() * Eot::R2D / 15.0 * 3600}
173
+
174
+ Greenwich Mean Sidereal Time = #{eot.string_time(eot.ml_Aries() * Eot::R2D / 15.0)}
175
+
176
+ Greenwich Apparent Sideral Time = #{eot.string_time(eot.ml_Aries() * Eot::R2D / 15.0 + eot.eq_of_equinox() * Eot::R2D / 15.0)}
177
+
178
+ To compare results enter the date and time into http://www.celnav.de/longterm.htm
179
+
180
+ You can use the methods in EOT instead of this example as this just shows how it works.
181
+
182
+ EOS
183
+
184
+ puts run
185
+
186
+ # Helpful info
187
+ =begin
188
+ these values are in arc seconds
189
+
190
+ Mean anomaly of the moon
191
+ ma_moon = 485868.249036 + 1717915923.2178 * t + 31.8792 * t2 + 0.051635 * t3 - 0.00024470 * t4
192
+
193
+ Mean anomaly of the sun
194
+ ma_sun = 1287104.79305 + 129596581.0481 * t - 0.5532 * t2 + 0.000136 * t3 - 0.00001149 * t4
195
+
196
+
197
+ Mean distance of the moon from the ascending node
198
+ md_moon = 335779.526232 + 1739527262.8478 * t - 12.7512 * t2 - 0.001037 * t3 + 0.00000417 * t4
199
+
200
+
201
+ Mean elongation of the moon
202
+ me_moon = 1072260.70369 + 1602961601.2090 * t - 6.3706 * t2 + 0.006593 * t3 - 0.00003169 * t4
203
+
204
+
205
+ Longitude of the ascending node of the moon
206
+ omega = 450160.398036 - 6962890.5431 * t + 7.4722 * t2 + 0.007702 * t3 - 0.00005939 * t4
207
+
208
+ =end
209
+
210
+ =begin
211
+
212
+ Manualy converted values from arc seconds to dergrees(not used here)
213
+
214
+ ma_moon = 134.96340251 + 477198.8675605 * t + t2 / 112.92629677 + t3 / 69720.15106 - t4 / 14711892.112791
215
+ ma_sun = 357.52910918 + 35999.0502911389 * t - t2 / 6507.592191 + t3 / 26470588.2353 - t4 / 313315926.89295
216
+ md_moon = 93.27209062 + 483202.01745772 * t - t2 / 282.3264 - t3 / 3471552.555 + t4 / 863309352.5179856
217
+ me_moon = 297.8501954694 + 445267.11144694 * t - t2 / 565.0959 + t3 / 546033.672 - t4 / 113600504.891
218
+ omega = 125.04455501 - 1934.136261972 * t + t2 / 481.78582 + 0.007702 * t3 / 467411.062 - t4 / 60616265.3645
219
+
220
+ =end
221
+
222
+
223
+ =begin
224
+
225
+ An example of usage for 'Circular_179.pdf' IAU 2000A Nutation Series
226
+ The JavaScript from: view-source:http://www.celnav.de/longterm.htm
227
+ //Nutation, obliquity of the ecliptic
228
+ function Nutation()
229
+ {
230
+ //IAU 1980 nutation theory:
231
+
232
+ //Mean anomaly of the moon
233
+ var Mm = 134.962981389+198.867398056*TE+trunc(477000*TE)+0.008697222222*TE2+TE3/56250;
234
+
235
+ //Mean anomaly of the sun
236
+ var M = 357.527723333+359.05034*TE+trunc(35640*TE)-0.0001602777778*TE2-TE3/300000;
237
+
238
+ //Mean distance of the moon from the ascending node
239
+ var F = 93.271910277+82.017538055*TE+trunc(483120*TE)-0.0036825*TE2+TE3/327272.7273;
240
+
241
+ //Mean elongation of the moon
242
+ var D = 297.850363055+307.11148*TE+trunc(444960*TE)-0.001914166667*TE2+TE3/189473.6842;
243
+
244
+ //Longitude of the ascending node of the moon
245
+ var omega = 125.044522222-134.136260833*TE-trunc(1800*TE)+0.002070833333*TE2+TE3/450000;
246
+
247
+ //Periodic terms for nutation
248
+ var nut = new Array(106);
249
+ nut[0] = " 0 0 0 0 1-171996-174.2 92025 8.9 ";
250
+ nut[1] = " 0 0 2-2 2 -13187 -1.6 5736-3.1 ";
251
+ nut[2] = " 0 0 2 0 2 -2274 -0.2 977-0.5 ";
252
+ nut[3] = " 0 0 0 0 2 2062 0.2 -895 0.5 ";
253
+ nut[4] = " 0-1 0 0 0 -1426 3.4 54-0.1 ";
254
+ nut[5] = " 1 0 0 0 0 712 0.1 -7 0.0 ";
255
+ nut[6] = " 0 1 2-2 2 -517 1.2 224-0.6 ";
256
+ nut[7] = " 0 0 2 0 1 -386 -0.4 200 0.0 ";
257
+ nut[8] = " 1 0 2 0 2 -301 0.0 129-0.1 ";
258
+ nut[9] = " 0-1 2-2 2 217 -0.5 -95 0.3 ";
259
+ nut[10] = "-1 0 0 2 0 158 0.0 -1 0.0 ";
260
+ nut[11] = " 0 0 2-2 1 129 0.1 -70 0.0 ";
261
+ nut[12] = "-1 0 2 0 2 123 0.0 -53 0.0 ";
262
+ nut[13] = " 1 0 0 0 1 63 0.1 -33 0.0 ";
263
+ nut[14] = " 0 0 0 2 0 63 0.0 -2 0.0 ";
264
+ nut[15] = "-1 0 2 2 2 -59 0.0 26 0.0 ";
265
+ nut[16] = "-1 0 0 0 1 -58 -0.1 32 0.0 ";
266
+ nut[17] = " 1 0 2 0 1 -51 0.0 27 0.0 ";
267
+ nut[18] = "-2 0 0 2 0 -48 0.0 1 0.0 ";
268
+ nut[19] = "-2 0 2 0 1 46 0.0 -24 0.0 ";
269
+ nut[20] = " 0 0 2 2 2 -38 0.0 16 0.0 ";
270
+ nut[21] = " 2 0 2 0 2 -31 0.0 13 0.0 ";
271
+ nut[22] = " 2 0 0 0 0 29 0.0 -1 0.0 ";
272
+ nut[23] = " 1 0 2-2 2 29 0.0 -12 0.0 ";
273
+ nut[24] = " 0 0 2 0 0 26 0.0 -1 0.0 ";
274
+ nut[25] = " 0 0 2-2 0 -22 0.0 0 0.0 ";
275
+ nut[26] = "-1 0 2 0 1 21 0.0 -10 0.0 ";
276
+ nut[27] = " 0 2 0 0 0 17 -0.1 0 0.0 ";
277
+ nut[28] = " 0 2 2-2 2 -16 0.1 7 0.0 ";
278
+ nut[29] = "-1 0 0 2 1 16 0.0 -8 0.0 ";
279
+ nut[30] = " 0 1 0 0 1 -15 0.0 9 0.0 ";
280
+ nut[31] = " 1 0 0-2 1 -13 0.0 7 0.0 ";
281
+ nut[32] = " 0-1 0 0 1 -12 0.0 6 0.0 ";
282
+ nut[33] = " 2 0-2 0 0 11 0.0 0 0.0 ";
283
+ nut[34] = "-1 0 2 2 1 -10 0.0 5 0.0 ";
284
+ nut[35] = " 1 0 2 2 2 -8 0.0 3 0.0 ";
285
+ nut[36] = " 0-1 2 0 2 -7 0.0 3 0.0 ";
286
+ nut[37] = " 0 0 2 2 1 -7 0.0 3 0.0 ";
287
+ nut[38] = " 1 1 0-2 0 -7 0.0 0 0.0 ";
288
+ nut[39] = " 0 1 2 0 2 7 0.0 -3 0.0 ";
289
+ nut[40] = "-2 0 0 2 1 -6 0.0 3 0.0 ";
290
+ nut[41] = " 0 0 0 2 1 -6 0.0 3 0.0 ";
291
+ nut[42] = " 2 0 2-2 2 6 0.0 -3 0.0 ";
292
+ nut[43] = " 1 0 0 2 0 6 0.0 0 0.0 ";
293
+ nut[44] = " 1 0 2-2 1 6 0.0 -3 0.0 ";
294
+ nut[45] = " 0 0 0-2 1 -5 0.0 3 0.0 ";
295
+ nut[46] = " 0-1 2-2 1 -5 0.0 3 0.0 ";
296
+ nut[47] = " 2 0 2 0 1 -5 0.0 3 0.0 ";
297
+ nut[48] = " 1-1 0 0 0 5 0.0 0 0.0 ";
298
+ nut[49] = " 1 0 0-1 0 -4 0.0 0 0.0 ";
299
+ nut[50] = " 0 0 0 1 0 -4 0.0 0 0.0 ";
300
+ nut[51] = " 0 1 0-2 0 -4 0.0 0 0.0 ";
301
+ nut[52] = " 1 0-2 0 0 4 0.0 0 0.0 ";
302
+ nut[53] = " 2 0 0-2 1 4 0.0 -2 0.0 ";
303
+ nut[54] = " 0 1 2-2 1 4 0.0 -2 0.0 ";
304
+ nut[55] = " 1 1 0 0 0 -3 0.0 0 0.0 ";
305
+ nut[56] = " 1-1 0-1 0 -3 0.0 0 0.0 ";
306
+ nut[57] = "-1-1 2 2 2 -3 0.0 1 0.0 ";
307
+ nut[58] = " 0-1 2 2 2 -3 0.0 1 0.0 ";
308
+ nut[59] = " 1-1 2 0 2 -3 0.0 1 0.0 ";
309
+ nut[60] = " 3 0 2 0 2 -3 0.0 1 0.0 ";
310
+ nut[61] = "-2 0 2 0 2 -3 0.0 1 0.0 ";
311
+ nut[62] = " 1 0 2 0 0 3 0.0 0 0.0 ";
312
+ nut[63] = "-1 0 2 4 2 -2 0.0 1 0.0 ";
313
+ nut[64] = " 1 0 0 0 2 -2 0.0 1 0.0 ";
314
+ nut[65] = "-1 0 2-2 1 -2 0.0 1 0.0 ";
315
+ nut[66] = " 0-2 2-2 1 -2 0.0 1 0.0 ";
316
+ nut[67] = "-2 0 0 0 1 -2 0.0 1 0.0 ";
317
+ nut[68] = " 2 0 0 0 1 2 0.0 -1 0.0 ";
318
+ nut[69] = " 3 0 0 0 0 2 0.0 0 0.0 ";
319
+ nut[70] = " 1 1 2 0 2 2 0.0 -1 0.0 ";
320
+ nut[71] = " 0 0 2 1 2 2 0.0 -1 0.0 ";
321
+ nut[72] = " 1 0 0 2 1 -1 0.0 0 0.0 ";
322
+ nut[73] = " 1 0 2 2 1 -1 0.0 1 0.0 ";
323
+ nut[74] = " 1 1 0-2 1 -1 0.0 0 0.0 ";
324
+ nut[75] = " 0 1 0 2 0 -1 0.0 0 0.0 ";
325
+ nut[76] = " 0 1 2-2 0 -1 0.0 0 0.0 ";
326
+ nut[77] = " 0 1-2 2 0 -1 0.0 0 0.0 ";
327
+ nut[78] = " 1 0-2 2 0 -1 0.0 0 0.0 ";
328
+ nut[79] = " 1 0-2-2 0 -1 0.0 0 0.0 ";
329
+ nut[80] = " 1 0 2-2 0 -1 0.0 0 0.0 ";
330
+ nut[81] = " 1 0 0-4 0 -1 0.0 0 0.0 ";
331
+ nut[82] = " 2 0 0-4 0 -1 0.0 0 0.0 ";
332
+ nut[83] = " 0 0 2 4 2 -1 0.0 0 0.0 ";
333
+ nut[84] = " 0 0 2-1 2 -1 0.0 0 0.0 ";
334
+ nut[85] = "-2 0 2 4 2 -1 0.0 1 0.0 ";
335
+ nut[86] = " 2 0 2 2 2 -1 0.0 0 0.0 ";
336
+ nut[87] = " 0-1 2 0 1 -1 0.0 0 0.0 ";
337
+ nut[88] = " 0 0-2 0 1 -1 0.0 0 0.0 ";
338
+ nut[89] = " 0 0 4-2 2 1 0.0 0 0.0 ";
339
+ nut[90] = " 0 1 0 0 2 1 0.0 0 0.0 ";
340
+ nut[91] = " 1 1 2-2 2 1 0.0 -1 0.0 ";
341
+ nut[92] = " 3 0 2-2 2 1 0.0 0 0.0 ";
342
+ nut[93] = "-2 0 2 2 2 1 0.0 -1 0.0 ";
343
+ nut[94] = "-1 0 0 0 2 1 0.0 -1 0.0 ";
344
+ nut[95] = " 0 0-2 2 1 1 0.0 0 0.0 ";
345
+ nut[96] = " 0 1 2 0 1 1 0.0 0 0.0 ";
346
+ nut[97] = "-1 0 4 0 2 1 0.0 0 0.0 ";
347
+ nut[98] = " 2 1 0-2 0 1 0.0 0 0.0 ";
348
+ nut[99] = " 2 0 0 2 0 1 0.0 0 0.0 ";
349
+ nut[100]= " 2 0 2-2 1 1 0.0 -1 0.0 ";
350
+ nut[101]= " 2 0-2 0 1 1 0.0 0 0.0 ";
351
+ nut[102]= " 1-1 0-2 0 1 0.0 0 0.0 ";
352
+ nut[103]= "-1 0 0 1 1 1 0.0 0 0.0 ";
353
+ nut[104]= "-1-1 0 2 1 1 0.0 0 0.0 ";
354
+ nut[105]= " 0 1 0 1 0 1 0.0 0 0.0 ";
355
+
356
+ //Reading periodic terms
357
+ var fMm, fM, fF, fD, f_omega, dp=0, de=0;
358
+
359
+ for (x=0; x<105; x++)
360
+ {
361
+ fMm = eval(nut[x].substring(0,2));
362
+ fM = eval(nut[x].substring(2,4));
363
+ fF = eval(nut[x].substring(4,6));
364
+ fD = eval(nut[x].substring(6,8));
365
+ f_omega = eval(nut[x].substring(8,10));
366
+ 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);
367
+ 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);
368
+ }
369
+
370
+ //Corrections (Herring, 1987)
371
+ /*
372
+ var corr = new Array(4);
373
+ corr[0] = " 0 0 0 0 1-725 417 213 224 ";
374
+ corr[1] = " 0 1 0 0 0 523 61 208 -24 ";
375
+ corr[2] = " 0 0 2-2 2 102-118 -41 -47 ";
376
+ corr[3] = " 0 0 2 0 2 -81 0 32 0 ";
377
+
378
+ for (x=0; x<4; x++)
379
+ {
380
+ fMm = eval(corr[x].substring(0,2));
381
+ fM = eval(corr[x].substring(2,4));
382
+ fF = eval(corr[x].substring(4,6));
383
+ fD = eval(corr[x].substring(6,8));
384
+ f_omega = eval(corr[x].substring(8,10));
385
+ 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));
386
+ 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));
387
+ }
388
+ */
389
+
390
+ //Nutation in longitude
391
+ delta_psi = dp/36000000;
392
+
393
+ //Nutation in obliquity
394
+ delta_eps = de/36000000;
395
+
396
+ //Mean obliquity of the ecliptic
397
+ eps0 = (84381.448-46.815*TE-0.00059*TE2+0.001813*TE3)/3600;
398
+
399
+ //True obliquity of the ecliptic
400
+ eps = eps0+delta_eps;
401
+ }
402
+
403
+ //Equation of the equinoxes
404
+ EoE = 240*delta_psi*cosd(eps);
405
+
406
+ =end