solcal 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.
- checksums.yaml +4 -4
- data/lib/solcal/commands.rb +1 -0
- data/lib/solcal/commands/time_to_angle_from_zenith_command.rb +16 -0
- data/lib/solcal/location.rb +7 -0
- data/lib/solcal/version.rb +1 -1
- data/spec/commands/app_longitude_command_spec.rb +8 -6
- data/spec/commands/declination_command_spec.rb +3 -6
- data/spec/commands/geometric_mean_long_command_spec.rb +8 -6
- data/spec/commands/julian_century_command_spec.rb +17 -4
- data/spec/commands/mean_oblique_ecliptic_command_spec.rb +6 -4
- data/spec/commands/oblique_correction_command_spec.rb +8 -6
- data/spec/commands/time_to_angle_from_zenith_command_spec.rb +38 -0
- data/spec/commands/true_longitude_command_spec.rb +8 -6
- data/spec/location_spec.rb +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2afbb64769ab3034ea32fa6ddb97a9a2e628e411
|
|
4
|
+
data.tar.gz: d8d4789eeb5a351226410fe08346222a20e26e36
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a79f0fc3f6245d736e4df3d1eaaee189bdf979402dfe1fb4912a0eb28ebba023958a4fd5cdd83702914016c8dc4c671feb0b520df13c342ede59e66fcb16ef92
|
|
7
|
+
data.tar.gz: 561a9b6a8a84628074dbabf6adebe2d0e8f741a0650565a5ff70f18eb3d523228d38edd505ee4059fd29746adcfadf8ccdee19a76df0befc67160d2b47498db3
|
data/lib/solcal/commands.rb
CHANGED
|
@@ -24,6 +24,7 @@ module SolCal
|
|
|
24
24
|
autoload :HaCivilTwighlightCommand, 'solcal/commands/ha_civil_twighlight_command'
|
|
25
25
|
autoload :CivilDawnCommand, 'solcal/commands/civil_dawn_command'
|
|
26
26
|
autoload :CivilDuskCommand, 'solcal/commands/civil_dusk_command'
|
|
27
|
+
autoload :TimeToAngleFromZenithCommand, 'solcal/commands/time_to_angle_from_zenith_command'
|
|
27
28
|
|
|
28
29
|
extend NamingConvention
|
|
29
30
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SolCal
|
|
2
|
+
module Commands
|
|
3
|
+
class TimeToAngleFromZenithCommand < BaseCommand
|
|
4
|
+
protected
|
|
5
|
+
def do_execute
|
|
6
|
+
a = Math.cos(Angle.from_deg(angle_from_zenith).to_rad)
|
|
7
|
+
b = Math.cos(latitude.to_rad)*Math.cos(declination.to_rad)
|
|
8
|
+
c = Math.tan(latitude.to_rad)*Math.tan(declination.to_rad)
|
|
9
|
+
d = a/b-c
|
|
10
|
+
return "The sun will not reach #{angle_from_zenith} degrees from zenith today." unless d >= 0 and d<=1
|
|
11
|
+
ha_angle_to_zenith = Angle.from_rad(Math.acos(d))
|
|
12
|
+
SolCal::TimeOfDay.new(solar_noon-ha_angle_to_zenith.to_deg*4/1440)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/solcal/location.rb
CHANGED
|
@@ -18,6 +18,13 @@ module SolCal
|
|
|
18
18
|
results
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def time_to_angle_from_zenith(year, month, day, time_zone, angle_from_zenith)
|
|
22
|
+
results = create_data(year, month, day, time_zone)
|
|
23
|
+
results[:angle_from_zenith] = angle_from_zenith
|
|
24
|
+
Commands.run(:time_to_angle_from_zenith, results)
|
|
25
|
+
results
|
|
26
|
+
end
|
|
27
|
+
|
|
21
28
|
def date_pair(year, month, day, time_zone)
|
|
22
29
|
results = create_data(year,month,day, time_zone)
|
|
23
30
|
Commands.run(:duration, results)
|
data/lib/solcal/version.rb
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "AppLongitudeCommand" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
it "should calculate the applied longitude on 2014-12-01" do
|
|
5
|
+
result = {true_longitude:SolCal::Angle.from_deg(247.9944),julian_century:0.149125142596397}
|
|
6
|
+
SolCal::Commands::AppLongitudeCommand.new(result).execute
|
|
7
|
+
expect(result[:app_longitude].to_deg).to be_within(0.01).of(247.99)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
it "should
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
it "should calculate the applied longitude on 2015-08-05" do
|
|
11
|
+
result = {true_longitude:SolCal::Angle.from_deg(247.9944),julian_century:0.15592060232717317}
|
|
12
|
+
SolCal::Commands::AppLongitudeCommand.new(result).execute
|
|
13
|
+
expect(result[:app_longitude].to_deg).to be_within(0.01).of(247.99)
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "DeclinationCommand" do
|
|
4
|
-
|
|
4
|
+
it "should calculate declination for the applied longitude" do
|
|
5
5
|
@result = {oblique_correction:SolCal::Angle.from_deg(247.99),app_longitude:SolCal::Angle.from_deg(23.4349)}
|
|
6
|
-
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "should execute" do
|
|
10
|
-
@command.execute
|
|
6
|
+
SolCal::Commands::DeclinationCommand.new(@result).execute
|
|
11
7
|
expect(@result[:declination].to_deg).to be_within(0.001).of(-21.6368)
|
|
12
8
|
end
|
|
9
|
+
|
|
13
10
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "GeometricMeanLongCommand" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
it "should calculate the geometric mean longitude on 2014-12-01" do
|
|
5
|
+
result = {julian_century:0.149125142596397}
|
|
6
|
+
SolCal::Commands::GeometricMeanLongCommand.new(result).execute
|
|
7
|
+
expect(result[:geometric_mean_long].to_deg).to be_within(0.0001).of(249.0864)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
it "should
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
it "should calculate the geometric mean longitude on 2015-08-05" do
|
|
11
|
+
result = {julian_century:0.15592060232717317}
|
|
12
|
+
SolCal::Commands::GeometricMeanLongCommand.new(result).execute
|
|
13
|
+
expect(result[:geometric_mean_long].to_deg).to be_within(0.0001).of(133.7282)
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -2,13 +2,26 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe "JulianCenturyCommand" do
|
|
4
4
|
before :each do
|
|
5
|
-
@results = {
|
|
6
|
-
@command = SolCal::Commands::JulianCenturyCommand.new(@results)
|
|
5
|
+
@results = {time_zone: -7}
|
|
7
6
|
end
|
|
8
7
|
|
|
9
|
-
it "should calculate julian century from
|
|
10
|
-
@
|
|
8
|
+
it "should calculate julian century from 2014-12-01" do
|
|
9
|
+
@results[:date] = Date.new(2014,12,1)
|
|
10
|
+
SolCal::Commands::JulianCenturyCommand.new(@results).execute
|
|
11
11
|
expect(@results[:julian_century]).not_to be_nil
|
|
12
12
|
expect(@results[:julian_century]).to be_within(0.0001).of(0.14912526)
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
it "should calculate julian century from 2015-08-05" do
|
|
16
|
+
@results[:date] = Date.new(2015,8,5)
|
|
17
|
+
SolCal::Commands::JulianCenturyCommand.new(@results).execute
|
|
18
|
+
expect(@results[:julian_century]).not_to be_nil
|
|
19
|
+
expect(@results[:julian_century]).to be_within(0.0000001).of(0.15592060232717317)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should calculate julian century from 2015-12-21" do
|
|
23
|
+
@results[:date] = Date.new(2015,12,21)
|
|
24
|
+
SolCal::Commands::JulianCenturyCommand.new(@results).execute
|
|
25
|
+
expect(@results[:julian_century]).to be_within(0.0000001).of(0.15969883641341548)
|
|
26
|
+
end
|
|
14
27
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "MeanObliqueEclipticCommand" do
|
|
4
|
-
|
|
4
|
+
it "should execute on 2014-12-01" do
|
|
5
5
|
@result = {julian_century:0.149125142596397}
|
|
6
|
-
|
|
6
|
+
SolCal::Commands::MeanObliqueEclipticCommand.new(@result).execute
|
|
7
|
+
expect(@result[:mean_oblique_ecliptic]).to be_within(0.001).of(23.43735)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
it "should execute" do
|
|
10
|
-
@
|
|
10
|
+
it "should execute on 2015-08-05" do
|
|
11
|
+
@result = {julian_century:0.15592060232717317}
|
|
12
|
+
SolCal::Commands::MeanObliqueEclipticCommand.new(@result).execute
|
|
11
13
|
expect(@result[:mean_oblique_ecliptic]).to be_within(0.001).of(23.43735)
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "ObliqueCorrectionCommand" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
it "should calculate oblique correction on 2014-12-01" do
|
|
5
|
+
result = {julian_century:0.149125142596397,mean_oblique_ecliptic:23.43735}
|
|
6
|
+
SolCal::Commands::ObliqueCorrectionCommand.new(result).execute
|
|
7
|
+
expect(result[:oblique_correction].to_deg).to be_within(0.001).of(23.4349)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
it "should
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
it "should calculate the oblique correction on 2015-08-05" do
|
|
11
|
+
result = {julian_century: 0.15592060232717317}
|
|
12
|
+
SolCal::Commands::ObliqueCorrectionCommand.new(result).execute
|
|
13
|
+
expect(result[:oblique_correction].to_deg).to be_within(0.001).of(23.4349)
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "TimeToAngleFromZenithCommand" do
|
|
4
|
+
it "should calculate the time the sun will reach a 90deg angle from the zenith" do
|
|
5
|
+
@result = {julian_century:0.149125142596397, latitude:SolCal::Angle.from_deg(53.5333),declination:SolCal::Angle.from_deg(-21.7958) ,solar_noon:0.515931}
|
|
6
|
+
@result[:angle_from_zenith] = 90
|
|
7
|
+
SolCal::Commands::TimeToAngleFromZenithCommand.new(@result).execute
|
|
8
|
+
expect(@result[:time_to_angle_from_zenith].to_s).to eql("08:33")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should calculate the time the sun will reach a 72deg angle from the zenith on 2015-08-05" do
|
|
12
|
+
@result = {julian_century:0.15592060, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
|
|
13
|
+
@result[:angle_from_zenith] = 72
|
|
14
|
+
SolCal::Commands::TimeToAngleFromZenithCommand.new(@result).execute
|
|
15
|
+
expect(@result[:time_to_angle_from_zenith].to_s).to eql("07:10")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should calculate the time the sun will reach a 72deg angle from the zenith on 2015-08-05" do
|
|
19
|
+
@result = {julian_century:0.15592060, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
|
|
20
|
+
@result[:angle_from_zenith] = 72
|
|
21
|
+
SolCal::Commands::TimeToAngleFromZenithCommand.new(@result).execute
|
|
22
|
+
expect(@result[:time_to_angle_from_zenith].to_s).to eql("07:10")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should calculate the time the sun will reach max angle on 2015-12-21" do
|
|
26
|
+
@result = {julian_century:0.15969883641341548, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
|
|
27
|
+
@result[:angle_from_zenith] = 76.97
|
|
28
|
+
SolCal::Commands::TimeToAngleFromZenithCommand.new(@result).execute
|
|
29
|
+
expect(@result[:time_to_angle_from_zenith].to_s).to eql("12:28")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return error when requesting time sun will reach above max angle on 2015-12-21" do
|
|
33
|
+
@result = {julian_century:0.15969883641341548, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
|
|
34
|
+
@result[:angle_from_zenith] = 76.96
|
|
35
|
+
SolCal::Commands::TimeToAngleFromZenithCommand.new(@result).execute
|
|
36
|
+
expect(@result[:time_to_angle_from_zenith].to_s).to eql("The sun will not reach 76.96 degrees from zenith today.")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "TrueLongitudeCommand" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
it "should calculate the true longitude on 2014-12-01" do
|
|
5
|
+
result = {geometric_mean_long:SolCal::Angle.from_deg(249.0864),equation_of_center:-1.092}
|
|
6
|
+
SolCal::Commands::TrueLongitudeCommand.new(result).execute
|
|
7
|
+
expect(result[:true_longitude].to_deg).to be_within(0.0001).of(247.9944)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
it "should
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
it "should calculate the true longitude on 2015-08-05" do
|
|
11
|
+
result = {geometric_mean_long:SolCal::Angle.from_deg(133.7282),equation_of_center:-1.092}
|
|
12
|
+
SolCal::Commands::TrueLongitudeCommand.new(result).execute
|
|
13
|
+
expect(result[:true_longitude].to_deg).to be_within(0.0001).of(132.6362)
|
|
12
14
|
end
|
|
13
15
|
end
|
data/spec/location_spec.rb
CHANGED
|
@@ -78,5 +78,30 @@ describe "Location" do
|
|
|
78
78
|
expect(results[:civil_dawn].to_s).to eql("06:32")
|
|
79
79
|
expect(results[:civil_dusk].to_s).to eql("17:21")
|
|
80
80
|
end
|
|
81
|
+
|
|
82
|
+
it "should calculate time to 70deg from zenith on 2015-09-06 in Edmonton" do
|
|
83
|
+
results = @edmonton.time_to_angle_from_zenith(2015, 9, 6, -6, 70)
|
|
84
|
+
expect(results[:time_to_angle_from_zenith].to_s).to eql("09:13")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should calculate time to 70deg from zenith on 2015-09-06 in Miami" do
|
|
88
|
+
results = @miami.time_to_angle_from_zenith(2015, 9, 6, -4, 70)
|
|
89
|
+
expect(results[:time_to_angle_from_zenith].to_s).to eql("08:35")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should calculate time to 70deg from zenith on 2015-09-06 in Sydney" do
|
|
93
|
+
results = @sydney.time_to_angle_from_zenith(2015, 9, 6, +10, 70)
|
|
94
|
+
expect(results[:time_to_angle_from_zenith].to_s).to eql("07:51")
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should return that the sun will never reach 47deg from zenith on 2015-09-06 in Edmonton" do
|
|
98
|
+
results = @edmonton.time_to_angle_from_zenith(2015, 9, 6, -6, 47)
|
|
99
|
+
expect(results[:time_to_angle_from_zenith].to_s).to eql("The sun will not reach 47 degrees from zenith today.")
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should return that the sun will never reach 19.3deg from zenith on 2015-09-06 in Miami" do
|
|
103
|
+
results = @miami.time_to_angle_from_zenith(2015, 9, 6, -6, 19.3)
|
|
104
|
+
expect(results[:time_to_angle_from_zenith].to_s).to eql("The sun will not reach 19.3 degrees from zenith today.")
|
|
105
|
+
end
|
|
81
106
|
end
|
|
82
107
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solcal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Neil Bourgeois
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-09-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- lib/solcal/commands/solar_noon_command.rb
|
|
77
77
|
- lib/solcal/commands/sunrise_command.rb
|
|
78
78
|
- lib/solcal/commands/sunset_command.rb
|
|
79
|
+
- lib/solcal/commands/time_to_angle_from_zenith_command.rb
|
|
79
80
|
- lib/solcal/commands/true_longitude_command.rb
|
|
80
81
|
- lib/solcal/commands/var_y_command.rb
|
|
81
82
|
- lib/solcal/location.rb
|
|
@@ -104,6 +105,7 @@ files:
|
|
|
104
105
|
- spec/commands/solar_noon_command_spec.rb
|
|
105
106
|
- spec/commands/sunrise_command_spec.rb
|
|
106
107
|
- spec/commands/sunset_command_spec.rb
|
|
108
|
+
- spec/commands/time_to_angle_from_zenith_command_spec.rb
|
|
107
109
|
- spec/commands/true_longitude_command_spec.rb
|
|
108
110
|
- spec/commands/var_y_command_spec.rb
|
|
109
111
|
- spec/date_pair_spec.rb
|
|
@@ -159,6 +161,7 @@ test_files:
|
|
|
159
161
|
- spec/commands/solar_noon_command_spec.rb
|
|
160
162
|
- spec/commands/sunrise_command_spec.rb
|
|
161
163
|
- spec/commands/sunset_command_spec.rb
|
|
164
|
+
- spec/commands/time_to_angle_from_zenith_command_spec.rb
|
|
162
165
|
- spec/commands/true_longitude_command_spec.rb
|
|
163
166
|
- spec/commands/var_y_command_spec.rb
|
|
164
167
|
- spec/date_pair_spec.rb
|