equationoftime 4.1.1 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.autotest +39 -0
  3. data/.gemtest +0 -0
  4. data/.minitest.rb +2 -0
  5. data/.ruby-version +1 -0
  6. data/.settings/org.eclipse.ltk.core.refactoring.prefs +2 -0
  7. data/CHANGELOG.rdoc +6 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +44 -3
  10. data/Guardfile +29 -0
  11. data/{LICENSE.md → LICENSE.rdoc} +0 -0
  12. data/Manifest.txt +82 -0
  13. data/README.rdoc +66 -0
  14. data/Rakefile +60 -45
  15. data/equationoftime.gemspec +17 -9
  16. data/examples/Equation_of_Time.jpg +0 -0
  17. data/examples/analemma_data_generator.rb +58 -0
  18. data/examples/check_date_type.rb +60 -0
  19. data/examples/compare_geoc_long_ra.rb +44 -0
  20. data/examples/data_table_for_astro_dog.rb +45 -0
  21. data/examples/earth_rotation.rb +42 -0
  22. data/examples/eot_methods_list.rb +48 -0
  23. data/examples/eot_plot.r +57 -0
  24. data/examples/eot_suntimes.rb +149 -0
  25. data/examples/equation_of_time.py +186 -0
  26. data/examples/figure_1.jpg +0 -0
  27. data/examples/file_converter.rb +31 -0
  28. data/examples/from_readme.rb +14 -0
  29. data/examples/from_wiki.rb +46 -0
  30. data/examples/geo_locator.rb +16 -0
  31. data/examples/getjd.rb +45 -0
  32. data/examples/gmst_gast_non_sofa.rb +406 -0
  33. data/examples/input_suntimes.rb +24 -0
  34. data/examples/julian_day_formula.rb +29 -0
  35. data/examples/julian_day_formula.txt +12 -0
  36. data/examples/my_time_conversion.rb +21 -0
  37. data/examples/nutation_series.txt +678 -0
  38. data/examples/nutation_table5_3a.txt +682 -0
  39. data/examples/ptime.rb +162 -0
  40. data/examples/suntimes.rb +30 -0
  41. data/examples/suntimes_test.rb +50 -0
  42. data/examples/t_sofa.rb +8228 -0
  43. data/examples/test_celes.rb +51 -0
  44. data/examples/test_ceot.rb +55 -0
  45. data/examples/test_poly_eval.rb +32 -0
  46. data/examples/time_scales.rb +29 -0
  47. data/examples/times_year.rb +53 -0
  48. data/examples/usage_example.rb +26 -0
  49. data/examples/use_angles.rb +222 -0
  50. data/ext/{ceot/eot.c → eot/ceot.c} +1 -1
  51. data/ext/{ceot/eot.h → eot/ceot.h} +0 -0
  52. data/ext/{ceot/ceot.c → eot/eot.c} +2 -2
  53. data/ext/{ceot → eot}/extconf.rb +1 -1
  54. data/lib/eot.rb +2 -1
  55. data/lib/eot/angles.rb +28 -28
  56. data/lib/eot/constants.rb +2 -0
  57. data/lib/eot/displays.rb +17 -17
  58. data/lib/eot/eot.so +0 -0
  59. data/lib/eot/geo_lat_lng_smt.rb +44 -31
  60. data/lib/eot/init.rb +20 -19
  61. data/lib/eot/nutation.rb +1 -1
  62. data/lib/eot/times.rb +22 -22
  63. data/lib/eot/utilities.rb +5 -5
  64. data/lib/eot/version.rb +2 -6
  65. data/test/aliased_angles_spec.rb +239 -0
  66. data/test/aliased_displays_spec.rb +105 -0
  67. data/test/aliased_utilities_spec.rb +36 -0
  68. data/test/angles_spec.rb +264 -0
  69. data/test/constants_spec.rb +20 -0
  70. data/test/displays_spec.rb +110 -0
  71. data/test/geo_spec.rb +38 -0
  72. data/test/init_spec.rb +44 -0
  73. data/test/nutation_spec.rb +37 -0
  74. data/test/spec_config.rb +8 -0
  75. data/test/times_spec.rb +133 -0
  76. data/test/utilities_spec.rb +35 -0
  77. metadata +109 -115
  78. data/.gitignore +0 -24
  79. data/.rvmrc +0 -1
  80. data/README.md +0 -83
  81. data/README2.txt +0 -70
  82. data/wiki.md +0 -43
  83. data/wiki2.md +0 -4
