astro_calc 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/astro_calc/moon_phases.rb +18 -6
- data/lib/astro_calc/telescopes.rb +119 -0
- data/lib/astro_calc/version.rb +1 -1
- data/lib/astro_calc.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31511e036e6ad014aa8f9ee6445239d877807a5c
|
4
|
+
data.tar.gz: 8bbd419eb39144b1e0fda6523a0efbe2504a35ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a351113e25f3e34722367b275822bf47f75ad6fad50ab64531268bbd1bceb6f7b76a12951990a8fbe7a0bb1a012bf1383327b009f314a2f281fce67ca69219e
|
7
|
+
data.tar.gz: 3fa4329ae7633ec5806dd5fa714b689670cf39644138d19f29830024116ff590d4490c42febafb957e78dcc1276382bb3c90be5fd707f10abece87f7bc2edd09
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "date"
|
2
2
|
|
3
|
+
#Credits
|
4
|
+
#{https://github.com/tingletech/moon-phase tingletech}
|
3
5
|
class MoonPhase
|
4
6
|
YEAR_IN_DAYS = 365.25
|
5
7
|
LIMIT_JULIAN_CALENDAR = 2299160
|
@@ -88,13 +90,19 @@ class MoonPhase
|
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
91
|
-
#
|
93
|
+
# Normalizes the value to be in the range 0..1
|
94
|
+
#
|
95
|
+
# @param value [Float] the value to normalize
|
96
|
+
# @return [Float] the normalized value
|
92
97
|
def normalize(value)
|
93
98
|
value -= value.floor
|
94
99
|
value += 1 if value < 0
|
95
100
|
value
|
96
101
|
end
|
97
102
|
|
103
|
+
# Provides the unicode characters for the moon phase
|
104
|
+
#
|
105
|
+
# @return [String] the unicode string showing the moon phase
|
98
106
|
def unicode
|
99
107
|
case @phase
|
100
108
|
when 0.0625..0.1875 then "\uD83C\uDF12"
|
@@ -108,13 +116,17 @@ class MoonPhase
|
|
108
116
|
end
|
109
117
|
end
|
110
118
|
|
119
|
+
# Calculates the magnification for a given telescope and eyepiece
|
120
|
+
#
|
121
|
+
# @param options [Hash] the options for SVG generation
|
122
|
+
# @return [String] the SVG output
|
111
123
|
def svg(options = {})
|
112
124
|
default_options = {
|
113
125
|
include_style: true,
|
114
|
-
height:
|
126
|
+
height: "200px",
|
115
127
|
background_color: "#111111",
|
116
|
-
left:
|
117
|
-
top:
|
128
|
+
left: "35%",
|
129
|
+
top: "75px",
|
118
130
|
moon_color: "#CDCDCD",
|
119
131
|
shadow_color: "#000000"
|
120
132
|
}
|
@@ -124,8 +136,8 @@ class MoonPhase
|
|
124
136
|
|
125
137
|
if options[:include_style] then
|
126
138
|
output << "<style>"
|
127
|
-
output << "#moonholder { height: #{options[:height]}
|
128
|
-
output << "#moon { position:absolute; left:#{options[:left]}
|
139
|
+
output << "#moonholder { height: #{options[:height]}; background-color: #{options[:background_color]}; }"
|
140
|
+
output << "#moon { position:absolute; left:#{options[:left]}; top:#{options[:top]}; }"
|
129
141
|
output << ".moon { fill: #{options[:moon_color]}; }"
|
130
142
|
output << ".moonback { stroke: #{options[:shadow_color]}; stroke-width: 1px; height: 180px; }"
|
131
143
|
output << "</style>"
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#Credits
|
2
|
+
#{http://www.nexstarsite.com/_RAC/articles/formulas.htm Mike Swanson}
|
3
|
+
class Telescopes
|
4
|
+
|
5
|
+
MM_IN_INCH = 25.4
|
6
|
+
RAYLEIGH_LIMIT = 5.5
|
7
|
+
DAWES_LIMIT = 4.56
|
8
|
+
UNIT_MILLIMETERS = :millimeters
|
9
|
+
UNIT_INCHES = :inches
|
10
|
+
|
11
|
+
attr_accessor :unit
|
12
|
+
|
13
|
+
def initialize(unit = UNIT_MILLIMETERS)
|
14
|
+
@unit = unit
|
15
|
+
end
|
16
|
+
|
17
|
+
# Calculates the magnification for a given telescope and eyepiece
|
18
|
+
#
|
19
|
+
# @param telescope [Integer] the focal length of the telescope tube
|
20
|
+
# @param eyepiece [Integer] the focal length of the eyepiece
|
21
|
+
# @return [Float] the magnification of the instrument
|
22
|
+
def magnification(telescope, eyepiece)
|
23
|
+
magnification = telescope / eyepiece
|
24
|
+
end
|
25
|
+
|
26
|
+
# Calculates the maximum probable magnification for a telescope
|
27
|
+
#
|
28
|
+
# @param diameter [Integer] the diameter of the telescope tube
|
29
|
+
# @return [Float] the maximum magnification usable with the given diameter
|
30
|
+
def maximum_magnification(diameter)
|
31
|
+
maximum = diameter * 2
|
32
|
+
maximum /= MM_IN_INCH if options[:unit] == UNIT_INCHES
|
33
|
+
end
|
34
|
+
|
35
|
+
# Calculates the focal ration of a telescope
|
36
|
+
#
|
37
|
+
# @param length [Integer] the focal length of the telescope
|
38
|
+
# @param aperture [Integer] the aperture of the telescope tube
|
39
|
+
# @return [Float] the focal ratio of the instrument
|
40
|
+
def focal_ratio(length, aperture)
|
41
|
+
ratio = length / aperture
|
42
|
+
end
|
43
|
+
|
44
|
+
# Calculates the diameter of the light leaving the eyepiece
|
45
|
+
#
|
46
|
+
# @param aperture [Integer] the aperture of the telescope tube
|
47
|
+
# @param magnification [Integer] the magnification of the instrument
|
48
|
+
# @return [Float] the diameter of the total light rays
|
49
|
+
def exit_pupil_for_binoculars(aperture, magnification)
|
50
|
+
exit_pupil = aperture / magnification
|
51
|
+
end
|
52
|
+
|
53
|
+
# Calculates the maximum probable magnification for a telescope
|
54
|
+
#
|
55
|
+
# @param diameter [Integer] the diameter of the telescope tube
|
56
|
+
# @return [Float] the maximum magnification usable with the given diameter
|
57
|
+
def exit_pupil_for_telescope(length, ratio)
|
58
|
+
exit_pupil = length / ratio
|
59
|
+
end
|
60
|
+
|
61
|
+
# Calculates the true field of view
|
62
|
+
#
|
63
|
+
# @param apparent [Integer] the apparent field of view of the eyepiece
|
64
|
+
# @param magnification [Integer] the magnification of the telescope and eyepiece
|
65
|
+
# @return [Float] the true field of view of the instrument
|
66
|
+
def true_field_of_view(apparent, magnification)
|
67
|
+
tfov = apparent / magnification
|
68
|
+
end
|
69
|
+
|
70
|
+
# Calculates the resolving limit of the instrument according to Rayleigh
|
71
|
+
#
|
72
|
+
# @param diameter [Integer] the diameter of the telescope tube
|
73
|
+
# @return [Float] the maximum magnification usable with the given diameter
|
74
|
+
def rayleigh_limit(aperture)
|
75
|
+
case @unit
|
76
|
+
when UNIT_MILLIMETERS
|
77
|
+
limit = RAYLEIGH_LIMIT / aperture / MM_IN_INCH
|
78
|
+
when UNIT_INCHES
|
79
|
+
limit = RAYLEIGH_LIMIT / aperture
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Calculates the resolving limit of the instrument according to Dawes
|
84
|
+
#
|
85
|
+
# @param diameter [Integer] the diameter of the telescope tube
|
86
|
+
# @return [Float] the maximum magnification usable with the given diameter
|
87
|
+
def dawes_limit(aperture)
|
88
|
+
case @unit
|
89
|
+
when UNIT_MILLIMETERS
|
90
|
+
limit = DAWES_LIMIT / aperture / MM_IN_INCH
|
91
|
+
when UNIT_INCHES
|
92
|
+
limit = DAWES_LIMIT / aperture
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Calculates the light gathering power between two instruments
|
97
|
+
#
|
98
|
+
# @param large_aperture [Integer] the aperture of the larger instrument
|
99
|
+
# @param small_aperture [Integer] the aperture of the smaller instrument
|
100
|
+
# @return [Float] the light gathering power of the instrument
|
101
|
+
def light_gathering_power(large_aperture, small_aperture)
|
102
|
+
power = (large_aperture * large_aperture) / (small_aperture * small_aperture)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Calculates the maximum probable magnification for a telescope
|
106
|
+
#
|
107
|
+
# @param aperture [Integer] the aperture in centimeters of the telescope tube
|
108
|
+
# @return [Float] the maximum magnitude with the given aperture
|
109
|
+
def limiting_magnitude(aperture)
|
110
|
+
case @unit
|
111
|
+
when UNIT_MILLIMETERS
|
112
|
+
limit = 5 * Math::log10(aperture * 10) + 7.5
|
113
|
+
when UNIT_INCHES
|
114
|
+
limit = 5 * Math::log10(aperture / 2.54) + 7.5
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
data/lib/astro_calc/version.rb
CHANGED
data/lib/astro_calc.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astro_calc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reuben Mallaby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- bin/setup
|
73
73
|
- lib/astro_calc.rb
|
74
74
|
- lib/astro_calc/moon_phases.rb
|
75
|
+
- lib/astro_calc/telescopes.rb
|
75
76
|
- lib/astro_calc/version.rb
|
76
77
|
homepage: http://mallaby.me/projects/astro_calc
|
77
78
|
licenses:
|