Skip to content

Commit 27fd18e

Browse files
committed
add get_irradiance, simple doc strings, and a few kwargs
1 parent e92acdd commit 27fd18e

File tree

1 file changed

+148
-13
lines changed

1 file changed

+148
-13
lines changed

pvlib/pvsystem.py

Lines changed: 148 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from pvlib import tools
2121
from pvlib.location import Location
22+
from pvlib import irradiance
2223

2324

2425
# not sure if this belongs in the pvsystem module.
@@ -62,14 +63,23 @@ class PVSystem(Location):
6263
name : None or string.
6364
Sets the name attribute of the PVSystem object.
6465
65-
surface_tilt: None, float, or array-like
66+
surface_tilt: float or array-like
6667
Tilt angle of the module surface.
6768
Up=0, horizon=90.
6869
69-
surface_azimuth: None, float, or array-like
70+
surface_azimuth: float or array-like
7071
Azimuth angle of the module surface.
7172
North=0, East=90, South=180, West=270.
7273
74+
albedo : None, float
75+
The ground albedo. If ``None``, will attempt to use
76+
``surface_type`` and ``irradiance.SURFACE_ALBEDOS``
77+
to lookup albedo.
78+
79+
surface_type : None, string
80+
The ground surface type. See ``irradiance.SURFACE_ALBEDOS``
81+
for valid values.
82+
7383
module : None, string
7484
The model name of the modules.
7585
May be used to look up the module_parameters dictionary
@@ -100,16 +110,27 @@ class PVSystem(Location):
100110
"""
101111

102112
def __init__(self, latitude, longitude, tz='UTC', altitude=0,
103-
name=None, module=None, module_parameters=None,
113+
name=None,
114+
surface_tilt=0, surface_azimuth=180,
115+
albedo=None, surface_type=None,
116+
module=None, module_parameters=None,
104117
inverter=None, inverter_parameters=None,
105-
racking_model=None, **kwargs):
118+
racking_model=None,
119+
**kwargs):
106120

107121
super(PVSystem, self).__init__(latitude, longitude, tz=tz,
108122
altitude=altitude, name=name)
109123

110124
self.surface_tilt = surface_tilt
111125
self.surface_azimuth = surface_azimuth
112126

127+
# could tie these together with @property
128+
self.surface_type = surface_type
129+
if albedo is None:
130+
self.albedo = irradiance.SURFACE_ALBEDOS.get(surface_type, 0.25)
131+
else:
132+
self.albedo = albedo
133+
113134
# could tie these together with @property
114135
self.module = module
115136
self.module_parameters = module_parameters
@@ -121,8 +142,55 @@ def __init__(self, latitude, longitude, tz='UTC', altitude=0,
121142

122143
# makes self.some_parameter = some_value for everything in kwargs
123144
[setattr(self, k, v) for k, v in kwargs.items()]
124-
125-
145+
146+
147+
def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
148+
dni_extra=None, airmass=None, model='isotropic',
149+
**kwargs):
150+
"""
151+
Uses the :func:`irradiance.total_irrad` function to calculate
152+
the plane of array irradiance components on a tilted surface
153+
defined by
154+
``self.surface_tilt``, ``self.surface_azimuth``, and
155+
``self.albedo``.
156+
157+
Parameters
158+
----------
159+
solar_zenith : float or Series.
160+
Solar zenith angle.
161+
solar_azimuth : float or Series.
162+
Solar azimuth angle.
163+
dni : float or Series
164+
Direct Normal Irradiance
165+
ghi : float or Series
166+
Global horizontal irradiance
167+
dhi : float or Series
168+
Diffuse horizontal irradiance
169+
dni_extra : float or Series
170+
Extraterrestrial direct normal irradiance
171+
airmass : float or Series
172+
Airmass
173+
model : String
174+
Irradiance model.
175+
176+
kwargs passed to :func:`irradiance.total_irrad`.
177+
178+
Returns
179+
-------
180+
poa_irradiance : DataFrame
181+
Column names are: ``total, beam, sky, ground``.
182+
"""
183+
184+
return irradiance.total_irrad(self.surface_tilt,
185+
self.surface_azimuth,
186+
solar_zenith, solar_azimuth,
187+
dni, ghi, dhi,
188+
dni_extra=dni_extra, airmass=airmass,
189+
model=model,
190+
albedo=self.albedo,
191+
**kwargs)
192+
193+
126194
# defaults to kwargs, falls back to attributes. complicated.
127195
# harder to support?
128196
def ashraeiam(self, **kwargs):
@@ -132,56 +200,123 @@ def ashraeiam(self, **kwargs):
132200
----------
133201
kwargs : None, b, a
134202
See pvsystem.ashraeiam for details
203+
204+
Returns
205+
-------
206+
See pvsystem.ashraeiam for details
135207
"""
136208
return ashraeiam(kwargs.pop('b', self.b), kwargs.pop('aoi', self.aoi))
137209

