equationoftime 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,112 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!top-level-namespace.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">Top Level Namespace</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Top Level Namespace
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</dl>
|
82
|
+
<div class="clear"></div>
|
83
|
+
|
84
|
+
<h2>Defined Under Namespace</h2>
|
85
|
+
<p class="children">
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Eot.html" title="Eot (class)">Eot</a></span>, <span class='object_link'><a href="GeoLatLng.html" title="GeoLatLng (class)">GeoLatLng</a></span>
|
91
|
+
|
92
|
+
|
93
|
+
</p>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<div id="footer">
|
106
|
+
Generated on Wed Aug 20 13:59:06 2014 by
|
107
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
|
+
0.8.7.4 (ruby-2.1.2).
|
109
|
+
</div>
|
110
|
+
|
111
|
+
</body>
|
112
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
# Metadata
|
8
|
+
spec.name = "equationoftime"
|
9
|
+
spec.version = Eot::VERSION
|
10
|
+
spec.authors = ["DouglasAllen"]
|
11
|
+
spec.email = ["kb9agt@gmail.com"]
|
12
|
+
spec.summary = %q{Equation of Time calculates time of solar transition.}
|
13
|
+
spec.description = %q{Calculate Sunrise and Sunset, GMST, and GAST for just about any date and location.
|
14
|
+
Lots of examples to play with included.}
|
15
|
+
spec.homepage = "http://equationoftime.herokuapp.com"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
|
19
|
+
# Manifest
|
20
|
+
#spec.files = Dir.glob("{examples, lib}/**/*") + %w(LICENSE README}
|
21
|
+
spec.files = `git ls-files -z`.split("\x0")
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
spec.platform = Gem::Platform::RUBY
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "minitest"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_runtime_dependency "astro-algo"
|
31
|
+
spec.add_runtime_dependency "multi_xml"
|
32
|
+
spec.add_runtime_dependency "rest-client"
|
33
|
+
spec.add_runtime_dependency "safe_yaml"
|
34
|
+
|
35
|
+
end
|
Binary file
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# analemma_data_generator.rb
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'eot'
|
7
|
+
require 'safe_yaml'
|
8
|
+
require 'time'
|
9
|
+
|
10
|
+
eot = Eot.new
|
11
|
+
|
12
|
+
start = "2014-1-1"
|
13
|
+
finish = "2014-12-31"
|
14
|
+
|
15
|
+
start_time = Time.utc( 2014, "jan", 1, 12, 0, 0 )
|
16
|
+
finish_time = Time.utc( 2014, "dec", 31, 12, 0, 0 )
|
17
|
+
|
18
|
+
|
19
|
+
start_jd = start_time.to_datetime.jd
|
20
|
+
finish_jd = finish_time.to_datetime.jd
|
21
|
+
|
22
|
+
fstr = "%b %d"
|
23
|
+
|
24
|
+
@data, @group, @group_id = [], {}, 0
|
25
|
+
|
26
|
+
(start_jd..finish_jd).each do |jd|
|
27
|
+
date = Date.jd(jd + 0.5).strftime(fstr)
|
28
|
+
jcta = eot.time_julian_century(jd)
|
29
|
+
eot.ajd = DateTime.jd(jd + 0.5)
|
30
|
+
delta_t = eot.show_minutes(eot.time_eot())
|
31
|
+
trans = eot.display_time_string(12 - eot.time_eot()/60.0)
|
32
|
+
e1 = eot.show_minutes(eot.time_delta_orbit())
|
33
|
+
e2 = eot.show_minutes(eot.time_delta_oblique())
|
34
|
+
decline = eot.degrees_to_s(eot.dec_Sun(jcta))
|
35
|
+
@group = {group_id: "#{@group_id}",
|
36
|
+
date: date,
|
37
|
+
eot: delta_t,
|
38
|
+
orbit: "#{e1}",
|
39
|
+
oblique: "#{e2}",
|
40
|
+
transit: "#{trans}",
|
41
|
+
declination: "#{decline}",
|
42
|
+
julian: "#{jd}",
|
43
|
+
}
|
44
|
+
@data << @group
|
45
|
+
@group_id += 1
|
46
|
+
end
|
47
|
+
|
48
|
+
file_path = "analemma_data.yml"
|
49
|
+
File::open( file_path, "w" ) do |f|
|
50
|
+
YAML.dump( @data, f )
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "File analemma_data.yml processed"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# check_date_type.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
|
+
output =<<EOO
|
11
|
+
|
12
|
+
eot = Eot.new()
|
13
|
+
|
14
|
+
eot.date = #{eot.date} = #{eot.date.class}
|
15
|
+
|
16
|
+
eot.ajd = eot.date.ajd.to_f = #{eot.ajd = eot.date.ajd.to_f}
|
17
|
+
|
18
|
+
eot.eot = #{eot.eot()} # getting default today
|
19
|
+
|
20
|
+
eot.date = #{eot.date = "2014-10-14"} = #{eot.date.class}
|
21
|
+
|
22
|
+
eot.ajd = Date.parse(eot.date).jd.to_f = #{eot.ajd = Date.parse(eot.date).jd.to_f}
|
23
|
+
|
24
|
+
eot.eot = #{eot.eot} # getting default today
|
25
|
+
|
26
|
+
eot.equation_of_time(eot.time_julian_century(eot.ajd)) = #{eot.eot()}
|
27
|
+
|
28
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()} with lat and lng 0.
|
29
|
+
|
30
|
+
eot.longitude = #{eot.longitude = 0}
|
31
|
+
|
32
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()}
|
33
|
+
|
34
|
+
eot.latitude = #{eot.latitude = 0}
|
35
|
+
|
36
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()}
|
37
|
+
|
38
|
+
eot.longitude = #{eot.longitude = 180.0}
|
39
|
+
|
40
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()}
|
41
|
+
|
42
|
+
eot.longitude = #{eot.longitude = -180.0}
|
43
|
+
|
44
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()}
|
45
|
+
|
46
|
+
eot.longitude = #{eot.longitude = 0}
|
47
|
+
eot.latitude = #{eot.latitude = 90}
|
48
|
+
|
49
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()}
|
50
|
+
|
51
|
+
eot.longitude = #{eot.longitude = 0}
|
52
|
+
eot.latitude = #{eot.latitude = -90}
|
53
|
+
|
54
|
+
eot.sunrise_dt() = #{eot.sunrise_dt()}
|
55
|
+
EOO
|
56
|
+
|
57
|
+
puts output
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# compare_geoc_long_ra.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
|
+
start = "2013-3-20"
|
11
|
+
finish = "2013-3-20"
|
12
|
+
|
13
|
+
start_date = Date.parse(start)
|
14
|
+
finish_date = Date.parse(finish)
|
15
|
+
|
16
|
+
puts "start julian date = #{start_date.jd} date = #{start}"
|
17
|
+
puts "finish julian date = #{finish_date.jd} date = #{finish}"
|
18
|
+
|
19
|
+
ajd = start_date.ajd * 1.0
|
20
|
+
|
21
|
+
for min in 0..59
|
22
|
+
h = 10 / 24.0
|
23
|
+
fd = h + min / 1440.0
|
24
|
+
timejc = eot.time_julian_century(ajd + fd)
|
25
|
+
ml = eot.geometric_mean_longitude(timejc)
|
26
|
+
tl = eot.true_longitude(timejc)
|
27
|
+
ra = eot.right_ascension(timejc)
|
28
|
+
puts "time\t\t\tmean longitude\t\tright ascension"
|
29
|
+
puts "10:#{min}\t\t\t#{ml}\t\t#{ra}\t\t#{}"
|
30
|
+
end
|
31
|
+
#~ end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class AnalemmaDataTable
|
2
|
+
|
3
|
+
attr_accessor :data, :finish, :start, :table, :html
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@start = Time.utc( 2014, "jan", 1, 12, 0, 0 ).to_s
|
7
|
+
@start_jd = Date.parse(@start).jd.to_s
|
8
|
+
@finish = Time.utc( 2014, "dec", 31, 12, 0, 0 ).to_s
|
9
|
+
@finish_jd = Date.parse(@finish).jd.to_s
|
10
|
+
@span = Date.parse( @finish ).jd - Date.parse( @start ).jd
|
11
|
+
@file_path = File.expand_path( File.dirname( __FILE__ ) + "/lib/analemma_data.yml" )
|
12
|
+
@data = YAML::load( File.open( @file_path, 'r'), :safe => true ).freeze
|
13
|
+
@table = ""
|
14
|
+
@html = ""
|
15
|
+
|
16
|
+
(0..@span).each do |i|
|
17
|
+
@jd = @data[i].fetch ":jd"
|
18
|
+
@date = @data[i].fetch ":date"
|
19
|
+
@delta_1 = @data[i].fetch ":delta_1"
|
20
|
+
@delta_2 = @data[i].fetch ":delta_2"
|
21
|
+
@delta_t = @data[i].fetch ":delta_t"
|
22
|
+
@declination = @data[i].fetch ":declination"
|
23
|
+
@transit = @data[i].fetch ":transit"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# earth_rotation.rb
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
|
5
|
+
factor = 1 / (1 - 1 / 365.25)
|
6
|
+
bd_factor = BigDecimal.new("#{1 / (1 - 1 / 365.25)}") * 1.0
|
7
|
+
puts "360 degrees x #{factor} = #{360 * factor} degrees"
|
8
|
+
puts "360 degrees x #{bd_factor} = #{360 * bd_factor} degrees"
|
9
|
+
|
10
|
+
sidereal_minutes = 4 / factor
|
11
|
+
bd_sidereal_minutes = 4 / bd_factor
|
12
|
+
puts sidereal_minutes
|
13
|
+
puts sidereal_minutes
|
@@ -0,0 +1,16 @@
|
|
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
|
+
|
14
|
+
date = DateTime.now.to_time.utc.to_datetime
|
15
|
+
puts date
|
16
|
+
|
data/examples/eot_plot.r
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
R version 3.0.0 (2013-04-03) -- "Masked Marvel"
|
3
|
+
Copyright (C) 2013 The R Foundation for Statistical Computing
|
4
|
+
Platform: i386-w64-mingw32/i386 (32-bit)
|
5
|
+
|
6
|
+
R is free software and comes with ABSOLUTELY NO WARRANTY.
|
7
|
+
You are welcome to redistribute it under certain conditions.
|
8
|
+
Type 'license()' or 'licence()' for distribution details.
|
9
|
+
|
10
|
+
R is a collaborative project with many contributors.
|
11
|
+
Type 'contributors()' for more information and
|
12
|
+
'citation()' on how to cite R or R packages in publications.
|
13
|
+
|
14
|
+
Type 'demo()' for some demos, 'help()' for on-line help, or
|
15
|
+
'help.start()' for an HTML browser interface to help.
|
16
|
+
Type 'q()' to quit R.
|
17
|
+
|
18
|
+
#formulas, equations and notation from http://homeweb2.unifr.ch/hungerbu/pub/sonnenuhr/sundial.ps
|
19
|
+
# and by the paper of C. Blatter (http://dz-srv1.sub.uni-goettingen.de/sub/digbib/loader?did=D241775)
|
20
|
+
|
21
|
+
epsilon=23.45*2*pi/360
|
22
|
+
alpha =78.5 *2*pi/360
|
23
|
+
kappa =0.016722
|
24
|
+
|
25
|
+
mu<-function(t,epsilon,alpha,kappa) {
|
26
|
+
zaehl= -sin(delta(t,kappa))+tan(epsilon/2)^2*sin(2*(t-alpha)+delta(t,kappa))
|
27
|
+
nenn = cos(delta(t,kappa))+tan(epsilon/2)^2*cos(2*(t-alpha)+delta(t,kappa))
|
28
|
+
return( atan(zaehl/nenn) )
|
29
|
+
}
|
30
|
+
|
31
|
+
# approximation by Blatter
|
32
|
+
psi<-function(t) {
|
33
|
+
return(t+delta(t))
|
34
|
+
}
|
35
|
+
|
36
|
+
delta<-function(t,kappa) {
|
37
|
+
return( 2*sin(t)*kappa+5/4*sin(2*t)*kappa^2 )
|
38
|
+
}
|
39
|
+
|
40
|
+
png(filename="Equation of time.jpg", width=1024, height=768, pointsize=12)
|
41
|
+
par(bg="whitesmoke")
|
42
|
+
time=seq(-0.6,2*pi+0.4,length=365+(0.6+0.4)/(2*pi)*365)
|
43
|
+
da<-paste("1.",as.character(seq(1,12,by=2)),".07",sep="")
|
44
|
+
da<-as.Date(c(da,"1.1.08"),"%d.%m.%y")
|
45
|
+
#umrechungsfaktor: 24h=2*pi
|
46
|
+
plot(time,mu(time,epsilon,alpha,kappa)*24*60/(2*pi),type="l",col="red",xlab="Tag",ylab="Time in Minutes",main="Equation of time: true solar time - mean solar time",cex.main=1.5,lwd=3,xaxt="n",xaxs="i",xlim=range(time))
|
47
|
+
lines(time,mu(time,epsilon=0,alpha,kappa)*24*60/(2*pi),lwd=2,col="navy",lty="dotdash")
|
48
|
+
lines(time,mu(time,epsilon,alpha,kappa=0)*24*60/(2*pi),lwd=2,col="purple",lty="dashed")
|
49
|
+
#grid
|
50
|
+
abline(h=c(-15,-10,-5,5,10,15),lty="dotted",col="grey")
|
51
|
+
abline(h=0,lty="solid",col="grey33")
|
52
|
+
tage=cumsum(c(0,31,28,31,30,31,30,31,31,30,31,30,31))/365-3/365
|
53
|
+
abline(v=tage*2*pi,lty="dotted",col="grey")
|
54
|
+
axis(1,at=seq(0,2*pi,length=7)-3*2*pi/365,labels=as.character(da,"1. %b"))
|
55
|
+
legend(x=5.5,y=-10.9,legend=c("Equation of time","Ecliptic","Earth Orbit"),col=c("red","navy","purple"),lwd=c(3,2,2),lty=c("solid","dotdash","dashed"))
|
56
|
+
dev.off()
|
57
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# eot_suntimes.rb
|
3
|
+
#
|
4
|
+
lib = File.expand_path('../../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
def sunrise_jd(arg)
|
8
|
+
|
9
|
+
arg.date.nil? ? result = "date parameter not set" : result = "date parameter OK"
|
10
|
+
|
11
|
+
arg.longitude.nil? ? result = "longitude parameter not set" : result = "longitude parameter OK"
|
12
|
+
|
13
|
+
arg.latitude.nil? ? result = "latitude parameter not set" : result = "latitude parameter OK"
|
14
|
+
|
15
|
+
utc_noon_jd = arg.date.jd
|
16
|
+
|
17
|
+
lng_jd = arg.longitude / 360.0
|
18
|
+
|
19
|
+
mean_utc_noon_jd = utc_noon_jd - lng_jd
|
20
|
+
|
21
|
+
tjc_mean_local_noon_array = arg.time_julian_century(mean_utc_noon_jd)
|
22
|
+
|
23
|
+
eot = arg.equation_of_time(tjc_mean_local_noon_array)
|
24
|
+
|
25
|
+
eot_jd = eot / 1440.0
|
26
|
+
|
27
|
+
true_utc_noon_jd = mean_utc_noon_jd - eot_jd
|
28
|
+
|
29
|
+
tjc_true_local_noon_array = arg.time_julian_century(true_utc_noon_jd)
|
30
|
+
|
31
|
+
mean_anomaly = arg.ma_Sun(tjc_true_local_noon_array)
|
32
|
+
|
33
|
+
lha = arg.ha_Sun(tjc_true_local_noon_array, mean_anomaly)
|
34
|
+
|
35
|
+
lha_jd = lha / 360.0
|
36
|
+
|
37
|
+
# rise_jd
|
38
|
+
true_utc_noon_jd - lha_jd
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def sunset_jd(arg)
|
43
|
+
|
44
|
+
arg.date.nil? ? result = "date parameter not set" : result = "date parameter OK"
|
45
|
+
|
46
|
+
arg.longitude.nil? ? result = "longitude parameter not set" : result = "longitude parameter OK"
|
47
|
+
|
48
|
+
arg.latitude.nil? ? result = "latitude parameter not set" : result = "latitude parameter OK"
|
49
|
+
|
50
|
+
utc_noon_jd = arg.date.jd
|
51
|
+
|
52
|
+
lng_jd = arg.longitude / 360.0
|
53
|
+
|
54
|
+
mean_utc_noon_jd = utc_noon_jd - lng_jd
|
55
|
+
|
56
|
+
tjc_mean_local_noon = arg.time_julian_century(mean_utc_noon_jd)
|
57
|
+
|
58
|
+
eot_jd = arg.equation_of_time(tjc_mean_local_noon) / 1440.0
|
59
|
+
|
60
|
+
true_utc_noon_jd = mean_utc_noon_jd - eot_jd
|
61
|
+
|
62
|
+
tjc_true_local_noon = arg.time_julian_century(true_utc_noon_jd)
|
63
|
+
|
64
|
+
mean_anomaly = arg.ma_Sun(tjc_true_local_noon)
|
65
|
+
|
66
|
+
lha_jd = arg.ha_Sun(tjc_true_local_noon, mean_anomaly) / 360.0
|
67
|
+
|
68
|
+
# sunset jd
|
69
|
+
true_utc_noon_jd + lha_jd
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
require 'eot'
|
75
|
+
|
76
|
+
addr = "8000 South Michigan Ave., Chicago, IL"
|
77
|
+
loc = GeoLatLng.new
|
78
|
+
loc.addr = addr
|
79
|
+
loc.get_coordinates_from_address
|
80
|
+
puts loc.lat, loc.lng
|
81
|
+
|
82
|
+
eot = Eot.new
|
83
|
+
eot.longitude = loc.lng
|
84
|
+
eot.ajd = Date.today.jd
|
85
|
+
eot.latitude = loc.lat
|
86
|
+
|
87
|
+
puts "Using this files methods"
|
88
|
+
puts sunrise_jd()
|
89
|
+
|
90
|
+
# Note: DateTime.jd() renders time from midnight not noon
|
91
|
+
# so 12 hours need to be added for correct time.
|
92
|
+
puts DateTime.jd(sunrise_jd() + 0.5)
|
93
|
+
puts DateTime.jd(sunrise_jd() + 0.5).to_time.utc
|
94
|
+
|
95
|
+
puts
|
96
|
+
puts sunset_jd()
|
97
|
+
|
98
|
+
puts DateTime.jd(sunset_jd() + 0.5)
|
99
|
+
puts DateTime.jd(sunset_jd() + 0.5).to_time.utc
|
100
|
+
|
101
|
+
OUT =<<EOS
|
102
|
+
|
103
|
+
Using eot gem methods
|
104
|
+
#{eot.date}
|
105
|
+
#{eot.date.jd}
|
106
|
+
|
107
|
+
#{eot.sunrise_jd()}
|
108
|
+
#{DateTime.jd(eot.sunrise_jd() + 0.5)}
|
109
|
+
#{DateTime.jd(eot.sunrise_jd() + 0.5).to_time}
|
110
|
+
|
111
|
+
#{eot.sunset_jd()}
|
112
|
+
#{DateTime.jd(eot.sunset_jd() + 0.5)}
|
113
|
+
#{DateTime.jd(eot.sunset_jd() + 0.5).to_time}
|
114
|
+
|
115
|
+
#{Date.jd(Date.today.jd)}
|
116
|
+
#{Date.today.jd}
|
117
|
+
|
118
|
+
#{DateTime.jd(Date.today.jd)}
|
119
|
+
#{DateTime.jd(Date.today.jd + 0.5)}
|
120
|
+
|
121
|
+
#{DateTime.jd(Date.today.jd).to_time.utc}
|
122
|
+
#{DateTime.jd(Date.today.jd + 0.5).to_time.utc}
|
123
|
+
|
124
|
+
#{Time.now.to_datetime}
|
125
|
+
#{Time.now.to_datetime.jd}
|
126
|
+
|
127
|
+
#{Time.now.utc.to_datetime}
|
128
|
+
#{Time.now.utc.to_date.jd}
|
129
|
+
|
130
|
+
#{Date.jd(Time.now.to_date.jd)}
|
131
|
+
#{Date.jd(Time.now.utc.to_date.jd)}
|
132
|
+
|
133
|
+
#{DateTime.jd(Time.now.to_datetime.jd)}
|
134
|
+
#{DateTime.jd(Time.now.utc.to_datetime.jd)}
|
135
|
+
|
136
|
+
#{DateTime.jd(Time.now.to_datetime.jd).to_time}
|
137
|
+
#{DateTime.jd(Time.now.utc.to_datetime.jd).to_time}
|
138
|
+
EOS
|
139
|
+
|
140
|
+
puts OUT
|