@@ -1,7 +1,8 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path('./lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'eot/version'
5
+ require 'eot'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  # Metadata
@@ -21,20 +22,27 @@ Gem::Specification.new do |spec|
21
22
  spec.files = Dir.glob("ext/**/*.{c,h,rb, so}") + Dir.glob("**") +
22
23
  Dir.glob("lib/**/*.rb") + Dir.glob(".*")
23
24
  #spec.files = `git ls-files -z`.split($/)#split("\x0")
24
- spec.extensions << "ext/ceot/extconf.rb"
25
+ spec.extensions << "ext/eot/extconf.rb"
25
26
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
27
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
28
  spec.require_paths = ["lib"]
28
29
  spec.platform = Gem::Platform::RUBY
30
+ # note: the last good build was with these development dependencies below
29
31
  spec.add_development_dependency "bundler", "~> 1.5"
30
- spec.add_development_dependency "rake"
31
- spec.add_development_dependency "rake-compiler"
32
- spec.add_development_dependency "minitest"
33
- spec.add_development_dependency "rspec"
34
- spec.add_development_dependency "yard"
32
+ #spec.add_development_dependency "rake",, "~> 10.3.2"
33
+ #spec. add_development_dependency 'rake-compiler', '~> 0.9.3'
34
+ #spec.add_development_dependency "hoe", "~> 3.12.0"
35
+ #spec.add_development_dependency "guard", "~> 2.6.1"
36
+ #spec.add_development_dependency "guard-minitest", "~> 2.3.2"
37
+ #spec.add_development_dependency "minitest", "~> 5.4.1"
38
+ #spec.add_development_dependency "ZenTest", "~> 4.10.1"
39
+ #spec.add_development_dependency "rspec", "~> 3.1.0"
40
+ #spec.add_development_dependency "yard", "~> 0.8.7.4"
41
+ #spec.add_development_dependency "rdoc", "~> 4.1.2"
42
+
35
43
  spec.add_runtime_dependency "celes"
36
44
  #spec.add_runtime_dependency "astro-algo"
37
- spec.add_runtime_dependency "multi_xml"
45
+ #spec.add_runtime_dependency "multi_xml"
38
46
  spec.add_runtime_dependency "rest-client"
39
47
  #spec.add_runtime_dependency "safe_yaml"
40
48
 
Binary file
@@ -0,0 +1,58 @@
1
+ # analemma_data_generator.rb
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+ require 'eot'
12
+ require 'safe_yaml'
13
+ require 'time'
14
+
15
+ eot = Eot.new
16
+
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
+
24
+ start_jd = start_time.to_datetime.jd
25
+ finish_jd = finish_time.to_datetime.jd
26
+
27
+ fstr = "%b %d"
28
+
29
+ @data, @group, @group_id = ["2014", eot.addr, eot.latitude, eot.longitude], {}, 1
30
+
31
+ (start_jd..finish_jd).each do |jd|
32
+ date = Date.jd(jd + 0.5).strftime(fstr)
33
+
34
+ eot.ajd = jd
35
+ delta_t = eot.show_minutes(eot.time_eot())
36
+ trans = eot.display_time_string(12 - eot.time_eot()/60.0)
37
+ e1 = eot.show_minutes(eot.time_delta_orbit())
38
+ e2 = eot.show_minutes(eot.time_delta_oblique())
39
+ decline = eot.degrees_to_s(eot.dec_Sun())
40
+ @group = { "id" => "#{@group_id}",
41
+ "date" => date,
42
+ "julian" => "#{jd}",
43
+ "rise" => eot.sunrise_dt().to_json,
44
+ "eot" => delta_t,
45
+ "transit" => eot.local_noon_dt().to_json,
46
+ "declination" => "#{decline}",
47
+ "set" => eot.sunset_dt().to_json
48
+ }
49
+ @data << @group
50
+ @group_id += 1
51
+ end
52
+
53
+ file_path = "analemma_data.yml"
54
+ File::open( file_path, "w" ) do |f|
55
+ YAML.dump( @data, f )
56
+ end
57
+
58
+ puts "File analemma_data.yml processed"
@@ -0,0 +1,60 @@
1
+ # check_date_type.rb
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+ require 'eot'
12
+
13
+ eot = Eot.new()
14
+
15
+ output =<<EOO
16
+
17
+ eot = Eot.new()
18
+
19
+ eot.ajd = #{eot.ajd}
20
+
21
+ eot.eot = #{eot.eot()} # this is radians for eot today.
22
+
23
+ eot.date = #{eot.date = "2014-10-14"} = #{eot.date.class}
24
+
25
+ eot.ajd = Date.parse(eot.date).jd.to_f = #{eot.ajd = Date.parse(eot.date).jd.to_f}
26
+
27
+ eot.eot = #{eot.eot} # getting default today
28
+
29
+ eot.equation_of_time(eot.time_julian_century(eot.ajd)) = #{eot.eot()}
30
+
31
+ eot.sunrise_dt() = #{eot.sunrise_dt()} with lat and lng 0.
32
+
33
+ eot.longitude = #{eot.longitude = 0}
34
+
35
+ eot.sunrise_dt() = #{eot.sunrise_dt()}
36
+
37
+ eot.latitude = #{eot.latitude = 0}
38
+
39
+ eot.sunrise_dt() = #{eot.sunrise_dt()}
40
+
41
+ eot.longitude = #{eot.longitude = 180.0}
42
+
43
+ eot.sunrise_dt() = #{eot.sunrise_dt()}
44
+
45
+ eot.longitude = #{eot.longitude = -180.0}
46
+
47
+ eot.sunrise_dt() = #{eot.sunrise_dt()}
48
+
49
+ eot.longitude = #{eot.longitude = 0}
50
+ eot.latitude = #{eot.latitude = 90}
51
+
52
+ eot.sunrise_dt() = #{eot.sunrise_dt()}
53
+
54
+ eot.longitude = #{eot.longitude = 0}
55
+ eot.latitude = #{eot.latitude = -90}
56
+
57
+ eot.sunrise_dt() = #{eot.sunrise_dt()}
58
+ EOO
59
+
60
+ puts output
@@ -0,0 +1,44 @@
1
+ # compare_geoc_long_ra.rb
2
+
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+ require 'eot'
12
+
13
+ eot = Eot.new()
14
+
15
+ start = "2014-6-21"
16
+ finish = "2014-6-21"
17
+
18
+ start_date = Date.parse(start)
19
+ finish_date = Date.parse(finish)
20
+
21
+ puts "start julian date = #{start_date.jd} date = #{start}"
22
+ puts "finish julian date = #{finish_date.jd} date = #{finish}"
23
+ puts
24
+
25
+ ajd = start_date.ajd * 1.0
26
+
27
+ for psec in 630..631
28
+ h = 10 / 24.0
29
+ fd = h + 45 / 1440.0 + 31 / 86400.0 + 691 / 86400.0 / 1e3 + 244 / 86400.0 / 1e6 + 989 / 86400.0 / 1e9 + psec / 86400.0 / 1e12
30
+ eot.ajd = ajd + fd
31
+ ml = eot.geometric_mean_longitude()
32
+ tl = eot.true_longitude()
33
+ da = ml - tl
34
+ al = eot.apparent_longitude()
35
+ ra = eot.right_ascension()
36
+ db = al - ra
37
+ # puts "time\t\t\tmean longitude\t\t\ttrue_longitude\t\t\tdifference"
38
+ # puts "10:45:31.691_#{usec}\t\t\t#{ml}\t\t#{tl}\t\t#{da}"
39
+ # puts
40
+ puts "time\t\t\tapparent longitude\t\tright ascension\t\t\tdifference"
41
+ puts "10:45:31.691_244_989_#{psec}\t\t\t#{al}\t\t#{ra}\t\t#{db}"
42
+ puts
43
+ end
44
+ #~ end
@@ -0,0 +1,45 @@
1
+ # class that goes with equationoftime.herokuapp.com/analemma
2
+ class AnalemmaDataTable
3
+
4
+ attr_accessor :data, :finish, :start, :table, :html
5
+
6
+ def initialize
7
+ @start = Time.utc( 2014, "jan", 1, 12, 0, 0 ).to_s
8
+ @start_jd = Date.parse(@start).jd.to_s
9
+ @finish = Time.utc( 2014, "dec", 31, 12, 0, 0 ).to_s
10
+ @finish_jd = Date.parse(@finish).jd.to_s
11
+ @span = Date.parse( @finish ).jd - Date.parse( @start ).jd
12
+ @file_path = File.expand_path( File.dirname( __FILE__ ) + "/analemma_data.yml" )
13
+ @data = YAML::load( File.open( @file_path, 'r'), :safe => true ).freeze
14
+ @table = ""
15
+ @html = ""
16
+
17
+ (0..@span).each do |i|
18
+ p @data[i]
19
+ # @jd = @data[i].fetch ":jd"
20
+ # @date = @data[i].fetch ":date"
21
+ # @delta_1 = @data[i].fetch ":delta_1"
22
+ # @delta_2 = @data[i].fetch ":delta_2"
23
+ # @delta_t = @data[i].fetch ":delta_t"
24
+ # @declination = @data[i].fetch ":declination"
25
+ # @transit = @data[i].fetch ":transit"
26
+ end
27
+ end
28
+ end
29
+
30
+ if __FILE__ == $PROGRAM_NAME
31
+
32
+ begin
33
+ require 'eot'
34
+ rescue LoadError
35
+ lib = File.expand_path('../../lib', __FILE__)
36
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
37
+ require 'eot'
38
+ end
39
+
40
+ require 'safe_yaml'
41
+ require 'eot'
42
+
43
+ adt = AnalemmaDataTable.new
44
+
45
+ end
@@ -0,0 +1,42 @@
1
+ # earth_rotation.rb
2
+
3
+ require 'bigdecimal'
4
+
5
+ factor = 1 / (1 - 1 / 366.0)
6
+ bd_factor = BigDecimal.new("#{1 / (1 - 1 / 366.0)}") * 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
14
+
15
+ begin
16
+ require 'eot'
17
+ rescue LoadError
18
+ lib = File.expand_path('../../lib', __FILE__)
19
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
20
+ require 'eot'
21
+ end
22
+
23
+ eot = Eot.new()
24
+ # From angles.rb:<br>
25
+ # angle factor for daily sidereal time (experimental)
26
+ def factor eot
27
+ eot.ajd = Date.parse("2000-01-01").jd
28
+ tlaa = eot.tl_Aries()
29
+ eot.ajd = eot.ajd + 1
30
+ tlab = eot.tl_Aries()
31
+ dif = (tlab - tlaa) * Eot::R2D
32
+ f1 = dif / 360.0 + 1
33
+ 1 / f1
34
+ end
35
+
36
+ p factor(eot) * 4
37
+ p factor(eot) * 4 * 360.0
38
+ p factor(eot) * 4 * 360.0 / 60.0
39
+ p factor(eot) * 4 * 360.0 / 60.0 * 366
40
+ shd = factor(eot) * 4 * 360.0 / 60.0
41
+ sdnl = shd * 366 * 4
42
+ p sdnl / (4 * 365 + 1)
@@ -0,0 +1,48 @@
1
+ # eot_methods_list.rb
2
+ #
3
+ begin
4
+ require 'eot'
5
+ rescue LoadError
6
+ lib = File.expand_path('../../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+ require 'eot'
9
+ end
10
+
11
+ require 'eot'
12
+ $DEBUG and set_trace_func proc { |event, file, line, id, binding, classname|
13
+ printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
14
+ }
15
+
16
+ date = DateTime.now.to_time.utc.to_datetime
17
+ puts date
18
+
19
+ eot = Eot.new
20
+ puts eot.nil?
21
+ puts eot.public_methods(false).count
22
+ list = eot.public_methods(false).sort
23
+ sym_list = []
24
+ list.each {|i|sym_list << i.to_sym}
25
+ #p sym_list
26
+ my_list =[:al_Sun, :angle_delta_oblique, :angle_delta_orbit, :angle_delta_psi, :angle_equation_of_time,
27
+ :apparent_longitude, :apparent_longitude_string, :center, :cosine_al_Sun, :cosine_apparent_longitude,
28
+ :cosine_tl_Sun, :cosine_to_Earth, :cosine_true_longitude, :cosine_true_obliquity, :dec_Sun,
29
+ :declination, :declination_string, :degrees_to_s, :delta_epsilon, :delta_equinox, :delta_oblique, :delta_orbit,
30
+ :delta_psi, :delta_t_ecliptic, :delta_t_elliptic, :display_equation_of_time, :display_time_string,
31
+ :eccentricity_Earth, :eccentricity_earth_orbit, :ecliptic_longitude, :eot, :eot_jd, :eq_of_equinox,
32
+ :equation_of_center, :geometric_mean_longitude, :gml_Sun, :ha_Sun, :horizon_angle,
33
+ :jd_to_date_string, :julian_period_day_fraction_to_time, :latitude, :latitude=, :local_noon_dt,
34
+ :ma_Sun, :mean_anomaly, :mean_anomaly_string, :mean_local_noon_dt, :mean_longitude_aries,
35
+ :mean_obliquity, :mean_obliquity_of_ecliptic, :ml_Aries, :mo_Earth, :mod_360, :now,
36
+ :obliquity_correction, :omega, :ra_Sun, :right_ascension, :right_ascension_string, :show_minutes,
37
+ :show_now, :sine_al_Sun, :sine_apparent_longitude, :sine_tl_Sun, :sine_to_Earth,
38
+ :sine_true_longitude, :string_al_Sun, :string_day_fraction_to_time, :string_dec_Sun,
39
+ :string_delta_oblique, :string_delta_orbit, :string_eot, :string_eqc, :string_jd_to_date,
40
+ :string_ma_Sun, :string_ra_Sun, :string_ta_Sun, :string_time, :string_tl_Sun, :string_to_Earth,
41
+ :sunrise_dt, :sunrise_jd, :sunset_dt, :sunset_jd, :ta_Sun, :time_delta_oblique, :time_delta_orbit,
42
+ :time_eot, :time_julian_centurey, :time_julian_century, :tl_Aries, :tl_Sun, :to_Earth,
43
+ :true_anomaly, :true_anomaly_string, :true_longitude, :true_longitude_aries,
44
+ :true_longitude_string, :true_obliquity, :true_obliquity_string, :truncate]
45
+ my_list.collect {|e| p e}
46
+
47
+ puts date
48
+
@@ -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,149 @@
1
+ #!/usr/bin/env ruby
2
+ # eot_suntimes.rb leftover from building the parts in the gem so just left it here.
3
+ #
4
+ begin
5
+ require 'eot'
6
+ rescue LoadError
7
+ lib = File.expand_path('../../lib', __FILE__)
8
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
9
+ require 'eot'
10
+ end
11
+
12
+ #def sunrise_jd(arg)
13
+ #
14
+ # arg.date.nil? ? result = "date parameter not set" : result = "date parameter OK"
15
+ #
16
+ # arg.longitude.nil? ? result = "longitude parameter not set" : result = "longitude parameter OK"
17
+ #
18
+ # arg.latitude.nil? ? result = "latitude parameter not set" : result = "latitude parameter OK"
19
+ #
20
+ # utc_noon_jd = arg.date.jd
21
+ #
22
+ # lng_jd = arg.longitude / 360.0
23
+ #
24
+ # mean_utc_noon_jd = utc_noon_jd - lng_jd
25
+ #
26
+ # tjc_mean_local_noon_array = arg.time_julian_century(mean_utc_noon_jd)
27
+ #
28
+ # eot = arg.equation_of_time(tjc_mean_local_noon_array)
29
+ #
30
+ # eot_jd = eot / 1440.0
31
+ #
32
+ # true_utc_noon_jd = mean_utc_noon_jd - eot_jd
33
+ #
34
+ # tjc_true_local_noon_array = arg.time_julian_century(true_utc_noon_jd)
35
+ #
36
+ # mean_anomaly = arg.ma_Sun(tjc_true_local_noon_array)
37
+ #
38
+ # lha = arg.ha_Sun(tjc_true_local_noon_array, mean_anomaly)
39
+ #
40
+ # lha_jd = lha / 360.0
41
+ #
42
+ # # rise_jd
43
+ # true_utc_noon_jd - lha_jd
44
+ #
45
+ #end
46
+ #
47
+ #def sunset_jd(arg)
48
+ #
49
+ # arg.date.nil? ? result = "date parameter not set" : result = "date parameter OK"
50
+ #
51
+ # arg.longitude.nil? ? result = "longitude parameter not set" : result = "longitude parameter OK"
52
+ #
53
+ # arg.latitude.nil? ? result = "latitude parameter not set" : result = "latitude parameter OK"
54
+ #
55
+ # utc_noon_jd = arg.date.jd
56
+ #
57
+ # lng_jd = arg.longitude / 360.0
58
+ #
59
+ # mean_utc_noon_jd = utc_noon_jd - lng_jd
60
+ #
61
+ # tjc_mean_local_noon = arg.time_julian_century(mean_utc_noon_jd)
62
+ #
63
+ # eot_jd = arg.equation_of_time(tjc_mean_local_noon) / 1440.0
64
+ #
65
+ # true_utc_noon_jd = mean_utc_noon_jd - eot_jd
66
+ #
67
+ # tjc_true_local_noon = arg.time_julian_century(true_utc_noon_jd)
68
+ #
69
+ # mean_anomaly = arg.ma_Sun(tjc_true_local_noon)
70
+ #
71
+ # lha_jd = arg.ha_Sun(tjc_true_local_noon, mean_anomaly) / 360.0
72
+ #
73
+ # # sunset jd
74
+ # true_utc_noon_jd + lha_jd
75
+ #
76
+ #end
77
+
78
+
79
+ require 'eot'
80
+
81
+ addr = "8000 South Michigan Ave., Chicago, IL"
82
+ #loc = GeoLatLng.new
83
+ #loc.addr = addr
84
+ #loc.get_coordinates_from_address
85
+ #puts loc.lat, loc.lng
86
+
87
+ eot = Eot.new(addr)
88
+ #eot.longitude = loc.lng
89
+ #eot.ajd = Date.today.jd
90
+ #eot.latitude = loc.lat
91
+
92
+ #puts "Using this files methods"
93
+ #puts sunrise_jd(Date.today)
94
+
95
+ ## Note: DateTime.jd() renders time from midnight not noon
96
+ ## so 12 hours need to be added for correct time.
97
+ #puts DateTime.jd(sunrise_jd() + 0.5)
98
+ #puts DateTime.jd(sunrise_jd() + 0.5).to_time.utc
99
+ #
100
+ #puts
101
+ #puts sunset_jd()
102
+ #
103
+ #puts DateTime.jd(sunset_jd() + 0.5)
104
+ #puts DateTime.jd(sunset_jd() + 0.5).to_time.utc
105
+
106
+ OUT =<<EOS
107
+
108
+ Using eot gem methods
109
+
110
+ #{eot.latitude}
111
+ #{eot.longitude}
112
+
113
+ #{eot.sunrise_jd()}
114
+ #{eot.ajd_to_datetime(eot.sunrise_jd())}
115
+ #{eot.ajd_to_datetime(eot.sunrise_jd()).to_time}
116
+
117
+ #{eot.sunset_jd()}
118
+ #{eot.ajd_to_datetime(eot.sunset_jd())}
119
+ #{eot.ajd_to_datetime(eot.sunset_jd()).to_time}
120
+
121
+ #{Date.jd(Date.today.jd)}
122
+ #{Date.today.jd}
123
+
124
+ #{DateTime.jd(Date.today.jd)}
125
+ #{DateTime.jd(Date.today.jd + 0.5)}
126
+
127
+ #{DateTime.jd(Date.today.jd).to_time.utc}
128
+ #{DateTime.jd(Date.today.jd + 0.5).to_time.utc}
129
+
130
+ #{Time.now.to_datetime}
131
+ #{Time.now.to_datetime.jd}
132
+
133
+ #{Time.now.utc.to_datetime}
134
+ #{Time.now.utc.to_date.jd}
135
+
136
+ #{Date.jd(Time.now.to_date.jd)}
137
+ #{Date.jd(Time.now.utc.to_date.jd)}
138
+
139
+ #{DateTime.jd(Time.now.to_datetime.jd)}
140
+ #{DateTime.jd(Time.now.utc.to_datetime.jd)}
141
+
142
+ #{DateTime.jd(Time.now.to_datetime.jd).to_time}
143
+ #{DateTime.jd(Time.now.utc.to_datetime.jd).to_time}
144
+
145
+ #{DateTime.jd(Time.now.to_datetime.jd + 0.5).to_time}
146
+ #{DateTime.jd(Time.now.utc.to_datetime.jd + 0.5).to_time}
147
+ EOS
148
+
149
+ puts OUT