138210

139211
# thin wrappers of other pvsystem functions
140212
def physicaliam(self, aoi):
141-
213+
"""Wrapper around the physicaliam function.
214+
215+
Parameters
216+
----------
217+
See pvsystem.physicaliam for details
218+
219+
Returns
220+
-------
221+
See pvsystem.physicaliam for details
222+
"""
142223
return physicaliam(K, L, n, aoi)
143224

144225

145226
def calcparams_desoto(self, poa_global, temp_cell, alpha_isc,
146227
module_parameters,
147228
EgRef, dEgdT, M=1, irrad_ref=1000, temp_ref=25):
148-
229+
"""Wrapper around the calcparams_desoto function.
230+
231+
Parameters
232+
----------
233+
See pvsystem.calcparams_desoto for details
234+
235+
Returns
236+
-------
237+
See pvsystem.calcparams_desoto for details
238+
"""
149239
return calcparams_desoto(poa_global, temp_cell, alpha_isc,
150240
module_parameters,
151-
EgRef, dEgdT, M, irrad_ref, temp_ref):
241+
EgRef, dEgdT, M, irrad_ref, temp_ref)
152242

153243

154244
def sapm(self, module, poa_direct, poa_diffuse,
155245
temp_cell, airmass_absolute, aoi):
246+
"""Wrapper around the sapm function.
247+
248+
Parameters
249+
----------
250+
See pvsystem.sapm for details
156251
252+
Returns
253+
-------
254+
See pvsystem.sapm for details
255+
"""
157256
return sapm(module, poa_direct, poa_diffuse,
158257
temp_cell, airmass_absolute, aoi)
159258

160259

161260
# model now specified by self.racking_model
162261
def sapm_celltemp(self, irrad, wind, temp):
163-
262+
"""Wrapper around the sapm_celltemp function.
263+
264+
Parameters
265+
----------
266+
See pvsystem.sapm_celltemp for details
267+
268+
Returns
269+
-------
270+
See pvsystem.sapm_celltemp for details
271+
"""
164272
return sapm_celltemp(irrad, wind, temp, self.racking_model)
165273

166274

167275
def singlediode(self, photocurrent, saturation_current,
168276
resistance_series, resistance_shunt, nNsVth):
169-
277+
"""Wrapper around the singlediode function.
278+
279+
Parameters
280+
----------
281+
See pvsystem.singlediode for details
282+
283+
Returns
284+
-------
285+
See pvsystem.singlediode for details
286+
"""
170287
return singlediode(self.module_parameters, photocurrent,
171288
saturation_current,
172289
resistance_series, resistance_shunt, nNsVth)
173290

174291

175292
def i_from_v(self, resistance_shunt, resistance_series, nNsVth, voltage,
176293
saturation_current, photocurrent):
177-
294+
"""Wrapper around the i_from_v function.
295+
296+
Parameters
297+
----------
298+
See pvsystem.i_from_v for details
299+
300+
Returns
301+
-------
302+
See pvsystem.i_from_v for details
303+
"""
178304
return i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
179305
saturation_current, photocurrent)
180306

181307

182308
# inverter now specified by self.inverter_parameters
183309
def snlinverter(self, v_dc, p_dc):
184-
310+
"""Wrapper around the snlinverter function.
311+
312+
Parameters
313+
----------
314+
See pvsystem.snlinverter for details
315+
316+
Returns
317+
-------
318+
See pvsystem.snlinverter for details
319+
"""
185320
return snlinverter(self.inverter_parameters, v_dc, p_dc)
186321

187322

0 commit comments

Comments
 (0)