equationoftime 4.0.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -3
  3. data/Gemfile.lock +48 -0
  4. data/README.md +22 -19
  5. data/Rakefile +14 -7
  6. data/equationoftime.gemspec +9 -6
  7. data/ext/ceot/ceot.c +52 -0
  8. data/ext/ceot/eot.c +79 -0
  9. data/ext/ceot/eot.h +8 -0
  10. data/ext/ceot/extconf.rb +5 -0
  11. data/lib/eot.rb +2 -1
  12. data/lib/eot/angles.rb +44 -43
  13. data/lib/eot/init.rb +13 -6
  14. data/lib/eot/version.rb +1 -1
  15. data/wiki.md +6 -7
  16. metadata +26 -255
  17. data/.settings/org.eclipse.ltk.core.refactoring.prefs +0 -2
  18. data/Makefile +0 -238
  19. data/analemma_data.yml +0 -2925
  20. data/examples/Equation_of_Time.jpg +0 -0
  21. data/examples/analemma_data_generator.rb +0 -53
  22. data/examples/celes_parts/.RUBYARCHDIR.time +0 -0
  23. data/examples/celes_parts/.cproject +0 -56
  24. data/examples/celes_parts/.project +0 -78
  25. data/examples/celes_parts/a2af.c +0 -120
  26. data/examples/celes_parts/a2tf.c +0 -116
  27. data/examples/celes_parts/af2a.c +0 -107
  28. data/examples/celes_parts/anp.c +0 -82
  29. data/examples/celes_parts/anpm.c +0 -82
  30. data/examples/celes_parts/bi00.c +0 -116
  31. data/examples/celes_parts/bp00.c +0 -173
  32. data/examples/celes_parts/bp06.c +0 -136
  33. data/examples/celes_parts/bpn2xy.c +0 -100
  34. data/examples/celes_parts/c2i00a.c +0 -139
  35. data/examples/celes_parts/c2i00b.c +0 -139
  36. data/examples/celes_parts/c2i06a.c +0 -136
  37. data/examples/celes_parts/c2ibpn.c +0 -142
  38. data/examples/celes_parts/c2ixy.c +0 -131
  39. data/examples/celes_parts/c2ixys.c +0 -123
  40. data/examples/celes_parts/c2s.c +0 -96
  41. data/examples/celes_parts/c2t00a.c +0 -154
  42. data/examples/celes_parts/c2t00b.c +0 -150
  43. data/examples/celes_parts/c2t06a.c +0 -152
  44. data/examples/celes_parts/c2tcio.c +0 -122
  45. data/examples/celes_parts/c2teqx.c +0 -122
  46. data/examples/celes_parts/c2tpe.c +0 -167
  47. data/examples/celes_parts/c2txy.c +0 -159
  48. data/examples/celes_parts/cal2jd.c +0 -139
  49. data/examples/celes_parts/celes_core.c +0 -2522
  50. data/examples/celes_parts/cp.c +0 -80
  51. data/examples/celes_parts/cpv.c +0 -82
  52. data/examples/celes_parts/cr.c +0 -83
  53. data/examples/celes_parts/d2dtf.c +0 -206
  54. data/examples/celes_parts/d2tf.c +0 -160
  55. data/examples/celes_parts/dat.c +0 -289
  56. data/examples/celes_parts/depend +0 -25
  57. data/examples/celes_parts/dtdb.c +0 -1213
  58. data/examples/celes_parts/dtf2d.c +0 -196
  59. data/examples/celes_parts/ee00.c +0 -128
  60. data/examples/celes_parts/ee00a.c +0 -135
  61. data/examples/celes_parts/ee00b.c +0 -141
  62. data/examples/celes_parts/ee06a.c +0 -122
  63. data/examples/celes_parts/eect00.c +0 -282
  64. data/examples/celes_parts/eform.c +0 -147
  65. data/examples/celes_parts/eo06a.c +0 -131
  66. data/examples/celes_parts/eors.c +0 -108
  67. data/examples/celes_parts/epb.c +0 -96
  68. data/examples/celes_parts/epb2jd.c +0 -91
  69. data/examples/celes_parts/epj.c +0 -93
  70. data/examples/celes_parts/epj2jd.c +0 -91
  71. data/examples/celes_parts/epv00.c +0 -2589
  72. data/examples/celes_parts/eqeq94.c +0 -131
  73. data/examples/celes_parts/era00.c +0 -136
  74. data/examples/celes_parts/extconf.rb +0 -4
  75. data/examples/celes_parts/fad03.c +0 -103
  76. data/examples/celes_parts/fae03.c +0 -102
  77. data/examples/celes_parts/faf03.c +0 -106
  78. data/examples/celes_parts/faju03.c +0 -102
  79. data/examples/celes_parts/fal03.c +0 -103
  80. data/examples/celes_parts/falp03.c +0 -103
  81. data/examples/celes_parts/fama03.c +0 -102
  82. data/examples/celes_parts/fame03.c +0 -102
  83. data/examples/celes_parts/fane03.c +0 -99
  84. data/examples/celes_parts/faom03.c +0 -104
  85. data/examples/celes_parts/fapa03.c +0 -103
  86. data/examples/celes_parts/fasa03.c +0 -102
  87. data/examples/celes_parts/faur03.c +0 -99
  88. data/examples/celes_parts/fave03.c +0 -102
  89. data/examples/celes_parts/fk52h.c +0 -143
  90. data/examples/celes_parts/fk5hip.c +0 -126
  91. data/examples/celes_parts/fk5hz.c +0 -160
  92. data/examples/celes_parts/fw2m.c +0 -134
  93. data/examples/celes_parts/fw2xy.c +0 -120
  94. data/examples/celes_parts/gc2gd.c +0 -134
  95. data/examples/celes_parts/gc2gde.c +0 -200
  96. data/examples/celes_parts/gd2gc.c +0 -134
  97. data/examples/celes_parts/gd2gce.c +0 -138
  98. data/examples/celes_parts/gmst00.c +0 -145
  99. data/examples/celes_parts/gmst06.c +0 -136
  100. data/examples/celes_parts/gmst82.c +0 -151
  101. data/examples/celes_parts/gst00a.c +0 -138
  102. data/examples/celes_parts/gst00b.c +0 -146
  103. data/examples/celes_parts/gst06.c +0 -140
  104. data/examples/celes_parts/gst06a.c +0 -131
  105. data/examples/celes_parts/gst94.c +0 -131
  106. data/examples/celes_parts/h2fk5.c +0 -148
  107. data/examples/celes_parts/hfk5z.c +0 -175
  108. data/examples/celes_parts/ir.c +0 -83
  109. data/examples/celes_parts/jd2cal.c +0 -155
  110. data/examples/celes_parts/jdcalf.c +0 -161
  111. data/examples/celes_parts/num00a.c +0 -121
  112. data/examples/celes_parts/num00b.c +0 -121
  113. data/examples/celes_parts/num06a.c +0 -125
  114. data/examples/celes_parts/numat.c +0 -109
  115. data/examples/celes_parts/nut00a.c +0 -2047
  116. data/examples/celes_parts/nut00b.c +0 -372
  117. data/examples/celes_parts/nut06a.c +0 -153
  118. data/examples/celes_parts/nut80.c +0 -325
  119. data/examples/celes_parts/nutm80.c +0 -117
  120. data/examples/celes_parts/obl06.c +0 -118
  121. data/examples/celes_parts/obl80.c +0 -118
  122. data/examples/celes_parts/p06e.c +0 -321
  123. data/examples/celes_parts/p2pv.c +0 -83
  124. data/examples/celes_parts/p2s.c +0 -91
  125. data/examples/celes_parts/pap.c +0 -139
  126. data/examples/celes_parts/pas.c +0 -96
  127. data/examples/celes_parts/pb06.c +0 -144
  128. data/examples/celes_parts/pdp.c +0 -84
  129. data/examples/celes_parts/pfw06.c +0 -165
  130. data/examples/celes_parts/plan94.c +0 -514
  131. data/examples/celes_parts/pm.c +0 -83
  132. data/examples/celes_parts/pmat00.c +0 -118
  133. data/examples/celes_parts/pmat06.c +0 -122
  134. data/examples/celes_parts/pmat76.c +0 -141
  135. data/examples/celes_parts/pmp.c +0 -85
  136. data/examples/celes_parts/pn.c +0 -109
  137. data/examples/celes_parts/pn00.c +0 -177
  138. data/examples/celes_parts/pn00a.c +0 -162
  139. data/examples/celes_parts/pn00b.c +0 -162
  140. data/examples/celes_parts/pn06.c +0 -187
  141. data/examples/celes_parts/pn06a.c +0 -152
  142. data/examples/celes_parts/pnm00a.c +0 -121
  143. data/examples/celes_parts/pnm00b.c +0 -121
  144. data/examples/celes_parts/pnm06a.c +0 -124
  145. data/examples/celes_parts/pnm80.c +0 -126
  146. data/examples/celes_parts/pom00.c +0 -115
  147. data/examples/celes_parts/ppp.c +0 -85
  148. data/examples/celes_parts/ppsp.c +0 -94
  149. data/examples/celes_parts/pr00.c +0 -142
  150. data/examples/celes_parts/prec76.c +0 -148
  151. data/examples/celes_parts/pv2p.c +0 -81
  152. data/examples/celes_parts/pv2s.c +0 -144
  153. data/examples/celes_parts/pvdpv.c +0 -102
  154. data/examples/celes_parts/pvm.c +0 -86
  155. data/examples/celes_parts/pvmpv.c +0 -87
  156. data/examples/celes_parts/pvppv.c +0 -87
  157. data/examples/celes_parts/pvstar.c +0 -207
  158. data/examples/celes_parts/pvu.c +0 -93
  159. data/examples/celes_parts/pvup.c +0 -88
  160. data/examples/celes_parts/pvxpv.c +0 -107
  161. data/examples/celes_parts/pxp.c +0 -94
  162. data/examples/celes_parts/rm2v.c +0 -111
  163. data/examples/celes_parts/rv2m.c +0 -118
  164. data/examples/celes_parts/rx.c +0 -110
  165. data/examples/celes_parts/rxp.c +0 -99
  166. data/examples/celes_parts/rxpv.c +0 -86
  167. data/examples/celes_parts/rxr.c +0 -99
  168. data/examples/celes_parts/ry.c +0 -110
  169. data/examples/celes_parts/rz.c +0 -110
  170. data/examples/celes_parts/s00.c +0 -371
  171. data/examples/celes_parts/s00a.c +0 -143
  172. data/examples/celes_parts/s00b.c +0 -143
  173. data/examples/celes_parts/s06.c +0 -368
  174. data/examples/celes_parts/s06a.c +0 -145
  175. data/examples/celes_parts/s2c.c +0 -85
  176. data/examples/celes_parts/s2p.c +0 -88
  177. data/examples/celes_parts/s2pv.c +0 -103
  178. data/examples/celes_parts/s2xpv.c +0 -87
  179. data/examples/celes_parts/sepp.c +0 -105
  180. data/examples/celes_parts/seps.c +0 -93
  181. data/examples/celes_parts/sofa.h +0 -379
  182. data/examples/celes_parts/sofam.h +0 -155
  183. data/examples/celes_parts/sp00.c +0 -118
  184. data/examples/celes_parts/starpm.c +0 -205
  185. data/examples/celes_parts/starpv.c +0 -264
  186. data/examples/celes_parts/sxp.c +0 -84
  187. data/examples/celes_parts/sxpv.c +0 -85
  188. data/examples/celes_parts/taitt.c +0 -110
  189. data/examples/celes_parts/taiut1.c +0 -112
  190. data/examples/celes_parts/taiutc.c +0 -182
  191. data/examples/celes_parts/tcbtdb.c +0 -132
  192. data/examples/celes_parts/tcgtt.c +0 -109
  193. data/examples/celes_parts/tdbtcb.c +0 -137
  194. data/examples/celes_parts/tdbtt.c +0 -122
  195. data/examples/celes_parts/test_celes.rb +0 -48
  196. data/examples/celes_parts/tf2a.c +0 -107
  197. data/examples/celes_parts/tf2d.c +0 -107
  198. data/examples/celes_parts/tr.c +0 -93
  199. data/examples/celes_parts/trxp.c +0 -93
  200. data/examples/celes_parts/trxpv.c +0 -93
  201. data/examples/celes_parts/tttai.c +0 -110
  202. data/examples/celes_parts/tttcg.c +0 -112
  203. data/examples/celes_parts/tttdb.c +0 -121
  204. data/examples/celes_parts/ttut1.c +0 -110
  205. data/examples/celes_parts/ut1tai.c +0 -111
  206. data/examples/celes_parts/ut1tt.c +0 -110
  207. data/examples/celes_parts/ut1utc.c +0 -193
  208. data/examples/celes_parts/utctai.c +0 -163
  209. data/examples/celes_parts/utcut1.c +0 -151
  210. data/examples/celes_parts/xy06.c +0 -2758
  211. data/examples/celes_parts/xys00a.c +0 -133
  212. data/examples/celes_parts/xys00b.c +0 -133
  213. data/examples/celes_parts/xys06a.c +0 -133
  214. data/examples/celes_parts/zp.c +0 -77
  215. data/examples/celes_parts/zpv.c +0 -79
  216. data/examples/celes_parts/zr.c +0 -83
  217. data/examples/check_date_type.rb +0 -55
  218. data/examples/compare_geoc_long_ra.rb +0 -39
  219. data/examples/data_table_for_astro_dog.rb +0 -40
  220. data/examples/earth_rotation.rb +0 -38
  221. data/examples/eot.c +0 -15
  222. data/examples/eot.h +0 -2
  223. data/examples/eot_methods_list.rb +0 -43
  224. data/examples/eot_plot.r +0 -57
  225. data/examples/eot_suntimes.rb +0 -144
  226. data/examples/equation_of_time.py +0 -186
  227. data/examples/extconf.rb +0 -2
  228. data/examples/figure_1.jpg +0 -0
  229. data/examples/file_converter.rb +0 -31
  230. data/examples/from_readme.rb +0 -10
  231. data/examples/geo_locator.rb +0 -12
  232. data/examples/getjd.rb +0 -45
  233. data/examples/gmst_gast_non_sofa.rb +0 -404
  234. data/examples/input_suntimes.rb +0 -21
  235. data/examples/julian_day_formula.rb +0 -29
  236. data/examples/julian_day_formula.txt +0 -12
  237. data/examples/my_time_conversion.rb +0 -21
  238. data/examples/nutation_series.txt +0 -678
  239. data/examples/nutation_series.yaml +0 -14239
  240. data/examples/nutation_table5_3a.txt +0 -682
  241. data/examples/nutation_table5_3a.yaml +0 -9532
  242. data/examples/ptime.rb +0 -162
  243. data/examples/rbeot.c +0 -24
  244. data/examples/suntimes.rb +0 -28
  245. data/examples/suntimes_test.rb +0 -47
  246. data/examples/test_eot.rb +0 -17
  247. data/examples/test_poly_eval.rb +0 -27
  248. data/examples/time_scales.rb +0 -26
  249. data/examples/times_year.rb +0 -50
  250. data/examples/usage_example.rb +0 -23
  251. data/examples/use_angles.rb +0 -219
  252. data/rise_set_data.yml +0 -1461
  253. data/tests/minitest/aliased_angles_spec.rb +0 -241
  254. data/tests/minitest/aliased_displays_spec.rb +0 -108
  255. data/tests/minitest/aliased_utilities_spec.rb +0 -38
  256. data/tests/minitest/angles_spec.rb +0 -266
  257. data/tests/minitest/constants_spec.rb +0 -21
  258. data/tests/minitest/delta_epsilon_spec.rb +0 -32
  259. data/tests/minitest/displays_spec.rb +0 -113
  260. data/tests/minitest/geo_spec.rb +0 -40
  261. data/tests/minitest/init_spec.rb +0 -46
  262. data/tests/minitest/nutation_spec.rb +0 -39
  263. data/tests/minitest/times_spec.rb +0 -139
  264. data/tests/minitest/utilities_spec.rb +0 -37
  265. data/tests/spec_config.rb +0 -3
