solcal 0.0.5 → 0.0.6
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/angle_to_zenith_at_time_command.rb +15 -0
 - data/lib/solcal/commands/julian_century_command.rb +3 -2
 - data/lib/solcal/location.rb +7 -0
 - data/lib/solcal/time_of_day.rb +2 -1
 - data/lib/solcal/version.rb +1 -1
 - data/spec/commands/angle_to_zenith_at_time_command_spec.rb +25 -0
 - data/spec/commands/time_to_angle_from_zenith_command_spec.rb +0 -7
 - data/spec/location_spec.rb +15 -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: 998c5512e1382263fc0c8c515f822fa4ef755dd1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0f39caa6a8a38eb83cb12a80cb1bf1776c2a85bf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c3a2bec3619b102c6e063caf5c6031731cf6d36e5de1eab169ee90776a79be85d5ba379ea432127cb66d540fa54cc4fc1ca3f8cc09a64091b752cc4e71154f62
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fa457d6e259578f642ff13239ae63015ba6bc0615cde5c53c536a8f6dfbf5ddb1104b9c1930df082d92ab2e417bce0ed7f28840b4216e3dfa60397f8acf94f9e
         
     | 
    
        data/lib/solcal/commands.rb
    CHANGED
    
    | 
         @@ -27,6 +27,7 @@ module SolCal 
     | 
|
| 
       27 
27 
     | 
    
         
             
            		autoload :HaAngleToZenithCommand,		'solcal/commands/ha_angle_to_zenith_command'
         
     | 
| 
       28 
28 
     | 
    
         
             
            		autoload :TimeToAngleFromZenithCommand,	'solcal/commands/time_to_angle_from_zenith_command'
         
     | 
| 
       29 
29 
     | 
    
         
             
            		autoload :OppositeTimeToAngleFromZenithCommand,	'solcal/commands/opposite_time_to_angle_from_zenith_command'
         
     | 
| 
      
 30 
     | 
    
         
            +
            		autoload :AngleToZenithAtTimeCommand, 'solcal/commands/angle_to_zenith_at_time_command'
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
32 
     | 
    
         
             
            		extend NamingConvention
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SolCal
         
     | 
| 
      
 2 
     | 
    
         
            +
            	module Commands
         
     | 
| 
      
 3 
     | 
    
         
            +
            		class AngleToZenithAtTimeCommand < BaseCommand
         
     | 
| 
      
 4 
     | 
    
         
            +
            			protected
         
     | 
| 
      
 5 
     | 
    
         
            +
            			def do_execute
         
     | 
| 
      
 6 
     | 
    
         
            +
            				ha_angle_at_time = Angle.from_deg((solar_noon - at_time)*1440/4)
         
     | 
| 
      
 7 
     | 
    
         
            +
            				d = Math.cos(ha_angle_at_time.to_rad)
         
     | 
| 
      
 8 
     | 
    
         
            +
            				b = Math.cos(latitude.to_rad)*Math.cos(declination.to_rad)
         
     | 
| 
      
 9 
     | 
    
         
            +
            				c = Math.tan(latitude.to_rad)*Math.tan(declination.to_rad)
         
     | 
| 
      
 10 
     | 
    
         
            +
            				a = (d+c)*b
         
     | 
| 
      
 11 
     | 
    
         
            +
            				Angle.from_rad(Math.acos(a))			
         
     | 
| 
      
 12 
     | 
    
         
            +
            			end
         
     | 
| 
      
 13 
     | 
    
         
            +
            		end
         
     | 
| 
      
 14 
     | 
    
         
            +
            	end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -4,11 +4,12 @@ module SolCal 
     | 
|
| 
       4 
4 
     | 
    
         
             
            			def initialize(data)
         
     | 
| 
       5 
5 
     | 
    
         
             
            				super(data)
         
     | 
| 
       6 
6 
     | 
    
         
             
            				@year,@month,@day = data[:date].year, data[:date].month, data[:date].day
         
     | 
| 
      
 7 
     | 
    
         
            +
            				@hour,@min,@sec = 12,0,0
         
     | 
| 
       7 
8 
     | 
    
         
             
            			end
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
            			protected
         
     | 
| 
       10 
     | 
    
         
            -
            			def do_execute
         
     | 
| 
       11 
     | 
    
         
            -
            				(DateTime.new(@year,@month,@day, 
     | 
| 
      
 11 
     | 
    
         
            +
            			def do_execute				
         
     | 
| 
      
 12 
     | 
    
         
            +
            				(DateTime.new(@year,@month,@day,@hour,@min,@sec,time_zone).jd.to_f - 2451545)/36525
         
     | 
| 
       12 
13 
     | 
    
         
             
            			end
         
     | 
| 
       13 
14 
     | 
    
         
             
            		end
         
     | 
| 
       14 
15 
     | 
    
         
             
            	end
         
     | 
    
        data/lib/solcal/location.rb
    CHANGED
    
    | 
         @@ -26,6 +26,13 @@ module SolCal 
     | 
|
| 
       26 
26 
     | 
    
         
             
            			results
         
     | 
| 
       27 
27 
     | 
    
         
             
            		end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
            		def angle_to_zenith_at_time(year, month, day, hour, minute, time_zone)
         
     | 
| 
      
 30 
     | 
    
         
            +
            			results = create_data(year, month, day, time_zone)
         
     | 
| 
      
 31 
     | 
    
         
            +
            			results[:at_time] = (hour*60.0+minute)/(24*60.0)
         
     | 
| 
      
 32 
     | 
    
         
            +
            			Commands.run(:angle_to_zenith_at_time, results)
         
     | 
| 
      
 33 
     | 
    
         
            +
            			results
         
     | 
| 
      
 34 
     | 
    
         
            +
            		end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       29 
36 
     | 
    
         
             
            		def date_pair(year, month, day, time_zone)
         
     | 
| 
       30 
37 
     | 
    
         
             
            			results = create_data(year,month,day, time_zone)
         
     | 
| 
       31 
38 
     | 
    
         
             
            			Commands.run(:duration, results)
         
     | 
    
        data/lib/solcal/time_of_day.rb
    CHANGED
    
    
    
        data/lib/solcal/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "AngleToZenithAtTimeCommand" do
         
     | 
| 
      
 4 
     | 
    
         
            +
            	it "should calculate the angle to the zenith at 8:33am" 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[:at_time] = (8*60+33)/(24*60.0)
         
     | 
| 
      
 7 
     | 
    
         
            +
            		SolCal::Commands::AngleToZenithAtTimeCommand.new(result).execute
         
     | 
| 
      
 8 
     | 
    
         
            +
            		expect(result[:angle_to_zenith_at_time].to_deg).to be_within(0.1).of(90.1)
         
     | 
| 
      
 9 
     | 
    
         
            +
            	end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            	it "should calculate the angle to the zenith at 7:10am on 2015-08-05" do
         
     | 
| 
      
 12 
     | 
    
         
            +
            		result = {julian_century: 0.15592060232717317, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
         
     | 
| 
      
 13 
     | 
    
         
            +
            		result[:at_time] = (7*60+10)/(24*60.0)
         
     | 
| 
      
 14 
     | 
    
         
            +
            		SolCal::Commands::AngleToZenithAtTimeCommand.new(result).execute
         
     | 
| 
      
 15 
     | 
    
         
            +
            		expect(result[:angle_to_zenith_at_time].to_deg.to_f).to be_within(0.1).of(72.0)
         
     | 
| 
      
 16 
     | 
    
         
            +
            	end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            	it "should calculate the angle to zenith at 12:28pm on 2015-12-21" do
         
     | 
| 
      
 19 
     | 
    
         
            +
            		result = {julian_century:0.15969883641341548, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
         
     | 
| 
      
 20 
     | 
    
         
            +
            		result[:at_time] = (12*60+28)/(24*60.0)
         
     | 
| 
      
 21 
     | 
    
         
            +
            		SolCal::Commands::AngleToZenithAtTimeCommand.new(result).execute
         
     | 
| 
      
 22 
     | 
    
         
            +
            		expect(result[:angle_to_zenith_at_time].to_deg).to be_within(0.1).of(77.0)
         
     | 
| 
      
 23 
     | 
    
         
            +
            	end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -15,13 +15,6 @@ describe "TimeToAngleFromZenithCommand" do 
     | 
|
| 
       15 
15 
     | 
    
         
             
            		expect(@result[:time_to_angle_from_zenith].to_s).to eql("07:10")
         
     | 
| 
       16 
16 
     | 
    
         
             
            	end
         
     | 
| 
       17 
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 
18 
     | 
    
         
             
            	it "should calculate the time the sun will reach max angle on 2015-12-21" do
         
     | 
| 
       26 
19 
     | 
    
         
             
            		@result = {julian_century:0.15969883641341548, latitude:SolCal::Angle.from_deg(53.5333),longitude:SolCal::Angle.from_deg(-113.5), time_zone: -7}
         
     | 
| 
       27 
20 
     | 
    
         
             
            		@result[:angle_from_zenith] = 76.97
         
     | 
    
        data/spec/location_spec.rb
    CHANGED
    
    | 
         @@ -84,18 +84,33 @@ describe "Location" do 
     | 
|
| 
       84 
84 
     | 
    
         
             
            		expect(results[:time_to_angle_from_zenith].to_s).to eql("09:13")
         
     | 
| 
       85 
85 
     | 
    
         
             
            	end
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
      
 87 
     | 
    
         
            +
            	it "should calculate angle to zenith of 70deg at 9:13 on 2015-09-06 in Edmonton" do
         
     | 
| 
      
 88 
     | 
    
         
            +
            		results = @edmonton.angle_to_zenith_at_time(2015, 9, 6, 9, 13, -6)
         
     | 
| 
      
 89 
     | 
    
         
            +
            		expect(results[:angle_to_zenith_at_time].to_deg).to be_within(0.1).of(70)
         
     | 
| 
      
 90 
     | 
    
         
            +
            	end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
       87 
92 
     | 
    
         
             
            	it "should calculate time to 70deg from zenith on 2015-09-06 in Miami" do
         
     | 
| 
       88 
93 
     | 
    
         
             
            		results = @miami.time_to_angle_from_zenith(2015, 9, 6, -4, 70)
         
     | 
| 
       89 
94 
     | 
    
         
             
            		expect(results[:time_to_angle_from_zenith].to_s).to eql("08:35")
         
     | 
| 
       90 
95 
     | 
    
         
             
            		expect(results[:opposite_time_to_angle_from_zenith].to_s).to eql("18:02")
         
     | 
| 
       91 
96 
     | 
    
         
             
            	end
         
     | 
| 
       92 
97 
     | 
    
         | 
| 
      
 98 
     | 
    
         
            +
            	it "should calculate angle from zenith of 70deg at 8:35 on 2015-09-06 in Miami" do
         
     | 
| 
      
 99 
     | 
    
         
            +
            		results = @miami.angle_to_zenith_at_time(2015, 9, 6, 8, 35, -4)
         
     | 
| 
      
 100 
     | 
    
         
            +
            		expect(results[:angle_to_zenith_at_time].to_deg).to be_within(0.2).of(70)
         
     | 
| 
      
 101 
     | 
    
         
            +
            	end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       93 
103 
     | 
    
         
             
            	it "should calculate time to 70deg from zenith on 2015-09-06 in Sydney" do
         
     | 
| 
       94 
104 
     | 
    
         
             
            		results = @sydney.time_to_angle_from_zenith(2015, 9, 6, +10, 70)
         
     | 
| 
       95 
105 
     | 
    
         
             
            		expect(results[:time_to_angle_from_zenith].to_s).to eql("07:51")
         
     | 
| 
       96 
106 
     | 
    
         
             
            		expect(results[:opposite_time_to_angle_from_zenith].to_s).to eql("15:56")
         
     | 
| 
       97 
107 
     | 
    
         
             
            	end
         
     | 
| 
       98 
108 
     | 
    
         | 
| 
      
 109 
     | 
    
         
            +
            	it "should calculate angle from zenith of 70deg at 7:51 on 2015-09-06 in Sydney" do
         
     | 
| 
      
 110 
     | 
    
         
            +
            		results = @sydney.angle_to_zenith_at_time(2015, 9, 6, 7, 51, +10)
         
     | 
| 
      
 111 
     | 
    
         
            +
            		expect(results[:angle_to_zenith_at_time].to_deg).to be_within(0.1).of(70)
         
     | 
| 
      
 112 
     | 
    
         
            +
            	end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
       99 
114 
     | 
    
         
             
            	it "should return that the sun will never reach 47deg from zenith on 2015-09-06 in Edmonton" do
         
     | 
| 
       100 
115 
     | 
    
         
             
            		results = @edmonton.time_to_angle_from_zenith(2015, 9, 6, -6, 47)
         
     | 
| 
       101 
116 
     | 
    
         
             
            		expect(results[:time_to_angle_from_zenith].to_s).to eql("The sun will not reach 47 degrees from zenith today.")
         
     | 
    
        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.6
         
     | 
| 
       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-10-10 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -55,6 +55,7 @@ files: 
     | 
|
| 
       55 
55 
     | 
    
         
             
            - lib/solcal.rb
         
     | 
| 
       56 
56 
     | 
    
         
             
            - lib/solcal/angle.rb
         
     | 
| 
       57 
57 
     | 
    
         
             
            - lib/solcal/commands.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/solcal/commands/angle_to_zenith_at_time_command.rb
         
     | 
| 
       58 
59 
     | 
    
         
             
            - lib/solcal/commands/app_longitude_command.rb
         
     | 
| 
       59 
60 
     | 
    
         
             
            - lib/solcal/commands/base_command.rb
         
     | 
| 
       60 
61 
     | 
    
         
             
            - lib/solcal/commands/civil_dawn_command.rb
         
     | 
| 
         @@ -86,6 +87,7 @@ files: 
     | 
|
| 
       86 
87 
     | 
    
         
             
            - lib/solcal/version.rb
         
     | 
| 
       87 
88 
     | 
    
         
             
            - solcal.gemspec
         
     | 
| 
       88 
89 
     | 
    
         
             
            - spec/angle_spec.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - spec/commands/angle_to_zenith_at_time_command_spec.rb
         
     | 
| 
       89 
91 
     | 
    
         
             
            - spec/commands/app_longitude_command_spec.rb
         
     | 
| 
       90 
92 
     | 
    
         
             
            - spec/commands/base_command_spec.rb
         
     | 
| 
       91 
93 
     | 
    
         
             
            - spec/commands/civil_dawn_command_spec.rb
         
     | 
| 
         @@ -142,6 +144,7 @@ summary: 'Solar Calculator: find sunrise, sunset, solar Noon and solar position 
     | 
|
| 
       142 
144 
     | 
    
         
             
              any place on earth.'
         
     | 
| 
       143 
145 
     | 
    
         
             
            test_files:
         
     | 
| 
       144 
146 
     | 
    
         
             
            - spec/angle_spec.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - spec/commands/angle_to_zenith_at_time_command_spec.rb
         
     | 
| 
       145 
148 
     | 
    
         
             
            - spec/commands/app_longitude_command_spec.rb
         
     | 
| 
       146 
149 
     | 
    
         
             
            - spec/commands/base_command_spec.rb
         
     | 
| 
       147 
150 
     | 
    
         
             
            - spec/commands/civil_dawn_command_spec.rb
         
     |