suntrack 0.0.3 → 0.0.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.
@@ -0,0 +1,97 @@
1
+ require 'test/unit'
2
+ require 'suntrack'
3
+
4
+ # Test cases for Suntrack::Point3D.
5
+
6
+ class Point3DTest < Test::Unit::TestCase
7
+
8
+ # Confirm that we get expected results for basic transformations
9
+ def test_ecliptic_Cartesian_1
10
+
11
+ # Ecliptic point: radius, ecliptic latitude, ecliptic longitude
12
+ # By setting the ecliptic latitude to zero, the point will be in the
13
+ # xy plane
14
+ pt = Suntrack::Point3D.new(1,0,30)
15
+ pt.polar_to_cartesian!
16
+ assert_equal pt.x.round(6), 0.866025
17
+ assert_equal pt.y.round(6), 0.5
18
+ assert_equal pt.z.round(6), 0.0
19
+ end
20
+
21
+ # Show the effect of precessing an ecliptic point between two epochs.
22
+ def test_precessed_Cartesian_ecliptic
23
+
24
+ # Spherical/Ecliptic/1950
25
+ pt = Suntrack::Point3D.new(1,0,30)
26
+ pt.polar_to_cartesian!
27
+ # Cartesian/Ecliptic/1950
28
+ pt.precess_ecliptic_cartesian!(Suntrack::RAstro::B1950_EPOCH,Suntrack::RAstro::J2000_EPOCH)
29
+ # Cartesian/Ecliptic/2000
30
+ assert_equal pt.x.round(6), 0.859866
31
+ assert_equal pt.y.round(6), 0.510519
32
+ assert_equal pt.z.round(6), 0.000067
33
+ end
34
+
35
+ # Show the effect of precessing an ecliptic point between two epochs, and
36
+ # show how much the original polar coordinates are affected.
37
+ def test_precessed_Cartesian_ecliptic_to_polar
38
+
39
+ # Spherical/Ecliptic/1950
40
+ pt = Suntrack::Point3D.new(1,0,30)
41
+ pt.polar_to_cartesian!
42
+ # Cartesian/Ecliptic/1950
43
+ pt.precess_ecliptic_cartesian!(Suntrack::RAstro::B1950_EPOCH,Suntrack::RAstro::J2000_EPOCH)
44
+ # Cartesian/Ecliptic/2000
45
+ d = Suntrack::Point3D.new(pt.x,pt.y,pt.z)
46
+ d.cartesian_to_polar!
47
+ # Polar/Ecliptic/2000
48
+ assert_equal d.x.round(6), 1.0
49
+ assert_equal d.y.round(6), 0.003811
50
+ assert_equal d.z.round(6), 30.698411
51
+ end
52
+
53
+ # The two approaches should give the same answer.
54
+ def test_consistency_of_conversions
55
+
56
+ # Spherical/Ecliptic/1950
57
+ pt = Suntrack::Point3D.new(1,0,30)
58
+ pt.polar_to_cartesian!
59
+ # Cartesian/Ecliptic/1950
60
+ pt.precess_ecliptic_cartesian!(Suntrack::RAstro::B1950_EPOCH,Suntrack::RAstro::J2000_EPOCH)
61
+ # Cartesian/Ecliptic/2000
62
+ d = Suntrack::Point3D.new(pt.x,pt.y,pt.z)
63
+ d.cartesian_to_polar!
64
+ # Polar/Ecliptic/2000
65
+
66
+ pt.ecliptic_to_equatorial!(Suntrack::RAstro::J2000_EPOCH)
67
+ # Cartesian/Equatorial/2000
68
+ pt.equatorial_to_ecliptic!(Suntrack::RAstro::J2000_EPOCH)
69
+ # Cartesian/Ecliptic/2000
70
+ pt.cartesian_to_polar!
71
+ # Polar/Ecliptic/2000
72
+ assert_equal pt.x, d.x
73
+ assert_equal pt.y.round(6), d.y.round(6)
74
+ assert_equal pt.z, d.z
75
+ end
76
+
77
+ # Montebruck/Pfleger test case on page 31
78
+ def test_MP_case
79
+
80
+ # Equatorial point r = 1, delta = 0, alpha = 0, in B1950
81
+ # delta = declination, alpha = right ascension
82
+ pt = Suntrack::Point3D.new(1,0,0)
83
+ pt.polar_to_cartesian!
84
+ pt.precess_equatorial_cartesian!(Suntrack::RAstro::B1950_EPOCH,Suntrack::RAstro::J2000_EPOCH)
85
+ pt.equatorial_to_ecliptic!(Suntrack::RAstro::J2000_EPOCH)
86
+ pt.cartesian_to_polar!
87
+ assert_equal pt.x.round(6), 1.0
88
+ dms = Suntrack::RAstro.get_dms(pt.y)
89
+ assert_equal dms.x, 0
90
+ assert_equal dms.y, 0
91
+ assert_equal dms.z.round(6), 2.335464
92
+ dms = Suntrack::RAstro.get_dms(pt.z)
93
+ assert_equal dms.x, 0
94
+ assert_equal dms.y, 41
95
+ assert_equal dms.z.round(6), 54.280965
96
+ end
97
+ end
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require 'suntrack'
3
+
4
+ # Test cases for Suntrack::Point3D and Suntrack::RAstro, to track the
5
+ # altitude/azimuth of Sirius.
6
+
7
+ class SiriusTest < Test::Unit::TestCase
8
+ def test_somerset_nj_1
9
+ x = DateTime.new(2012,1,16,0,0,0)
10
+ # y component is elevation
11
+ # z component is azimuth
12
+ r = Suntrack.sirius_location(x,40.5,74.5)
13
+ assert_equal r.y.round(3),9.598
14
+ assert_equal r.z.round(3),238.104
15
+ end
16
+ def test_somerset_nj_2
17
+ x = DateTime.new(2012,1,16,4,0,0)
18
+ # y component is elevation
19
+ # z component is azimuth
20
+ r = Suntrack.sirius_location(x,40.5,74.5)
21
+ assert_equal r.y.round(3),32.765
22
+ assert_equal r.z.round(3),0.885
23
+ end
24
+ end
@@ -0,0 +1,64 @@
1
+ require 'test/unit'
2
+ require 'suntrack'
3
+ require 'date'
4
+
5
+ # Test cases for Suntrack::Point3D and Suntrack::RAstro, tracking the position
6
+ # of the Sun, in declination and right ascension, as a function of time.
7
+ # These results do not depend on latitude and longitude. For a given moment
8
+ # in time, declination/right ascension of the Sun is a specific point on the
9
+ # sky; latitude and longitude are then used along with an appropriate
10
+ # coordinate system to compute altitude and azimuth.
11
+
12
+ class SuntrackTest < Test::Unit::TestCase
13
+
14
+ def test_point_one
15
+
16
+ # August 7th 1997
17
+ # http://www.stargazing.net/kepler/sun.html
18
+ pointOne = DateTime.new(1997,8,7,11,0,0)
19
+ mjd = Suntrack::RAstro.to_mjd(pointOne)
20
+ assert_equal mjd.round(3), 50667.458
21
+ jd = Suntrack::RAstro.jd(mjd)
22
+ assert_equal jd.round(3), 2450667.958
23
+ tm = Suntrack::RAstro.get_time(jd)
24
+ assert_equal tm.round(4), -0.0240
25
+ dec = Suntrack::RAstro.sun_position(tm)
26
+ # Declination
27
+ assert_equal dec.y.round(5), 16.34011
28
+ # Right ascension
29
+ assert_equal dec.z.round(5), 9.16339
30
+ end
31
+
32
+ def test_point_two
33
+
34
+ pointTwo = DateTime.new(2004,1,3,11,0,0)
35
+ mjd = Suntrack::RAstro.to_mjd(pointTwo)
36
+ assert_equal mjd.round(3), 53007.458
37
+ jd = Suntrack::RAstro.jd(mjd)
38
+ assert_equal jd.round(3), 2453007.958
39
+ tm = Suntrack::RAstro.get_time(jd)
40
+ assert_equal tm.round(4), 0.0401
41
+ dec = Suntrack::RAstro.sun_position(tm)
42
+ # Declination
43
+ assert_equal dec.y.round(5), -22.86037
44
+ # Right ascension
45
+ assert_equal dec.z.round(5), 18.89909
46
+ end
47
+
48
+ def test_point_three
49
+
50
+ pointTwo = DateTime.new(2012,9,7,19,0,0)
51
+ mjd = Suntrack::RAstro.to_mjd(pointTwo)
52
+ assert_equal mjd.round(3), 56177.792
53
+ jd = Suntrack::RAstro.jd(mjd)
54
+ assert_equal jd.round(3), 2456178.292
55
+ tm = Suntrack::RAstro.get_time(jd)
56
+ assert_equal tm.round(4), 0.1269
57
+ dec = Suntrack::RAstro.sun_position(tm)
58
+ # Declination
59
+ assert_equal dec.y.round(5), 5.69534
60
+ # Right ascension
61
+ assert_equal dec.z.round(5), 11.11341
62
+ end
63
+
64
+ end
@@ -0,0 +1,35 @@
1
+ require 'test/unit'
2
+ require 'suntrack'
3
+
4
+ # Test cases for Suntrack::Point3D and RAstro, to track the position of the
5
+ # Sun as a function of time, in altitude and azimuth.
6
+
7
+ class SuntrackTest < Test::Unit::TestCase
8
+
9
+ def test_somerset_nj
10
+ x = DateTime.new(2012,9,7,19,0,0)
11
+ # y component is elevation
12
+ # z component is azimuth
13
+ r = Suntrack.sun_location(x,40.5,74.5)
14
+ assert_equal r.y.round(3),45.453
15
+ assert_equal r.z.round(3),47.026
16
+ end
17
+
18
+ def test_miami_fl
19
+ x = DateTime.new(2012,9,7,19,30,0)
20
+ # y component is elevation
21
+ # z component is azimuth
22
+ r = Suntrack.sun_location(x,25.76,80.21)
23
+ assert_equal r.y.round(3),52.751
24
+ assert_equal r.z.round(3),63.075
25
+ end
26
+
27
+ def test_san_francisco
28
+ x = DateTime.new(2012,9,7,19,45,0)
29
+ # y component is elevation
30
+ # z component is azimuth
31
+ r = Suntrack.sun_location(x,37.766,122.42)
32
+ assert_equal r.y.round(3),57.513
33
+ assert_equal r.z.round(3),10.446
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'suntrack'
3
+
4
+ # Test cases for Suntrack::Point3D and Suntrack::RAstro, to track the
5
+ # altitude/azimuth of a user-provided star
6
+
7
+ class UserProvidedTest < Test::Unit::TestCase
8
+ def test_vega_somerset_nj_1
9
+ x = DateTime.new(2012,1,16,0,0,0)
10
+ # y component is elevation
11
+ # z component is azimuth
12
+ Suntrack.vega_declination=38.784
13
+ Suntrack.vega_ra=18.616
14
+ r = Suntrack.vega_location(x,40.5,74.5)
15
+ assert_equal r.y.round(3),5.773
16
+ assert_equal r.z.round(3),222.132
17
+ end
18
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: suntrack
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joel M. Gottlieb
@@ -33,6 +33,11 @@ files:
33
33
  - doc/Suntrack.html
34
34
  - doc/class_list.html
35
35
  - doc/_index.html
36
+ - test/test_sun_points.rb
37
+ - test/test_suntrack.rb
38
+ - test/test_sirius.rb
39
+ - test/test_user_define.rb
40
+ - test/test_point3d.rb
36
41
  homepage:
37
42
  licenses: []
38
43
 
@@ -59,7 +64,7 @@ rubyforge_project:
59
64
  rubygems_version: 1.8.21
60
65
  signing_key:
61
66
  specification_version: 3
62
- summary: Suntrack
67
+ summary: Suntrack offers methods for obtaining star positions given time, latitude and longitude
63
68
  test_files: []
64
69
 
65
70
  has_rdoc: