suntrack 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/suntrack.rb +23 -0
- metadata +2 -2
data/lib/suntrack.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
class Suntrack
|
5
5
|
|
6
|
+
@@attributes = {}
|
7
|
+
|
6
8
|
# Return Sun location, in altitude(y) and azimuth(z), given
|
7
9
|
# DateTime, latitude and longitude
|
8
10
|
def self.sun_location(date_time,latitude,longitude)
|
@@ -26,6 +28,27 @@ class Suntrack
|
|
26
28
|
z = z_in.equatorial_to_horizon
|
27
29
|
z
|
28
30
|
end
|
31
|
+
|
32
|
+
# allow user to create new star location functions
|
33
|
+
# User must define declination and right ascension
|
34
|
+
def self.method_missing name, *args
|
35
|
+
attribute = name.to_s
|
36
|
+
if attribute =~ /=$/
|
37
|
+
@@attributes[attribute.chop] = args[0]
|
38
|
+
elsif attribute =~ /location/
|
39
|
+
@@star = attribute.match(/(\w+)_location/)[1]
|
40
|
+
begin
|
41
|
+
dt = DateTime.now
|
42
|
+
mjd = Suntrack::RAstro.to_mjd(args[0])
|
43
|
+
tau = 15 * (Suntrack::RAstro.lmst(mjd,args[2]) - @@attributes["#{@@star}_ra"])
|
44
|
+
z_in = Suntrack::Point3D.new(@@attributes["#{@@star}_declination"],tau,args[1])
|
45
|
+
z = z_in.equatorial_to_horizon
|
46
|
+
z
|
47
|
+
rescue Exception => ex
|
48
|
+
p "Suntrack ERROR: Please define declination and right ascension for #{@@star}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
29
52
|
end
|
30
53
|
require 'suntrack/Point3D'
|
31
54
|
require 'suntrack/RAstro'
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: suntrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Joel M. Gottlieb
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-11 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Sun position as function of time
|