Class: RubyPvWatts

Inherits:
Object
  • Object
show all
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/

Author:

  • Shad Self

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


60
61
62
63
64
65
# File 'lib/ruby_pvwatts.rb', line 60

def initialize(opts)
  error_message = check_required_params(opts)
  raise ArgumentError.new(error_message) if error_message
  options = { query: opts }
  @response = self.class.get('/api/pvwatts/v5.json', options)
end

Instance Method Details

#acObject 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_monthlyObject



123
124
125
# File 'lib/ruby_pvwatts.rb', line 123

def ac_monthly
  @response['outputs']['ac_monthly']
end

#cityObject



79
80
81
# File 'lib/ruby_pvwatts.rb', line 79

def city
  @response['station_info']['city']
end

#dcObject 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_monthlyObject



119
120
121
# File 'lib/ruby_pvwatts.rb', line 119

def dc_monthly
  @response['outputs']['dc_monthly']
end

#dfObject



155
156
157
158
# File 'lib/ruby_pvwatts.rb', line 155

def df
  return nil unless hourly
  @response['outputs']['df']
end

#dnObject 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

#elevObject



91
92
93
# File 'lib/ruby_pvwatts.rb', line 91

def elev
  @response['station_info']['elev']
end

#errorsObject



71
72
73
# File 'lib/ruby_pvwatts.rb', line 71

def errors
  @response['errors']
end

#latObject



83
84
85
# File 'lib/ruby_pvwatts.rb', line 83

def lat
  @response['station_info']['lat']
end

#locationObject



99
100
101
# File 'lib/ruby_pvwatts.rb', line 99

def location
  @response['station_info']['location']
end

#longObject



87
88
89
# File 'lib/ruby_pvwatts.rb', line 87

def long
  @response['station_info']['lon']
end

#meters_from_stationObject Also known as: distance



111
112
113
# File 'lib/ruby_pvwatts.rb', line 111

def meters_from_station
  @response['station_info']['distance']
end

#poaObject 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_monthlyObject



115
116
117
# File 'lib/ruby_pvwatts.rb', line 115

def poa_monthly
  @response['outputs']['poa_monthly']
end

#solar_resource_fileObject



107
108
109
# File 'lib/ruby_pvwatts.rb', line 107

def solar_resource_file
  @response['station_info']['solar_resource_file']
end

#solrad_annualObject



131
132
133
# File 'lib/ruby_pvwatts.rb', line 131

def solrad_annual
  @response['outputs']['solrad_annual']
end

#solrad_monthlyObject



127
128
129
# File 'lib/ruby_pvwatts.rb', line 127

def solrad_monthly
  @response['outputs']['solrad_monthly']
end

#stateObject



103
104
105
# File 'lib/ruby_pvwatts.rb', line 103

def state
  @response['station_info']['state']
end

#tambObject 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

#tcellObject 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

#timezoneObject



95
96
97
# File 'lib/ruby_pvwatts.rb', line 95

def timezone
  @response['station_info']['tz']
end

#versionObject



67
68
69
# File 'lib/ruby_pvwatts.rb', line 67

def version
  @response['version']
end

#warningsObject



75
76
77
# File 'lib/ruby_pvwatts.rb', line 75

def warnings
  @response['warnings']
end

#wspdObject 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