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/

Constant Summary collapse

VERSION =
'0.0.3'

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



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

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

#ac_monthlyObject



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

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

#dcObject Also known as: hourly_diffuse_irradiance



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

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

#dc_monthlyObject



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

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

#dfObject



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

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

#dnObject Also known as: hourly_beam_normal_irradiance



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

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

#poaObject Also known as: hourly_plane_of_array_irradiance



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

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

#poa_monthlyObject



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

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

#solrad_annualObject



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

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

#solrad_monthlyObject



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

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

#tambObject Also known as: hourly_ambient_temperature



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

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

#tcellObject Also known as: hourly_module_temperature



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

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

#wspdObject Also known as: hourly_windspeed



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

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