solar 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8f9579b11f6e74d46611e8558786d36fd18a6f3
4
- data.tar.gz: 73152c453267480d1d4b9db82fdf4fbad9b8e82b
3
+ metadata.gz: 005d89590b19cdba0788bd1e2443e1d454822112
4
+ data.tar.gz: 244ced1474bfee06c0ec4e40ff9e08b44e728c67
5
5
  SHA512:
6
- metadata.gz: 40c66e8eca3c9457b31e6863d44057fcd758622133e6b11b2de734f5a06ec00812551ed09ff2a28fa51d574255366c41c2d9d439cffc0e8ebe98b5626554621c
7
- data.tar.gz: d5d1537301f3f070966a250c874525dbb9be2f6e50c68a6f8d3e39e49617adf0a136d55b8a7c226798c3650f06e73efe2254758d60db8a30eb9b30a572177dd4
6
+ metadata.gz: fb4b4fea8a3831e1948ca68ac950737454a23d4326a9f9d3c986e18a396251dc57ce24e79e847f32bf566a454a6f8cbeffb3dcfec1cfab99ffe69750085697ac
7
+ data.tar.gz: 828f03efed02b337853b41ba120f574cd43d05210ed5a8244ada69d0975db9f9f8965bfd8be3bcaaf6b4815d2432c295350120c42be013c80da44c2f3e49142d
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /rdoc/
@@ -0,0 +1 @@
1
+ ruby-2.2.2
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile CHANGED
@@ -1,12 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'activesupport'
4
-
5
- # Add dependencies to develop your gem here.
6
- # Include everything needed to run rake, tests, features, etc.
7
- group :development do
8
- gem "shoulda", ">= 0"
9
- gem "rdoc", "~> 3.12"
10
- gem "bundler", "~> 1"
11
- gem "jeweler", "~> 2.0.1"
12
- end
3
+ # Specify your gem's dependencies in dicompack.gemspec
4
+ gemspec
@@ -0,0 +1,182 @@
1
+ # Solar
2
+
3
+ Solar position & radiation calculations.
4
+
5
+ This gem provides functions to compute solar position, rise & set times for a given position & time,
6
+ as weel as solar radiation and radiation on a sloped surface.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'solar'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install solar
23
+
24
+ ## Examples
25
+
26
+ ### Compute solar passages at a date and Earth's position.
27
+
28
+ The position is specified as longitude and latitude in degrees:
29
+
30
+ ```ruby
31
+ longitude = 1.5 # 1 degree 30 minutes East
32
+ latitude = 42.0 # 42 degrees North
33
+ ```
34
+
35
+ The date as a `Date` object:
36
+ ```ruby
37
+ date = Date.new(2014, 3, 22)
38
+ ```
39
+
40
+ The +passages+ method returns the time of sun rise, transit and set.
41
+ Transit refers to the moment the sun crosses the local meridian, i.e.
42
+ to local solar noon.
43
+
44
+ ```ruby
45
+ rise, transit, set = Solar.passages(date, longitude, latitude)
46
+ puts rise # => Sat, 22 Mar 2014 05:54:29 +0000
47
+ puts transit # => Sat, 22 Mar 2014 12:00:54 +0000
48
+ puts set # => Sat, 22 Mar 2014 18:07:51 +0000
49
+ ```
50
+
51
+ ### Solar position in horizontal coordinates
52
+
53
+ We can also compute the local relative position of the sun
54
+ for a given instant and place.
55
+
56
+ Now, instead of a +Date+ we need to specify a +Time+; e.g.
57
+ we can specify the given date at 1 pm like so:
58
+
59
+ ```ruby
60
+ time = date.to_time + 13*3600.0
61
+ ```
62
+
63
+ The +position+ method returns the sun's elevation and azimuth in degrees
64
+ at the given time and place:
65
+
66
+ ```ruby
67
+ elevation, azimuth = Solar.position(time, longitude, latitude)
68
+ puts elevation # => 48.710153789164785
69
+ puts azimuth # => 179.6564173373824
70
+ ```
71
+
72
+ Azimuth is measured on the horizontal plane clockwise from North.
73
+ Elevation is the measured from the horizontal plane to the Sun.
74
+
75
+ It's complementary angle is the solar zenith, the angular distance from
76
+ the local zenith to the sun:
77
+
78
+ ```ruby
79
+ zenith = 90.0 - elevation
80
+ puts zenith # => 41.289846210835215
81
+ ```
82
+
83
+ ### Day and Night
84
+
85
+ We can query for the day/night situation for a given time and place:
86
+
87
+ ```ruby
88
+ situation = Solar.day_or_night(time, longitude, latitude)
89
+ puts situation.inspect # => :day
90
+ ```
91
+
92
+ This method returns +:day+, +:night+ or +:twilight+.
93
+ Twilight refers to the period when the sun has set (appears under the hozizon)
94
+ but the sky is not completely dark.
95
+
96
+ ```ruby
97
+ situation = Solar.day_or_night(Time.utc(2014,3,22,18,10), longitude, latitude)
98
+ puts situation.inspect # => :twilight
99
+ ```
100
+
101
+ Actually there are different
102
+ [definitions of twilight](https://en.wikipedia.org/wiki/Twilight#Definitions)
103
+ and you can differentiate between them with the +:detaild+ option:
104
+
105
+ ```ruby
106
+ situation = Solar.day_or_night(
107
+ Time.utc(2014,3,22,18,10), longitude, latitude, detaild: true
108
+ )
109
+ puts situation.inspect # => :civil_twilight
110
+ situation = Solar.day_or_night(
111
+ Time.utc(2014,3,22,18,40), longitude, latitude, detailed: true
112
+ )
113
+ puts situation.inspect # => :nautical_twilight
114
+ situation = Solar.day_or_night(
115
+ Time.utc(2014,3,22,19,30), longitude, latitude, detailed: true
116
+ )
117
+ puts situation.inspect # => :astronomical_twilight
118
+ situation = Solar.day_or_night(
119
+ Time.utc(2014,3,22,20), longitude, latitude, detailed: true
120
+ )
121
+ puts situation.inspect # => :night
122
+ ```
123
+
124
+ ### Solar Radiation
125
+
126
+ The +radiation+ method can compute the radiation (W per square meter)
127
+ on at a given time and location on a horizonta plane:
128
+
129
+ ```ruby
130
+ global_radiation_h = Solar.radiation(time, longitude, latitude)
131
+ puts global_radiation_h # => 1021.7400285752376
132
+ ```
133
+
134
+ In this case whe're assuming a *clearness index* of 1.0, i.e.
135
+ clear skies.
136
+
137
+ It can also compute the radiation on an inclined surface, defined by
138
+ its slope (angle in degrees from 0--horizontal to 90--vertical)
139
+ and aspect (horizontal clockwise angle from North):
140
+
141
+ ```ruby
142
+ r = Solar.radiation(time, longitude, latitude, slope: 10, aspect: 0)
143
+ puts r # 852.5943696877531
144
+ ```
145
+
146
+ But this method was not created to give estimates of the radiation, but
147
+ to adjust measures of the global radiation on the horizontal to what
148
+ a sloping surface would get. For this, we need to provide the
149
+ measured radiation on a horizontal plane as +:global_radiation+:
150
+
151
+ ```ruby
152
+ r = Solar.radiation(
153
+ time, longitude, latitude,
154
+ slope: 10, aspect: 0,
155
+ global_radiation: 432
156
+ )
157
+ puts r # => 410.89951605660417
158
+ ```
159
+
160
+ ### Pending...
161
+
162
+ Please refer to the code documentation for more information.
163
+
164
+ * TODO: explain how to use ActiveSupport date & time methods, time zones, etc.
165
+ * TODO: explain the use of zenith/elevations to work with civil/nautical/astronomcial etc.
166
+ * TODO: more information about the uses of +radiation+
167
+
168
+ ## Development
169
+
170
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec solar` to use the gem in this directory, ignoring other installed copies of this gem.
171
+
172
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
173
+
174
+ ## Contributing
175
+
176
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/solar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
177
+
178
+
179
+ ## Copyright
180
+
181
+ Copyright (c) 2012-2015 Javier Goizueta. See LICENSE.txt for
182
+ further details.
data/Rakefile CHANGED
@@ -1,45 +1,22 @@
1
- # encoding: utf-8
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
2
3
 
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
11
8
  end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "solar"
18
- gem.homepage = "http://github.com/jgoizueta/solar"
19
- gem.license = "MIT"
20
- gem.summary = %Q{# Calculation of solar position, rise & set times}
21
- gem.description = %Q{# Calculation of solar position, rise & set times for a given position & time.}
22
- gem.email = "jgoizueta@gmail.com"
23
- gem.authors = ["Javier Goizueta"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
33
- end
34
-
35
- task :default => :test
36
9
 
37
10
  require 'rdoc/task'
38
11
  Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
12
+ version = Solar::VERSION
40
13
 
41
14
  rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "solar #{version}"
15
+ rdoc.title = "Solar #{version}"
16
+ rdoc.main = "README.md"
43
17
  rdoc.rdoc_files.include('README*')
44
18
  rdoc.rdoc_files.include('lib/**/*.rb')
19
+ rdoc.markup = 'markdown' if rdoc.respond_to?(:markup)
45
20
  end
21
+
22
+ task :default => :test
@@ -7,6 +7,7 @@ require 'active_support/time'
7
7
  module Solar
8
8
  end
9
9
 
10
+ require 'solar/version.rb'
10
11
  require 'solar/support.rb'
11
12
  require 'solar/passages.rb'
12
13
  require 'solar/position.rb'
@@ -43,6 +43,7 @@ module Solar
43
43
  # optional: diffuse radiation (horizontal)
44
44
  g_d = options[:diffuse_radiation]
45
45
  k_t = options[:clearness_index]
46
+ k_t ||= 1.0 if g.nil?
46
47
 
47
48
  # ground reflectance (albedo) as %
48
49
  rg = options[:albedo] || 0.2
@@ -0,0 +1,3 @@
1
+ module Solar
2
+ VERSION = "0.1.2"
3
+ end
@@ -1,69 +1,26 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: solar 0.1.1 ruby lib
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'solar/version'
6
5
 
7
- Gem::Specification.new do |s|
8
- s.name = "solar"
9
- s.version = "0.1.1"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "solar"
8
+ spec.version = Solar::VERSION
9
+ spec.authors = ["Javier Goizueta"]
10
+ spec.email = ["jgoizueta@gmail.com"]
10
11
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Javier Goizueta"]
14
- s.date = "2015-07-23"
15
- s.description = "# Calculation of solar position, rise & set times for a given position & time."
16
- s.email = "jgoizueta@gmail.com"
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE.txt",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "lib/solar.rb",
30
- "lib/solar/day_night.rb",
31
- "lib/solar/lambert.rb",
32
- "lib/solar/passages.rb",
33
- "lib/solar/position.rb",
34
- "lib/solar/radiation.rb",
35
- "lib/solar/support.rb",
36
- "solar.gemspec",
37
- "test/helper.rb",
38
- "test/test_solar.rb"
39
- ]
40
- s.homepage = "http://github.com/jgoizueta/solar"
41
- s.licenses = ["MIT"]
42
- s.rubygems_version = "2.2.2"
43
- s.summary = "# Calculation of solar position, rise & set times"
12
+ spec.summary = %q{Calculation of solar position & radiation.}
13
+ spec.description = %q{Methods to compute solar position, rise & set times, radiation, etc.}
14
+ spec.homepage = "https://github.com/jgoizueta/solar"
44
15
 
45
- if s.respond_to? :specification_version then
46
- s.specification_version = 4
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
47
20
 
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
50
- s.add_development_dependency(%q<shoulda>, [">= 0"])
51
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
52
- s.add_development_dependency(%q<bundler>, ["~> 1"])
53
- s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
54
- else
55
- s.add_dependency(%q<activesupport>, [">= 0"])
56
- s.add_dependency(%q<shoulda>, [">= 0"])
57
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
- s.add_dependency(%q<bundler>, ["~> 1"])
59
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
60
- end
61
- else
62
- s.add_dependency(%q<activesupport>, [">= 0"])
63
- s.add_dependency(%q<shoulda>, [">= 0"])
64
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
- s.add_dependency(%q<bundler>, ["~> 1"])
66
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
67
- end
68
- end
21
+ spec.add_dependency 'activesupport', ">= 0"
69
22
 
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest"
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,77 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: shoulda
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rdoc
28
+ name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '3.12'
33
+ version: '1.10'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '3.12'
40
+ version: '1.10'
55
41
  - !ruby/object:Gem::Dependency
56
- name: bundler
42
+ name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1'
47
+ version: '10.0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1'
54
+ version: '10.0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: jeweler
56
+ name: minitest
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 2.0.1
61
+ version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 2.0.1
83
- description: "# Calculation of solar position, rise & set times for a given position
84
- & time."
85
- email: jgoizueta@gmail.com
68
+ version: '0'
69
+ description: Methods to compute solar position, rise & set times, radiation, etc.
70
+ email:
71
+ - jgoizueta@gmail.com
86
72
  executables: []
87
73
  extensions: []
88
- extra_rdoc_files:
89
- - LICENSE.txt
90
- - README.rdoc
74
+ extra_rdoc_files: []
91
75
  files:
92
- - ".document"
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - ".travis.yml"
93
79
  - Gemfile
94
- - Gemfile.lock
95
80
  - LICENSE.txt
96
- - README.rdoc
81
+ - README.md
97
82
  - Rakefile
98
- - VERSION
99
83
  - lib/solar.rb
100
84
  - lib/solar/day_night.rb
101
85
  - lib/solar/lambert.rb
@@ -103,12 +87,10 @@ files:
103
87
  - lib/solar/position.rb
104
88
  - lib/solar/radiation.rb
105
89
  - lib/solar/support.rb
90
+ - lib/solar/version.rb
106
91
  - solar.gemspec
107
- - test/helper.rb
108
- - test/test_solar.rb
109
- homepage: http://github.com/jgoizueta/solar
110
- licenses:
111
- - MIT
92
+ homepage: https://github.com/jgoizueta/solar
93
+ licenses: []
112
94
  metadata: {}
113
95
  post_install_message:
114
96
  rdoc_options: []
@@ -126,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
108
  version: '0'
127
109
  requirements: []
128
110
  rubyforge_project:
129
- rubygems_version: 2.2.2
111
+ rubygems_version: 2.4.8
130
112
  signing_key:
131
113
  specification_version: 4
132
- summary: "# Calculation of solar position, rise & set times"
114
+ summary: Calculation of solar position & radiation.
133
115
  test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
@@ -1,59 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activesupport (3.2.8)
5
- i18n (~> 0.6)
6
- multi_json (~> 1.0)
7
- addressable (2.3.8)
8
- builder (3.2.2)
9
- faraday (0.7.6)
10
- addressable (~> 2.2)
11
- multipart-post (~> 1.1)
12
- rack (~> 1.1)
13
- git (1.2.9.1)
14
- github_api (0.4.10)
15
- faraday (~> 0.7.6)
16
- hashie (~> 1.2.0)
17
- multi_json (~> 1.0)
18
- oauth2 (~> 0.5.2)
19
- hashie (1.2.0)
20
- highline (1.7.2)
21
- i18n (0.6.1)
22
- jeweler (2.0.1)
23
- builder
24
- bundler (>= 1.0)
25
- git (>= 1.2.5)
26
- github_api
27
- highline (>= 1.6.15)
28
- nokogiri (>= 1.5.10)
29
- rake
30
- rdoc
31
- json (1.7.5)
32
- mini_portile (0.6.2)
33
- multi_json (1.3.6)
34
- multipart-post (1.2.0)
35
- nokogiri (1.6.6.2)
36
- mini_portile (~> 0.6.0)
37
- oauth2 (0.5.2)
38
- faraday (~> 0.7)
39
- multi_json (~> 1.0)
40
- rack (1.6.4)
41
- rake (10.4.2)
42
- rdoc (3.12)
43
- json (~> 1.4)
44
- shoulda (3.1.1)
45
- shoulda-context (~> 1.0)
46
- shoulda-matchers (~> 1.2)
47
- shoulda-context (1.0.0)
48
- shoulda-matchers (1.3.0)
49
- activesupport (>= 3.0.0)
50
-
51
- PLATFORMS
52
- ruby
53
-
54
- DEPENDENCIES
55
- activesupport
56
- bundler (~> 1)
57
- jeweler (~> 2.0.1)
58
- rdoc (~> 3.12)
59
- shoulda
@@ -1,19 +0,0 @@
1
- = solar
2
-
3
- Calculation of solar position, rise & set times for a given position & time.
4
- Also calculation of solar radiation and radiation on a sloped surface.
5
-
6
- == Contributing to solar
7
-
8
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
9
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
10
- * Fork the project.
11
- * Start a feature/bugfix branch.
12
- * Commit and push until you are happy with your contribution.
13
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
14
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
15
-
16
- == Copyright
17
-
18
- Copyright (c) 2012-2015 Javier Goizueta. See LICENSE.txt for
19
- further details.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.1
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'solar'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,40 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSolar < Test::Unit::TestCase
4
-
5
- should "calculate transits for the required date" do
6
- d = Date.new(2012,10,7)
7
- for lon in -360..360
8
- for lat in -5..5
9
- lat *= 10
10
- r,trans,s = Solar.passages(d, lon, lat)
11
- assert_equal d, trans.utc.to_date, "longitude: #{lon} latitude: #{lat}"
12
- end
13
- end
14
- end
15
-
16
- should "determine if it's day or night" do
17
- assert_equal :day, Solar.day_or_night(Time.utc(2012,10,7,9,0,0), 0, 42)
18
- assert_equal :day, Solar.day_or_night(Time.utc(2012,10,7,9,0,0), 0, 42, :detailed=>true)
19
- assert_equal :day, Solar.day_or_night(Time.utc(2012,10,7,9,0,0), 0, 42, :simple=>true)
20
- assert_equal :night, Solar.day_or_night(Time.utc(2012,10,7,21,0,0), 0, 42)
21
- assert_equal :night, Solar.day_or_night(Time.utc(2012,10,7,21,0,0), 0, 42, :detailed=>true)
22
- assert_equal :night, Solar.day_or_night(Time.utc(2012,10,7,21,0,0), 0, 42, :simple=>true)
23
- assert_equal :night, Solar.day_or_night(Time.utc(2012,12,7,9,0,0), 0, 89)
24
- assert_equal :twilight, Solar.day_or_night(Time.utc(2012,10,7,9,0,0), 0, 89)
25
- assert_equal :day, Solar.day_or_night(Time.utc(2012,12,7,9,0,0), 0, -89)
26
- assert_equal :day, Solar.day_or_night(Time.utc(2012,10,7,9,0,0), 0, -89)
27
- end
28
-
29
- should "compute radiation accurately" do
30
- # from [Duffie-1991] Example 1.10.1
31
- dt = 600.0 # integrate in 10-minute steps
32
- r = 0.0
33
- (0...24*3600.0).step(dt) do |h|
34
- t = Date.new(1991, 4, 15).to_time + h
35
- r += dt*Solar.radiation(t, 0.0, 43.0, clearness_index: 1.0)*1E-6
36
- end
37
- assert_in_delta 33.8, r, 33.8*1E-3
38
- end
39
-
40
- end