agroclimatology 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/agroclimatology.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/agroclimatology.rb +37 -0
- data/lib/agroclimatology/version.rb +3 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 614aa05f4413eb3aaf19cecbcf9939391d77dafd
|
4
|
+
data.tar.gz: 3bb1eb9b5433675f805a0d994ea0c3d4f865ecca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3af64c9064612ab623c8e8b73310ccc4dab603f1dc2a5b64f840fc7c3bb1471716b88fe14efd37669fb02dcbe415df392dc5a3dd7faed99634c4e991d5a713a
|
7
|
+
data.tar.gz: f0055cd757a1d13a0e7a159cefedf073336189ad8ce0888ceae673f799a35451a7d301fbf58a07833f5775bb483d4e96be76d2d46df2a0102033d589e7773294
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Bryce Johnston
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Agroclimatology
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/agroclimatology.svg)](https://badge.fury.io/rb/agroclimatology)
|
3
|
+
[![Build Status](https://travis-ci.org/brycejohnston/agroclimatology.svg?branch=master)](https://travis-ci.org/brycejohnston/agroclimatology)
|
4
|
+
|
5
|
+
Ruby client for interacting with the [NASA (POWER) Agroclimatology Web Resource](http://power.larc.nasa.gov/cgi-bin/agro.cgi)
|
6
|
+
|
7
|
+
Initial functionality is focused on getting solar radiation datasets (insolation on horizontal surface)
|
8
|
+
for a given latitude and longitude. Other solar radiation and meteorological query parameters will be available in subsequent versions.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'agroclimatology'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install agroclimatology
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Required params
|
29
|
+
- latitude
|
30
|
+
- longitude
|
31
|
+
|
32
|
+
Optional params
|
33
|
+
- year_start (default: 1983)
|
34
|
+
- year_end (default: current year)
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Agroclimatology.fetch(latitude, longitude, year_start, year_end)
|
38
|
+
```
|
39
|
+
|
40
|
+
### Examples
|
41
|
+
|
42
|
+
Fetch all solar radiation data available for Manhattan, KS, United States (1983 - Current Year)
|
43
|
+
```ruby
|
44
|
+
Agroclimatology.fetch(39.1836111, -96.5713889)
|
45
|
+
```
|
46
|
+
|
47
|
+
Fetch solar radiation data for Woombye, QLD, Australia from 2015 - 2016
|
48
|
+
```ruby
|
49
|
+
Agroclimatology.fetch(-26.660446, 152.964647, 2015, 2016)
|
50
|
+
```
|
51
|
+
|
52
|
+
### Output
|
53
|
+
|
54
|
+
Returns result set containing records for every day included in year_start - year_end range as JSON
|
55
|
+
- year - Year
|
56
|
+
- day - Day of Year
|
57
|
+
- insolation_surface - Average Insolation Incident On A Horizontal Surface (MJ/m^2/day)
|
58
|
+
|
59
|
+
## Development
|
60
|
+
|
61
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`.
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bjohnston/agroclimatology.
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'agroclimatology/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "agroclimatology"
|
8
|
+
spec.version = Agroclimatology::VERSION
|
9
|
+
spec.authors = ["Bryce Johnston"]
|
10
|
+
spec.email = ["johnstonbrc@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby client for interacting with the NASA (POWER) Agroclimatology Web Resource}
|
12
|
+
spec.description = %q{Ruby client for interacting with the NASA (POWER) Agroclimatology Web Resource}
|
13
|
+
spec.homepage = "https://github.com/brycejohnston/agroclimatology"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "faraday", "~> 0.9.2"
|
21
|
+
spec.add_dependency "oj", "~> 2.15"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "agroclimatology"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "agroclimatology/version"
|
2
|
+
require "csv"
|
3
|
+
require "faraday"
|
4
|
+
require "oj"
|
5
|
+
|
6
|
+
module Agroclimatology
|
7
|
+
|
8
|
+
def self.fetch(lat, lon, year_start = 1983, year_end = DateTime.now.year)
|
9
|
+
url = "http://power.larc.nasa.gov/cgi-bin/agro.cgi?&step=1"
|
10
|
+
url << "&lat=#{lat.to_s}&lon=#{lon.to_s}"
|
11
|
+
url << "&ms=1&ds=1&ys=#{year_start.to_s}"
|
12
|
+
url << "&me=12&de=31&ye=#{year_end.to_s}"
|
13
|
+
url << "&p=swv_dwn&submit=Submit"
|
14
|
+
|
15
|
+
response = Faraday.get url
|
16
|
+
if response.status == 200
|
17
|
+
page_data = response.body.split("-END HEADER-").last
|
18
|
+
data = []
|
19
|
+
page_data.split("\n").each do |line|
|
20
|
+
row = line.split(" ")
|
21
|
+
unless row[0].to_s.empty?
|
22
|
+
daily_record = {
|
23
|
+
"year": row[0],
|
24
|
+
"day_of_year": row[1],
|
25
|
+
"insolation_surface": row[2]
|
26
|
+
}
|
27
|
+
data << daily_record
|
28
|
+
end
|
29
|
+
end
|
30
|
+
json = Oj.dump(data)
|
31
|
+
puts json
|
32
|
+
else
|
33
|
+
puts "Error: #{response.status}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: agroclimatology
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryce Johnston
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.15'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: Ruby client for interacting with the NASA (POWER) Agroclimatology Web
|
84
|
+
Resource
|
85
|
+
email:
|
86
|
+
- johnstonbrc@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- agroclimatology.gemspec
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/agroclimatology.rb
|
102
|
+
- lib/agroclimatology/version.rb
|
103
|
+
homepage: https://github.com/brycejohnston/agroclimatology
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.5.1
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Ruby client for interacting with the NASA (POWER) Agroclimatology Web Resource
|
127
|
+
test_files: []
|