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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.ruby-version +1 -1
- data/Gemfile +6 -4
- data/Gemfile.lock +21 -14
- data/Guardfile +4 -21
- data/Manifest.txt +18 -52
- data/README.rdoc +6 -6
- data/Rakefile +53 -92
- data/equationoftime.gemspec +48 -49
- data/examples/my_lst.rb +9 -0
- data/examples/use_addr.rb +20 -0
- data/examples/use_ajd.rb +40 -0
- data/ext/eot/ceot.c +18 -14
- data/ext/eot/extconf.rb +4 -5
- data/lib/eot/angle_displays.rb +95 -0
- data/lib/eot/angles.rb +160 -291
- data/lib/eot/constants.rb +78 -81
- data/lib/eot/deltas.rb +40 -0
- data/lib/eot/geo_lat_lng_smt.rb +30 -57
- data/lib/eot/init.rb +86 -124
- data/lib/eot/time_displays.rb +105 -0
- data/lib/eot/times.rb +118 -121
- data/lib/eot/trigometric.rb +51 -0
- data/lib/eot/utilities.rb +49 -50
- data/lib/eot/version.rb +3 -2
- data/lib/eot.rb +11 -5
- data/test/eot/aliased_angles_spec.rb +291 -0
- data/test/eot/aliased_displays_spec.rb +126 -0
- data/test/{aliased_utilities_spec.rb → eot/aliased_utilities_spec.rb} +32 -36
- data/test/eot/angles_spec.rb +261 -0
- data/test/eot/constants_spec.rb +17 -0
- data/test/eot/displays_spec.rb +111 -0
- data/test/eot/geo_spec.rb +40 -0
- data/test/eot/init_spec.rb +45 -0
- data/test/eot/times_spec.rb +137 -0
- data/wiki.md +55 -0
- data/wiki2.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +55 -69
- metadata.gz.sig +0 -0
- data/.settings/org.eclipse.ltk.core.refactoring.prefs +0 -2
- data/examples/analemma_data_generator.rb +0 -58
- data/examples/check_date_type.rb +0 -60
- data/examples/compare_geoc_long_ra.rb +0 -44
- data/examples/data_table_for_astro_dog.rb +0 -45
- data/examples/earth_rotation.rb +0 -42
- data/examples/eot_methods_list.rb +0 -48
- data/examples/eot_plot.r +0 -57
- data/examples/eot_suntimes.rb +0 -149
- data/examples/equation_of_time.py +0 -186
- data/examples/figure_1.jpg +0 -0
- data/examples/file_converter.rb +0 -31
- data/examples/from_readme.rb +0 -14
- data/examples/from_wiki.rb +0 -46
- data/examples/geo_locator.rb +0 -16
- data/examples/getjd.rb +0 -45
- data/examples/gmst_gast_non_sofa.rb +0 -406
- data/examples/input_suntimes.rb +0 -24
- data/examples/julian_day_formula.rb +0 -29
- data/examples/julian_day_formula.txt +0 -12
- data/examples/my_time_conversion.rb +0 -21
- data/examples/nutation_series.txt +0 -678
- data/examples/nutation_table5_3a.txt +0 -682
- data/examples/ptime.rb +0 -162
- data/examples/suntimes.rb +0 -30
- data/examples/suntimes_test.rb +0 -50
- data/examples/t_sofa.rb +0 -8228
- data/examples/test_celes.rb +0 -51
- data/examples/test_ceot.rb +0 -55
- data/examples/test_poly_eval.rb +0 -32
- data/examples/time_scales.rb +0 -29
- data/examples/times_year.rb +0 -53
- data/examples/usage_example.rb +0 -26
- data/examples/use_angles.rb +0 -222
- data/lib/eot/displays.rb +0 -216
- data/lib/eot/eot.so +0 -0
- data/lib/eot/nutation.rb +0 -78
- data/run_tests_eclipse.rb +0 -1
- data/test/aliased_angles_spec.rb +0 -239
- data/test/aliased_displays_spec.rb +0 -105
- data/test/angles_spec.rb +0 -264
- data/test/constants_spec.rb +0 -20
- data/test/displays_spec.rb +0 -110
- data/test/geo_spec.rb +0 -38
- data/test/init_spec.rb +0 -44
- data/test/nutation_spec.rb +0 -37
- data/test/spec_config.rb +0 -8
- data/test/times_spec.rb +0 -133
- data/test/utilities_spec.rb +0 -35
data/lib/eot/constants.rb
CHANGED
|
@@ -1,159 +1,156 @@
|
|
|
1
|
-
# constants.rb
|
|
2
|
-
|
|
3
|
-
require 'date'
|
|
4
|
-
|
|
1
|
+
# class Eot file = constants.rb
|
|
5
2
|
class Eot
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
# A2000 = [0.0, 0.0, 0.0, 0.0, 0.0]
|
|
3
|
+
# Array result for time_julian_century default = [0.0, 0.0, 0.0, 0.0, 0.0]
|
|
4
|
+
# A2000 = [0.0, 0.0, 0.0, 0.0, 0.0]
|
|
9
5
|
|
|
10
|
-
# Arc seconds in a degree = 3_600.0
|
|
6
|
+
# Arc seconds in a degree = 3_600.0
|
|
11
7
|
ARCSEC = 3_600.0
|
|
12
|
-
|
|
13
|
-
# Arc seconds in a degree = 3_600.0
|
|
8
|
+
|
|
9
|
+
# Arc seconds in a degree = 3_600.0
|
|
14
10
|
ASD = 3_600.0
|
|
15
|
-
|
|
11
|
+
|
|
16
12
|
# Arc seconds in an hour = 240.0
|
|
17
13
|
# ASH = 240.0
|
|
18
|
-
|
|
14
|
+
|
|
19
15
|
# Light time for 1 au (s) = 499.004782
|
|
20
16
|
# AULT = 499.004782
|
|
21
17
|
|
|
22
18
|
# Speed of light (m/s) = 299792458.0
|
|
23
|
-
# CMPS = 299792458.0
|
|
19
|
+
# CMPS = 299792458.0
|
|
24
20
|
|
|
25
|
-
# Default date string = "2000-01-01"
|
|
21
|
+
# Default date string = "2000-01-01"
|
|
26
22
|
# D2000 = "2000-01-01"
|
|
27
23
|
|
|
28
|
-
# 2Pi = 6.283185307179586476925287
|
|
29
|
-
# D2PI = 6.283185307179586476925287
|
|
24
|
+
# 2Pi = 6.283185307179586476925287
|
|
25
|
+
# D2PI = 6.283185307179586476925287
|
|
30
26
|
|
|
31
27
|
# from desktop calculator DAS2R = 4.8481368110953599358991410235795e-6
|
|
32
28
|
DAS2R = 4.8481368110953599358991410235795e-6
|
|
33
29
|
|
|
34
30
|
# Astronomical unit (m) = 149597870e3
|
|
35
|
-
# DAU = 149597870e3
|
|
31
|
+
# DAU = 149597870e3
|
|
32
|
+
|
|
33
|
+
# Hours in a day = 24.0
|
|
34
|
+
DAY_HOURS = 24.0
|
|
36
35
|
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# Minutes in a day = 1_440.0
|
|
41
|
-
DAY_MINUTES = 1_440.0
|
|
36
|
+
# Minutes in a day = 1_440.0
|
|
37
|
+
DAY_MINUTES = 1_440.0
|
|
42
38
|
|
|
43
|
-
# Seconds in a day = 86_400.0
|
|
39
|
+
# Seconds in a day = 86_400.0
|
|
44
40
|
DAY_SECONDS = 86_400.0
|
|
45
|
-
|
|
41
|
+
|
|
46
42
|
# Seconds in a day = 86_400.0
|
|
47
|
-
DAYSEC =
|
|
43
|
+
DAYSEC = 86_400.0
|
|
48
44
|
|
|
49
|
-
# Micro Seconds in a day = 86_400_000_000.0
|
|
45
|
+
# Micro Seconds in a day = 86_400_000_000.0
|
|
50
46
|
DAY_USECS = 86_400_000_000.0
|
|
51
|
-
|
|
47
|
+
|
|
52
48
|
# Speed of light (AU per day) = DAYSEC / AULT
|
|
53
49
|
# DC = DAYSEC / AULT
|
|
54
|
-
|
|
50
|
+
|
|
55
51
|
# from desktop calculator D2R = 0.017453292519943295769236907684886
|
|
56
52
|
D2R = 0.017453292519943295769236907684886
|
|
57
|
-
|
|
58
|
-
# dint(A) - truncate to nearest whole number towards zero (double)
|
|
53
|
+
|
|
54
|
+
# dint(A) - truncate to nearest whole number towards zero (double)
|
|
59
55
|
# dint(A) = ((A)<0.0?ceil(A):floor(A))
|
|
60
56
|
|
|
61
|
-
# dnint(A) - round to nearest whole number (double)
|
|
57
|
+
# dnint(A) - round to nearest whole number (double)
|
|
62
58
|
# dnint(A) = ((A)<0.0?ceil((A)-0.5):floor((A)+0.5))
|
|
63
59
|
|
|
64
|
-
# dsign(A,B) - magnitude of A with sign of B (double)
|
|
60
|
+
# dsign(A,B) - magnitude of A with sign of B (double)
|
|
65
61
|
# dsign(A,B) = ((B)<0.0?-fabs(A):fabs(A))
|
|
66
|
-
|
|
62
|
+
|
|
67
63
|
# Reference epoch (J2000.0), Julian Date
|
|
68
|
-
# Default Julian Number = 2451545.0
|
|
69
|
-
DJ00 =
|
|
70
|
-
|
|
71
|
-
# Days per Julian century = 36525.0
|
|
72
|
-
DJC =
|
|
73
|
-
|
|
64
|
+
# Default Julian Number = 2451545.0
|
|
65
|
+
DJ00 = 2_451_545.0
|
|
66
|
+
|
|
67
|
+
# Days per Julian century = 36525.0
|
|
68
|
+
DJC = 36_525.0
|
|
69
|
+
|
|
74
70
|
# Days per Julian millennium = 365250.0
|
|
75
71
|
# DJM = 365250.0
|
|
76
72
|
|
|
77
73
|
# Julian Date of Modified Julian Date zero
|
|
78
74
|
# 1858, 11, 17, 0.0 midnight start of calendar reform = 2400000.5
|
|
79
75
|
# Removed from Julian Date to get Modified Julian Date
|
|
80
|
-
# DJM0 = 2400000.5
|
|
76
|
+
# DJM0 = 2400000.5
|
|
81
77
|
|
|
82
|
-
# Reference epoch (J2000.0), Modified Julian Date = 51544.5
|
|
78
|
+
# Reference epoch (J2000.0), Modified Julian Date = 51544.5
|
|
83
79
|
# DJM00 = 51544.5
|
|
84
80
|
|
|
85
|
-
# 1977 Jan 1.0 as MJD = 43144.0
|
|
86
|
-
# DJM77 = 43144.0
|
|
87
|
-
|
|
88
|
-
# Days per Julian year = 365.25
|
|
81
|
+
# 1977 Jan 1.0 as MJD = 43144.0
|
|
82
|
+
# DJM77 = 43144.0
|
|
83
|
+
|
|
84
|
+
# Days per Julian year = 365.25
|
|
89
85
|
# DJY = 365.25
|
|
90
|
-
|
|
86
|
+
|
|
91
87
|
# Milli-arc-seconds to radians = DAS2R / 1e3
|
|
92
88
|
# DMAS2R = DAS2R / 1e3
|
|
93
|
-
|
|
94
|
-
# Radians to arc seconds = 206264.8062470963551564734
|
|
95
|
-
# DR2AS = 206264.8062470963551564734
|
|
96
|
-
|
|
97
|
-
# Seconds of time to radians = 7.272205216643039903848712e-5
|
|
89
|
+
|
|
90
|
+
# Radians to arc seconds = 206264.8062470963551564734
|
|
91
|
+
# DR2AS = 206264.8062470963551564734
|
|
92
|
+
|
|
93
|
+
# Seconds of time to radians = 7.272205216643039903848712e-5
|
|
98
94
|
# DS2R = 7.272205216643039903848712e-5
|
|
99
95
|
|
|
100
|
-
# Default DateTime = DateTime.new( 2000, 01, 01, 12, 00, 00, "+00:00" )
|
|
101
|
-
DT2000 = DateTime.new(
|
|
96
|
+
# Default DateTime = DateTime.new( 2000, 01, 01, 12, 00, 00, "+00:00" )
|
|
97
|
+
DT2000 = DateTime.new(2000, 01, 01, 12, 00, 00, '+00:00')
|
|
102
98
|
|
|
103
|
-
# arc seconds degrees to radians = PI / 180.0 / ARCSEC
|
|
99
|
+
# arc seconds degrees to radians = PI / 180.0 / ARCSEC
|
|
104
100
|
# DTR = PI / 180.0 / ARCSEC
|
|
105
|
-
# DTR = 4.8481368110953599358991410235795e-6 # from calculator
|
|
106
|
-
|
|
107
|
-
# Length of tropical year B1900 (days) = 365.242198781
|
|
101
|
+
# DTR = 4.8481368110953599358991410235795e-6 # from calculator
|
|
102
|
+
|
|
103
|
+
# Length of tropical year B1900 (days) = 365.242198781
|
|
108
104
|
# DTY = 365.242198781
|
|
109
105
|
|
|
110
106
|
# L_G = 1 - d(TT)/d(TCG) = 6.969290134e-10
|
|
111
107
|
# ELG = 6.969290134e-10
|
|
112
108
|
|
|
113
|
-
# L_B = 1 - d(TDB)/d(TCB) = 1.550519768e-8
|
|
114
|
-
# ELB = 1.550519768e-8
|
|
109
|
+
# L_B = 1 - d(TDB)/d(TCB) = 1.550519768e-8
|
|
110
|
+
# ELB = 1.550519768e-8
|
|
115
111
|
|
|
116
|
-
# max(A,B) - larger (most +ve) of two numbers (generic)
|
|
112
|
+
# max(A,B) - larger (most +ve) of two numbers (generic)
|
|
117
113
|
# gmax(A,B) = (((A)>(B))?(A):(B))
|
|
118
114
|
|
|
119
|
-
# min(A,B) - smaller (least +ve) of two numbers (generic)
|
|
120
|
-
# gmin(A,B) = (((A)<(B))?(A):(B))
|
|
115
|
+
# min(A,B) - smaller (least +ve) of two numbers (generic)
|
|
116
|
+
# gmin(A,B) = (((A)<(B))?(A):(B))
|
|
121
117
|
|
|
122
118
|
# Reference epoch (J2000.0), Julian Date
|
|
123
|
-
# Default Julian Number = 2451545.0
|
|
124
|
-
# J2000 = 2451545.0
|
|
125
|
-
|
|
119
|
+
# Default Julian Number = 2451545.0
|
|
120
|
+
# J2000 = 2451545.0
|
|
121
|
+
|
|
126
122
|
# Julian Date of Modified Julian Date zero
|
|
127
|
-
# 1858, 11, 17, 0.0 midnight start of calendar reform = 2400000.5
|
|
123
|
+
# 1858, 11, 17, 0.0 midnight start of calendar reform = 2400000.5
|
|
128
124
|
# MJD0 = 2400000.5
|
|
129
|
-
|
|
125
|
+
|
|
130
126
|
# 2Pi from Math module = Math::PI * 2.0
|
|
131
127
|
# P2 = PI * 2.0
|
|
132
128
|
|
|
133
129
|
# from desktop calculator PI = 3.1415926535897932384626433832795
|
|
134
|
-
PI = 3.1415926535897932384626433832795
|
|
135
|
-
|
|
130
|
+
PI = 3.1415926535897932384626433832795
|
|
131
|
+
|
|
136
132
|
# from desktop calculator R2D = 57.295779513082320876798154814105
|
|
137
133
|
R2D = 57.295779513082320876798154814105
|
|
138
|
-
|
|
134
|
+
|
|
139
135
|
# from desktop calculator RTD = 0.015915494309189533576888376337251
|
|
140
|
-
RTD = 0.015915494309189533576888376337251
|
|
141
|
-
|
|
142
|
-
# from desktop calculator Sidereal minutes =
|
|
136
|
+
RTD = 0.015915494309189533576888376337251
|
|
137
|
+
|
|
138
|
+
# from desktop calculator Sidereal minutes =
|
|
139
|
+
# 4.0 / 1.0027379093507953456536618754278
|
|
143
140
|
SM = 4.0 / 1.0027379093507953456536618754278
|
|
144
|
-
|
|
145
|
-
# Schwarzschild radius of the Sun (au) =
|
|
141
|
+
|
|
142
|
+
# Schwarzschild radius of the Sun (au) =
|
|
143
|
+
# 2 * 1.32712440041e20 / (2.99792458e8)^2 / 1.49597870700e11
|
|
146
144
|
# SRS = 1.97412574336e-8
|
|
147
|
-
|
|
145
|
+
|
|
148
146
|
# TDB (s) at TAI 1977/1/1.0 = -6.55e-5
|
|
149
|
-
# TDB0 = -6.55e-5
|
|
147
|
+
# TDB0 = -6.55e-5
|
|
150
148
|
|
|
151
149
|
# TT minus TAI (s) = 32.184
|
|
152
150
|
# TTMTAI = 32.184
|
|
153
151
|
|
|
154
|
-
# Arcseconds in a full circle = 1296000.0
|
|
155
|
-
# TURNAS = 1296000.0
|
|
156
|
-
|
|
152
|
+
# Arcseconds in a full circle = 1296000.0
|
|
153
|
+
# TURNAS = 1296000.0
|
|
157
154
|
end
|
|
158
155
|
|
|
159
156
|
if __FILE__ == $PROGRAM_NAME
|
|
@@ -164,4 +161,4 @@ if __FILE__ == $PROGRAM_NAME
|
|
|
164
161
|
$LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
|
|
165
162
|
require 'constants_spec'
|
|
166
163
|
|
|
167
|
-
end
|
|
164
|
+
end
|
data/lib/eot/deltas.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# class Eot file = deltas.rb
|
|
2
|
+
class Eot
|
|
3
|
+
# From deltas.rb:
|
|
4
|
+
# delta epsilon
|
|
5
|
+
# component of equation of equinox
|
|
6
|
+
def angle_delta_epsilon
|
|
7
|
+
Celes.nut06a(@ajd, 0)[1]
|
|
8
|
+
end
|
|
9
|
+
alias_method :delta_epsilon, :angle_delta_epsilon
|
|
10
|
+
|
|
11
|
+
# From deltas.rb:
|
|
12
|
+
# one time component to total equation of time
|
|
13
|
+
def angle_delta_oblique
|
|
14
|
+
al_sun - ra_sun
|
|
15
|
+
end
|
|
16
|
+
alias_method :delta_t_ecliptic, :angle_delta_oblique
|
|
17
|
+
alias_method :delta_oblique, :angle_delta_oblique
|
|
18
|
+
|
|
19
|
+
# From angles.rb:
|
|
20
|
+
# one time component to total equation of time
|
|
21
|
+
def angle_delta_orbit
|
|
22
|
+
-1.0 * eqc(@ma, @ta)
|
|
23
|
+
end
|
|
24
|
+
alias_method :delta_t_elliptic, :angle_delta_orbit
|
|
25
|
+
alias_method :delta_orbit, :angle_delta_orbit
|
|
26
|
+
|
|
27
|
+
# From angles.rb:
|
|
28
|
+
# component of equation of equinox
|
|
29
|
+
def angle_delta_psi
|
|
30
|
+
Celes.nut06a(@ajd, 0)[0]
|
|
31
|
+
end
|
|
32
|
+
alias_method :delta_psi, :angle_delta_psi
|
|
33
|
+
|
|
34
|
+
# From angles.rb:
|
|
35
|
+
# total equation of time
|
|
36
|
+
def angle_equation_of_time
|
|
37
|
+
delta_orbit + delta_oblique
|
|
38
|
+
end
|
|
39
|
+
alias_method :eot, :angle_equation_of_time
|
|
40
|
+
end
|
data/lib/eot/geo_lat_lng_smt.rb
CHANGED
|
@@ -1,94 +1,67 @@
|
|
|
1
|
-
# geo_lat_lng_smt.rb
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
require 'rest-client'
|
|
5
|
-
require 'json'
|
|
6
|
-
|
|
7
|
-
# class for location lookup
|
|
8
|
-
# in geo_lat_lng_smt.rb
|
|
1
|
+
# class GeoLatLng file = geo_lat_lng_smt.rb
|
|
2
|
+
# class for location lookup
|
|
3
|
+
# in geo_lat_lng_smt.rb
|
|
9
4
|
class GeoLatLng
|
|
10
|
-
|
|
11
5
|
# Base address for Google maps api
|
|
12
|
-
attr_reader :
|
|
6
|
+
attr_reader :base_json
|
|
13
7
|
|
|
14
8
|
# Default US set to PARCS
|
|
15
9
|
attr_reader :default_us
|
|
16
|
-
|
|
10
|
+
|
|
17
11
|
# Default International set to GMT Museum
|
|
18
12
|
attr_reader :default_int
|
|
19
|
-
|
|
13
|
+
|
|
20
14
|
# Address entered
|
|
21
15
|
attr_accessor :addr
|
|
22
|
-
|
|
16
|
+
|
|
23
17
|
# Latitude returned
|
|
24
18
|
attr_accessor :lat
|
|
25
|
-
|
|
19
|
+
|
|
26
20
|
# Longitude returned
|
|
27
21
|
attr_accessor :lng
|
|
28
22
|
|
|
29
23
|
# Instance variables
|
|
30
24
|
def initialize
|
|
31
|
-
|
|
32
|
-
@
|
|
33
|
-
|
|
34
|
-
@
|
|
35
|
-
@default_int = "Blackheath Ave, London SE10 8XJ, UK"
|
|
25
|
+
@base_json = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address='
|
|
26
|
+
@default_us = '3333 Coyote Hill Road, Palo Alto, CA, 94304, USA'
|
|
27
|
+
@default_int = 'Blackheath Ave, London SE10 8XJ, UK'
|
|
28
|
+
@addr = @default_int
|
|
36
29
|
@lat = 0.0
|
|
37
30
|
@lng = 0.0
|
|
38
|
-
|
|
39
|
-
@addr = @default_int
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# set address
|
|
44
|
-
#def addr=(addr = @default_int)
|
|
45
|
-
# @addr = addr
|
|
46
|
-
#end
|
|
31
|
+
end
|
|
47
32
|
|
|
48
|
-
# coordinates lookup
|
|
49
|
-
def
|
|
50
|
-
addr
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@
|
|
59
|
-
else
|
|
60
|
-
@lat = results[0]["geometry"]["location"][ "lat" ].to_f
|
|
61
|
-
@lng = results[0]["geometry"]["location"][ "lng" ].to_f
|
|
62
|
-
|
|
33
|
+
# coordinates lookup
|
|
34
|
+
def set_coordinates
|
|
35
|
+
addr = Addressable::URI.escape(@base_json + @addr)
|
|
36
|
+
rest_resource = JSON.parse(RestClient.get(addr))
|
|
37
|
+
results = rest_resource['results']
|
|
38
|
+
status = rest_resource['status']
|
|
39
|
+
if status != 'OK'
|
|
40
|
+
@addr = @default_int
|
|
41
|
+
else
|
|
42
|
+
@lat = results[0]['geometry']['location']['lat'].to_f
|
|
43
|
+
@lng = results[0]['geometry']['location']['lng'].to_f
|
|
63
44
|
end
|
|
64
|
-
|
|
65
45
|
end
|
|
66
|
-
|
|
67
46
|
end
|
|
68
47
|
|
|
69
48
|
if __FILE__ == $PROGRAM_NAME
|
|
70
|
-
|
|
71
49
|
lib = File.expand_path('../../../lib', __FILE__)
|
|
72
50
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
73
|
-
|
|
74
51
|
require 'eot'
|
|
75
52
|
eot = Eot.new
|
|
76
53
|
p eot.addr
|
|
77
54
|
p eot.latitude
|
|
78
55
|
p eot.longitude
|
|
79
|
-
geo = GeoLatLng.new
|
|
56
|
+
geo = GeoLatLng.new
|
|
80
57
|
p geo.addr
|
|
81
58
|
p geo.lat
|
|
82
59
|
p geo.lng
|
|
83
|
-
geo.
|
|
60
|
+
geo.get_coordinates
|
|
84
61
|
p geo.lat
|
|
85
62
|
p geo.lng
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
#~ require 'geo_spec'
|
|
91
|
-
system 'rake test'
|
|
92
|
-
|
|
63
|
+
spec = File.expand_path('../../../test/eot', __FILE__)
|
|
64
|
+
$LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
|
|
65
|
+
require 'geo_spec'
|
|
66
|
+
system 'bundle exec ruby ~/workspace/equationoftime/test/eot/geo_spec.rb'
|
|
93
67
|
end
|
|
94
|
-
|
data/lib/eot/init.rb
CHANGED
|
@@ -1,124 +1,86 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
@ta = (( @ajd - DJ00 ) / DJC).to_f
|
|
88
|
-
@ma = Celes.falp03(@ta)
|
|
89
|
-
|
|
90
|
-
# comment out below if you do not have internet connection
|
|
91
|
-
geo = GeoLatLng.new()
|
|
92
|
-
geo.get_coordinates_from_address
|
|
93
|
-
@addr = geo.addr
|
|
94
|
-
@latitude = geo.lat
|
|
95
|
-
@longitude = geo.lng
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
# we can run some tests from inside this file.
|
|
102
|
-
if __FILE__ == $PROGRAM_NAME
|
|
103
|
-
|
|
104
|
-
lib = File.expand_path('../../../lib', __FILE__)
|
|
105
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
106
|
-
require 'eot'
|
|
107
|
-
eot = Eot.new
|
|
108
|
-
|
|
109
|
-
# p eot.ajd
|
|
110
|
-
p eot.date
|
|
111
|
-
p eot.jd
|
|
112
|
-
|
|
113
|
-
p eot.ma
|
|
114
|
-
p eot.ta
|
|
115
|
-
p eot.addr
|
|
116
|
-
p eot.latitude
|
|
117
|
-
p eot.longitude
|
|
118
|
-
|
|
119
|
-
#~ spec = File.expand_path('../../../tests/minitest', __FILE__)
|
|
120
|
-
#~ $LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
|
|
121
|
-
#~ require 'init_spec'
|
|
122
|
-
system 'rake test'
|
|
123
|
-
|
|
124
|
-
end
|
|
1
|
+
# class Eot file = int.rb
|
|
2
|
+
class Eot
|
|
3
|
+
# From init.rb:
|
|
4
|
+
# address used for GeoLatLng.addr
|
|
5
|
+
attr_accessor :addr
|
|
6
|
+
|
|
7
|
+
# From init.rb:
|
|
8
|
+
# Astronomical Julian Day Number is an instance of DateTime class.
|
|
9
|
+
# ajd or jd. Use ajd for time now and jd for suntimes. Initially
|
|
10
|
+
# @ajd = DateTime.now.to_time.utc.to_datetime.jd.to_f
|
|
11
|
+
attr_reader :ajd
|
|
12
|
+
def ajd=(ajd)
|
|
13
|
+
@ajd = ajd
|
|
14
|
+
@ta = ((@ajd - DJ00) / DJC).to_f
|
|
15
|
+
@ma = Celes.falp03(@ta)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# From init.rb:
|
|
19
|
+
# @date is an instance of DateTime class.
|
|
20
|
+
# When new Eot class is initialized @date = ajd_to_datetime(@ajd)
|
|
21
|
+
attr_accessor :date
|
|
22
|
+
|
|
23
|
+
# From init.rb:
|
|
24
|
+
# Julian Day Number is an instance of DateTime class.
|
|
25
|
+
# When new Eot class is initialized @jd = @ajd
|
|
26
|
+
attr_accessor :jd
|
|
27
|
+
|
|
28
|
+
# From init.rb:
|
|
29
|
+
# Latitude input is an instance of Float class.
|
|
30
|
+
# When new Eot class is initialized @latitude = 0.0
|
|
31
|
+
# if GeoLatLng class can't set it.
|
|
32
|
+
attr_accessor :latitude
|
|
33
|
+
|
|
34
|
+
# From init.rb:
|
|
35
|
+
# Longitude input is an instance of Float class.
|
|
36
|
+
# When new Eot class is initialized @longitude = 0.0
|
|
37
|
+
# if GeoLatLng class can't set it.
|
|
38
|
+
attr_accessor :longitude
|
|
39
|
+
|
|
40
|
+
# From init.rb:
|
|
41
|
+
# JCT gets called a lot so class attribute it.
|
|
42
|
+
# Setting @ajd will set this and @ma
|
|
43
|
+
# @ta = (( @ajd - DJ00 ) / DJC).to_f
|
|
44
|
+
attr_accessor :ta
|
|
45
|
+
|
|
46
|
+
# From init.rb:
|
|
47
|
+
# Mean Anomaly gets called a lot so class attribute saves it.
|
|
48
|
+
# @ma = Celes.falp03(@ta)
|
|
49
|
+
attr_accessor :ma
|
|
50
|
+
|
|
51
|
+
# From init.rb:
|
|
52
|
+
# Initialize to set attributes
|
|
53
|
+
# You may use GeoLatLng to set up @latitude and @longitude
|
|
54
|
+
def initialize
|
|
55
|
+
require_relative 'geo_lat_lng_smt'
|
|
56
|
+
@geo = GeoLatLng.new
|
|
57
|
+
@addr = @geo.default_int
|
|
58
|
+
@geo.addr = @addr
|
|
59
|
+
@ajd = DateTime.now.to_time.utc.to_datetime.jd.to_f
|
|
60
|
+
@date, @jd = ajd_to_datetime(@ajd), @ajd
|
|
61
|
+
@geo.set_coordinates
|
|
62
|
+
# queries could excede quotas or you get disconnected.
|
|
63
|
+
@geo.lat.zero? ? @latitude = 0.0 : @latitude = @geo.lat
|
|
64
|
+
@geo.lng.zero? ? @longitude = 0.0 : @longitude = @geo.lng
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# we can run some tests from inside this file.
|
|
69
|
+
if __FILE__ == $PROGRAM_NAME
|
|
70
|
+
lib = File.expand_path('../../../lib', __FILE__)
|
|
71
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
72
|
+
require 'eot'
|
|
73
|
+
eot = Eot.new
|
|
74
|
+
p eot.ajd
|
|
75
|
+
p eot.date
|
|
76
|
+
p eot.jd
|
|
77
|
+
p eot.ma
|
|
78
|
+
p eot.ta
|
|
79
|
+
p eot.addr
|
|
80
|
+
p eot.latitude
|
|
81
|
+
p eot.longitude
|
|
82
|
+
spec = File.expand_path('../../../test/eot', __FILE__)
|
|
83
|
+
$LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
|
|
84
|
+
require 'init_spec'
|
|
85
|
+
system 'bundle exec ruby ~/workspace/equationoftime/test/eot/init_spec.rb'
|
|
86
|
+
end
|