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.0.2'

Instance Method Summary collapse

Constructor Details

#initialize(api_key, 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
# File 'lib/ruby_pvwatts.rb', line 60

def initialize(api_key, opts)
  options = { query: { api_key: api_key }.merge(opts) }
  @response = self.class.get('/api/pvwatts/v5.json', options)
end

Instance Method Details

#acObject Also known as: hourly_ac_output



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

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

#ac_monthlyObject



73
74
75
# File 'lib/ruby_pvwatts.rb', line 73

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

#dcObject Also known as: hourly_diffuse_irradiance



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

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

#dc_monthlyObject



69
70
71
# File 'lib/ruby_pvwatts.rb', line 69

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

#dfObject



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

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

#dnObject Also known as: hourly_beam_normal_irradiance



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

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

#poaObject Also known as: hourly_plane_of_array_irradiance



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

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

#poa_monthlyObject



65
66
67
# File 'lib/ruby_pvwatts.rb', line 65

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

#solrad_annualObject



81
82
83
# File 'lib/ruby_pvwatts.rb', line 81

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

#solrad_monthlyObject



77
78
79
# File 'lib/ruby_pvwatts.rb', line 77

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

#tambObject Also known as: hourly_ambient_temperature



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

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

#tcellObject Also known as: hourly_module_temperature



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

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

#wspdObject Also known as: hourly_windspeed



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

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