data/examples/ptime.rb DELETED
@@ -1,162 +0,0 @@
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
-
data/examples/rbeot.c DELETED
@@ -1,24 +0,0 @@
1
- #include "ruby.h"
2
-
3
- #ifndef DBL2NUM
4
- # define DBL2NUM(dbl) rb_float_new(dbl)
5
- #endif
6
-
7
- VALUE cEot;
8
- ID id_status;
9
-
10
- static VALUE
11
- ma_Sun(VALUE self, VALUE vt) {
12
-
13
- rb_ivar_set(self, id_status, INT2FIX(0));
14
- return DBL2NUM(maSun(NUM2DBL(vt)));
15
- }
16
-
17
-
18
- void
19
- Init_rbeot(void) {
20
-
21
- cEot = rb_define_class("EOT", rb_cObject);
22
- id_status = rb_intern("@status");
23
- rb_define_method(cEot, "ma", ma_Sun, 1);
24
- }
data/examples/suntimes.rb DELETED
@@ -1,28 +0,0 @@
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
@@ -1,47 +0,0 @@
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
-
data/examples/test_eot.rb DELETED
@@ -1,17 +0,0 @@
1
- require_relative 'rbeot'
2
- require_relative '../lib/eot'
3
-
4
- rbeot = EOT.new
5
- eot = Eot.new
6
-
7
- p eot.ta
8
- p rbeot.ma(eot.ta)
9
- #~ p eot.ma_Sun
10
-
11
- require 'benchmark'
12
-
13
- n = 5_000
14
- Benchmark.bm do |x|
15
- x.report("eot") { n.times { rbeot.ma(eot.ta) } }
16
- #~ x.report("ruby") { n.times {eot.ma_Sun() } }
17
- end
@@ -1,27 +0,0 @@
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
- # From astro-algo gem
7
- # class Array
8
- # Evaluate polynomial using Horner's method.
9
- # Array consists of coefficients of a polynomial, the
10
- # coefficient of the highest order term first, the
11
- # constant coefficient last.
12
- # Returns evaluation of polynomial at +x+.
13
- #
14
- # Example: evaluate the polynomial x**2 - 0.5*x + 3.0 where x = 2.0
15
- # [1.0, -0.5, 3.0].poly_eval(2.0) # => 6.0
16
- # def poly_eval(x)
17
- # self.inject(0.0) {|p, a|
18
- # p*x + a}
19
- # end
20
- # end
21
-
22
- my_array = [1.0, -0.5, 3.0]
23
- my_array.inject(0.0) {|sum, n| p sum * 2.0 + n }
24
-
25
- ecc = [-0.0000001235, -0.000042037, 0.016708617]
26
- ta = 0.14
27
- ecc.inject(0.0) {|sum, n| p sum * ta + n }
@@ -1,26 +0,0 @@
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
- puts DateTime.now.to_time.utc.nsec.inspect
15
- puts DateTime.jd(DateTime.now.to_time.utc.to_datetime.ajd + 0.5).to_time.nsec.inspect
16
- sleep 0.7
17
- puts
18
- end
19
-
20
- # puts Astro.solar_longitude(date)
21
- # tjc = eot.time_julian_century( ajd)
22
- # puts eot.tl_Sun(tjc)
23
-
24
- # tjc = eot.time_julian_century( ajd + dt )
25
- # puts eot.tl_Sun(tjc)
26
-
@@ -1,50 +0,0 @@
1
- # a list of sunrise and sunset times for a year of dates.
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
- require 'time'
9
-
10
- eot = Eot.new
11
-
12
- # set your latitude and longitude first.
13
- eot.latitude = 41.9474
14
- eot.longitude = -88.74467
15
-
16
- # make some start and finish dates.
17
- start = "2014-1-1"
18
- finish = "2014-12-31"
19
-
20
- start_time = Time.utc( 2014, "jan", 1, 12, 0, 0 )
21
- finish_time = Time.utc( 2014, "dec", 31, 12, 0, 0 )
22
-
23
- start_jd = Date.parse(start).jd
24
- finish_jd = Date.parse(finish).jd
25
-
26
- fstr = "%b %d"
27
-
28
- @data, @group, @group_id = [], {}, 1
29
-
30
- (start_jd..finish_jd).each do |jd|
31
- # date = DateTime.jd(jd + 0.5).to_date
32
- eot.ajd = jd
33
- rise = eot.sunrise_dt().to_time.to_json
34
- trans = eot.local_noon_dt().to_time.to_json
35
- set = eot.sunset_dt().to_time.to_json
36
- @group = { "id" => @group_id,
37
- "rise" => rise,
38
- "noon" => trans,
39
- "sset" => set
40
- }
41
- @data << @group
42
- @group_id += 1
43
- end
44
-
45
- file_path = "rise_set_data.yml"
46
- File::open( file_path, "w" ) do |f|
47
- YAML.dump( @data, f )
48
- end
49
-
50
- puts "File rise_set_data.yml processed"
@@ -1,23 +0,0 @@
1
- # usage_example.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
- # find what the defaults are set to
10
- show = <<RAN
11
- ajd = #{eot.ajd}
12
- date = #{eot.date}
13
- jd = #{eot.jd}
14
- longitude = #{eot.longitude}
15
- latitude = #{eot.latitude}
16
- sunrise = #{eot.sunrise_dt}
17
- trnasit = #{eot.local_noon_dt}
18
- min eot = #{eot.time_eot}
19
- sunset = #{eot.sunset_dt}
20
- gasa = #{eot.tl_Aries}
21
- RAN
22
-
23
- puts show
@@ -1,219 +0,0 @@
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 = <<DISPLAY
10
-
11
- This will explain how the equation of time is derived by showing each method that comprises the formula.
12
-
13
- eot = Eot.new
14
-
15
- Instance of Eot class eot = #{eot = Eot.new}
16
-
17
-
18
- Set the class attribute ajd for the deisired date ex : eot.ajd = Date.parse("yyyy, mm, dd").jd.to_f
19
-
20
- eot.ajd = Date.today.jd.to_f
21
-
22
- eot.ajd = #{eot.ajd = Date.today.jd.to_f}
23
-
24
- The class attribute ajd has been set to a nice whole number even though it is a Float class now.
25
-
26
- The Astronomical Julian Day Number is a half day less than Julian Day Number with the fractional day time included when we DateTime class.
27
-
28
- DateTime.now.day_fraction.to_f = #{DateTime.now.day_fraction.to_f}
29
-
30
- DateTime class has the method day_fraction and Date class does not.
31
-
32
- We used Date class which doesn't give us the UTC time of date. It yields your time zone date.
33
-
34
- Let's just prove this.
35
-
36
- Date.today.to_time.utc = #{Date.today.to_time.utc}
37
-
38
- It looks like that was your midnight in UTC time.
39
-
40
- Maybe we could get away with getting the ajd from that.
41
-
42
- Date.today.to_time.utc.to_date.ajd.to_f = #{Date.today.to_time.utc.to_date.ajd.to_f}
43
-
44
- No. That's a half day less than the Julian Day Number.
45
-
46
- So let's start over setting the adj correctly for UTC using the DateTime class.
47
-
48
- eot.ajd = DateTime.now.to_time.utc.to_datetime.ajd.to_f
49
-
50
- eot.ajd = #{eot.ajd = DateTime.now.to_time.utc.to_datetime.ajd.to_f}
51
-
52
-
53
- Because this gem is going to calculate the sunrise and sunset times it's okay to set the day for noon and is encouraged.
54
-
55
- So go ahead and set the ajd using the Date class and jd method as was first done.
56
-
57
- The class init.rb sets everything to defaults and one of them is today's datetime.jd
58
-
59
- But for right now we won't do that so we get current angles of the present time UTC.
60
-
61
-
62
-
63
- eot.ma is the solar Mean anomaly mu(M) and is called quite often hence the attribute.
64
-
65
- eot.ma was set using eot.ma_Sun() method.
66
-
67
- It is an angle with respect to perihelion of Earth orbit around Sun in an assumed circular orbit.
68
-
69
- M is calculated within the nutation.rb file under delta_equinox() method and returned as the third element of an array.
70
-
71
- eot.ma = #{eot.ma}
72
-
73
- eot.ma_Sun() = #{eot.ma_Sun()}
74
-
75
-
76
- angle one = eot.ma_Sun() - eot.ta_Sun()
77
-
78
- a1 = #{eot.ma_Sun() - eot.ta_Sun()} degrees
79
-
80
- a1 is a delta angle difference for mean and true anomalies in degrees.
81
-
82
- True anomaly (nu) is the actual angle with respect to perihelion in an eliptical orbit.
83
-
84
- It was calculated by using the equation of center formula which you may access also.
85
-
86
- eot.center() = #{eot.center()} degrees.
87
-
88
- nu = equation of center + M or mu or mean anomaly
89
-
90
- The delta is M - nu.
91
-
92
-
93
- The method inside the gem is called delta_orbit()
94
-
95
- eot.delta_orbit = #{eot.delta_orbit} degrees
96
-
97
- We could just change the sign of eot.center().
98
-
99
- In fact let's just do that now. a1 = - eot.center()
100
-
101
- - eot.center() = #{- eot.center()}
102
-
103
-
104
- The next delta is calculated as follows.
105
-
106
- lambda or apparent longitude of the Sun minus alpha or right ascension of the Sun.
107
-
108
- a2 = lambda - alpha
109
-
110
- lambda = mean longitude + equation of center
111
-
112
- eot.gml_Sun() + eot.center() = #{eot.gml_Sun() + eot.center()} or
113
-
114
- eot.tl_Sun = #{eot.tl_Sun}
115
-
116
- Lambda is the \"ecliptic coordinate system\" angle of the sun.
117
-
118
- Alpha is the Right Ascension of the sun in the celestial coordinate system.
119
-
120
- alpha = eot.ra_Sun()
121
-
122
- alpha = #{eot.ra_Sun()}
123
-
124
- lambda - alpha = #{eot.tl_Sun - eot.ra_Sun()}
125
-
126
- The method inside the gem is called delta_oblique.
127
-
128
- eot.delta_oblique() = #{eot.delta_oblique()}
129
-
130
-
131
- The sum of these two delta angles is the equation of time angle in degrees not time.
132
-
133
- eot.eot() = #{eot.eot()}
134
-
135
- That was for the time UTC now which was easy.
136
-
137
-
138
- Now using your longitude to compute your mean solar transit from longitude / 15.0
139
-
140
- my longitude is -88.74467 deg. so I'll set the longitude attribute in Eot class.
141
-
142
- eot.longitude = #{eot.longitude = -88.74467}
143
-
144
-
145
- So my mean solar transit UTC is 12.0 - my_longitude / 15.0
146
-
147
- my_mean_noon = #{12.0 - -88.74467 / 15.0} hr.
148
-
149
- Be sure to set everything for UTC noon before adding it to your longitude because we were doing angles for time now.
150
-
151
- eot.ajd = #{eot.ajd = Date.today.jd.to_f}
152
-
153
-
154
-
155
- Using the Eot class I may also compute it with eot.mean_local_noon_dt() method if I have the ajd set right.
156
-
157
- eot.mean_local_noon_dt() = #{eot.mean_local_noon_dt()}
158
-
159
- I'm showing what time mean noon for my_longitude normally is without the equation of time considered.
160
-
161
- This time is true only four days a year. Lets get the right one for today to be sure.
162
-
163
-
164
-
165
- We can add longitude plus equation of time as angles.
166
-
167
- eot.longitude + eot.eot() = #{eot.longitude} + #{eot.eot()}
168
-
169
- What's the time of solar transit here now?
170
-
171
- 12.0 - (eot.longitude + eot.eot()) / 15.0 = #{12.0 - (eot.longitude + eot.eot()) / 15.0}
172
-
173
- That looks about right.
174
-
175
-
176
-
177
- Let's make a time out of that by converting it to a fractional day.
178
-
179
- (12.0 - (eot.longitude + eot.eot()) / 15.0) / 24.0 = #{(12.0 - (eot.longitude + eot.eot()) / 15.0) / 24.0}
180
-
181
- We'll add that to the ajd then.
182
-
183
- ajd = Date.today.ajd.to_f
184
-
185
- ajd = #{Date.today.ajd.to_f}
186
-
187
- #{Date.today.ajd.to_f} + #{(12.0 - (eot.longitude + eot.eot()) / 15.0) / 24.0} = #{Date.today.ajd.to_f + (12.0 - (eot.longitude + eot.eot()) / 15.0) / 24.0}
188
-
189
-
190
- There is a method in Eot class to make that a DateTime object.
191
-
192
- eot.ajd_to_datetime(ajd + transit)
193
-
194
- #{eot.ajd_to_datetime(Date.today.ajd.to_f + (12.0 - (eot.longitude + eot.eot()) / 15.0) / 24.0)}
195
-
196
-
197
- Be sure to set your latitude attribute as well when you want to compute sunrise and sunset times for the days of interest.
198
-
199
- eot.latitude = my_latitude
200
-
201
-
202
- Your longitude and the GHA of the Sun will match at True Solar Transit time.
203
-
204
- Check it here http://douglasallen.github.io/planets/ just put in the correct time and date then hit calculate.
205
-
206
- Does GHA Sun = your longitude?
207
-
208
- It's off a little bit because that site uses a different formula that is commonly used in older programs.
209
-
210
- I get about 3 seconds difference in the EOT is all.
211
- DISPLAY
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
- puts file