Class: RubyPvWatts
- Inherits:
-
Object
- Object
- RubyPvWatts
- Includes:
- HTTParty
- Defined in:
- lib/ruby_pvwatts.rb,
lib/ruby_pvwatts/version.rb
Overview
Creates the wrapper object for querying NREL PVWatts. Uses the JSON API provided by NREL. More information is available at developer.nrel.gov/docs/solar/pvwatts-v5/
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Method Summary collapse
- #ac ⇒ Object (also: #hourly_ac_output)
- #ac_monthly ⇒ Object
- #city ⇒ Object
- #dc ⇒ Object (also: #hourly_diffuse_irradiance)
- #dc_monthly ⇒ Object
- #df ⇒ Object
- #dn ⇒ Object (also: #hourly_beam_normal_irradiance)
- #elev ⇒ Object
- #errors ⇒ Object
-
#initialize(opts) ⇒ RubyPvWatts
constructor
Required Parameters.
- #lat ⇒ Object
- #location ⇒ Object
- #long ⇒ Object
- #meters_from_station ⇒ Object (also: #distance)
- #poa ⇒ Object (also: #hourly_plane_of_array_irradiance)
- #poa_monthly ⇒ Object
- #solar_resource_file ⇒ Object
- #solrad_annual ⇒ Object
- #solrad_monthly ⇒ Object
- #state ⇒ Object
- #tamb ⇒ Object (also: #hourly_ambient_temperature)
- #tcell ⇒ Object (also: #hourly_module_temperature)
- #timezone ⇒ Object
- #version ⇒ Object
- #warnings ⇒ Object
- #wspd ⇒ Object (also: #hourly_windspeed)
Constructor Details
#initialize(opts) ⇒ RubyPvWatts
Required Parameters
These are the minimum fields required to use the API. Support for file_id has not been implemented. Additionally, the callback option is not supported.
- :
system_capacity: -
Nameplate capacity (kW) Range: 0.05 to 500000
- :
module_type: -
Module Type. 0=standard 1=premium 2=thin film
- :
losses: -
System losses (percent). Range -5 to 99
- :
array_type: -
Array Type
0 = Fixed - Open Rack
1 = Fixed - Roof Mounted
2 = 1-Axis
3 = 1-Axis Backtracking
4 = 2-Axis
- :
tilt: -
Tilt angle (degrees). range: 0 to 90
- :
azimuth: -
Azimuth angle (degrees) Range: 0 to 359
Conditional Params
- :
address: -
The address to use. (lat/lon returned by Google’s geocoding
service). Required if lat/lon is not specified
- :
lat: -
The latitude for the location in use. Required if address is not
specified.
- :
lon: -
The longitude for the location in use. Required if address is not
specified.
Optional Parameters
- :
dataset: -
The climate dataset to use.
tmy2 = TMY2 station data (see http://rredc.nrel.gov/solar/old_data/nsrdb/1961-1990/tmy2/State.html)
tmy3 = TMY3 station data (see http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/tmy3/by_USAFN.html)
intl = International station data
- :
radius: -
The search radius to use when searching for the closest
climate data station (miles). Pass in radius=0 to use the closest
station regardless of the distance.
- :
timeframe: -
Granularity of the output response
- :
dc_ac_ratio: -
DC to AC ratio
- :
gcr: -
Ground coverage ratio
- :
inv_eff: -
Inverter efficiency at rated power.
60 61 62 63 64 65 |
# File 'lib/ruby_pvwatts.rb', line 60 def initialize(opts) = check_required_params(opts) raise ArgumentError.new() if = { query: opts } @response = self.class.get('/api/pvwatts/v5.json', ) end |
Instance Method Details
#ac ⇒ Object Also known as: hourly_ac_output
135 136 137 138 |
# File 'lib/ruby_pvwatts.rb', line 135 def ac return nil unless hourly @response['outputs']['ac'] end |
#ac_monthly ⇒ Object
123 124 125 |
# File 'lib/ruby_pvwatts.rb', line 123 def ac_monthly @response['outputs']['ac_monthly'] end |
#city ⇒ Object
79 80 81 |
# File 'lib/ruby_pvwatts.rb', line 79 def city @response['station_info']['city'] end |
#dc ⇒ Object Also known as: hourly_diffuse_irradiance
150 151 152 153 |
# File 'lib/ruby_pvwatts.rb', line 150 def dc return nil unless hourly @response['outputs']['dc'] end |
#dc_monthly ⇒ Object
119 120 121 |
# File 'lib/ruby_pvwatts.rb', line 119 def dc_monthly @response['outputs']['dc_monthly'] end |
#df ⇒ Object
155 156 157 158 |
# File 'lib/ruby_pvwatts.rb', line 155 def df return nil unless hourly @response['outputs']['df'] end |
#dn ⇒ Object Also known as: hourly_beam_normal_irradiance
145 146 147 148 |
# File 'lib/ruby_pvwatts.rb', line 145 def dn return nil unless hourly @response['outputs']['dn'] end |
#elev ⇒ Object
91 92 93 |
# File 'lib/ruby_pvwatts.rb', line 91 def elev @response['station_info']['elev'] end |
#errors ⇒ Object
71 72 73 |
# File 'lib/ruby_pvwatts.rb', line 71 def errors @response['errors'] end |
#lat ⇒ Object
83 84 85 |
# File 'lib/ruby_pvwatts.rb', line 83 def lat @response['station_info']['lat'] end |
#location ⇒ Object
99 100 101 |
# File 'lib/ruby_pvwatts.rb', line 99 def location @response['station_info']['location'] end |
#long ⇒ Object
87 88 89 |
# File 'lib/ruby_pvwatts.rb', line 87 def long @response['station_info']['lon'] end |
#meters_from_station ⇒ Object Also known as: distance
111 112 113 |
# File 'lib/ruby_pvwatts.rb', line 111 def meters_from_station @response['station_info']['distance'] end |
#poa ⇒ Object Also known as: hourly_plane_of_array_irradiance
140 141 142 143 |
# File 'lib/ruby_pvwatts.rb', line 140 def poa return nil unless hourly @response['outputs']['poa'] end |
#poa_monthly ⇒ Object
115 116 117 |
# File 'lib/ruby_pvwatts.rb', line 115 def poa_monthly @response['outputs']['poa_monthly'] end |
#solar_resource_file ⇒ Object
107 108 109 |
# File 'lib/ruby_pvwatts.rb', line 107 def solar_resource_file @response['station_info']['solar_resource_file'] end |
#solrad_annual ⇒ Object
131 132 133 |
# File 'lib/ruby_pvwatts.rb', line 131 def solrad_annual @response['outputs']['solrad_annual'] end |
#solrad_monthly ⇒ Object
127 128 129 |
# File 'lib/ruby_pvwatts.rb', line 127 def solrad_monthly @response['outputs']['solrad_monthly'] end |
#state ⇒ Object
103 104 105 |
# File 'lib/ruby_pvwatts.rb', line 103 def state @response['station_info']['state'] end |
#tamb ⇒ Object Also known as: hourly_ambient_temperature
160 161 162 163 |
# File 'lib/ruby_pvwatts.rb', line 160 def tamb return nil unless hourly @response['outputs']['tamb'] end |
#tcell ⇒ Object Also known as: hourly_module_temperature
165 166 167 168 |
# File 'lib/ruby_pvwatts.rb', line 165 def tcell return nil unless hourly @response['outputs']['tcell'] end |
#timezone ⇒ Object
95 96 97 |
# File 'lib/ruby_pvwatts.rb', line 95 def timezone @response['station_info']['tz'] end |
#version ⇒ Object
67 68 69 |
# File 'lib/ruby_pvwatts.rb', line 67 def version @response['version'] end |
#warnings ⇒ Object
75 76 77 |
# File 'lib/ruby_pvwatts.rb', line 75 def warnings @response['warnings'] end |
#wspd ⇒ Object Also known as: hourly_windspeed
170 171 172 173 |
# File 'lib/ruby_pvwatts.rb', line 170 def wspd return nil unless hourly @response['outputs']['wspd'] end |