equationoftime 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.md +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/README2.txt +70 -0
- data/Rakefile +80 -0
- data/doc/GeoLatLng.html +770 -0
- data/doc/_index.html +123 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +179 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +179 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +611 -0
- data/doc/top-level-namespace.html +112 -0
- data/equationoftime.gemspec +35 -0
- data/examples/Equation_of_Time.jpg +0 -0
- data/examples/analemma_data_generator.rb +53 -0
- data/examples/check_date_type.rb +57 -0
- data/examples/compare_geoc_long_ra.rb +31 -0
- data/examples/data_table.rb +26 -0
- data/examples/earth_rotation.rb +13 -0
- data/examples/eot_methods_list.rb +16 -0
- data/examples/eot_plot.r +57 -0
- data/examples/eot_suntimes.rb +140 -0
- data/examples/equation_of_time.py +186 -0
- data/examples/figure_1.jpg +0 -0
- data/examples/file_converter.rb +31 -0
- data/examples/from_readme.rb +10 -0
- data/examples/geo_locator.rb +12 -0
- data/examples/getjd.rb +45 -0
- data/examples/input_suntimes.rb +21 -0
- data/examples/julian_day_formula.rb +29 -0
- data/examples/julian_day_formula.txt +12 -0
- data/examples/my_time_conversion.rb +21 -0
- data/examples/nutation_series.txt +678 -0
- data/examples/nutation_series.yaml +14239 -0
- data/examples/nutation_table5_3a.txt +682 -0
- data/examples/nutation_table5_3a.yaml +9532 -0
- data/examples/ptime.rb +162 -0
- data/examples/read_nutation_data.rb +399 -0
- data/examples/suntimes.rb +28 -0
- data/examples/suntimes_test.rb +47 -0
- data/examples/test_poly_eval.rb +38 -0
- data/examples/time_scales.rb +29 -0
- data/examples/usage_example.rb +13 -0
- data/examples/use_angles.rb +155 -0
- data/lib/eot/angles.rb +337 -0
- data/lib/eot/constants.rb +168 -0
- data/lib/eot/displays.rb +213 -0
- data/lib/eot/geo_lat_lng_smt.rb +80 -0
- data/lib/eot/init.rb +93 -0
- data/lib/eot/nutation.rb +70 -0
- data/lib/eot/nutation_table5_3a.yaml +9532 -0
- data/lib/eot/times.rb +130 -0
- data/lib/eot/utilities.rb +129 -0
- data/lib/eot/version.rb +6 -0
- data/lib/eot.rb +11 -0
- data/tests/minitest/aliased_angles_spec.rb +287 -0
- data/tests/minitest/aliased_displays_spec.rb +106 -0
- data/tests/minitest/aliased_times_spec.rb +36 -0
- data/tests/minitest/aliased_utilities_spec.rb +49 -0
- data/tests/minitest/angles_spec.rb +313 -0
- data/tests/minitest/constants_spec.rb +27 -0
- data/tests/minitest/delta_epsilon_spec.rb +35 -0
- data/tests/minitest/displays_spec.rb +111 -0
- data/tests/minitest/geo_spec.rb +36 -0
- data/tests/minitest/init_spec.rb +32 -0
- data/tests/minitest/nutation_spec.rb +33 -0
- data/tests/minitest/times_spec.rb +137 -0
- data/tests/minitest/utilities_spec.rb +121 -0
- data/tests/spec_config.rb +3 -0
- data/wiki.md +46 -0
- data/wiki2.md +4 -0
- metadata +240 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# eot_methods_list.rb
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'eot'
|
7
|
+
$DEBUG and set_trace_func proc { |event, file, line, id, binding, classname|
|
8
|
+
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
9
|
+
}
|
10
|
+
eot = Eot.new
|
11
|
+
# puts eot.public_methods(false).sort
|
12
|
+
# puts eot.nil?
|
13
|
+
loop do
|
14
|
+
p date = DateTime.now.to_time.utc.to_datetime
|
15
|
+
#~ dt = Astro.delta_T(date) / 86400.0
|
16
|
+
ajd = date.ajd
|
17
|
+
#~ ajd1 = ajd + dt
|
18
|
+
p date2 = DateTime.jd(ajd + 0.5)
|
19
|
+
sleep 0.7
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
# puts Astro.solar_longitude(date)
|
24
|
+
# tjc = eot.time_julian_century( ajd)
|
25
|
+
# puts eot.tl_Sun(tjc)
|
26
|
+
|
27
|
+
# tjc = eot.time_julian_century( ajd + dt )
|
28
|
+
# puts eot.tl_Sun(tjc)
|
29
|
+
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# use_angles.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
|
+
|
9
|
+
file = <<EOS
|
10
|
+
|
11
|
+
This will explain how the equation of time is derived by showing
|
12
|
+
each method that comprises the formula.
|
13
|
+
|
14
|
+
eot = Eot.new
|
15
|
+
#{eot = Eot.new}
|
16
|
+
|
17
|
+
Set the ajd instance to the deisired date ex : eot.ajd = Date.parse("yyyy, mm, dd").jd
|
18
|
+
|
19
|
+
eot.ajd = Date.today.jd
|
20
|
+
#{eot.ajd = Date.today.jd}
|
21
|
+
The ajd has been set to #{eot.ajd}
|
22
|
+
|
23
|
+
|
24
|
+
The Astronomical Julian Day Number plus the fractional day time now will be used to calculate current angles.
|
25
|
+
|
26
|
+
The current time expressed as an AJDN :
|
27
|
+
#{eot.ajd}
|
28
|
+
|
29
|
+
|
30
|
+
mu is the solar Mean anomaly. It is an angle with respect to perihelion of Earth orbit around Sun.
|
31
|
+
It is calculated as if the Earths orbit were circular.
|
32
|
+
|
33
|
+
mu = eot.ma
|
34
|
+
#{mu = eot.ma} deg.
|
35
|
+
|
36
|
+
|
37
|
+
nu is the True anomaly. It is the actual angle with respect to perihelion in an eliptical orbit.
|
38
|
+
It was calculated by using the equation of center formula which you may access also.
|
39
|
+
|
40
|
+
eqc = eot.center()
|
41
|
+
#{eqc = eot.center()} deg.
|
42
|
+
|
43
|
+
nu = eot.ta_Sun()
|
44
|
+
#{nu = eot.ta_Sun()} deg.
|
45
|
+
|
46
|
+
We find the delta or difference of these first two angles.
|
47
|
+
Notice it is counter sign of equation of center. It just may have taken longer to calculate.
|
48
|
+
|
49
|
+
delta_eccentric = mu - nu
|
50
|
+
#{delta_eccentric = mu - nu} deg.
|
51
|
+
|
52
|
+
The next delta is calculated as follows.
|
53
|
+
|
54
|
+
lambda = mean longitude + equation of center
|
55
|
+
|
56
|
+
mean_longitude = eot.gml_Sun()
|
57
|
+
#{mean_longitude = eot.gml_Sun()} deg.
|
58
|
+
|
59
|
+
eqc = eot.center(eot.time_julian_century())
|
60
|
+
#{eqc = eot.center(eot.time_julian_century())} deg
|
61
|
+
|
62
|
+
true longitude = mean longitude + equation of center
|
63
|
+
#{mean_longitude + eqc}
|
64
|
+
|
65
|
+
Lambda is the \"ecliptic coordinate system\" angle of the sun.
|
66
|
+
|
67
|
+
lambda_1 = eot.tl_Sun(eot.time_julian_century())
|
68
|
+
#{lambda_1 = eot.tl_Sun(eot.time_julian_century())} deg
|
69
|
+
|
70
|
+
This may also be used and is a very small difference to lambda 1
|
71
|
+
|
72
|
+
lambda_2 = eot.al_Sun(eot.time_julian_century())
|
73
|
+
#{lambda_2 = eot.al_Sun(eot.time_julian_century())} deg
|
74
|
+
|
75
|
+
Alpha is the Right Ascension of the sun in the celestial coordinate system.
|
76
|
+
|
77
|
+
alpha = eot.ra_Sun(eot.time_julian_century())
|
78
|
+
#{alpha = eot.ra_Sun(eot.time_julian_century())} deg
|
79
|
+
|
80
|
+
Delta ecliptic is the difference in these two angles.
|
81
|
+
|
82
|
+
delta_ecliptic = lambda_1 - alpha
|
83
|
+
#{delta_ecliptic = lambda_1 - alpha} deg.
|
84
|
+
|
85
|
+
The method inside the gem is called angle_delta_oblique.
|
86
|
+
|
87
|
+
The sum of these two delta angles is
|
88
|
+
|
89
|
+
delta_total = delta_eccentric + delta_ecliptic
|
90
|
+
#{delta_total = delta_eccentric + delta_ecliptic} deg.
|
91
|
+
|
92
|
+
That was for the time UTC now which was easy.
|
93
|
+
|
94
|
+
Now using your longitude to compute your mean solar transit from longitude / 15.0
|
95
|
+
my longitude is #{my_longitude = -88.74467}
|
96
|
+
#{my_longitude} deg. note: -deg. because I'm west of UTC or 0.0 deg.
|
97
|
+
|
98
|
+
So my mean solar transit UTC is
|
99
|
+
|
100
|
+
mean_noon = 12 - my_longitude / 15.0
|
101
|
+
#{mean_noon = 12 - my_longitude / 15.0} hr.
|
102
|
+
|
103
|
+
using the equation of time library method get_time(Date.today.to_datetime + mean_noon)
|
104
|
+
I'm showing what time mean noon for my_longitude normally is without
|
105
|
+
the equation of time considered and this is true only four days a year.
|
106
|
+
|
107
|
+
Be sure to set your longitude and latitude as attributes.
|
108
|
+
eot.longitude = my_longitude
|
109
|
+
eot.latitude = my_latitude
|
110
|
+
#{eot.longitude = my_longitude}
|
111
|
+
|
112
|
+
eot.mean_local_noon_dt()
|
113
|
+
#{eot.mean_local_noon_dt()}
|
114
|
+
|
115
|
+
Now we need to calculate the delta total for our mean solar transit.
|
116
|
+
We will use the mean noon time to get equation of time.
|
117
|
+
We will be using mean_noon as a time object.
|
118
|
+
First create a time object for the date at 12:00 and subtract
|
119
|
+
(my_longitude / 15.0) * 3600.0 to get the time object.
|
120
|
+
This is what get_time did without the longitude because it was provided before.
|
121
|
+
|
122
|
+
mean_noon = Time.utc(DateTime.now.to_time.utc.to_datetime.year, DateTime.now.to_time.utc.to_datetime.month, DateTime.now.to_time.utc.to_datetime.day, 12, 0, 0) - (my_longitude / 15.0) * 3600.0}
|
123
|
+
#{mean_noon = Time.utc(DateTime.now.to_time.utc.to_datetime.year, DateTime.now.to_time.utc.to_datetime.month, DateTime.now.to_time.utc.to_datetime.day, 12, 0, 0) - (my_longitude / 15.0) * 3600.0}
|
124
|
+
|
125
|
+
delta_total = eot.eot()
|
126
|
+
#{delta_total = eot.eot()} min
|
127
|
+
|
128
|
+
Let us convert that to an angle.
|
129
|
+
|
130
|
+
delta_deg = delta_total / 4.0 * 360.0 / 360.98564736629 Note: not quite 4 minutes per degree.
|
131
|
+
#{delta_deg = delta_total / 4.0 * 360.0 / 360.98564736629} deg.
|
132
|
+
|
133
|
+
Now we can add that from our longitude or mean noon angle
|
134
|
+
|
135
|
+
noon_angle = my_longitude + delta_deg
|
136
|
+
#{noon_angle = my_longitude + delta_deg}
|
137
|
+
|
138
|
+
Your longitude and the GHA of the Sun will match atTrue Solar Transit time.
|
139
|
+
|
140
|
+
So lets convert that angle to a time now.
|
141
|
+
|
142
|
+
12 - noon_angle / 15.0
|
143
|
+
#{12 - noon_angle / 15.0}
|
144
|
+
|
145
|
+
my_transit = eot.ajd + (12 - noon_angle / 15.0) / 24.0
|
146
|
+
#{my_transit = eot.ajd + (12 - noon_angle / 15.0) / 24.0}
|
147
|
+
|
148
|
+
DateTime.jd(my_transit)
|
149
|
+
#{DateTime.jd(my_transit)}
|
150
|
+
|
151
|
+
check it here http://douglasallen.github.io/planets/ just put in the correct time and date then hit calculate.
|
152
|
+
Does GHA Sun = your longitude?
|
153
|
+
EOS
|
154
|
+
|
155
|
+
puts file
|
data/lib/eot/angles.rb
ADDED
@@ -0,0 +1,337 @@
|
|
1
|
+
# angles.rb
|
2
|
+
|
3
|
+
class Eot
|
4
|
+
|
5
|
+
# From angles.rb:<br>
|
6
|
+
# Apparent solar longitude = true longitude - aberation
|
7
|
+
def al_Sun( ta = A2000 )
|
8
|
+
ta = check_jct_zero( ta )
|
9
|
+
tl_Sun( ta ) -
|
10
|
+
0.00569 -
|
11
|
+
0.00478 * sin( deg_to_rad( omega( ta ) ) )
|
12
|
+
end
|
13
|
+
alias_method :apparent_longitude, :al_Sun
|
14
|
+
|
15
|
+
# From angles.rb:<br>
|
16
|
+
# one time component to total equation of time
|
17
|
+
def angle_delta_oblique( ta = A2000 )
|
18
|
+
ta = check_jct_zero( ta )
|
19
|
+
tl_Sun( ta ) -
|
20
|
+
ra_Sun( ta )
|
21
|
+
end
|
22
|
+
|
23
|
+
# From angles.rb:<br>
|
24
|
+
# one time component to total equation of time
|
25
|
+
def angle_delta_orbit( ta = A2000 )
|
26
|
+
ta = check_jct_zero( ta )
|
27
|
+
@ma - ta_Sun( ta )
|
28
|
+
end
|
29
|
+
|
30
|
+
# From angles.rb:<br>
|
31
|
+
# component of equation of equinox
|
32
|
+
def angle_delta_psi( ta = A2000 )
|
33
|
+
ta = check_jct_zero( ta )
|
34
|
+
delta_equinox( ta )[ 1 ]
|
35
|
+
end
|
36
|
+
|
37
|
+
# From angles.rb:<br>
|
38
|
+
# total equation of time
|
39
|
+
def angle_equation_of_time( ta = A2000 )
|
40
|
+
ta = check_jct_zero( ta )
|
41
|
+
@ma = ma_Sun()
|
42
|
+
angle_delta_oblique( ta ) +
|
43
|
+
angle_delta_orbit( ta )
|
44
|
+
end
|
45
|
+
|
46
|
+
# From angles.rb:<br>
|
47
|
+
# equation of centre
|
48
|
+
# added to mean anomaly to get true anomaly.
|
49
|
+
def center( ta = A2000)
|
50
|
+
ta = check_jct_zero( ta )
|
51
|
+
sine_1M = sin( 1.0 * deg_to_rad( @ma ) )
|
52
|
+
sine_2M = sin( 2.0 * deg_to_rad( @ma ) )
|
53
|
+
sine_3M = sin( 3.0 * deg_to_rad( @ma ) )
|
54
|
+
sine_4M = sin( 4.0 * deg_to_rad( @ma ) )
|
55
|
+
sine_5M = sin( 5.0 * deg_to_rad( @ma ) )
|
56
|
+
e = eccentricity_Earth( ta )
|
57
|
+
rad_to_deg( sine_1M * ( 2.0 * e - e**3/4.0 + 5/96.0 * e**5 ) +
|
58
|
+
sine_2M * ( 5/4.0 * e**2 - 11/24.0 * e**4 ) +
|
59
|
+
sine_3M * ( 13/12.0 * e**3 - 43/64.0 * e**5 ) +
|
60
|
+
sine_4M * 103/96.0 * e**4 +
|
61
|
+
sine_5M * 1097/960.0 * e**5 )
|
62
|
+
# sine_1M *( 1.914602 - ta[ 0 ] * ( 0.004817 + ta[ 0 ] * 0.000014 )) + +
|
63
|
+
# sine_2M *( 0.019993 - ta[ 0 ] * 0.000101 ) + +
|
64
|
+
# sine_3M * 0.000289
|
65
|
+
end
|
66
|
+
alias_method :equation_of_center, :center
|
67
|
+
|
68
|
+
# From angles.rb:<br>
|
69
|
+
# cosine apparent longitude
|
70
|
+
# could be useful when dividing
|
71
|
+
def cosine_al_Sun( ta = A2000 )
|
72
|
+
ta = check_jct_zero( ta )
|
73
|
+
cos( deg_to_rad( al_Sun( ta ) ) )
|
74
|
+
end
|
75
|
+
alias_method :cosine_apparent_longitude, :cosine_al_Sun
|
76
|
+
|
77
|
+
# From angles.rb:<br>
|
78
|
+
# cosine true longitude
|
79
|
+
# used in solar right ascension
|
80
|
+
def cosine_tl_Sun( ta = A2000 )
|
81
|
+
ta = check_jct_zero( ta )
|
82
|
+
cos( deg_to_rad( tl_Sun( ta ) ) )
|
83
|
+
end
|
84
|
+
alias_method :cosine_true_longitude, :cosine_tl_Sun
|
85
|
+
|
86
|
+
# From angles.rb:<br>
|
87
|
+
# cosine true obliquity
|
88
|
+
# used in solar right ascension
|
89
|
+
def cosine_to_Earth( ta = A2000 )
|
90
|
+
ta = check_jct_zero( ta )
|
91
|
+
cos( deg_to_rad( to_Earth( ta ) ) )
|
92
|
+
end
|
93
|
+
alias_method :cosine_true_obliquity, :cosine_to_Earth
|
94
|
+
|
95
|
+
# From angles.rb:<br>
|
96
|
+
# solar declination
|
97
|
+
def dec_Sun( ta = A2000 )
|
98
|
+
ta = check_jct_zero( ta )
|
99
|
+
sine_declination = sin( deg_to_rad( to_Earth( ta ) ) ) *
|
100
|
+
sine_al_Sun( ta )
|
101
|
+
rad_to_deg( asin( sine_declination ) )
|
102
|
+
end
|
103
|
+
alias_method :declination, :dec_Sun
|
104
|
+
|
105
|
+
# From angles.rb:<br>
|
106
|
+
# delta epsilon
|
107
|
+
# component of equation of equinox
|
108
|
+
def delta_epsilon( ta = A2000 )
|
109
|
+
ta = check_jct_zero( ta )
|
110
|
+
delta_equinox( ta )[ 0 ]
|
111
|
+
end
|
112
|
+
|
113
|
+
# From angles.rb:<br>
|
114
|
+
# one time component to total equation of time
|
115
|
+
def delta_oblique( ta = A2000 )
|
116
|
+
ta = check_jct_zero( ta )
|
117
|
+
tl_Sun( ta ) -
|
118
|
+
ra_Sun( ta )
|
119
|
+
end
|
120
|
+
alias_method :delta_t_ecliptic, :delta_oblique
|
121
|
+
|
122
|
+
# From angles.rb:<br>
|
123
|
+
# one time component to total equation of time
|
124
|
+
def delta_orbit( ta = A2000 )
|
125
|
+
ta = check_jct_zero( ta )
|
126
|
+
@ma - ta_Sun( ta )
|
127
|
+
end
|
128
|
+
alias_method :delta_t_elliptic, :delta_orbit
|
129
|
+
|
130
|
+
# From angles.rb:<br>
|
131
|
+
# component of equation of equinox
|
132
|
+
def delta_psi( ta = A2000 )
|
133
|
+
ta = check_jct_zero( ta )
|
134
|
+
delta_equinox( ta )[ 1 ]
|
135
|
+
end
|
136
|
+
|
137
|
+
# From angles.rb:<br>
|
138
|
+
# eccentricity of elliptical Earth orbit around Sun
|
139
|
+
# Horner calculation method
|
140
|
+
def eccentricity_Earth( ta = A2000 )
|
141
|
+
ta = check_jct_zero( ta )
|
142
|
+
# 0.016708617 - ta[ 0 ] * ( 0.000042037 + ta[ 0 ] * 0.0000001235 )
|
143
|
+
[-0.0000001235, -0.000042037, 0.016708617].inject(0.0) {|p, a| p * ta[0] + a}
|
144
|
+
end
|
145
|
+
alias_method :eccentricity_earth_orbit, :eccentricity_Earth
|
146
|
+
|
147
|
+
# From angles.rb:<br>
|
148
|
+
# equation of equinox
|
149
|
+
def eq_of_equinox( ta = A2000 )
|
150
|
+
ta = check_jct_zero( ta )
|
151
|
+
cosine_to_Earth( ta ) *
|
152
|
+
delta_psi( ta )
|
153
|
+
end
|
154
|
+
|
155
|
+
# From angles.rb:<br>
|
156
|
+
# total equation of time
|
157
|
+
def eot()
|
158
|
+
ta = time_julian_century( @ajd )
|
159
|
+
@ma = ma_Sun()
|
160
|
+
delta_orbit( ta ) + delta_oblique( ta )
|
161
|
+
end
|
162
|
+
|
163
|
+
# From angles.rb:<br>
|
164
|
+
# angle factor for daily sidereal time (experimental)
|
165
|
+
def factor
|
166
|
+
jda = Date.parse("2000-01-01").jd
|
167
|
+
jdb = jda + 1
|
168
|
+
tjca = time_julian_century( jda )
|
169
|
+
tjcb = time_julian_century( jdb )
|
170
|
+
tlaa = tl_Aries( tjca )
|
171
|
+
tlab = tl_Aries( tjcb )
|
172
|
+
dif = tlab - tlaa
|
173
|
+
dr = dif + 360.0
|
174
|
+
360 / dr
|
175
|
+
end
|
176
|
+
|
177
|
+
# From angles.rb:<br>
|
178
|
+
# angle geometric mean longitude
|
179
|
+
# needed to get true longitude for low accuracy.
|
180
|
+
def gml_Sun( ta = A2000 )
|
181
|
+
ta = check_jct_zero( ta )
|
182
|
+
total = [ 1.0/-19880000.0, 1.0/-152990.0, 1.0/499310.0,
|
183
|
+
0.0003032028, 36000.76982779, 280.4664567 ]
|
184
|
+
mod_360( total.inject(0.0) {|p, a| p * ta[0] + a} )
|
185
|
+
end
|
186
|
+
alias_method :geometric_mean_longitude, :gml_Sun
|
187
|
+
|
188
|
+
# From angles.rb:<br>
|
189
|
+
# horizon angle for provided geo coordinates
|
190
|
+
# used for angles from transit to horizon
|
191
|
+
def ha_Sun( ta = A2000 )
|
192
|
+
ta = check_jct_zero( ta )
|
193
|
+
zenith = 90.8333
|
194
|
+
cosine_zenith = cos( deg_to_rad( zenith ) )
|
195
|
+
cosine_declination = cos( deg_to_rad( dec_Sun( ta ) ) )
|
196
|
+
sine_declination = sin( deg_to_rad( dec_Sun( ta ) ) )
|
197
|
+
cosine_latitude = cos( deg_to_rad( @latitude ) )
|
198
|
+
sine_latitude = sin( deg_to_rad( @latitude ) )
|
199
|
+
top = cosine_zenith - sine_declination * sine_latitude
|
200
|
+
bottom = cosine_declination * cosine_latitude
|
201
|
+
t_cosine = top / bottom
|
202
|
+
t_cosine > 1.0 || t_cosine < -1.0 ? cos = 1.0 : cos = t_cosine
|
203
|
+
rad_to_deg( acos( cos ) )
|
204
|
+
end
|
205
|
+
alias_method :horizon_angle, :ha_Sun
|
206
|
+
|
207
|
+
# From angles.rb:<br>
|
208
|
+
# angle of Suns' mean anomaly
|
209
|
+
# used in equation of time
|
210
|
+
# and to get true anomaly.
|
211
|
+
def ma_Sun()
|
212
|
+
ta = time_julian_century( @ajd )
|
213
|
+
ade = delta_equinox( ta )[ 2 ] / ASD
|
214
|
+
@ma = mod_360 ade
|
215
|
+
end
|
216
|
+
alias_method :mean_anomaly, :ma_Sun
|
217
|
+
|
218
|
+
# From angles.rb:<br>
|
219
|
+
# Mean equinox point where right ascension is measured from as zero hours.
|
220
|
+
# # see http://www.iausofa.org/publications/aas04.pdf
|
221
|
+
def ml_Aries( ta = A2000 )
|
222
|
+
ta = check_jct_zero( ta )
|
223
|
+
jd = ta[ 0 ] * DJC # convert first term back to jdn - J2000
|
224
|
+
# old terms
|
225
|
+
# angle = (36000.770053608 / DJC + 360) * jd # 36000.770053608 = 0.9856473662862 * DJC
|
226
|
+
# total = [ -1.0/3.8710000e7, 3.87930e-4, 0, 100.460618375 ].inject(0.0) {|p, a| p * ta[0] + a} + 180 + angle
|
227
|
+
# newer terms seem to be in arcseconds / 15.0
|
228
|
+
# 0.0000013, - 0.0000062, 0.0931118, 307.4771600, 8639877.3173760, 24110.5493771
|
229
|
+
angle = (35999.4888224 / DJC + 360) * jd
|
230
|
+
total = angle + 280.460622404583 +
|
231
|
+
ta[ 0 ] * 1.281154833333 +
|
232
|
+
ta[ 1 ] * 3.87965833333e-4 +
|
233
|
+
ta[ 2 ] * -2.58333333333e-8 +
|
234
|
+
ta[ 3 ] * 5.41666666666e-9
|
235
|
+
mod_360( total )
|
236
|
+
end
|
237
|
+
alias_method :mean_longitude_aries, :ml_Aries
|
238
|
+
|
239
|
+
# From angles.rb:<br>
|
240
|
+
# mean obliquity of Earth
|
241
|
+
def mo_Earth( ta = A2000 )
|
242
|
+
ta = check_jct_zero( ta )
|
243
|
+
[ -0.0000000434, -0.000000576, 0.00200340,
|
244
|
+
-0.0001831, -46.836769, 84381.406 ].inject(0.0) {|p, a| p * ta[0] + a} / ASD
|
245
|
+
end
|
246
|
+
alias_method :mean_obliquity_of_ecliptic, :mo_Earth
|
247
|
+
alias_method :mean_obliquity, :mo_Earth
|
248
|
+
|
249
|
+
# From angles.rb:<br>
|
250
|
+
# omega is a component of nutation and used
|
251
|
+
# in apparent longitude
|
252
|
+
# omega is the longitude of the mean ascending node of the lunar orbit
|
253
|
+
# on the ecliptic plane measured from the mean equinox of date.
|
254
|
+
def omega( ta = A2000 )
|
255
|
+
ta = check_jct_zero( ta )
|
256
|
+
delta_equinox( ta )[ 3 ] / ASD
|
257
|
+
end
|
258
|
+
|
259
|
+
# From angles.rb:<br>
|
260
|
+
# solar right ascension
|
261
|
+
def ra_Sun( ta = A2000 )
|
262
|
+
ta = check_jct_zero( ta )
|
263
|
+
y0 = sine_al_Sun( ta ) * cosine_to_Earth( ta )
|
264
|
+
180.0 +
|
265
|
+
rad_to_deg( atan2( -y0, -cosine_al_Sun( ta ) ) )
|
266
|
+
end
|
267
|
+
alias_method :right_ascension, :ra_Sun
|
268
|
+
|
269
|
+
# From angles.rb:<br>
|
270
|
+
# sine apparent longitude
|
271
|
+
# used in solar declination
|
272
|
+
def sine_al_Sun( ta = A2000 )
|
273
|
+
ta = check_jct_zero( ta )
|
274
|
+
sin( deg_to_rad( al_Sun( ta ) ) )
|
275
|
+
end
|
276
|
+
alias_method :sine_apparent_longitude, :sine_al_Sun
|
277
|
+
|
278
|
+
# From angles.rb:<br>
|
279
|
+
# sine true longitude
|
280
|
+
# used in solar right ascension
|
281
|
+
def sine_tl_Sun( ta = A2000 )
|
282
|
+
ta = check_jct_zero( ta )
|
283
|
+
sin( deg_to_rad( tl_Sun( ta ) ) )
|
284
|
+
end
|
285
|
+
alias_method :sine_true_longitude, :sine_tl_Sun
|
286
|
+
|
287
|
+
# From angles.rb:<br>
|
288
|
+
# angle true anomaly
|
289
|
+
# used in equation of time
|
290
|
+
def ta_Sun( ta = A2000 )
|
291
|
+
ta = check_jct_zero( ta )
|
292
|
+
@ma + center( ta )
|
293
|
+
end
|
294
|
+
alias_method :true_anomaly, :ta_Sun
|
295
|
+
|
296
|
+
# From angles.rb:<br>
|
297
|
+
# true longitude of equinox 'first point of aries'
|
298
|
+
# considers nutation
|
299
|
+
def tl_Aries( ta = A2000 )
|
300
|
+
ta = check_jct_zero( ta )
|
301
|
+
eq_of_equinox( ta ) +
|
302
|
+
ml_Aries( ta )
|
303
|
+
end
|
304
|
+
alias_method :true_longitude_aries, :tl_Aries
|
305
|
+
|
306
|
+
# From angles.rb:<br>
|
307
|
+
# angle of true longitude sun
|
308
|
+
# used in equation of time
|
309
|
+
def tl_Sun( ta = A2000 )
|
310
|
+
ta = check_jct_zero( ta )
|
311
|
+
mod_360(
|
312
|
+
gml_Sun( ta ) +
|
313
|
+
center( ta )
|
314
|
+
)
|
315
|
+
end
|
316
|
+
alias_method :true_longitude, :tl_Sun
|
317
|
+
|
318
|
+
# From angles.rb:<br>
|
319
|
+
# true obliquity considers nutation
|
320
|
+
def to_Earth( ta = A2000 )
|
321
|
+
ta = check_jct_zero( ta )
|
322
|
+
delta_epsilon( ta ) +
|
323
|
+
mo_Earth( ta )
|
324
|
+
end
|
325
|
+
alias_method :obliquity_correction, :to_Earth
|
326
|
+
alias_method :true_obliquity, :to_Earth
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
if __FILE__ == $PROGRAM_NAME
|
331
|
+
|
332
|
+
spec = File.expand_path('../../../tests/minitest', __FILE__)
|
333
|
+
$LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
|
334
|
+
require 'angles_spec'
|
335
|
+
require 'aliased_angles_spec'
|
336
|
+
|
337
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# constants.rb
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
class Eot
|
5
|
+
|
6
|
+
include Math
|
7
|
+
|
8
|
+
# Array result for time_julian_century default = [0.0, 0.0, 0.0, 0.0, 0.0]
|
9
|
+
A2000 = [0.0, 0.0, 0.0, 0.0, 0.0]
|
10
|
+
|
11
|
+
# Arc seconds in a degree = 3_600.0
|
12
|
+
ARCSEC = 3_600.0
|
13
|
+
|
14
|
+
# Arc seconds in a degree = 3_600.0
|
15
|
+
ASD = 3_600.0
|
16
|
+
|
17
|
+
# Arc seconds in an hour = 240.0
|
18
|
+
ASH = 240.0
|
19
|
+
|
20
|
+
# Light time for 1 au (s) = 499.004782
|
21
|
+
AULT = 499.004782
|
22
|
+
|
23
|
+
# Speed of light (m/s) = 299792458.0
|
24
|
+
CMPS = 299792458.0
|
25
|
+
|
26
|
+
# Default date string = "2000-01-01"
|
27
|
+
D2000 = "2000-01-01"
|
28
|
+
|
29
|
+
# 2Pi = 6.283185307179586476925287
|
30
|
+
D2PI = 6.283185307179586476925287
|
31
|
+
|
32
|
+
# Arcseconds to radians = 4.848136811095359935899141e-6
|
33
|
+
DAS2R = 4.848136811095359935899141e-6
|
34
|
+
|
35
|
+
# Astronomical unit (m) = 149597870e3
|
36
|
+
DAU = 149597870e3
|
37
|
+
|
38
|
+
# Hours in a day = 24.0
|
39
|
+
DAY_HOURS = 24.0
|
40
|
+
|
41
|
+
# Minutes in a day = 1_440.0
|
42
|
+
DAY_MINUTES = 1_440.0
|
43
|
+
|
44
|
+
# Seconds in a day = 86_400.0
|
45
|
+
DAY_SECONDS = 86_400.0
|
46
|
+
|
47
|
+
# Seconds in a day = 86_400.0
|
48
|
+
DAYSEC = 86400.0
|
49
|
+
|
50
|
+
# Micro Seconds in a day = 86_400_000_000.0
|
51
|
+
DAY_USECS = 86_400_000_000.0
|
52
|
+
|
53
|
+
# Speed of light (AU per day) = DAYSEC / AULT
|
54
|
+
DC = DAYSEC / AULT
|
55
|
+
|
56
|
+
# Degrees to radians = 1.745329251994329576923691e-2
|
57
|
+
DD2R = 1.745329251994329576923691e-2
|
58
|
+
|
59
|
+
# dint(A) - truncate to nearest whole number towards zero (double)
|
60
|
+
# dint(A) = ((A)<0.0?ceil(A):floor(A))
|
61
|
+
|
62
|
+
# dnint(A) - round to nearest whole number (double)
|
63
|
+
# dnint(A) = ((A)<0.0?ceil((A)-0.5):floor((A)+0.5))
|
64
|
+
|
65
|
+
# dsign(A,B) - magnitude of A with sign of B (double)
|
66
|
+
# dsign(A,B) = ((B)<0.0?-fabs(A):fabs(A))
|
67
|
+
|
68
|
+
# Reference epoch (J2000.0), Julian Date
|
69
|
+
# Default Julian Number = 2451545.0
|
70
|
+
DJ00 = 2451545.0
|
71
|
+
|
72
|
+
# Days per Julian century = 36525.0
|
73
|
+
DJC = 36525.0
|
74
|
+
|
75
|
+
# Days per Julian millennium = 365250.0
|
76
|
+
DJM = 365250.0
|
77
|
+
|
78
|
+
# Julian Date of Modified Julian Date zero
|
79
|
+
# 1858, 11, 17, 0.0 midnight start of calendar reform = 2400000.5
|
80
|
+
# Removed from Julian Date to get Modified Julian Date
|
81
|
+
DJM0 = 2400000.5
|
82
|
+
|
83
|
+
# Reference epoch (J2000.0), Modified Julian Date = 51544.5
|
84
|
+
DJM00 = 51544.5
|
85
|
+
|
86
|
+
# 1977 Jan 1.0 as MJD = 43144.0
|
87
|
+
DJM77 = 43144.0
|
88
|
+
|
89
|
+
# Days per Julian year = 365.25
|
90
|
+
DJY = 365.25
|
91
|
+
|
92
|
+
# Milli-arc-seconds to radians = DAS2R / 1e3
|
93
|
+
DMAS2R = DAS2R / 1e3
|
94
|
+
|
95
|
+
# Pi = 3.141592653589793238462643
|
96
|
+
DPI = 3.141592653589793238462643
|
97
|
+
|
98
|
+
# Radians to arc seconds = 206264.8062470963551564734
|
99
|
+
DR2AS = 206264.8062470963551564734
|
100
|
+
|
101
|
+
# Radians to degrees = 57.29577951308232087679815
|
102
|
+
DR2D = 57.29577951308232087679815
|
103
|
+
|
104
|
+
# Seconds of time to radians = 7.272205216643039903848712e-5
|
105
|
+
DS2R = 7.272205216643039903848712e-5
|
106
|
+
|
107
|
+
# Default DateTime = DateTime.new( 2000, 01, 01, 12, 00, 00, "+00:00" )
|
108
|
+
DT2000 = DateTime.new( 2000, 01, 01, 12, 00, 00, "+00:00" )
|
109
|
+
|
110
|
+
# arc seconds degrees to radians = PI / 180.0 / ARCSEC
|
111
|
+
DTR = PI / 180.0 / ARCSEC
|
112
|
+
|
113
|
+
# Length of tropical year B1900 (days) = 365.242198781
|
114
|
+
DTY = 365.242198781
|
115
|
+
|
116
|
+
# L_G = 1 - d(TT)/d(TCG) = 6.969290134e-10
|
117
|
+
ELG = 6.969290134e-10
|
118
|
+
|
119
|
+
# L_B = 1 - d(TDB)/d(TCB) = 1.550519768e-8
|
120
|
+
ELB = 1.550519768e-8
|
121
|
+
|
122
|
+
# max(A,B) - larger (most +ve) of two numbers (generic)
|
123
|
+
# gmax(A,B) = (((A)>(B))?(A):(B))
|
124
|
+
|
125
|
+
# min(A,B) - smaller (least +ve) of two numbers (generic)
|
126
|
+
# gmin(A,B) = (((A)<(B))?(A):(B))
|
127
|
+
|
128
|
+
# Reference epoch (J2000.0), Julian Date
|
129
|
+
# Default Julian Number = 2451545.0
|
130
|
+
J2000 = 2451545.0
|
131
|
+
|
132
|
+
# Julian Date of Modified Julian Date zero
|
133
|
+
# 1858, 11, 17, 0.0 midnight start of calendar reform = 2400000.5
|
134
|
+
MJD0 = 2400000.5
|
135
|
+
|
136
|
+
# 2Pi from Math module = Math::PI * 2.0
|
137
|
+
P2 = PI * 2.0
|
138
|
+
|
139
|
+
# pi from Math module = Math::PI
|
140
|
+
PI
|
141
|
+
|
142
|
+
# arc seconds radians to degrees = 180.0 / PI * ARCSEC
|
143
|
+
RTD = 180.0 / PI * ARCSEC
|
144
|
+
|
145
|
+
# Sidereal minutes = 4.0 / 1.0027379093507953456536618754278
|
146
|
+
SM = 4.0 / 1.0027379093507953456536618754278
|
147
|
+
|
148
|
+
# Schwarzschild radius of the Sun (au) = 2 * 1.32712440041e20 / (2.99792458e8)^2 / 1.49597870700e11
|
149
|
+
SRS = 1.97412574336e-8
|
150
|
+
|
151
|
+
# TDB (s) at TAI 1977/1/1.0 = -6.55e-5
|
152
|
+
TDB0 = -6.55e-5
|
153
|
+
|
154
|
+
# TT minus TAI (s) = 32.184
|
155
|
+
TTMTAI = 32.184
|
156
|
+
|
157
|
+
# Arcseconds in a full circle = 1296000.0
|
158
|
+
TURNAS = 1296000.0
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
if __FILE__ == $PROGRAM_NAME
|
163
|
+
|
164
|
+
spec = File.expand_path('../../../tests/minitest', __FILE__)
|
165
|
+
$LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
|
166
|
+
require 'constants_spec'
|
167
|
+
|
168
|
+
end
|